/* VOICE: confident match-day coach; encouraging, never babyish
   IDEA: a cricket ground he builds out of bricks; every question is a ball he faces
   COLOUR and TYPE: deep navy + turf green, one brick-red accent; Figtree throughout, tabular numerals for scores
   LAYOUT: scoreboard strip, stadium hero, then match card, season road, badges, shop */
:root {
  --grass: #2f7d46; --grass2: #3f9a5a; --red: #c8453b; --yellow: #f2b632; --blue: #2f6fb5; --orange: #d9772b;
  --ink: #17233a; --paper: #ffffff; --card: #ffffff; --muted: #566177; --board: #14213d; --led: #f2c14e; --line: #dde3ea;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,33,61,.08), 0 4px 12px rgba(20,33,61,.07);
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; }
body {
  font: 16px/1.5 "Figtree", system-ui, sans-serif; color: var(--ink); overflow-x: clip;
  background: #eef2f1;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.led { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--led); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* brick buttons: studs on top like a toy brick */
.brick {
  position: relative; border: 0; border-radius: 10px; padding: 12px 20px; min-height: 48px;
  background: var(--c, var(--red)); color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18); transition: filter .15s, transform .15s; margin-top: 4px;
}
.brick:hover { filter: brightness(1.07); } .brick:active { transform: translateY(1px); }
.brick.yellow { --c: var(--yellow); color: var(--ink); } .brick.blue { --c: var(--blue); } .brick.green { --c: var(--grass); }
.brick.ghost { --c: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.brick[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login .scene { position: relative; background: var(--grass); overflow: hidden; }
.login .scene > div, .login .scene svg, .login .scene img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.login .panel { display: grid; place-items: center; padding: 32px 20px; }
.login h1 { font-weight: 800; font-size: clamp(30px, 4vw, 40px); line-height: 1.1; letter-spacing: -.01em; margin: 0 0 6px; color: var(--board); text-wrap: balance; }
.login .lead { margin: 0 0 22px; color: var(--muted); font-size: 18px; }
.who { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.pinbox { display: flex; gap: 12px; justify-content: center; margin: 8px 0 16px; }
.pinbox span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.pinbox span.on { background: var(--ink); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; justify-content: center; }
.pad .brick { padding: 8px 0; font-size: 22px; font-weight: 800; }
.login .card { background: var(--card); border-radius: 16px; padding: 28px clamp(18px, 4vw, 34px); box-shadow: var(--shadow); width: min(440px, 100%); text-align: center; }
.login .err { color: var(--red); min-height: 1.5em; font-weight: 700; }

/* ---------- kid app ---------- */
.scorebar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px;
  background: var(--board); color: #fff; padding: 10px max(3vw, 14px); border-bottom: 3px solid var(--yellow);
}
.scorebar .team { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.crest { width: 40px; height: 40px; border-radius: 10px; background: var(--red); display: grid; place-items: center; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
.scorebar b { display: block; line-height: 1.1; }
.scorebar small { color: #adb5bd; font-size: 13px; display: block; line-height: 1.1; }
.scorebar .stat .led { font-size: 22px; }
.iconbtn { background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 10px; min-width: 44px; height: 44px; padding: 0 12px; font-weight: 700; }

main.home { max-width: 1180px; margin: 0 auto; padding: 18px max(3vw, 14px) 60px; display: grid; gap: 22px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.panel h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.005em; line-height: 1.1; }
.panel .sub { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.span2 { grid-column: 1 / -1; }

.stadium { position: relative; padding: 0; overflow: hidden; grid-row: span 2; }
.stadium .art { aspect-ratio: 1000 / 520; background: #74c0fc; }
.stadium .art svg, .stadium .art img { width: 100%; height: 100%; display: block; object-fit: cover; }
.layer.locked { opacity: .13; filter: grayscale(1); }
.layer.built { animation: rise .5s cubic-bezier(.16,1,.3,1) both; animation-delay: var(--d); transform-box: fill-box; transform-origin: bottom; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scaleY(.85); } }
.glow { animation: flicker 3s ease-in-out infinite alternate; }
@keyframes flicker { to { opacity: .55; } }
.stadium .info { padding: 14px 20px 18px; display: grid; gap: 8px; }
.stadium .title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stadium .title b { font-size: 20px; }
.brickbar { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 3px; }
.brickbar i { height: 12px; border-radius: 3px; background: #e9ecef; }
.brickbar i.on { background: var(--red); box-shadow: none; }
.brickbar i.on:nth-child(3n+2) { background: var(--yellow); } .brickbar i.on:nth-child(3n) { background: var(--blue); }

.coach { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: end; }
.coach .bot { width: 110px; height: 120px; } .coach .bot svg, .coach .bot img { width: 100%; height: 100%; object-fit: contain; }
.bubble { position: relative; background: #f3f6fb; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; }
.bubble::after { content: ""; position: absolute; left: -16px; bottom: 18px; border: 8px solid transparent; border-right-color: var(--line); }
.bubble .from { font-size: 13px; color: var(--muted); font-weight: 700; }
.reacts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.reacts button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; min-height: 40px; font-weight: 700; }
.reacts button.on { background: var(--yellow); }

.goal { display: flex; align-items: center; gap: 14px; }
.ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--grass2) calc(var(--p) * 1%), #e9ecef 0); }
.ring span { width: 64px; height: 64px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 18px; }

.mission { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.task { text-align: left; border: 0; border-radius: 12px; padding: 14px 12px 12px; color: #fff; background: var(--c); position: relative; min-height: 140px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 4px; transition: transform .1s; }
.task:hover { transform: translateY(-2px); } .task:active { transform: translateY(1px); }
.task b { font-size: 18px; line-height: 1.1; } .task small { font-size: 13px; opacity: .92; line-height: 1.25; }
.task .dots { display: flex; gap: 5px; margin-top: auto; }
.task .dots i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.35); }
.task .dots i.on { background: #fff; }
.task.done { filter: saturate(.85) brightness(.95); } .task.done .tick { position: absolute; right: 10px; top: 8px; font-size: 22px; }
.task.na { opacity: .5; }
.task.yellow { color: var(--ink); } .task.yellow .dots i { background: rgba(0,0,0,.15); } .task.yellow .dots i.on { background: var(--ink); }

.season { display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 10px; scroll-snap-type: x mandatory; }
.wk { flex: none; width: 120px; scroll-snap-align: center; border-radius: 10px; padding: 10px; background: #f1f3f5; font-size: 13px; line-height: 1.25; border: 2px solid transparent; }
.wk b { display: block; font-size: 15px; } .wk.past { background: #e3f1e7; } .wk.now { border-color: var(--red); background: #fff; }
.wk .ph { display: inline-block; font-size: 11px; font-weight: 800; border-radius: 6px; padding: 0 6px; background: #dee2e6; margin-bottom: 4px; }
.wk.final { background: #fbf0d3; }

.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.badge { text-align: center; font-size: 13px; line-height: 1.2; background: none; border: 0; padding: 4px; border-radius: 12px; color: var(--ink); }
.badge .ic { width: 78px; height: 72px; margin: 0 auto 4px; } .badge .ic svg, .badge .ic img { width: 100%; height: 100%; object-fit: contain; }
.badge.locked { opacity: .55; }
.badge.fresh .ic { animation: pop .8s cubic-bezier(.2,1.6,.5,1); }
@keyframes pop { from { transform: scale(0) rotate(-30deg); } }

.shop { display: grid; gap: 10px; }
.reward { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: #f8f9fa; }
.reward b { display: block; } .reward small { color: var(--muted); }
.reward .brick { padding: 8px 14px; min-height: 44px; font-size: 15px; margin: 0; }
.meter { height: 8px; border-radius: 4px; background: #e9ecef; margin-top: 6px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--grass2); }

.innings-list { display: grid; gap: 8px; }
.inn { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #f3f6fb; color: var(--ink); }
.inn small { color: var(--muted); } .inn .led { font-size: 18px; color: var(--grass); }

/* ---------- innings (quiz) ---------- */
.pitch { min-height: calc(100vh - 69px); background: linear-gradient(#e9eef0, #dfe7e5); padding: 18px max(3vw, 14px) 60px; }
.innbar { max-width: 860px; margin: 0 auto 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--board); color: #fff; border-radius: 12px; padding: 10px 16px; }
.innbar .big { font-size: 32px; } .innbar small { color: #adb5bd; display: block; font-size: 12px; line-height: 1; }
.balls { flex: 1 1 320px; display: flex; gap: 6px; flex-wrap: wrap; }
.balls i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 800; background: #2b2d42; color: #8d99ae; border: 2px solid #3d405b; }
.balls i.now { border-color: var(--yellow); color: var(--yellow); animation: pulse 1.2s infinite; }
.balls i.r2 { background: #74c0fc; color: var(--ink); } .balls i.r4 { background: var(--grass2); color: #fff; } .balls i.r6 { background: var(--yellow); color: var(--ink); }
.balls i.w { background: var(--red); color: #fff; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(252,196,25,.35); } }
.qcard { max-width: 860px; margin: 0 auto; background: var(--paper); border-radius: 16px; padding: clamp(18px, 4vw, 34px); box-shadow: var(--shadow); position: relative; }
.qmeta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; background: #e7f5ff; color: #1864ab; }
.chip.pace1 { background: #d3f9d8; color: #2b8a3e; } .chip.pace2 { background: #fff3bf; color: #e67700; } .chip.pace3 { background: #ffe3e3; color: #c92a2a; }
.qtext { font-size: clamp(20px, 2.6vw, 26px); line-height: 1.4; font-weight: 600; margin: 6px 0 22px; }
.answer-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.answer-row input { font: inherit; font-size: 26px; font-weight: 700; width: min(320px, 100%); padding: 12px 16px; border-radius: 10px; border: 2px solid var(--ink); background: #fff; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 6px; }
.opts .brick { text-align: left; font-size: 17px; }
.opts .brick.picked { outline: 3px solid var(--ink); outline-offset: 2px; }
.checklist { margin-top: 18px; font-size: 14px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.checklist span::before { content: "✓ "; color: var(--grass); font-weight: 800; }
.clock { position: absolute; right: 18px; top: 16px; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; color: var(--muted); }
.quit { background: none; border: 0; color: #fff; text-decoration: underline; min-height: 44px; }

.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(20,33,61,.55); padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.result { background: #fff; border-radius: 16px; padding: 26px clamp(18px, 4vw, 34px); width: min(560px, 100%); text-align: center; box-shadow: var(--shadow); animation: zoom .25s cubic-bezier(.16,1,.3,1); max-height: 92vh; overflow: auto; }
@keyframes zoom { from { transform: scale(.94); opacity: 0; } }
.shout { font-weight: 800; font-variant-numeric: tabular-nums; font-size: clamp(40px, 8vw, 64px); line-height: 1; letter-spacing: -.02em; margin: 6px 0 8px; }
.shout.six { color: var(--orange); } .shout.four { color: var(--grass); }
.shout.two { color: var(--blue); } .shout.out { color: var(--red); }
.ballfly { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff8787, #c92a2a); margin: 0 auto; animation: fly 1s ease-out both; position: relative; }
.ballfly::after { content: ""; position: absolute; inset: 15px 0; border-top: 2px dashed #fff; transform: rotate(-30deg); }
@keyframes fly { from { transform: translate(-120px, 60px) scale(.4); } to { transform: translate(0,0) scale(1) rotate(720deg); } }
.stumps { display: flex; gap: 8px; justify-content: center; height: 60px; align-items: flex-end; }
.stumps i { width: 9px; height: 56px; background: #f2c18d; border-radius: 3px; transform-origin: bottom; animation: fall .6s .15s ease-in both; }
.stumps i:nth-child(1) { --r: -35deg; } .stumps i:nth-child(2) { --r: 12deg; } .stumps i:nth-child(3) { --r: 40deg; }
@keyframes fall { to { transform: rotate(var(--r)); } }
.how { background: #f1f3f5; border-radius: 10px; padding: 10px 14px; text-align: left; margin: 12px 0; }
.why { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; margin-top: 14px; }
.why .brick { font-size: 15px; padding: 10px; }

.summary { max-width: 860px; margin: 0 auto; display: grid; gap: 18px; }
.board { background: var(--board); color: #fff; border-radius: 16px; padding: 20px 24px; text-align: center; }
.board .score { font-size: clamp(48px, 9vw, 80px); line-height: 1; }
.board .row { display: flex; justify-content: center; gap: 26px; flex-wrap: wrap; margin-top: 10px; }
.board .row div { min-width: 90px; } .board .row b { display: block; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--led); font-size: 22px; font-weight: 400; }
.board .row small { color: #adb5bd; }
.unlock { text-align: center; }
.unlock .shout { font-size: clamp(28px, 5vw, 40px); color: var(--red); }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 99; display: grid; gap: 8px; }
.toast { background: var(--board); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); transition: opacity .4s; }
.toast.error { background: var(--red); } .toast.ok { background: var(--grass); } .toast.out { opacity: 0; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
.loading { display: grid; place-items: center; min-height: 60vh; font-size: 22px; font-weight: 800; color: #fff; }

@media (max-width: 900px) {
  main.home { grid-template-columns: minmax(0, 1fr); }
  .stadium { grid-row: auto; }
  .mission { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (max-width: 700px) {
  .login { grid-template-columns: 1fr; } .login .scene { min-height: 34vh; }
  .scorebar { position: static; gap: 6px 14px; padding: 8px 12px; }
  .scorebar .team { flex: 1 1 100%; margin-right: 0; }
  .scorebar .stat .led { font-size: 18px; }
  .iconbtn { height: 36px; min-width: 36px; padding: 0 10px; font-size: 13px; }
  .scorebar .iconbtn:first-of-type { margin-left: auto; }
  .why { grid-template-columns: 1fr; }
  .coach { grid-template-columns: 80px minmax(0,1fr); } .coach .bot { width: 80px; height: 90px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
