/* Calm, high contrast, big targets. Plain backgrounds help children who find busy screens hard to read. */
:root {
  --bg: #FFF8EA;
  --ink: #1B2A41;
  --muted: #4A5A72;
  --primary: #0F7B8F;
  --primary-dark: #0A5E6E;
  --accent: #F2A22E;
  --good: #2E8B57;
  --card: #FFFFFF;
  --soft: #E6F2F4;
  --danger: #B3261E;
  --c1: #FFD98A;
  --c2: #BFE3F2;
  --c3: #CDEBC5;
  --radius: 26px;
  --shadow: 0 6px 0 rgba(27, 42, 65, .14);
  --scale: 1.3;
  --ts: 1.3;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Devanagari', sans-serif;
  font-size: 20px;
  line-height: 1.35;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
#app { min-height: 100dvh; display: flex; flex-direction: column; }
h1 { font-size: clamp(30px, 6vw, 48px); margin: 8px 0 12px; text-align: center; }
h2 { font-size: 26px; margin: 8px 0; }
h3 { font-size: 20px; margin: 18px 0 8px; }
.lead { font-size: 22px; text-align: center; margin: 4px 0 16px; color: var(--muted); }
.hint-small { font-size: 16px; color: var(--muted); text-align: center; }
.big-emoji { font-size: 96px; text-align: center; line-height: 1.1; }
.screen { flex: 1; padding: 16px max(16px, env(safe-area-inset-left)) 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 800; font-size: 22px;
  min-height: 72px; min-width: 72px; padding: 12px 26px;
  border: 3px solid var(--ink); border-radius: var(--radius);
  background: #fff; color: var(--ink); box-shadow: var(--shadow);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  position: relative;
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(27, 42, 65, .14); }
.btn.big { font-size: 28px; min-height: 96px; padding: 16px 40px; }
.btn.small { font-size: 18px; min-height: 56px; padding: 8px 18px; border-radius: 18px; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.btn.ghost { background: transparent; box-shadow: none; border-width: 2px; border-color: #9AA7B8; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:focus-visible, .tile:focus-visible, .gcard:focus-visible { outline: 6px solid #5B3FE0; outline-offset: 3px; }
.row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.row.wrap { justify-content: flex-start; }
.chip { background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 20px; font-weight: 800; font-size: 26px; }
.chip.big { font-size: 48px; padding: 12px 32px; }

/* ---------- targets (anything a child can pick) ---------- */
.target { position: relative; transition: transform .12s; }
.target .dw {
  position: absolute; inset: -10px; border-radius: inherit; padding: 9px; pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.target.hover { transform: scale(1.05); outline: 5px solid var(--accent); outline-offset: 4px; }
.target.scan { transform: scale(1.06); outline: 9px solid #5B3FE0; outline-offset: 5px; }
.target.off { opacity: .18; transform: scale(.92); pointer-events: none; }
.target.hint { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }

/* pointer shown for hand and head input */
#cursor { position: fixed; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none; z-index: 60; }
#cursor[hidden] { display: none; }
#cursor::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 8px solid #5B3FE0; background: rgba(255, 255, 255, .55); box-shadow: 0 0 0 4px #fff; }

/* ---------- home ---------- */
.home-top { display: flex; gap: 14px; align-items: center; justify-content: space-between; width: 100%; flex-wrap: wrap; }
.who-btn { font: inherit; font-weight: 800; font-size: 24px; display: inline-flex; align-items: center; gap: 10px; background: var(--card); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 22px 6px 10px; min-height: 64px; cursor: pointer; }
.who-btn { font-size: 32px; }
.who-btn span { font-size: 22px; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 22px; width: 100%; margin-top: 8px; }
.gcard { font: inherit; border: 4px solid var(--ink); border-radius: 34px; padding: 22px 16px; min-height: calc(190px * var(--scale) * .8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; box-shadow: var(--shadow); color: var(--ink); background: var(--c1); }
.gcard.c1 { background: var(--c1); } .gcard.c2 { background: var(--c2); } .gcard.c3 { background: var(--c3); }
.gicon { font-size: 84px; line-height: 1; }
.gname { font-size: 30px; font-weight: 900; }
.gsub { font-size: 20px; color: var(--muted); font-weight: 600; }
.btn.resume { background: var(--accent); width: 100%; max-width: 640px; }
.stickers { width: 100%; text-align: center; margin-top: 8px; }
.srow { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 46px; }

/* ---------- welcome, who, pin ---------- */
.field { display: flex; flex-direction: column; gap: 8px; font-weight: 700; width: 100%; max-width: 520px; }
input[type=text] { font: inherit; font-size: 28px; padding: 14px 18px; border: 3px solid var(--ink); border-radius: 18px; background: #fff; user-select: text; -webkit-user-select: text; }
.avatars { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar { font-size: 48px; width: 84px; height: 84px; border-radius: 50%; border: 4px solid #C6CFDA; background: #fff; cursor: pointer; }
.avatar.sel { border-color: var(--primary); box-shadow: 0 0 0 5px var(--soft); }
.who-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px; width: 100%; }
.who-card { font: inherit; font-weight: 800; font-size: 26px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 4px solid var(--ink); border-radius: 30px; background: #fff; cursor: pointer; box-shadow: var(--shadow); }
.who-card .av { font-size: 72px; }
.dots { font-size: 44px; letter-spacing: 12px; margin: 8px 0; }
.pad { display: grid; grid-template-columns: repeat(3, 96px); gap: 14px; }
.btn.key { font-size: 34px; min-height: 96px; padding: 0; }

/* ---------- games ---------- */
.game { flex: 1; width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 12px max(14px, env(safe-area-inset-left)) 16px; max-width: 1100px; margin: 0 auto; position: relative; min-height: 100dvh; }
.gbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.qcard { background: var(--card); border: 4px solid var(--ink); border-radius: 30px; padding: 14px 20px; text-align: center; box-shadow: var(--shadow); }
.qtext { font-size: clamp(28px, 5.4vw, 46px); font-weight: 900; }
.qvis { font-size: clamp(34px, 7vw, 64px); min-height: 1.2em; letter-spacing: 6px; word-break: break-all; }
.msg { min-height: 1.5em; text-align: center; font-size: 28px; font-weight: 800; color: var(--primary-dark); }
.gfoot { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

/* finger quest camera */
.camwrap { position: relative; width: min(100%, 560px, calc(40dvh * 4 / 3)); aspect-ratio: 4 / 3; margin: 0 auto; border: 5px solid var(--ink); border-radius: 28px; overflow: hidden; background: #0f1a2b; }
.camvideo, #cam { width: 100%; height: 100%; object-fit: cover; display: block; }
video.mirror, canvas.mirror { transform: scaleX(-1); }
.camwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.holdring { position: absolute; top: 10px; right: 10px; width: 92px; height: 92px; border-radius: 50%; background: conic-gradient(#3DDC84 calc(var(--p, 0) * 1turn), rgba(255, 255, 255, .85) 0); display: grid; place-items: center; }
.holdring::before { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: #fff; }
.holdring span { position: relative; font-size: 44px; font-weight: 900; color: var(--ink); }
.holdring.done { background: #3DDC84; }
.camhint { position: absolute; left: 10px; bottom: 10px; background: rgba(255, 255, 255, .95); border-radius: 22px; padding: 6px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.camhint[hidden] { display: none; }
.camhint .big { font-size: 80px; font-weight: 900; line-height: 1; }
.camhint .dots { font-size: 26px; letter-spacing: 4px; }
.camnote { position: absolute; left: 10px; top: 10px; color: #fff; font-size: 16px; background: rgba(0, 0, 0, .5); border-radius: 10px; padding: 2px 10px; }
.camnote:empty { display: none; }

/* pick and learn tiles */
.tiles { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; align-items: center; flex: 1; padding: 12px 0; }
.tile { font: inherit; width: calc(190px * var(--ts)); height: calc(190px * var(--ts)); max-width: 44vw; max-height: 44vw; border: 5px solid var(--ink); border-radius: 36px; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; color: var(--ink); }
.tnum { font-size: calc(96px * var(--ts)); font-weight: 900; line-height: 1; }
.temoji { font-size: calc(96px * var(--ts)); line-height: 1; }
.swatch { width: 62%; height: 52%; border-radius: 24px; border: 4px solid var(--ink); }
.tlabel { font-size: 24px; font-weight: 800; }
.tile.right { background: #CFF3DD; border-color: var(--good); animation: pulse .6s ease 2; }

/* bubble pop */
.arena { position: relative; flex: 1; min-height: 50dvh; border-radius: 34px; background: linear-gradient(#DDF1F7, #F3FBFD); border: 4px solid var(--ink); overflow: hidden; }
.bubble { position: absolute; border-radius: 50%; border: 5px solid #0F7B8F; background: radial-gradient(circle at 30% 30%, #fff, #B7E3EE 70%); display: grid; place-items: center; cursor: pointer; padding: 0; box-shadow: inset -8px -8px 0 rgba(15, 123, 143, .12); }
.bubble.drift { animation: drift var(--dur, 6s) ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(calc(var(--amp) * -1), calc(var(--amp) * .6)); } to { transform: translate(var(--amp), calc(var(--amp) * -.6)); } }
.bubble.pop { animation: popit .25s ease-out forwards; pointer-events: none; }
@keyframes popit { to { transform: scale(1.6); opacity: 0; } }
.bubble .dw { border-radius: 50%; }
.pip { position: fixed; right: 12px; bottom: 12px; width: 150px; aspect-ratio: 4 / 3; border: 4px solid var(--ink); border-radius: 18px; overflow: hidden; z-index: 40; background: #000; opacity: .95; }
.pip video { width: 100%; height: 100%; object-fit: cover; }

/* overlays */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 70; }
.confetti span { position: absolute; top: -50px; animation: fall 2.2s linear forwards; }
@keyframes fall { to { transform: translateY(115dvh) rotate(300deg); } }
#loading { position: fixed; inset: 0; background: rgba(255, 248, 234, .96); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 90; font-size: 26px; font-weight: 800; }
.spinner { width: 70px; height: 70px; border: 9px solid #C6CFDA; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rest { position: fixed; inset: 0; background: var(--bg); z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); background: var(--ink); color: #fff; padding: 14px 24px; border-radius: 18px; font-size: 20px; max-width: 90vw; text-align: center; transition: transform .25s, opacity .25s; z-index: 100; opacity: 0; visibility: hidden; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.sticker-new { font-size: 110px; animation: pulse 1.2s ease-in-out infinite; }

/* ---------- grown up area ---------- */
.parent { align-items: stretch; user-select: text; -webkit-user-select: text; }
.ptop { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ptop h1 { text-align: left; margin: 0; }
.card { background: var(--card); border: 3px solid #D3DBE6; border-radius: 24px; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.opts { display: grid; gap: 10px; }
.opt { display: grid; grid-template-columns: 28px 1fr; column-gap: 12px; padding: 12px 14px; border: 3px solid #D3DBE6; border-radius: 18px; cursor: pointer; }
.opt.sel { border-color: var(--primary); background: var(--soft); }
.opt input { grid-row: span 2; width: 24px; height: 24px; margin-top: 4px; }
.opt span { grid-column: 2; font-size: 17px; color: var(--muted); }
.slider, .select { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.select { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; }
select { font: inherit; padding: 10px 12px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; }
input[type=range] { width: 100%; height: 40px; accent-color: var(--primary); }
.check { display: flex; gap: 12px; align-items: center; font-weight: 700; }
.check input { width: 28px; height: 28px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stats div { background: var(--soft); border-radius: 16px; padding: 10px; text-align: center; display: flex; flex-direction: column; }
.stats b { font-size: 34px; } .stats span { font-size: 16px; color: var(--muted); }
.bars { display: flex; gap: 4px; align-items: flex-end; height: 120px; padding-top: 6px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar i { display: block; width: 100%; background: var(--primary); border-radius: 6px 6px 0 0; }
.bar em { font-style: normal; font-size: 12px; color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: 17px; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #E1E7EF; }

@media (max-width: 560px) {
  body { font-size: 18px; }
  .btn { font-size: 20px; padding: 10px 18px; }
  .btn.big { font-size: 24px; min-height: 84px; padding: 12px 26px; }
  .gicon { font-size: 64px; }
  .pip { width: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* Finger Quest needs room for the camera, so its question card is tighter */
.fq { gap: 8px; }
.fq .qcard { padding: 8px 16px; }
.fq .qtext { font-size: clamp(24px, 4.4vw, 38px); }
.fq .qvis { font-size: clamp(26px, 5vw, 44px); letter-spacing: 4px; }
.fq .msg { font-size: 24px; min-height: 1.3em; }
.fq .btn { min-height: 64px; }
