:root {
  color-scheme: light;
  font-family: ui-rounded, "SF Pro Rounded", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #172033;
  --muted: #64748b;
  --soft: #f5f8fb;
  --paper: rgba(255, 255, 255, 0.88);
  --line: rgba(30, 64, 94, 0.13);
  --water: #0ea5e9;
  --deep: #075985;
  --mint: #10b981;
  --gold: #f59e0b;
  --coral: #f97316;
  --pink: #ec4899;
  --shadow: 0 24px 70px rgba(15, 45, 80, 0.14);
  --radius: 28px;
  background: #f7fbff;
  color: var(--ink);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -8%, rgba(14,165,233,.28), transparent 34rem),
    radial-gradient(circle at 98% 6%, rgba(16,185,129,.20), transparent 30rem),
    linear-gradient(135deg, #f8fcff 0%, #fffaf3 48%, #f2fbff 100%);
}
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.app-shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; position: sticky; top: 0; z-index: 5; padding: 10px 0; backdrop-filter: blur(18px); }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 950; }
.logo { width: 42px; height: 42px; border-radius: 16px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--water), var(--mint)); box-shadow: 0 12px 30px rgba(14,165,233,.28); }
.settings-btn, .secondary, .mode-card, select { border: 1px solid var(--line); background: rgba(255,255,255,.76); color: var(--ink); box-shadow: 0 10px 24px rgba(15,45,80,.06); }
.settings-btn, .primary, .secondary { border-radius: 999px; padding: 12px 16px; font-weight: 900; }
.primary { border: 0; color: white; background: linear-gradient(135deg, var(--deep), var(--water)); box-shadow: 0 16px 35px rgba(14,165,233,.28); }
.secondary { color: var(--ink); }
.full { width: 100%; margin-top: 8px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); backdrop-filter: blur(20px); padding: 24px; }
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 20px; align-items: stretch; margin-bottom: 22px; }
.hero-main { padding: clamp(24px, 5vw, 46px); position: relative; overflow: hidden; }
.hero-main:after { content: ""; position: absolute; width: 220px; height: 220px; right: -80px; bottom: -95px; border-radius: 999px; background: radial-gradient(circle, rgba(14,165,233,.20), transparent 65%); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.45rem, 8vw, 5.65rem); line-height: .9; letter-spacing: -.07em; margin-bottom: 16px; }
h2 { font-size: clamp(1.35rem, 3.5vw, 2.05rem); letter-spacing: -.04em; margin-bottom: 10px; }
h3 { line-height: 1.35; }
.lede { color: var(--muted); font-size: clamp(1.04rem, 2.5vw, 1.28rem); max-width: 58ch; line-height: 1.55; }
.eyebrow { margin: 0 0 9px; color: var(--deep); letter-spacing: .12em; font-weight: 950; text-transform: uppercase; font-size: .74rem; }
.eyebrow.light { color: #bae6fd; }
.hero-actions, .quiz-actions, .result-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hero-side { display: grid; gap: 14px; }
.score-card { min-height: 146px; padding: 18px; border-radius: 24px; background: linear-gradient(145deg, #052e46, #0f766e); color: white; position: relative; overflow: hidden; }
.score-card p { margin-bottom: 0; color: rgba(255,255,255,.84); }
.score-big { font-size: 3.1rem; line-height: 1; font-weight: 1000; letter-spacing: -.05em; }
.meter, .progress-track { height: 12px; background: rgba(7,89,133,.12); border-radius: 99px; overflow: hidden; margin: 14px 0 8px; }
.meter > span { display:block; height:100%; width:70%; border-radius:inherit; background: linear-gradient(90deg, #fcd34d, #34d399); }
.progress-track > span { display:block; height:100%; width:0; border-radius:inherit; background: linear-gradient(90deg, var(--water), var(--mint)); transition: width .18s ease; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini { padding: 15px; border-radius: 20px; background: rgba(255,255,255,.64); border: 1px solid var(--line); }
.mini strong { display: block; font-size: 1.3rem; }
.grid { display: grid; gap: 18px; }
.section { margin-top: 22px; }
.setup-grid { grid-template-columns: 1.3fr 1fr .78fr; align-items: start; }
.stack { display: grid; gap: 16px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode-card { text-align: left; border-radius: 24px; padding: 17px; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.mode-card:hover, .mode-card.active { transform: translateY(-2px); border-color: rgba(14,165,233,.48); box-shadow: 0 18px 40px rgba(14,165,233,.14); }
.mode-card.active { outline: 3px solid rgba(14,165,233,.13); background: #f0f9ff; }
.mode-icon { width: 42px; height: 42px; border-radius: 16px; display:grid; place-items:center; margin-bottom: 12px; background: #e0f2fe; font-size: 1.25rem; }
.mode-card strong { display: block; margin-bottom: 6px; font-size: 1.03rem; }
.mode-card span { color: var(--muted); line-height: 1.45; }
.choice-row { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.choice-row.strong { color: var(--ink); font-weight: 800; }
.choice-row input, .topic-list input { width: 20px; height: 20px; accent-color: var(--water); }
.muted-panel { opacity: .74; }
.muted-panel .topic-list { pointer-events: none; }
.topic-list { display: grid; gap: 10px; max-height: 430px; overflow: auto; padding-right: 4px; }
.topic-list label { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 12px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,.58); }
.topic-list b { display: block; }
select { width: 100%; border-radius: 16px; padding: 13px; }
.hint, .mode-card span, .topic-list small { color: var(--muted); }
.hidden { display: none !important; }
.quiz-screen, .results-screen, .explainer { margin-top: 20px; }
.quiz-topline { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.shuffle-note { color: var(--gold); font-weight: 850; }
.question-card { margin-top: 18px; padding: 22px; border-radius: 24px; background: linear-gradient(180deg, #ffffff, #f8fbff); border: 1px solid var(--line); }
.topic-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pill { border: 1px solid rgba(14,165,233,.26); background: #e0f2fe; border-radius: 999px; padding: 5px 9px; color: #075985; font-size: .8rem; font-weight: 900; }
.question-prompt, .feedback, .review-card p { white-space: pre-wrap; }
.answers { display: grid; gap: 10px; margin-top: 16px; }
.answer-option { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: white; transition: .15s ease; }
.answer-option:hover, .answer-option:has(input:checked) { border-color: rgba(16,185,129,.65); background: #ecfdf5; transform: translateX(2px); }
.answer-letter { min-width: 30px; height: 30px; border-radius: 11px; background: #eef6ff; display:grid; place-items:center; font-weight: 950; color: var(--deep); }
.feedback { margin-top: 16px; border-radius: 18px; padding: 15px; border: 1px solid var(--line); line-height: 1.5; animation: pop .18s ease-out; }
.feedback.correct { border-color: rgba(16,185,129,.34); background: #ecfdf5; color: #064e3b; }
.feedback.wrong { border-color: rgba(249,115,22,.38); background: #fff7ed; color: #7c2d12; }
@keyframes pop { from { transform: scale(.98); opacity: .2; } to { transform: scale(1); opacity: 1; } }
.review-list { display: grid; gap: 12px; margin-top: 12px; }
.review-card { padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.7); }
.review-card strong { color: var(--deep); }
.flashcard-card { border-style: dashed; background: #f0f9ff; }
dialog { border:0; border-radius: 28px; padding:0; max-width: min(520px, calc(100% - 24px)); box-shadow: 0 35px 90px rgba(15,45,80,.30); }
dialog::backdrop { background: rgba(10,30,55,.35); backdrop-filter: blur(5px); }
.modal { padding: 24px; background: white; }
.setting-row { display:flex; align-items:center; justify-content:space-between; gap:16px; border-top:1px solid var(--line); padding: 16px 0; }
.setting-row small { display:block; color: var(--muted); margin-top: 2px; }
.switch { position:relative; width:54px; height:32px; flex: 0 0 auto; }
.switch input { opacity:0; width:0; height:0; }
.slider { position:absolute; inset:0; background:#cbd5e1; border-radius:99px; transition:.18s; }
.slider:before { content:""; position:absolute; width:24px; height:24px; left:4px; top:4px; background:white; border-radius:50%; box-shadow:0 3px 10px rgba(0,0,0,.18); transition:.18s; }
.switch input:checked + .slider { background: linear-gradient(135deg, var(--water), var(--mint)); }
.switch input:checked + .slider:before { transform:translateX(22px); }
@media (max-width: 980px) {
  .hero, .setup-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { position: static; }
}
@media (max-width: 560px) {
  .app-shell { width: min(100% - 18px, 480px); padding-top: 8px; }
  .mode-grid, .mini-grid { grid-template-columns: 1fr; }
  .hero-main, .card, .modal { padding: 18px; border-radius: 20px; }
  .brand span:last-child { display:none; }
  h1 { font-size: 3rem; }
  .quiz-actions .primary, .quiz-actions .secondary, .result-actions .primary, .result-actions .secondary { width: 100%; }
}

.game-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.game-card { text-align: left; border: 1px solid var(--line); border-radius: 24px; padding: 18px; background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(240,249,255,.86)); box-shadow: 0 14px 36px rgba(14,165,233,.10); transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.game-card:hover { transform: translateY(-3px); border-color: rgba(14,165,233,.5); box-shadow: 0 22px 48px rgba(14,165,233,.16); }
.game-card span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 16px; background: #e0f2fe; font-size: 1.5rem; margin-bottom: 10px; }
.game-card b { display: block; margin-bottom: 6px; font-size: 1.05rem; }
.game-card small { color: var(--muted); line-height: 1.45; }
.game-board { display: grid; gap: 12px; margin-top: 16px; }
.play-tile { text-align: left; border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: white; font-weight: 850; box-shadow: 0 8px 20px rgba(15,45,80,.06); }
.play-tile.selected { outline: 3px solid rgba(245,158,11,.34); border-color: rgba(245,158,11,.72); background: #fffbeb; }
.big-input { width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 12px 0; font-size: 1.1rem; }
.choice-button { width: 100%; cursor: pointer; color: var(--ink); font: inherit; }
@media (max-width: 980px) { .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .game-grid { grid-template-columns: 1fr; } }

/* Full-screen activity mode: games, quizzes, and flashcards should feel like entering an activity. */
body.activity-active .hero,
body.activity-active #setupScreen,
body.activity-active #gameHub,
body.activity-active .explainer { display: none !important; }
body.activity-active .app-shell { width: min(980px, calc(100% - 24px)); min-height: 100vh; padding-top: 12px; }
body.activity-active .topbar { margin-bottom: 10px; }
body.activity-active .quiz-screen,
body.activity-active .results-screen { min-height: calc(100vh - 92px); margin-top: 0; display: flex; flex-direction: column; justify-content: flex-start; animation: activityIn .24s ease-out; }
body.activity-active .question-card,
body.activity-active .game-board { flex: 1; }
@keyframes activityIn { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }

/* Smooth tap-to-flip flashcards */
.flip-card { width: 100%; min-height: min(56vh, 520px); border: 0; padding: 0; background: transparent; box-shadow: none; perspective: 1200px; cursor: pointer; text-align: left; }
.flip-card-inner { position: relative; min-height: min(56vh, 520px); transition: transform .62s cubic-bezier(.2,.75,.2,1); transform-style: preserve-3d; }
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border: 1px solid var(--line); border-radius: 28px; padding: clamp(22px, 5vw, 42px); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; background: linear-gradient(145deg, #f0f9ff, #ffffff 55%, #ecfdf5); }
.flip-back { transform: rotateY(180deg); background: linear-gradient(145deg, #ecfdf5, #ffffff 55%, #f0f9ff); }
.flip-card .question-prompt { font-size: clamp(1.45rem, 4vw, 2.35rem); line-height: 1.2; }
.flip-card .feedback { margin: 0; font-size: clamp(1.05rem, 2.5vw, 1.35rem); }
.tap-hint { margin-top: auto; margin-bottom: 0; font-weight: 850; color: var(--deep); }
