:root {
  --bg: #f7f4ef;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: #ffffff;
  --text: #1d2433;
  --muted: #657089;
  --line: rgba(255, 255, 255, 0.6);

  --blue: #4d96ff;
  --purple: #b26bff;
  --green: #63c174;
  --red: #ff6b6b;
  --yellow: #ffcf4a;
  --orange: #ff9f43;

  --shadow: 0 16px 40px rgba(30, 40, 80, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Nunito", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 107, 107, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(77, 150, 255, 0.16), transparent 30%),
    radial-gradient(circle at bottom center, rgba(178, 107, 255, 0.16), transparent 28%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  width: min(1100px, calc(100% - 28px));
  margin: 22px auto;
}

.topbar {
  background: linear-gradient(135deg, #ff7e6b 0%, #ffcf4a 45%, #7cd67c 100%);
  border-radius: 32px;
  padding: 28px 36px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.08) 0px,
      rgba(255, 255, 255, 0.08) 2px,
      transparent 2px,
      transparent 16px
    );
  pointer-events: none;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.brand-icon {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-copy {
  min-width: 0;
  text-align: left;
}

.brand-copy h1,
.brand-copy p {
  word-break: normal;
  overflow-wrap: anywhere;
}

.brand h1 {
  margin: 0;
  font-family: "Baloo 2", cursive;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  color: #fff;
}

.brand p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 1rem;
  font-weight: 700;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 22px 0 26px;
}

.nav-btn {
  border: none;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(30, 40, 80, 0.08);
  transition: 0.2s ease;
  backdrop-filter: blur(12px);
}

.nav-btn:hover {
  transform: translateY(-2px);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--blue), #6aa7ff);
  color: white;
  box-shadow: 0 14px 28px rgba(77, 150, 255, 0.35);
}

.main-content {
  min-height: 500px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.section-head {
  margin-bottom: 22px;
}

.section-head h2,
.screen-title-wrap h2,
.quiz-card h3,
.result-card h2 {
  margin: 0;
  font-family: "Baloo 2", cursive;
  line-height: 1.05;
}

.section-head h2,
.screen-title-wrap h2 {
  font-size: 2rem;
}

.section-head p,
.screen-title-wrap p,
#q-subtitle,
#r-msg {
  color: var(--muted);
  margin-top: 8px;
  font-weight: 700;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 18px;
}

.cat-card {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
  border-radius: 26px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(30, 40, 80, 0.08);
  transition: 0.2s ease;
}

.cat-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 18px 40px rgba(30, 40, 80, 0.13);
}

.cat-card .emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}

.cat-card .cat-name {
  font-family: "Baloo 2", cursive;
  font-size: 1.15rem;
  font-weight: 800;
}

.cat-card .cat-count {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.screen-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 12px;
}

.screen-title-wrap {
  text-align: left;
}

.screen-title-wrap p {
  margin-top: 4px;
}

.ghost-btn,
.primary-btn,
.secondary-btn,
.speak-btn {
  border: none;
  cursor: pointer;
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  transition: 0.2s ease;
}

.ghost-btn {
  background: transparent;
  color: var(--blue);
  font-size: 1rem;
  padding: 8px 0;
}

.ghost-btn:hover {
  transform: translateX(-2px);
}

.flashcard-wrap {
  max-width: 620px;
  margin: 0 auto;
}

.progress-wrap {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 22px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width 0.25s ease;
}

.flashcard-card {
  position: relative;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px);
  border-radius: 34px;
  padding: 40px 24px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fadePop 0.28s ease;
}

@keyframes fadePop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-counter {
  position: absolute;
  top: 18px;
  right: 20px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9rem;
}

.card-emoji {
  font-size: 6rem;
  line-height: 1;
}

.card-word {
  margin-top: 14px;
  font-family: "Baloo 2", cursive;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
}

.card-actions {
  margin-top: 20px;
}

.speak-btn {
  background: linear-gradient(135deg, var(--orange), #ffb46b);
  color: white;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.98rem;
  box-shadow: 0 10px 24px rgba(255, 159, 67, 0.28);
}

.speak-btn:hover {
  transform: translateY(-2px);
}

.auto-read-box {
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 10px 22px rgba(30, 40, 80, 0.07);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--text);
}

.controls-row,
.result-actions,
.quiz-next-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.primary-btn {
  background: linear-gradient(135deg, var(--blue), #68a4ff);
  color: white;
  padding: 14px 24px;
  border-radius: 999px;
  box-shadow: 0 12px 26px rgba(77, 150, 255, 0.28);
  font-size: 1rem;
}

.primary-btn:hover {
  transform: translateY(-2px);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  padding: 14px 24px;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(30, 40, 80, 0.08);
  font-size: 1rem;
}

.secondary-btn:hover {
  transform: translateY(-2px);
}

.score-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.score-box {
  min-width: 130px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 22px;
  padding: 16px 18px;
  text-align: center;
  box-shadow: 0 10px 24px rgba(30, 40, 80, 0.08);
}

.score-number {
  display: block;
  font-family: "Baloo 2", cursive;
  font-size: 2rem;
  font-weight: 800;
}

.score-label {
  display: block;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9rem;
}

.quiz-card,
.result-card {
  max-width: 720px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 32px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.quiz-card h3 {
  text-align: center;
  font-size: 2rem;
}

#q-subtitle {
  text-align: center;
  margin-bottom: 22px;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.quiz-opt {
  border: none;
  border-radius: 24px;
  padding: 20px 16px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(30, 40, 80, 0.08);
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  transition: 0.2s ease;
  color: var(--text);
}

.quiz-opt:hover:not(:disabled) {
  transform: translateY(-3px);
}

.opt-emoji {
  display: block;
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.quiz-opt.correct {
  outline: 3px solid var(--green);
  background: #effcef;
}

.quiz-opt.wrong {
  outline: 3px solid var(--red);
  background: #fff0f0;
}

.quiz-feedback {
  min-height: 34px;
  margin-top: 18px;
  text-align: center;
  font-family: "Baloo 2", cursive;
  font-size: 1.35rem;
  font-weight: 800;
}

.quiz-feedback.correct {
  color: var(--green);
}

.quiz-feedback.wrong {
  color: var(--red);
}

.result-card {
  text-align: center;
}

.result-emoji {
  font-size: 5rem;
}

/* ── EMPAREJA ─────────────────────────────── */

.match-card {
  max-width: 620px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 32px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  text-align: center;
}

.match-prompt {
  font-family: "Baloo 2", cursive;
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 16px;
}

.match-item-display {
  background: var(--bg);
  border-radius: 22px;
  padding: 24px 16px;
  margin-bottom: 22px;
  display: inline-block;
  min-width: 180px;
}

.match-emoji {
  font-size: 5rem;
  line-height: 1;
}

.match-word {
  font-family: "Baloo 2", cursive;
  font-size: 2rem;
  font-weight: 800;
  margin-top: 10px;
}

.match-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.match-opt {
  border: none;
  border-radius: 20px;
  padding: 18px 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(30, 40, 80, 0.08);
  cursor: pointer;
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  transition: 0.2s ease;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.match-opt .opt-cat-emoji {
  font-size: 2rem;
}

.match-opt:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(30, 40, 80, 0.13);
}

.match-opt.correct {
  outline: 3px solid var(--green);
  background: #effcef;
}

.match-opt.wrong {
  outline: 3px solid var(--red);
  background: #fff0f0;
}

.match-opt:disabled {
  cursor: default;
}

/* ── RESPONSIVE ───────────────────────────── */

@media (max-width: 768px) {
  .app-shell {
    width: calc(100% - 20px);
    margin: 12px auto 20px;
  }

  .topbar {
    padding: 18px 16px;
    border-radius: 24px;
  }

  .brand {
    gap: 12px;
    align-items: center;
    justify-content: center;
    max-width: 100%;
  }

  .brand-icon {
    width: 78px;
    height: 78px;
  }

  .brand h1 {
    font-size: 2rem;
    line-height: 1.05;
  }

  .brand p {
    font-size: 0.95rem;
    margin-top: 4px;
  }

  .main-nav {
    gap: 10px;
    margin: 18px 0 22px;
  }

  .nav-btn {
    padding: 12px 18px;
    font-size: 0.95rem;
  }

  .section-head h2,
  .screen-title-wrap h2 {
    font-size: 1.8rem;
  }

  .section-head p,
  .screen-title-wrap p {
    font-size: 1rem;
  }

  .cat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .cat-card {
    padding: 20px 12px;
    border-radius: 22px;
  }

  .cat-card .emoji {
    font-size: 2.5rem;
    margin-bottom: 8px;
  }

  .cat-card .cat-name {
    font-size: 1rem;
  }

  .cat-card .cat-count {
    font-size: 0.85rem;
  }

  .flashcard-wrap {
    max-width: 100%;
  }

  .flashcard-card {
    min-height: 240px;
    padding: 30px 18px 22px;
    border-radius: 24px;
  }

  .card-emoji {
    font-size: 4.5rem;
  }

  .card-word {
    font-size: 2rem;
  }

  .card-counter {
    top: 14px;
    right: 16px;
    font-size: 0.85rem;
  }

  .auto-read-box {
    padding: 12px 14px;
  }

  .toggle-row {
    font-size: 0.95rem;
    align-items: flex-start;
  }

  .controls-row {
    flex-direction: column;
    gap: 10px;
  }

  .primary-btn,
  .secondary-btn,
  .speak-btn {
    width: 100%;
    justify-content: center;
  }

  .score-row {
    gap: 10px;
    margin-bottom: 16px;
  }

  .score-box {
    min-width: unset;
    flex: 1 1 calc(33.333% - 8px);
    padding: 14px 10px;
    border-radius: 18px;
  }

  .score-number {
    font-size: 1.7rem;
  }

  .score-label {
    font-size: 0.8rem;
  }

  .quiz-card,
  .result-card {
    padding: 22px 16px;
    border-radius: 24px;
  }

  .quiz-card h3 {
    font-size: 1.8rem;
  }

  .quiz-options {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .quiz-opt {
    padding: 18px 14px;
    border-radius: 18px;
  }

  .opt-emoji {
    font-size: 2.4rem;
  }

  .match-card {
    padding: 22px 16px;
    border-radius: 24px;
  }

  .match-options {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .app-shell {
    width: calc(100% - 14px);
    margin: 8px auto 16px;
  }

  .topbar {
    padding: 16px 14px;
    border-radius: 20px;
  }

  .brand {
    gap: 10px;
    align-items: center;
    justify-content: center;
    max-width: 100%;
  }

  .brand-icon {
    width: 64px;
    height: 64px;
    margin-top: 0;
  }

  .brand h1 {
    font-size: 1.55rem;
    line-height: 1.05;
  }

  .brand p {
    font-size: 0.84rem;
    margin-top: 4px;
  }

  .main-nav {
    gap: 8px;
    margin: 16px 0 18px;
  }

  .nav-btn {
    padding: 10px 14px;
    font-size: 0.88rem;
    border-radius: 999px;
  }

  .section-head {
    margin-bottom: 16px;
  }

  .section-head h2,
  .screen-title-wrap h2 {
    font-size: 1.45rem;
  }

  .section-head p,
  .screen-title-wrap p,
  #q-subtitle,
  #r-msg {
    font-size: 0.92rem;
  }

  .cat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .cat-card {
    padding: 18px 10px;
    border-radius: 20px;
  }

  .cat-card .emoji {
    font-size: 2.1rem;
  }

  .cat-card .cat-name {
    font-size: 0.95rem;
  }

  .cat-card .cat-count {
    font-size: 0.78rem;
  }

  .screen-top {
    gap: 4px;
    margin-bottom: 10px;
  }

  .ghost-btn {
    font-size: 0.95rem;
  }

  .progress-wrap {
    height: 10px;
    margin-bottom: 16px;
  }

  .flashcard-card {
    min-height: 210px;
    padding: 24px 14px 18px;
    border-radius: 20px;
  }

  .card-emoji {
    font-size: 3.7rem;
  }

  .card-word {
    font-size: 1.7rem;
    margin-top: 10px;
  }

  .card-actions {
    margin-top: 16px;
  }

  .speak-btn,
  .primary-btn,
  .secondary-btn {
    padding: 12px 16px;
    font-size: 0.95rem;
  }

  .toggle-row {
    font-size: 0.88rem;
    gap: 8px;
  }

  .score-row {
    gap: 8px;
  }

  .score-box {
    padding: 12px 8px;
    border-radius: 16px;
  }

  .score-number {
    font-size: 1.45rem;
  }

  .score-label {
    font-size: 0.72rem;
  }

  .quiz-card,
  .result-card {
    padding: 18px 12px;
    border-radius: 20px;
  }

  .quiz-card h3 {
    font-size: 1.5rem;
  }

  .quiz-opt {
    padding: 16px 12px;
    font-size: 0.95rem;
    border-radius: 16px;
  }

  .opt-emoji {
    font-size: 2rem;
    margin-bottom: 6px;
  }

  .quiz-feedback {
    font-size: 1.1rem;
    min-height: 28px;
  }

  .result-emoji {
    font-size: 4rem;
  }

  .match-emoji {
    font-size: 3.8rem;
  }

  .match-word {
    font-size: 1.6rem;
  }

  .match-opt {
    padding: 14px 10px;
    font-size: 1rem;
  }

  .match-card {
    padding: 18px 12px;
    border-radius: 20px;
  }
}