/* Gameucate IQ - mobile-first. Themes: neutral (menus), playful (PreK-5), mature (6+). */
:root { --bg: #f4f5fb; --fg: #1b1f3b; --card: #fff; --muted: #6b6f8a; --accent: #4f5bd5; --accent-fg: #fff;
  --ok: #1fa37a; --bad: #e0475b; --radius: 16px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[data-theme="playful"] { --bg: #fff6d9; --fg: #2b2350; --card: #fff; --accent: #ff7a1a; --muted: #7a6a9a; --radius: 26px;
  --font: "Trebuchet MS", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif; }
[data-theme="mature"] { --bg: #0f1220; --fg: #e8eaf6; --card: #1a1f35; --accent: #6c7cff; --muted: #8e95b8; --radius: 10px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); -webkit-text-size-adjust: 100%;
  transition: background .25s, color .25s; }
.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 10px 14px; }
.top h1 { font-size: 1.1rem; margin: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; min-width: 0; }
.logo-horizontal { display: block; height: 30px; width: auto; }
.home-logo { display: flex; justify-content: center; padding: 2px 0 6px; }
.hero { display: flex; justify-content: center; padding: 4px 0 18px; }
.logo-stacked { display: block; width: min(68vw, 260px); height: auto; }
.on-dark, [data-theme="mature"] .on-light { display: none; }
[data-theme="mature"] .on-dark { display: block; }
@media (max-width: 360px) { .logo-horizontal { height: 24px; } }
.screen { flex: 1; padding: 8px 14px 24px; }

button { font: inherit; color: inherit; cursor: pointer; }
.btn, .card, .icon, .chip { border: 0; border-radius: var(--radius); background: var(--card); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.btn { min-height: 52px; padding: 12px 18px; font-size: 1.05rem; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn:active, .card:active { transform: scale(.97); }
.icon { width: 44px; height: 44px; font-size: 1.6rem; line-height: 1; }
.chip { padding: 8px 12px; min-height: 44px; font-size: .9rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; min-height: 44px; }
small { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; }

/* Profiles */
.profiles { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.profiles li { display: flex; gap: 8px; align-items: center; }
.card.profile { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left; min-height: 64px; }
.avatar { font-size: 2rem; }
.grow { flex: 1; }
.del { font-size: 1rem; color: var(--muted); }
.new { display: grid; gap: 10px; padding: 14px; }
.new label[for] { font-weight: 700; }
.new input[type=text], .new input:not([type]) , #pname { font: inherit; font-size: 1.05rem; padding: 12px; border-radius: 12px; border: 2px solid #d9dcef; min-height: 48px; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avatars input { position: absolute; opacity: 0; pointer-events: none; }
.avatars span { display: grid; place-items: center; font-size: 1.6rem; height: 48px; border-radius: 12px; background: var(--bg); }
.avatars input:checked + span { outline: 3px solid var(--accent); }
.avatars input:focus-visible + span { outline: 3px dashed var(--accent); }

/* Grades + subjects */
.tier h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.btn.grade.on { outline: 3px solid var(--accent); }
.hint { color: var(--muted); margin: 4px 0 10px; }
.subjects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card.subject { padding: 16px 10px; min-height: 120px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.card.subject:disabled { opacity: .45; }
.sicon { font-size: 2.2rem; }
.toggle { display: flex; gap: 10px; align-items: center; margin-top: 18px; min-height: 44px; }
.toggle input { width: 22px; height: 22px; }

/* Game */
.qcard { background: var(--card); border-radius: var(--radius); padding: 22px 16px; text-align: center; margin: 10px 0 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.prompt { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.visual { font-size: 2.4rem; line-height: 1.4; margin-bottom: 8px; word-break: break-all; }
.playful-q .prompt { font-size: 1.9rem; }
.mature-q .prompt { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.35rem; font-weight: 600; }
.answers { display: grid; gap: 10px; }
.answers.big .btn { min-height: 76px; font-size: 2rem; }
.answers.grid2 { grid-template-columns: 1fr 1fr; }
.answers.grid2 .btn { min-height: 64px; font-size: 1.25rem; font-family: ui-monospace, Menlo, Consolas, monospace; }
.btn.right { background: var(--ok); color: #fff; }
.btn.wrong { background: var(--bad); color: #fff; animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.progress { text-align: center; letter-spacing: 4px; color: var(--accent); font-size: 1.1rem; }
.stars { text-align: center; font-size: 1.3rem; margin-top: 14px; font-weight: 700; }
.hud { display: flex; justify-content: space-between; font-size: .95rem; color: var(--muted); padding: 4px 2px; }
.hud b { color: var(--fg); }
.tierline { text-align: center; color: var(--muted); font-size: .85rem; }
.stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; color: var(--muted); margin-top: 10px; }
.badge { color: var(--accent); font-weight: 700; }

/* Ad placeholder (one-time unlock removes it) */
.ad { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 50px; padding: 4px 14px calc(4px + env(safe-area-inset-bottom)); background: #e7e8f0; color: #555; font-size: .8rem; }
[data-theme="mature"] .ad { background: #151827; color: #8e95b8; }

/* Tablets */
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
  .subjects { grid-template-columns: repeat(3, 1fr); }
  .prompt { font-size: 1.9rem; }
  .answers.big { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Learning modes */
.modes { display: grid; gap: 10px; }
.card.mode { display: flex; align-items: center; gap: 14px; padding: 14px; min-height: 72px; text-align: left; }
.card.mode .sicon { font-size: 2rem; width: 44px; text-align: center; }
.feedback { text-align: center; min-height: 1.4em; font-weight: 700; margin: 10px 0 0; }
.flashcard { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; width: 100%; min-height: 230px;
  margin: 10px 0 16px; padding: 20px; border: 0; border-radius: var(--radius); background: var(--card); color: var(--fg);
  box-shadow: 0 4px 16px rgba(0,0,0,.12); transition: transform .3s; }
.flashcard.flipped { background: var(--accent); color: var(--accent-fg); transform: rotateY(360deg); }
.flashcard.flipped small { color: inherit; opacity: .85; }
.answer-face { font-size: 2.6rem; font-weight: 800; }
.hidden-until-flip { visibility: hidden; }
.hidden-until-flip.show { visibility: visible; }
.match { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.btn.tile { min-height: 64px; font-size: 1rem; padding: 8px; }
.btn.tile.sel { outline: 3px solid var(--accent); }
.mini { display: block; font-size: .9rem; word-break: break-all; }
.scene { text-align: center; font-size: 1.6rem; min-height: 2.2rem; letter-spacing: 2px; word-break: break-all; }

/* Grade games */
.pond { position: relative; display: flex; justify-content: space-around; align-items: flex-end; height: 260px; margin-top: 8px; }
.bubble { width: 92px; height: 92px; border-radius: 50%; border: 3px solid rgba(80,160,255,.6); font-size: 2rem; font-weight: 800;
  background: radial-gradient(circle at 30% 30%, #fff, #bfe3ff 60%, #8cc8ff); color: var(--fg); animation: float 3.2s ease-in-out infinite; }
.bubble.b1 { animation-delay: .5s; } .bubble.b2 { animation-delay: 1s; } .bubble.b3 { animation-delay: 1.5s; }
.bubble.pop { animation: pop .5s forwards; } .bubble.wobble { opacity: .35; animation: shake .3s; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-110px); } }
@keyframes pop { to { transform: scale(1.6); opacity: 0; } }
.line { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin: 26px 0 8px; border-top: 4px solid var(--accent); }
.tick { background: none; border: 0; border-left: 2px solid var(--muted); min-height: 76px; padding: 4px 0; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between; font-size: 1.05rem; }
.tick .hop { visibility: hidden; font-size: 1.6rem; transform: translateY(-8px); }
.tick.here .hop { visibility: visible; animation: hop .4s; }
.tick.right b { color: var(--ok); } .tick.wrong b { color: var(--bad); text-decoration: line-through; }
@keyframes hop { 50% { transform: translateY(-34px); } }
.sky { position: relative; height: 300px; overflow: hidden; border-radius: var(--radius); background: linear-gradient(#1d2357, #4b3f8f); margin-top: 6px; }
.meteor { position: absolute; top: 4px; min-width: 88px; min-height: 52px; border: 0; border-radius: 26px; background: #ffd35a; color: #2b2350;
  font-weight: 800; font-size: 1.15rem; animation: fall var(--fall, 9s) linear forwards; }
.meteor.m0 { left: 4%; } .meteor.m1 { left: 36%; animation-delay: .4s; } .meteor.m2 { left: 66%; animation-delay: .8s; } .meteor.m3 { left: 20%; animation-delay: 1.2s; }
.meteor.right { background: var(--ok); color: #fff; animation-play-state: paused; } .meteor.wrong { background: var(--bad); color: #fff; animation-play-state: paused; }
.ground { position: absolute; bottom: 0; left: 0; right: 0; height: 18px; background: #6b4f2a; }
@keyframes fall { to { top: 236px; } }
.bossbar { background: var(--card); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; }
.boss-name { font-weight: 700; } .hearts { margin-top: 6px; font-size: 1.05rem; }
.hp { height: 14px; border-radius: 7px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 6px; }
.hp i { display: block; height: 100%; background: linear-gradient(90deg, #e0475b, #ff9a3c); transition: width .4s; }
.locks { text-align: center; font-size: 1.6rem; letter-spacing: 6px; margin: 6px 0; }
.btn.gone { opacity: .25; }
@media (prefers-reduced-motion: reduce) { .meteor { top: 90px; } .meteor.m1, .meteor.m3 { top: 170px; } }
.answers.words .btn { font-size: 1.1rem; min-height: 52px; font-family: inherit; line-height: 1.25; padding: 10px 12px; overflow-wrap: anywhere; }
.answers.big.words .btn { font-size: 1.25rem; min-height: 58px; }
.answers.words:not(.big) { grid-template-columns: 1fr; }
@media (min-width: 700px) { .answers.words:not(.big), .answers.big.words { grid-template-columns: 1fr 1fr; } }
.prompt.long, .playful-q .prompt.long { font-size: 1.2rem; }
.mature-q .prompt.long { font-family: inherit; font-size: 1.15rem; }
@media (min-width: 700px) { .prompt.long, .playful-q .prompt.long { font-size: 1.45rem; } }
/* Short phones (iPhone SE, small Androids): keep all answers above the ad bar without scrolling. */
@media (max-height: 700px) {
  .qcard { padding: 14px 12px; margin: 6px 0 10px; }
  .visual { font-size: 1.8rem; line-height: 1.2; margin-bottom: 4px; }
  .scene { font-size: 1.2rem; min-height: 1.6rem; }
  .answers { gap: 8px; }
  .answers.big .btn { min-height: 56px; font-size: 1.6rem; }
  .answers.big.words .btn, .answers.words .btn { min-height: 48px; font-size: 1.1rem; }
  .playful-q .prompt { font-size: 1.6rem; }
}
