/* Think Tank: kid-friendly theme */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f6ff;
  --ink: #253358;
  --ink-soft: #6b7a9e;
  --card: #ffffff;
  --accent: #4f7cff;
  --good: #2fb46a;
  --bad: #e8556d;
  --gold: #ffb703;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(37, 51, 88, 0.12);
}

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "Comic Sans MS", system-ui, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 20%, #dcebff 0 18%, transparent 20%),
                    radial-gradient(circle at 85% 75%, #e5dcff 0 16%, transparent 18%);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
}
.brand { font-size: 1.35rem; font-weight: 800; letter-spacing: 0.3px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.star-bank {
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.icon-btn {
  font-size: 1.3rem;
  background: var(--card);
  border: none;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(37,51,88,0.12); }

/* ---------- settings popover ---------- */
.settings-pop {
  position: absolute;
  top: 72px;
  right: 24px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  width: 300px;
  box-shadow: 0 10px 30px rgba(37,51,88,0.25);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-pop[hidden] { display: none; }
.settings-pop h3 { font-size: 1.05rem; }
.settings-pop label { font-size: 0.9rem; font-weight: 700; color: var(--ink-soft); }
.voice-source { font-size: 0.85rem; color: var(--ink-soft); background: #eef3ff; border-radius: 10px; padding: 8px 10px; }
.settings-pop select, .settings-pop input[type="range"] { width: 100%; font-size: 0.95rem; padding: 6px; }

.tts-warning {
  margin: 12px 24px;
  background: #fff3cd;
  border: 2px solid #f0c419;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 700;
}

/* ---------- screens ---------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 24px 48px;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}
.screen[hidden] { display: none; }
.screen-nav { width: 100%; display: flex; justify-content: flex-start; }

/* ---------- home / mode grid ---------- */
.home-title { font-size: 2.4rem; font-weight: 900; margin: 18px 0 26px; text-align: center; }

.mode-grid, .category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 18px;
  width: 100%;
}
.mode-btn, .category-btn {
  border: none;
  border-radius: var(--radius);
  padding: 24px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  color: #fff;
  /* Solid fallback so white text is always readable, even if a
     gradient class is missing or the stylesheet is stale-cached. */
  background: var(--accent);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
  font-family: inherit;
}
.mode-btn:hover, .category-btn:hover { transform: translateY(-3px) scale(1.02); }
.mode-btn:active, .category-btn:active { transform: translateY(1px); }
.mode-big, .cat-big { font-size: 1.5rem; font-weight: 900; }
.mode-sub, .cat-example { font-size: 0.98rem; opacity: 0.92; }

.cat-f     { background: linear-gradient(135deg, #ff8a5c, #ff5c8a); }
.cat-d     { background: linear-gradient(135deg, #4f7cff, #6fc3ff); }
.cat-v     { background: linear-gradient(135deg, #9d5cff, #ce6fff); }
.cat-t     { background: linear-gradient(135deg, #2fb46a, #7ed957); }
.cat-mix   { background: linear-gradient(135deg, #253358, #4f5f8f); }
.cat-say   { background: linear-gradient(135deg, #ff9f1c, #ffbf69); }
.cat-learn { background: linear-gradient(135deg, #12b5b0, #6fd8c9); grid-column: 1 / -1; }
.cat-hard  { background: linear-gradient(135deg, #d90429, #ff6d3f); }
.category-grid .cat-mix, .category-grid .cat-hard { grid-column: 1 / -1; }
.category-btn[hidden] { display: none; }

/* ---------- quiz ---------- */
.quiz-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 8px;
}
.progress { font-size: 1.2rem; font-weight: 800; color: var(--ink-soft); }
.streak {
  font-size: 1.3rem;
  font-weight: 900;
  background: var(--card);
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: var(--shadow);
}
.streak.hot { background: #fff1d6; }

.quiz-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: 100%;
}

.say-note {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--card);
  border-radius: 999px;
  padding: 10px 20px;
  box-shadow: var(--shadow);
}
.say-note[hidden] { display: none; }

.say-card {
  font-size: 3.4rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ff9f1c, #ffbf69);
  color: #fff;
  border-radius: var(--radius);
  padding: 44px 56px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 100%;
}
.say-card.twister { font-size: 1.8rem; line-height: 1.4; padding: 32px 36px; }
.say-card[hidden] { display: none; }

.replay-btn {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  padding: 18px 34px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 #3457bd;
  transition: transform 0.1s ease;
}
.replay-btn:hover { transform: scale(1.04); }
.replay-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #3457bd; }
.replay-btn.speaking { animation: pulse 0.9s ease infinite; }

/* answers */
.answers {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
}
.answer-btn {
  font-family: inherit;
  font-weight: 900;
  color: var(--ink);
  background: var(--card);
  border: 4px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.answer-btn:hover:not(:disabled) { transform: translateY(-3px); border-color: #cfe0ff; }
.answer-btn:disabled { cursor: default; }
.answer-btn.correct {
  background: #e2f8ec;
  border-color: var(--good);
  color: var(--good);
  animation: bounce 0.5s ease;
}
.answer-btn.wrong {
  background: #fde7ec;
  border-color: var(--bad);
  color: var(--bad);
  animation: shake 0.45s ease;
}

.word-btn { font-size: 2.6rem; padding: 34px 20px; min-width: 250px; }
.choice-btn { font-size: 1.7rem; padding: 26px 40px; min-width: 230px; }
.count-btn {
  font-size: 1.9rem;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sentence-btn {
  font-size: 1.25rem;
  font-weight: 800;
  padding: 22px 26px;
  width: 100%;
  max-width: 640px;
  text-align: left;
}
.judge-good { font-size: 1.6rem; padding: 26px 40px; min-width: 240px; background: #e2f8ec; color: var(--good); }
.judge-try  { font-size: 1.6rem; padding: 26px 40px; min-width: 240px; background: #fff1d6; color: #b07b00; }

.reveal {
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 26px;
  box-shadow: var(--shadow);
  max-width: 640px;
  text-align: center;
  line-height: 1.5;
}
.reveal[hidden] { display: none; }
.reveal mark {
  background: #ffe89b;
  border-radius: 8px;
  padding: 2px 6px;
  font-weight: 900;
}

.feedback {
  font-size: 1.5rem;
  font-weight: 900;
  min-height: 2.2rem;
  text-align: center;
}
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.small-btn {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.small-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(37,51,88,0.12); }

/* ---------- how-to screen ---------- */
.mouth-figure {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  width: 100%;
  max-width: 520px;
}
.mouth-svg { width: 100%; height: auto; display: block; }
.tongue-group { animation: tonguePeek 2.2s ease-in-out infinite; }
.air path { stroke-dasharray: 10 14; animation: airFlow 1.1s linear infinite; }

.howto-steps {
  margin: 26px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 640px;
  list-style: none;
  counter-reset: step;
}
.howto-steps li {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  font-size: 1.15rem;
  line-height: 1.5;
}
.howto-demos { display: flex; gap: 16px; margin: 20px 0 8px; flex-wrap: wrap; justify-content: center; }
.fixit-title { font-size: 1.4rem; font-weight: 900; margin: 26px 0 14px; }
.fixit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 720px;
}
.fixit {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  font-size: 1.05rem;
  line-height: 1.45;
}

/* ---------- summary ---------- */
.summary-title { font-size: 2.6rem; font-weight: 900; margin-top: 48px; }
.summary-stars { font-size: 3rem; margin: 22px 0 10px; letter-spacing: 6px; animation: bounce 0.6s ease; }
.summary-line { font-size: 1.3rem; font-weight: 700; margin: 6px 0; text-align: center; }
.summary-line.tricky { color: var(--ink-soft); font-size: 1.1rem; }
.summary-actions { display: flex; gap: 16px; margin-top: 36px; }
.big-btn {
  font-size: 1.3rem;
  font-weight: 800;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  padding: 18px 30px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 #3457bd;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #3457bd; }
.big-btn.ghost { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- animations ---------- */
@keyframes bounce {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.12); }
  70%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes tonguePeek {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-10px); }
}
@keyframes airFlow {
  to { stroke-dashoffset: -24; }
}

@media (max-width: 640px) {
  .mode-grid, .category-grid, .fixit-grid { grid-template-columns: 1fr; }
  .word-btn { min-width: 80%; }
  .say-card { font-size: 2.4rem; padding: 32px 28px; }
}
