:root {
  --bg: #eaf3fa;
  --ink: #33424f;
  --muted: #7188a0;
  --line: #d3e3ee;
  --surface: #ffffff;

  /* temă deschisă, pastel, bazată pe albastru — ușoară pentru ochii unui copil */
  --accent: #6fa8d8;
  --accent-dark: #4f8fc4;
  --c-lectie: #6fa8d8;
  --c-litere: #8ecae6;
  --c-numere: #8fd6c9;
  --c-silabe: #a8dba0;
  --c-cuvinte: #b8b3e8;
  --c-propozitii: #93bfe0;
  --c-rapid: #f3c98f;

  --good: #7cc499;
  --bad: #ef9a94;
  --neutral-btn: #9db3c2;

  --card-radius: 22px;
  --btn-radius: 14px;

  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --read-font: Georgia, "Iowan Old Style", "Times New Roman", serif;

  font-size: clamp(16px, 1.4vw + 10px, 22px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* elementele cu [hidden] trebuie să rămână ascunse indiferent de alte
   reguli display:flex/grid definite pe aceeași clasă (.stage, .controls...) */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui-font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 1.2rem;
  gap: 1rem;
}

.screen.active {
  display: flex;
}

/* ---------- Top bar (shown on menu) ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: clamp(1.3rem, 2vw + 1rem, 2.1rem);
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stars {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--btn-radius);
  padding: 0.4rem 1rem;
  display: inline-block;
}

.stars.pulse {
  animation: starPulse 0.5s ease;
}

@keyframes starPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
}

.icon-btn:active {
  transform: translateY(1px);
}

/* ---------- Menu grid ---------- */

.menu-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  align-content: center;
}

.menu-card {
  border: none;
  border-radius: var(--card-radius);
  padding: 1.4rem 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  transition: transform 0.08s ease, opacity 0.08s ease;
}

.menu-card:active {
  transform: translateY(2px);
  opacity: 0.92;
}

.menu-card .icon {
  font-size: 2.6rem;
}

.menu-card.lectie { background: var(--c-lectie); grid-column: 1 / -1; }
.menu-card.litere { background: var(--c-litere); }
.menu-card.numere { background: var(--c-numere); }
.menu-card.silabe { background: var(--c-silabe); }
.menu-card.cuvinte { background: var(--c-cuvinte); }
.menu-card.propozitii { background: var(--c-propozitii); }
.menu-card.rapid { background: var(--c-rapid); }

/* ---------- Practice screens ---------- */

.practice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.back-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--btn-radius);
  padding: 0.5rem 1.1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.round-progress {
  font-weight: 700;
  color: var(--muted);
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.item-display {
  font-family: var(--read-font);
  font-size: clamp(6rem, 26vw, 11rem);
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
  word-break: break-word;
}

.item-display.sentence {
  font-size: clamp(2.1rem, 8vw, 4.2rem);
  max-width: 92%;
}

.syllable-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 1.1rem;
  font-family: var(--read-font);
}

.syllable {
  font-size: clamp(4rem, 18vw, 8rem);
  font-weight: 400;
  padding: 0 0.15rem;
  color: var(--ink);
}

.syllable + .syllable {
  border-left: 2px dashed var(--line);
  padding-left: 1.1rem;
}

.controls {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}

.big-btn {
  border: none;
  border-radius: var(--btn-radius);
  padding: 1rem 1.8rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  min-width: 150px;
  font-family: var(--ui-font);
}

.big-btn:active {
  transform: translateY(2px);
}

.big-btn.correct {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--good);
}
.big-btn.wrong {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--bad);
}
.big-btn.neutral { background: var(--accent); }
.big-btn.secondary { background: var(--neutral-btn); }
.big-btn.small {
  min-width: 0;
  padding: 0.7rem 1.1rem;
  font-size: 0.95rem;
}

/* ---------- Difficulty / duration pickers ---------- */

.picker-title {
  text-align: center;
  font-weight: 700;
  margin: 0 0 1rem;
  color: var(--muted);
}

.picker-wrap {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.9rem;
}

.picker-btn {
  border: none;
  border-radius: var(--btn-radius);
  padding: 1.2rem 0.6rem;
  font-size: clamp(0.95rem, 2.1vw, 1.25rem);
  font-weight: 700;
  color: white;
  background: var(--accent);
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.picker-btn:active { transform: translateY(2px); }

.picker-btn.chosen {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- Chip toggles (selecție tip conținut) ---------- */

.type-chip-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1.1rem;
}

.type-chip {
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: var(--btn-radius);
  padding: 0.5rem 1rem;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
}

.type-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ---------- Flash mode ---------- */

.flash-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #dbeaf5;
  border: 2px solid var(--line);
  border-radius: var(--card-radius);
  min-height: 36vh;
}

.flash-stage .item-display,
.flash-stage .syllable {
  color: var(--ink);
}

/* ---------- Lesson (Lecție) ---------- */

.lesson-timer {
  font-weight: 700;
  color: var(--muted);
  font-size: 1.1rem;
}

.lesson-phase-label {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}

.recap-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 420px;
  width: 100%;
}

.recap-list li {
  display: flex;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.celebration {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2.3rem);
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Settings / Stats panels ---------- */

.overlay-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.overlay-panel.active {
  display: flex;
}

.overlay-box {
  background: var(--surface);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.overlay-box h2 {
  margin: 0;
  color: var(--ink);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-weight: 700;
}

.setting-row select,
.setting-row input[type="number"] {
  font-size: 1rem;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.toggle-chip {
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
}

.toggle-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.settings-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
}

.settings-actions .big-btn {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
}

.stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 1rem;
  font-weight: 700;
}

.stats-list .ok { color: var(--good); }
.stats-list .no { color: var(--bad); }

@media (max-width: 480px) {
  .menu-card.lectie { grid-column: auto; }

  :root {
    font-size: 18px;
  }

  .big-btn {
    font-size: 1.25rem;
    padding: 1.1rem 1.4rem;
    min-width: 130px;
  }

  .icon-btn {
    width: 2.8rem;
    height: 2.8rem;
    font-size: 1.35rem;
  }

  .stars {
    font-size: 1.3rem;
  }

  .picker-btn {
    font-size: clamp(1.05rem, 4.5vw, 1.35rem);
    padding: 1.3rem 0.6rem;
  }
}
