/* Design tokens — pastel, readable contrast */
:root {
  --bg: #f3ecff;
  --bg-card: #fff8fb;
  --text: #2d2a32;
  --muted: #5c5668;
  --accent: #e8919c;
  --accent-dark: #c75d6b;
  --mint: #7ecfc0;
  --mint-dark: #4a9e8f;
  --lavender: #9b8ab8;
  --ten-fill: #b8d4e8;
  --ten-border: #7aa8c8;
  --one-fill: #ffd9a8;
  --one-border: #e8a860;
  --shadow: 0 8px 28px rgba(45, 42, 50, 0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #e8d9ff 0%, var(--bg) 45%);
  line-height: 1.45;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.75rem 1rem 2rem;
}

/* Lehce větší než mobil — bez přehnaného měřítka (aby šlo odpovídat bez skrollování) */
@media (min-width: 900px) {
  html {
    font-size: 104%;
  }

  .app {
    max-width: 760px;
    padding: 0.65rem 1rem 1.5rem;
  }

  .card {
    padding: 1.15rem 1.25rem 1.35rem;
  }

  .brand {
    font-size: 1.12rem;
  }

  .problem-text {
    font-size: clamp(1.85rem, 3.5vw, 2.35rem);
  }

  .step-hint {
    font-size: 1.02rem;
  }

  .field-label {
    font-size: 1.02rem;
  }

  .step-input {
    font-size: 1.35rem;
    width: 5rem;
    padding: 0.6rem 0.7rem;
  }

  .btn {
    padding: 0.7rem 1.25rem;
    min-height: 48px;
  }

  .feedback {
    font-size: 1rem;
  }

  .mid-label {
    font-size: 1.08rem;
  }

  .block {
    width: 23px;
    height: 23px;
  }

  .blocks-area {
    min-height: 110px;
    margin-bottom: 0.55rem;
  }

  .recipe {
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.75rem;
  }

  .recipe__steps {
    font-size: 0.95rem;
    margin-top: 0.4rem;
  }

  .anchor-panel {
    font-size: 0.95rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.55rem;
  }

  .toolbar-toggle {
    font-size: 0.88rem;
  }

  .screen--game .game-card .problem-text {
    margin-bottom: 0.35rem;
  }

  .screen--game .game-card .step-hint {
    margin-bottom: 0.65rem;
  }

  .screen--game .game-card .step-panel {
    margin-top: 0.35rem;
  }

  .screen--game .game-card .feedback {
    margin-top: 0.55rem;
  }
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.15rem;
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.sound-toggle input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--lavender);
}

.main {
  position: relative;
}

.screen.hidden {
  display: none !important;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1.5rem;
}

/* Welcome */
.screen--welcome .welcome-card {
  text-align: center;
}

.welcome-mascot {
  margin-bottom: 0.25rem;
}

.welcome-mascot .mascot {
  filter: drop-shadow(0 6px 12px rgba(139, 124, 174, 0.35));
}

.greeting {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 0 0 0.35rem;
  line-height: 1.35;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.greeting__heart {
  display: inline-block;
  font-style: normal;
  line-height: 1;
  transform: scale(1.15);
  vertical-align: middle;
}

.title {
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 800;
  margin: 0.5rem 0 0.75rem;
  line-height: 1.2;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
}

.level-grid {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 520px) {
  .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .level-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.card--level {
  text-align: left;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  padding: 1rem 1rem 1.1rem;
  background: #fff;
}

.card--level:hover,
.card--level:focus-visible {
  transform: translateY(-2px);
  border-color: var(--lavender);
  box-shadow: var(--shadow), 0 0 0 3px rgba(155, 138, 184, 0.25);
  outline: none;
}

.level-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  font: inherit;
  color: inherit;
  width: 100%;
}

.level-btn__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--mint);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
}

.level-btn__title {
  font-weight: 800;
  font-size: 1.05rem;
}

.level-btn__desc {
  font-size: 0.88rem;
  color: var(--muted);
}

.level-btn__example {
  display: block;
  margin-top: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px dashed rgba(155, 138, 184, 0.45);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  text-align: left;
}

.level-btn__example strong {
  color: var(--lavender);
  font-weight: 800;
}

/* Game — cíl úrovně + režim strategie */
.level-banner {
  width: 100%;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  background: linear-gradient(135deg, rgba(155, 138, 184, 0.14) 0%, rgba(126, 207, 192, 0.12) 100%);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(155, 138, 184, 0.35);
  box-sizing: border-box;
}

.level-banner__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.4rem;
}

.level-pill {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.strategy-badge {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 2px solid transparent;
}

.strategy-badge--add {
  background: rgba(126, 207, 192, 0.35);
  border-color: var(--mint-dark);
  color: #2a5c52;
}

.strategy-badge--bridge {
  background: rgba(155, 138, 184, 0.28);
  border-color: var(--lavender);
  color: #4a3d5c;
}

.strategy-badge--split {
  background: rgba(232, 145, 156, 0.28);
  border-color: var(--accent-dark);
  color: #6b3038;
}

.level-banner__goal {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

/* Game */
.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.toolbar-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.toolbar-toggle input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--lavender);
}

.recipe {
  width: 100%;
  max-width: 100%;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: rgba(155, 138, 184, 0.12);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(155, 138, 184, 0.35);
  box-sizing: border-box;
}

/* Výchozí <summary> je list-item — bere místo mimo box; sjednotíme šířku a zarovnání */
.recipe > .recipe__summary {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  padding: 0;
  font-weight: 800;
  cursor: pointer;
  color: var(--lavender);
  list-style: none;
}

.recipe > .recipe__summary::-webkit-details-marker,
.recipe > .recipe__summary::marker {
  display: none;
}

.recipe > .recipe__summary::before {
  content: "▸";
  flex: 0 0 auto;
  width: 1.15em;
  text-align: center;
  line-height: 1.35;
  color: var(--lavender);
  transition: transform 0.2s ease;
}

.recipe[open] > .recipe__summary::before {
  content: "▾";
}

.recipe__steps {
  margin: 0.55rem 0 0;
  padding-left: 1.35rem;
  padding-right: 0.25rem;
  font-size: 0.98rem;
  color: var(--text);
  line-height: 1.5;
}

.recipe__steps li {
  margin-bottom: 0.25rem;
}

.anchor-panel {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(126, 207, 192, 0.15);
  border: 1px solid rgba(74, 158, 143, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
}

.anchor-panel.hidden {
  display: none;
}

.anchor-panel p {
  margin: 0.25rem 0;
}

.anchor-panel p:first-child {
  margin-top: 0;
}

.anchor-panel p:last-child {
  margin-bottom: 0;
}

.problem-text {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  text-align: center;
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}

.step-hint {
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  min-height: 1.4em;
}

.blocks-area {
  min-height: 120px;
  margin-bottom: 0.75rem;
}

.blocks-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.ten-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  padding: 0.45rem 0.5rem;
  background: rgba(184, 212, 232, 0.25);
  border-radius: var(--radius-sm);
  border: 2px dashed var(--ten-border);
}

.block {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--one-border);
  background: var(--one-fill);
  transition: transform 0.35s ease, background 0.35s ease, border-color 0.35s ease;
}

.block--ten {
  border-color: var(--ten-border);
  background: var(--ten-fill);
}

.blocks-area.is-celebrate .block {
  animation: pop 0.5s ease both;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.mid-label {
  text-align: center;
  font-weight: 800;
  color: var(--lavender);
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.mid-label.hidden {
  display: none;
}

/* Druhé číslo po částech (jen ve 2. kroku) */
.b-parts-panel {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 217, 168, 0.28);
  border: 2px solid var(--one-border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

.b-parts-panel.hidden {
  display: none;
}

.b-parts-panel__text {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
}

.b-parts-panel__text strong {
  color: var(--accent-dark);
  font-weight: 800;
}

.b-parts-bar {
  display: flex;
  width: 100%;
  min-height: 3.25rem;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(45, 42, 50, 0.15);
  margin-bottom: 0.4rem;
}

.b-parts-bar__chunk {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.25rem;
  text-align: center;
  min-width: 0;
}

.b-parts-bar__chunk strong {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
}

.b-parts-bar__label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.9;
}

.b-parts-bar__chunk--done {
  background: rgba(155, 138, 184, 0.35);
  color: #3d3550;
}

.b-parts-bar__chunk--todo {
  background: rgba(126, 207, 192, 0.45);
  color: #1f4d44;
  box-shadow: inset 0 0 0 2px var(--mint-dark);
}

.b-parts-panel__legend {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}

.step-panel {
  margin-top: 0.5rem;
}

.field-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.step-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.step-input {
  font: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  width: 5rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 2px solid #ddd5e8;
  text-align: center;
}

.step-input:focus {
  outline: none;
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(155, 138, 184, 0.3);
}

.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.35rem;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(231, 93, 107, 0.35);
}

.btn--primary:hover,
.btn--primary:focus-visible {
  box-shadow: 0 6px 18px rgba(231, 93, 107, 0.45);
  outline: none;
}

.btn--secondary {
  background: var(--mint);
  color: #fff;
  box-shadow: 0 4px 14px rgba(78, 158, 143, 0.3);
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
  background: var(--mint-dark);
  outline: none;
}

.btn--ghost {
  background: transparent;
  color: var(--lavender);
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  box-shadow: none;
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  color: var(--text);
  outline: none;
}

.btn--small {
  margin-top: 0.65rem;
  font-size: 0.9rem;
  min-height: 40px;
}

.feedback {
  min-height: 1.5em;
  margin: 0.85rem 0 0;
  font-weight: 700;
  font-size: 1rem;
}

.feedback--ok {
  color: var(--mint-dark);
}

.feedback--err {
  color: var(--accent-dark);
}

.feedback--tip {
  color: #3d6b8a;
  font-weight: 700;
}

.actions-done {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 1rem;
}

.actions-done.hidden {
  display: none;
}

/* Confetti */
.confetti {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 50;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -12px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.9;
  }
}

.screen--game .game-card.mascot-bounce {
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .confetti {
    display: none;
  }
}
