:root {
  --bg: #fff6e5;
  --ink: #2b2340;
  --pop: #ff6b5b;
  --sun: #ffc93c;
  --mint: #2ec4b6;
  --grape: #7b5cff;
  --card: #fff;
  --shadow: 4px 4px 0 var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0 auto; max-width: 640px; padding: 16px; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 4px solid var(--grape); outline-offset: 3px; }
/* Old TV WebViews lack :focus-visible and drop the second rule, keeping the :focus ring. */
button:focus, summary:focus, input:focus { outline: 4px solid var(--grape); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

header { text-align: center; margin: 8px 0 20px; }
.logo { font-size: 2rem; font-weight: 900; color: var(--ink); text-decoration: none; letter-spacing: -0.5px; }
.logo span { color: var(--pop); }
.logo small { font-size: 1rem; font-weight: 700; color: var(--grape); margin-left: 4px; }
.tagline { margin: 4px 0 0; opacity: 0.7; }
footer { text-align: center; opacity: 0.55; font-size: 0.85rem; padding: 24px 0 8px; }
.center { text-align: center; }

.card, .tile, .big-btn, .opt, .tile-l, .cell, .stats > div {
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: var(--card);
}
button.tile, .topic, .big-btn, .opt, .tile-l, .cell.on { transition: transform 0.1s, box-shadow 0.1s; }
button.tile:active, .topic:active, .big-btn:active, .opt:not(:disabled):active, .tile-l:not(:disabled):active, .cell.on:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.pick { display: grid; gap: 14px; }
.tile { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; text-align: left; padding: 16px; }
.tile .big { font-size: 2.4rem; grid-row: span 2; align-self: center; }
.tile b { font-size: 1.2rem; }
.tile:nth-child(3n+1), .topic:nth-child(3n+1) { background: #ffe3df; }
.tile:nth-child(3n+2), .topic:nth-child(3n+2) { background: #fff0c2; }
.tile:nth-child(3n), .topic:nth-child(3n) { background: #d9f6f2; }

.levels { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 10px; margin: 0 -4px; }
.chip { flex: none; border: 2px solid var(--ink); border-radius: 99px; background: var(--card); padding: 6px 12px; font-weight: 700; white-space: nowrap; }
.chip.on { background: var(--grape); color: #fff; }
.parent { margin-top: 28px; padding-top: 12px; border-top: 2px dashed #d8ccb4; font-size: 0.9rem; }
.parent summary { cursor: pointer; text-align: center; opacity: 0.6; padding: 6px; }
.parent p { margin: 8px 0 4px; opacity: 0.7; }
.parent .link { display: block; margin: 8px auto 0; }
.gate { text-align: center; margin-top: 8px; }
.gate .opts { grid-template-columns: repeat(4, 1fr); }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.topic { display: grid; justify-items: center; gap: 2px; padding: 12px 8px; border: 3px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); }
.topic .big { font-size: 2.2rem; }
.topic small { opacity: 0.7; }
.up { display: block; margin: 0 auto; font-weight: 800; }

.hello p { text-align: center; }
.link { background: none; border: 0; color: var(--grape); text-decoration: underline; padding: 4px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 12px 0 18px; }
.stats > div { padding: 12px; text-align: center; background: var(--sun); }
.stats b { display: block; font-size: 1.8rem; }

.big-btn { display: block; width: 100%; padding: 16px; margin: 18px 0; font-size: 1.2rem; font-weight: 800; background: var(--pop); color: #fff; }

.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 10px; }
.cell { aspect-ratio: 1; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; background: #eee3cf; box-shadow: none; opacity: 0.6; }
.cell.on { background: var(--card); box-shadow: var(--shadow); opacity: 1; }

.dots { display: flex; justify-content: center; gap: 8px; margin: 0 0 12px; }
.dots span { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; background: var(--card); }
.dots .done { background: var(--mint); }
.dots .now { background: var(--sun); transform: scale(1.35); }
.card { padding: 20px; animation: pop 0.25s ease-out; }
.card .emoji { display: block; margin: 0 auto; font-size: 6rem; line-height: 1.1; background: none; border: 0; padding: 0; }
.card .emoji:active { transform: scale(0.92); }
.card h2 { text-align: center; margin: 6px 0 0; font-size: 2rem; }
.zh { text-align: center; margin: 4px 0 14px; opacity: 0.7; }
.fact { background: #f3efff; border-radius: 12px; padding: 12px 14px; line-height: 1.7; margin: 0; }
.fact b { color: var(--grape); }
.say { background: none; border: 0; font-size: 1.4rem; vertical-align: middle; }

.q { font-size: 1.2rem; font-weight: 700; text-align: center; }
.opts { display: grid; gap: 12px; }
.opt { padding: 14px; font-size: 1.05rem; text-align: left; }
.opts.pics { grid-template-columns: repeat(3, 1fr); }
.opts.pics .opt { font-size: 3rem; text-align: center; padding: 10px 0; }
.opt.right { background: var(--mint); color: #fff; }
.opt.wrong { background: var(--pop); color: #fff; animation: shake 0.3s; }
.opt.tried { opacity: 0.35; box-shadow: none; animation: shake 0.3s; }

.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 18px; }
.slots span { width: 36px; height: 44px; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; border-bottom: 4px solid var(--ink); }
.slots.miss span { color: var(--pop); animation: shake 0.3s; }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 8px; }
.tile-l { width: 48px; height: 48px; font-size: 1.4rem; font-weight: 800; background: var(--sun); }
.tile-l:disabled { opacity: 0.25; box-shadow: none; }
.undo { display: block; margin: 4px auto 0; background: var(--card); }

#fb p { text-align: center; font-size: 1.2rem; font-weight: 800; margin: 18px 0 0; }
.ok { color: #138a7e; }
.no { color: var(--pop); }

.stickers { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 16px 0 8px; font-size: 3.2rem; }
.stickers span { display: grid; place-items: center; width: 76px; height: 76px; background: #fff0c2; border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow); animation: stamp 0.35s calc(0.25s + var(--k, 0) * 0.18s) cubic-bezier(.3, 1.6, .5, 1) both; }
.stickers span:nth-child(even) { rotate: 4deg; }
.stickers span:nth-child(odd) { rotate: -3deg; }
.cell.new { animation: stamp 0.35s cubic-bezier(.3, 1.6, .5, 1) both; }
.bar { height: 14px; margin: 14px 0 4px; border: 2px solid var(--ink); border-radius: 99px; background: var(--card); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--mint); }

@keyframes stamp { from { transform: scale(1.8); opacity: 0; } }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.en { font: inherit; background: none; border: 0; padding: 0; color: var(--grape); text-decoration: underline dotted; text-underline-offset: 3px; }

.account h2 { margin-top: 0; }
.account label { display: block; font-weight: 700; margin: 12px 0; }
.account input { display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; border: 3px solid var(--ink); border-radius: 12px; }
.account .no { text-align: center; min-height: 1.2em; margin: 0; }
.account .link { display: block; margin: 0 auto; }

/* Short screens (a TV WebView is often 960x540 or less): drop the tagline and footer and
   tighten spacing, so a card's picture and its button fit on one screen. */
@media (max-height: 600px) {
  body { padding-top: 6px; }
  header { margin: 0 0 6px; }
  .logo { font-size: 1.5rem; }
  .tagline, footer { display: none; }
  .dots { margin-bottom: 6px; }
}
