/* Quiz Race: the family look (Math Cube's and Word Cube's light paper theme, Fredoka for display, Nunito for text).
   The page: a top bar, the race track, and the question below it; every other screen is a card over the page. */
:root{
  --paper:#edf2f8; --rule:rgba(38,78,150,.09); --ink:#18263f; --muted:#5b6983;
  --tile:#ffffff; --tile-edge:#c3cfe0; --given:#dfe7f2; --slot:#f8fafd; --slot-line:#9cadc9;
  --you:#2f5bff; --you-soft:#dde5ff; --you-edge:#1c3dc2; --on-you:#ffffff;
  --good:#12a165; --good-soft:#d7f3e6; --on-good:#ffffff; --gold:#f2b705; --gold-soft:#fff3c4;
  --soft:#eef1f6;
  --panel:rgba(255,255,255,.75); --panel-line:rgba(24,38,63,.1); --scrim:rgba(237,242,248,.72);
  --lift:0 1px 2px rgba(24,38,63,.06),0 16px 44px rgba(24,38,63,.16);
  --font-display:"Fredoka","Baloo 2","Trebuchet MS",system-ui,sans-serif;
  --font-body:"Nunito",system-ui,-apple-system,"Segoe UI",sans-serif;
  color-scheme:light;
}
html,body{height:100%; touch-action:manipulation}
body{background-color:var(--paper); background-image:linear-gradient(var(--rule) 1px,transparent 1px),linear-gradient(90deg,var(--rule) 1px,transparent 1px); background-size:22px 22px;
  color:var(--ink); font-family:var(--font-body); margin:0; overflow:hidden; -webkit-tap-highlight-color:transparent}
button{font:inherit; color:inherit; cursor:pointer}
[hidden]{display:none!important}
#app{height:100vh; height:100dvh; max-width:720px; margin:0 auto; display:flex; flex-direction:column; gap:8px; box-sizing:border-box;
  padding-left:max(16px, env(safe-area-inset-left, 0px)); padding-right:max(16px, env(safe-area-inset-right, 0px));
  padding-top:max(8px, env(safe-area-inset-top, 0px)); padding-bottom:max(8px, env(safe-area-inset-bottom, 0px))}

/* Cards */
.overlay{position:fixed; inset:0; z-index:40; display:grid; place-items:center; grid-template-columns:minmax(0, 1fr); background:var(--scrim); backdrop-filter:blur(5px); overflow:auto;
  padding-left:max(16px, env(safe-area-inset-left, 0px)); padding-right:max(16px, env(safe-area-inset-right, 0px)); padding-block:max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px))}
.card{width:100%; max-width:420px; box-sizing:border-box; padding:24px 20px 20px; border-radius:24px; background:var(--tile); border:0; box-shadow:var(--lift); display:flex; flex-direction:column; gap:16px; animation:cardIn .4s cubic-bezier(.3,1.4,.5,1)}
@keyframes cardIn{0%{transform:translateY(20px) scale(.95); opacity:0}}
.card > *{flex-shrink:0}
h1,h2{margin:0; font-family:var(--font-display); font-weight:700; line-height:1.05; text-wrap:balance}
h1{font-size:38px} h2{font-size:26px}
.card h2{text-align:center}
.lede{margin:0; font-size:16px; line-height:1.45; color:var(--muted); font-weight:600; text-align:center}
.hint{margin:-4px 0 0; font-size:13px; font-weight:700; color:var(--muted); text-align:center}
.status{margin:0; min-height:18px; font-size:14px; font-weight:700; color:var(--muted); text-align:center}
.sublab{font:700 13px/1 var(--font-body); letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin:0 0 8px}
.btn{border:0; border-radius:16px; min-height:56px; padding:12px 18px; font-family:var(--font-display); font-weight:600; font-size:20px; background:var(--you); color:var(--on-you); box-shadow:0 4px 0 var(--you-edge); touch-action:manipulation}
.btn:active{transform:translateY(3px); box-shadow:0 1px 0 var(--you-edge)}
.btn.ghost{min-height:48px; background:var(--given); color:var(--ink); box-shadow:none; font-size:17px}
.btn.ghost:active{transform:translateY(1px); background:color-mix(in srgb, var(--given) 85%, var(--ink))}
.btn[disabled]{opacity:.55; pointer-events:none}
.btns{display:flex; flex-direction:column; gap:10px}
.linkbtn{align-self:center; min-height:44px; padding:8px 16px; border:0; border-radius:12px; background:none; color:var(--you); font:600 16px/1.2 var(--font-display); cursor:pointer}
.linkbtn:active{background:var(--you-soft)}
.chip{padding:8px 14px; border-radius:999px; border:0; background:var(--given); color:var(--ink); font-size:14px; font-weight:800; touch-action:manipulation}
.chip[aria-checked="true"],.chip.on{background:var(--you); color:var(--on-you)}
:is(.btn,.chip,.linkbtn,.choice,.pl-strip,.pl-tgt,.iconbtn,.ab,.mebtn):focus-visible{outline:3px solid var(--you); outline-offset:2px}
.card.sheet{gap:14px; max-height:calc(100dvh - 32px); overflow:auto; overscroll-behavior:contain}

/* The start card */
.card.start{position:relative; max-width:440px; gap:14px; padding-top:20px}
.card.start h1{text-align:center; margin-top:-4px}
.card.start .logo{display:block; width:72px; height:72px; margin:30px auto 0; border-radius:18px; box-shadow:0 3px 0 rgba(11,107,58,.35)}
.links{display:flex; justify-content:center; gap:8px; flex-wrap:wrap; margin-top:-6px}
.linkbtn.small{min-height:36px; font-size:15px; padding:6px 10px}
.linkbtn.small[aria-checked="true"]{color:var(--ink)}
.rules{margin:0; padding-left:20px; display:flex; flex-direction:column; gap:8px; font-size:16px; line-height:1.45}
.startmain{display:flex; flex-direction:column; gap:14px}
.mebtn{position:absolute; right:12px; top:12px; display:inline-flex; align-items:center; gap:6px; max-width:60%; min-height:36px; padding:5px 12px 5px 8px; border:0; border-radius:999px; background:var(--given); color:var(--ink);
  font:800 14px/1 var(--font-body); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; touch-action:manipulation}
.choice{display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; min-height:52px; padding:10px 16px; border:0; border-radius:16px; background:var(--given); color:var(--ink); text-align:left; touch-action:manipulation}
.choice .ct{min-width:0; font:600 17px/1.2 var(--font-display); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.choice .cg{flex:none; font-size:15px; font-weight:800; color:var(--you)}
.ageask{display:flex; flex-direction:column; gap:12px}
.ageask h2{font-size:24px}
.agebig,.agegrid{display:grid; grid-template-columns:repeat(5, 1fr); gap:8px}
.ab{height:56px; border:0; border-radius:16px; background:var(--given); color:var(--ink); font:700 24px/1 var(--font-display); box-shadow:0 3px 0 var(--tile-edge); touch-action:manipulation}
.ab:active{transform:translateY(2px); box-shadow:0 1px 0 var(--tile-edge)}
.ab.wide{grid-column:span 2; font-size:20px}
.agegrid .ab{height:48px; font-size:20px}
.agegrid .ab[aria-checked="true"]{background:var(--you); color:var(--on-you); box-shadow:0 3px 0 var(--you-edge)}
.topics{display:flex; flex-direction:column; gap:6px}
.topic{display:flex; align-items:center; gap:10px; width:100%; padding:10px 12px; border:0; border-radius:14px; background:var(--given); color:var(--ink); text-align:left; font:700 16px/1.25 var(--font-body)}
.topic .tk{flex:none; width:26px; height:26px; border-radius:8px; background:var(--tile); display:grid; place-items:center; font-size:16px; color:var(--you)}
.topic[aria-checked="true"] .tk{background:var(--you); color:var(--on-you)}
.topic small{display:block; font-weight:600; color:var(--muted); font-size:13px}
.topic .tl{margin-left:auto; flex:none; font-size:12px; font-weight:800; color:var(--muted)}
/* the strip: one target first, then Others */
.pl-row{display:flex; gap:8px; width:100%}
.pl-strip{display:flex; align-items:center; justify-content:center; gap:10px; flex:1 1 auto; min-height:44px; padding:8px 14px; border:0; border-radius:14px; background:transparent; color:var(--muted); font:800 15px/1.2 var(--font-body); box-shadow:inset 0 0 0 1.5px var(--panel-line); touch-action:manipulation}
.pl-tgt:not([hidden]) + .pl-strip{flex:0 0 auto}
.pl-tgt{flex:1 1 0; min-width:0; min-height:44px; padding:8px 14px; border:0; border-radius:14px; background:var(--you-soft); color:var(--ink); font:800 15px/1.25 var(--font-body); text-align:left; touch-action:manipulation;
  display:grid; grid-template-columns:auto minmax(0,1fr); column-gap:8px; align-items:center}
.pl-tgt .pl-vs{grid-row:1 / span 2; display:inline-flex}
.pl-tgt .tg-what{overflow-wrap:anywhere}
.pl-tgt .tg-go{color:var(--you); font-size:14px}
.pl-vsf{width:26px; height:26px; background:var(--tile); box-shadow:0 0 0 2px var(--tile); font-size:17px}
.pl-vsf + .pl-vsf{margin-left:-6px; background:var(--given)}
.together{margin:0; text-align:center; text-wrap:balance; font-size:13px; font-weight:700; color:var(--muted)}
.together-end{margin:0; text-align:center; font-size:15px; font-weight:800; color:var(--you)}

/* Faces (src/chars/faces.js) */
.cface{display:inline-grid; place-items:center; vertical-align:middle; border-radius:50%; line-height:1; flex:none}
.cface.drawn{overflow:hidden; font-size:0; background:var(--given)}
.cface canvas{display:block}
.me-face{width:24px; height:24px; background:var(--tile)}

/* The end card */
.tally{display:grid; grid-template-columns:repeat(3, 1fr); gap:8px}
.tally div{display:flex; flex-direction:column; align-items:center; gap:2px; padding:12px 4px 10px; border-radius:16px; background:var(--given); font-weight:800; font-size:12px; color:var(--muted); text-align:center}
.tally b{font-family:var(--font-display); font-weight:600; font-size:26px; line-height:1; font-variant-numeric:tabular-nums; color:var(--ink)}
.tally div:first-child b{color:var(--you)}
.went{margin:0; padding:10px 14px; border-radius:14px; background:var(--good-soft); color:var(--ink); text-align:center; font:500 16px/1.35 var(--font-display)}
.rank{margin:0; padding:0; list-style:none; display:flex; flex-direction:column; gap:6px; max-height:40vh; overflow:auto}
.rank li{display:flex; align-items:center; gap:8px; padding:8px 12px; border-radius:12px; background:var(--given); font-weight:800}
.rank li.me{background:var(--you-soft); box-shadow:inset 0 0 0 2px var(--you)}
.rank li .pl{flex:none; width:22px; color:var(--muted); font-variant-numeric:tabular-nums}
.rank li .nm{flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.rank li .sc{flex:none; font:600 16px/1 var(--font-display); font-variant-numeric:tabular-nums}
.rank li .cface{width:26px; height:26px}
.rank li .clap{flex:none; min-width:40px; min-height:34px; border:0; border-radius:999px; background:var(--tile); font-size:16px}
.rank li .clap:disabled{opacity:.5}
.rank li.more{justify-content:center; color:var(--muted); background:transparent}

.toast{position:fixed; left:50%; top:max(70px, calc(env(safe-area-inset-top, 0px) + 60px)); transform:translateX(-50%); z-index:80; display:flex; align-items:center; gap:8px; padding:8px 8px 8px 14px; border-radius:22px; background:var(--tile); border:2px solid var(--you);
  color:var(--ink); font-weight:800; font-size:15px; box-shadow:0 4px 14px rgba(0,0,0,.12); max-width:calc(100vw - 32px); box-sizing:border-box}
.toast .tt{flex:1 1 auto; min-width:0; line-height:1.25}
.toast button{flex:none; border:0; border-radius:999px; padding:8px 14px; background:var(--you); color:#fff; font:800 14px/1 var(--font-body)}
.toast:not(:has(button)){padding-right:14px}
@media (prefers-reduced-motion: reduce){ .card{animation:none!important} }
