/* Kinder Town. Big touch targets everywhere: little fingers, and a mouse too. */
:root {
  --orange: #ff8a1f; --orange-d: #d96b00; --blue: #3a86ff; --green: #2dc653; --red: #e63946; --yellow: #ffd60a; --purple: #9b5de5;
  --ink: #1f2937; --paper: #fffaf3; --sky: #9ad8ff;
  --font: "Trebuchet MS", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink); font-family: var(--font); }
body { -webkit-user-select: none; user-select: none; touch-action: none; overscroll-behavior: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; touch-action: auto; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- start screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; overflow-y: auto; touch-action: pan-y;
  background: linear-gradient(#9ad8ff, #c9ecff 60%, #7ccf6b 60%); }
.screen.title { gap: 10px; }
.title-art { font-size: clamp(60px, 12vw, 130px); }
.game-title { font-size: clamp(44px, 9vw, 96px); margin: 0; color: #fff; text-shadow: 0 5px 0 var(--orange-d), 0 8px 18px rgba(0, 0, 0, .25); letter-spacing: 2px; }
.game-title.small { font-size: clamp(32px, 6vw, 60px); }
.play-btn { width: 160px; height: 160px; border-radius: 50%; border: 8px solid #fff; background: var(--orange); color: #fff; font-size: 80px; box-shadow: 0 10px 0 var(--orange-d); animation: bob 1.4s ease-in-out infinite; }
.play-btn:active { transform: translateY(6px); box-shadow: 0 4px 0 var(--orange-d); }
@keyframes bob { 50% { transform: scale(1.06); } }
.card { background: var(--paper); border-radius: 24px; padding: 28px; width: min(440px, 100%); box-shadow: 0 12px 40px rgba(0, 0, 0, .2); display: flex; flex-direction: column; gap: 12px; }
.card h1, .card h2 { margin: 0; text-align: center; }
.login .logo { font-size: 56px; text-align: center; }
.login label, .p-card label { display: flex; flex-direction: column; gap: 4px; font-weight: bold; font-size: 15px; }
.login input, .p-card input, .p-card textarea, .p-card select, .parent select { font: inherit; font-size: 18px; padding: 12px; border-radius: 12px; border: 2px solid #ccc; background: #fff; width: 100%; }
.p-card label.check { flex-direction: row; align-items: center; font-weight: normal; gap: 10px; }
.p-card label.check input { width: 26px; height: 26px; }
.form-msg { color: var(--red); min-height: 1.2em; margin: 0; font-weight: bold; }
.small { font-size: 14px; color: #555; font-weight: normal; }
.link-btn { background: none; border: none; color: var(--blue); font-size: 16px; text-decoration: underline; padding: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }

.big-btn { font-size: 26px; font-weight: bold; padding: 16px 28px; border-radius: 20px; border: none; color: #fff; background: var(--blue); box-shadow: 0 6px 0 #1f5fc4; min-width: 90px; }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f5fc4; }
.big-btn.go { background: var(--green); box-shadow: 0 6px 0 #1e8f3c; }
.big-btn.stop { background: var(--red); box-shadow: 0 6px 0 #a7232f; }
.big-btn.buy { background: var(--orange); box-shadow: 0 6px 0 var(--orange-d); }
.big-btn.cant { background: #aaa; box-shadow: 0 6px 0 #777; }
.big-btn.small { font-size: 18px; padding: 10px 16px; }
.big-btn:disabled { opacity: .45; }
.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.players { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.player-card { width: 180px; height: 200px; border-radius: 28px; border: 6px solid #fff; background: var(--orange); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 10px 0 var(--orange-d); }
.player-card.new { background: var(--blue); box-shadow: 0 10px 0 #1f5fc4; }
.player-face { font-size: 70px; }
.player-name { font-size: 30px; font-weight: bold; }
.player-money { font-size: 20px; }
.name-shown { min-height: 80px; min-width: 300px; padding: 8px 24px; background: #fff; border-radius: 20px; font-size: 60px; font-weight: bold; text-align: center; letter-spacing: 4px; border: 4px dashed var(--orange); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 900px; }
.tile { width: 70px; height: 76px; font-size: 40px; font-weight: bold; border-radius: 16px; border: none; background: #fff; color: var(--ink); box-shadow: 0 6px 0 #c9c9c9; }
.tile:active { transform: translateY(4px); box-shadow: 0 2px 0 #c9c9c9; }
.tile.used { visibility: hidden; }
.tile.hint { outline: 6px solid var(--yellow); animation: pulse .8s infinite; }
.tile.shake { animation: shake .4s; background: #ffd9dc; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keyboard .tile { width: 62px; height: 66px; font-size: 34px; }

/* ---------- the 3D world and HUD ---------- */
canvas.world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: fixed; inset: 0; pointer-events: none; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.hud > *, .hud-left, .hud-right, .hud button { pointer-events: auto; }
.hud-left { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.money { background: rgba(255, 255, 255, .92); border-radius: 30px; padding: 8px 20px 8px 12px; font-size: 34px; font-weight: bold; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); color: #1e8f3c; }
.who { background: rgba(0, 0, 0, .35); color: #fff; border-radius: 16px; padding: 3px 14px; font-size: 20px; font-weight: bold; align-self: flex-start; }
.hud-right { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 10px; }
.hud-btn { width: 64px; height: 64px; border-radius: 50%; border: 4px solid #fff; background: rgba(255, 255, 255, .9); font-size: 30px; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.hud-btn.grown { opacity: .7; position: relative; }
.hud-btn.grown.holding { background: conic-gradient(var(--orange) 0, var(--orange) 0); animation: fillup 2s linear forwards; }
@keyframes fillup { from { box-shadow: inset 0 0 0 0 var(--orange); } to { box-shadow: inset 0 0 0 40px var(--orange); } }
.job-banner { position: absolute; top: max(86px, calc(env(safe-area-inset-top) + 76px)); left: 50%; transform: translateX(-50%); background: var(--yellow); border-radius: 22px; padding: 10px 14px 10px 18px; font-size: 24px; font-weight: bold; display: flex; align-items: center; gap: 10px; box-shadow: 0 5px 0 #c9a800; max-width: 90vw; }
.banner-icon { font-size: 32px; }
.banner-x { border: none; background: rgba(0, 0, 0, .12); border-radius: 50%; width: 38px; height: 38px; font-size: 18px; }
.action-btn { position: absolute; right: max(24px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%; border: 6px solid #fff; background: var(--orange); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 8px 0 var(--orange-d); animation: pulse 1.2s ease-in-out infinite; }
.act-icon { font-size: 56px; line-height: 1; }
.act-label { font-size: 20px; font-weight: bold; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jump-btn { position: absolute; right: max(190px, calc(env(safe-area-inset-right) + 180px)); bottom: max(30px, env(safe-area-inset-bottom)); width: 96px; height: 96px; border-radius: 50%; border: 5px solid #fff; background: rgba(58, 134, 255, .85); font-size: 44px; box-shadow: 0 6px 0 #1f5fc4; }
.joystick { position: fixed; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .25); border: 4px solid rgba(255, 255, 255, .7); display: none; pointer-events: none; z-index: 5; }
.joystick.on { display: block; }
.knob { position: absolute; left: 30px; top: 30px; width: 60px; height: 60px; border-radius: 50%; background: rgba(255, 255, 255, .9); box-shadow: 0 3px 8px rgba(0, 0, 0, .3); }
.money-pop { position: fixed; top: 70px; left: 40px; font-size: 44px; font-weight: bold; color: #1e8f3c; text-shadow: 0 3px 0 #fff; animation: rise 1.6s ease-out forwards; pointer-events: none; z-index: 50; }
@keyframes rise { to { transform: translateY(-60px); opacity: 0; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 14px; height: 20px; border-radius: 3px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
body.panel-open .hud > .action-btn, body.panel-open .hud > .jump-btn { display: none; }

/* ---------- panels (games, shops, dialogs) ---------- */
.panel { position: fixed; inset: 0; background: rgba(20, 40, 70, .45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: max(10px, env(safe-area-inset-top)) 10px 10px; }
.panel-card { background: var(--paper); border-radius: 28px; width: min(1000px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 16px 50px rgba(0, 0, 0, .35); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--orange); color: #fff; }
.panel-icon { font-size: 36px; }
.panel-title { font-size: 28px; font-weight: bold; flex: 1; }
.panel-x { width: 56px; height: 56px; border-radius: 50%; border: 4px solid #fff; background: rgba(255, 255, 255, .25); color: #fff; font-size: 24px; }
.panel-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; align-items: center; touch-action: pan-y; }
.dialog .panel-card { width: min(640px, 100%); }
.dialog-text { font-size: 30px; font-weight: bold; text-align: center; display: flex; align-items: center; gap: 12px; }
.yes-no { display: flex; gap: 24px; }
.yes-no .big-btn { font-size: 34px; padding: 18px 36px; }
.speak-btn { width: 60px; height: 60px; flex: none; border-radius: 50%; border: none; background: var(--yellow); font-size: 30px; box-shadow: 0 4px 0 #c9a800; }
.prompt { display: flex; align-items: center; gap: 14px; font-size: 34px; font-weight: bold; text-align: center; min-height: 64px; }
.round-dots { display: flex; gap: 8px; }
.round-dots i { width: 18px; height: 18px; border-radius: 50%; background: #ddd; }
.round-dots i.done { background: var(--green); }
.round-dots i.now { background: var(--orange); transform: scale(1.3); }
.stage { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 120px; width: 100%; }
.choices { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.choice { min-width: 120px; min-height: 110px; padding: 10px 18px; border-radius: 24px; border: 5px solid #fff; background: var(--blue); color: #fff; box-shadow: 0 7px 0 #1f5fc4; display: flex; align-items: center; justify-content: center; }
.choice:active { transform: translateY(4px); box-shadow: 0 3px 0 #1f5fc4; }
.choice.right { background: var(--green); box-shadow: 0 7px 0 #1e8f3c; transform: scale(1.1); }
.choice.wrong { background: #bbb; box-shadow: 0 7px 0 #888; opacity: .6; animation: shake .4s; }
.choice.hint { outline: 7px solid var(--yellow); animation: pulse .8s infinite; }
.num { font-size: 60px; font-weight: bold; }
.finish { text-align: center; }
.finish .stars { font-size: 80px; }
.finish .pay { font-size: 70px; font-weight: bold; color: #1e8f3c; }

/* counting */
.crates { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; width: 100%; max-width: 760px; }
.crate { position: relative; font-size: 52px; background: none; border: none; padding: 4px; }
.crate.counted { filter: saturate(.4) brightness(1.15); }
.crate-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: bold; color: #fff; text-shadow: 0 0 6px #000, 0 0 3px #000; }
.number-train { display: flex; gap: 10px; }
.train-car { width: 130px; height: 110px; border-radius: 18px; background: var(--red); color: #fff; font-size: 60px; font-weight: bold; display: flex; align-items: center; justify-content: center; border-bottom: 14px solid #333; }
.train-car.empty { background: #ddd; color: #777; border: 5px dashed #999; border-bottom: 14px solid #333; }
.police-line { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 900px; }
.police-car { width: 84px; border: none; border-radius: 16px; background: #eaf2ff; display: flex; flex-direction: column; align-items: center; padding: 4px; }
.car-emoji { font-size: 44px; }
.car-num { font-size: 32px; font-weight: bold; }
.police-car.missing { background: #ddd; }
.police-car.asking { outline: 6px solid var(--yellow); animation: pulse 1s infinite; }
.ladder-scene { position: relative; width: 320px; height: 420px; }
.ladder { position: absolute; left: 90px; top: 50px; bottom: 0; width: 140px; display: flex; flex-direction: column; justify-content: space-between; border-left: 10px solid #b0b0b0; border-right: 10px solid #b0b0b0; padding: 4px 0; }
.rung { height: 48px; margin: 0 -10px; background: #d0d0d0; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: bold; color: #777; }
.rung.on { background: var(--red); color: #fff; }
.climber { position: absolute; left: 10px; bottom: 8%; font-size: 64px; transition: bottom .5s; }
.fire { position: absolute; right: 10px; top: 0; font-size: 72px; animation: pulse .6s infinite; }

/* reading */
.letter-art { font-size: 80px; }
.choice.mailbox { background: #fff; color: var(--ink); border: 6px solid var(--blue); box-shadow: 0 7px 0 #1f5fc4; min-width: 180px; }
.mailbox-inner { display: flex; flex-direction: column; align-items: center; }
.mailbox-icon { font-size: 40px; }
.word { font-size: 54px; font-weight: bold; text-transform: none; }
.choice.mailbox.right { background: #d8f8df; }
/* spelling */
.sign-board { display: flex; gap: 10px; padding: 18px 22px; background: #8b5a2b; border-radius: 16px; border: 8px solid #5c3a1e; }
.sign-board.done { background: var(--green); border-color: #1e8f3c; }
.slot { width: 76px; height: 90px; border-radius: 12px; background: #fff7e6; display: flex; align-items: center; justify-content: center; font-size: 56px; font-weight: bold; }
.slot .ghost { color: #c8c8c8; }
.slot .ghost.hidden { visibility: hidden; }
.slot.filled { background: #fff; }
.hint-btn { margin-top: 10px; border: none; background: var(--yellow); border-radius: 16px; font-size: 22px; padding: 8px 18px; box-shadow: 0 4px 0 #c9a800; }
/* shapes */
.shape-card { display: flex; flex-direction: column; align-items: center; }
.shape-svg { width: 120px; height: 120px; }
.shape-name { font-size: 20px; font-weight: bold; }
.choice:has(.shape-card) { background: #fff; color: var(--ink); border-color: var(--blue); }
.real-thing, .toy-machine { font-size: 110px; }

/* coloring */
.coloring .panel-card { width: min(1100px, 100%); }
.color-wrap { display: flex; gap: 16px; align-items: flex-start; justify-content: center; width: 100%; flex-wrap: wrap; }
.canvas-box { position: relative; width: min(64vh, 86vw, 560px); aspect-ratio: 1; border-radius: 18px; overflow: hidden; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); background: #fff; }
.canvas-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.canvas-box canvas.paint { touch-action: none; cursor: crosshair; }
.canvas-box canvas.guide, .canvas-box canvas.lines { pointer-events: none; }
.guide.wiggle { animation: shake .4s 3; }
.side { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.crayons { display: grid; grid-template-columns: repeat(3, 60px); gap: 10px; }
.crayon { width: 60px; height: 60px; border-radius: 50%; border: 5px solid #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.crayon.picked { transform: scale(1.2); outline: 5px solid var(--ink); }
.meter { width: 200px; height: 24px; border-radius: 12px; background: #e5e5e5; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--orange); transition: width .3s; }
.meter.full i { background: var(--green); }
.color-actions { min-height: 70px; }

/* shops */
.shop-money { font-size: 28px; font-weight: bold; color: #1e8f3c; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; width: 100%; }
.shop-card { background: #fff; border-radius: 20px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 4px 0 #ddd; text-align: center; }
.shop-card.cant { opacity: .6; }
.shop-card.owned, .shop-card.worn { outline: 4px solid var(--green); }
.shop-icon { font-size: 64px; background: none; border: none; }
.shop-name { font-size: 18px; font-weight: bold; min-height: 2.4em; }
.stuff-group { width: 100%; }
.stuff-group h3 { margin: 4px 0 8px; font-size: 24px; }
.swatches { display: grid; grid-template-columns: repeat(5, 80px); gap: 14px; }
.swatch { width: 80px; height: 80px; border-radius: 50%; border: 6px solid #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }

/* ---------- grown-up area ---------- */
.parent { position: fixed; inset: 0; z-index: 100; background: #f3f4f6; overflow-y: auto; touch-action: pan-y; -webkit-user-select: text; user-select: text; font-family: system-ui, sans-serif; }
.parent .screen { position: static; min-height: 100%; background: #f3f4f6; }
.parent-head { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: #1f2937; color: #fff; position: sticky; top: 0; z-index: 2; flex-wrap: wrap; }
.parent-head h1 { margin: 0; font-size: 24px; flex: 1; }
.parent-head .small { color: #ccc; }
.parent-head .big-btn { font-size: 18px; padding: 10px 16px; }
.parent-tabs { display: flex; gap: 6px; padding: 10px 20px 0; flex-wrap: wrap; }
.parent-tabs button { font-size: 17px; padding: 10px 16px; border: none; border-radius: 12px 12px 0 0; background: #e5e7eb; position: relative; }
.parent-tabs button.on { background: #fff; font-weight: bold; }
.dot { display: inline-block; margin-left: 6px; background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 13px; }
.parent-body { padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 16px; max-width: 1100px; }
.p-card { background: #fff; border-radius: 16px; padding: 18px 20px; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); display: flex; flex-direction: column; gap: 10px; }
.p-card h2 { margin: 0; font-size: 22px; }
.p-card h3 { margin: 8px 0 0; font-size: 17px; }
.p-card p { margin: 0; }
.p-card .big-btn { align-self: flex-start; }
.levels { display: flex; gap: 10px; flex-wrap: wrap; }
.level { background: #fff4e6; border-radius: 12px; padding: 8px 12px; min-width: 160px; }
.p-table { border-collapse: collapse; width: 100%; font-size: 15px; }
.p-table th, .p-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
.p-table tr.sev-warn td { background: #fff8db; }
.p-table tr.sev-alert td { background: #ffe0e3; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; border-radius: 16px; background: #e5e7eb; }
.chip.on { background: #d8f8df; outline: 2px solid var(--green); }
.chip-word { border: none; background: none; font-size: 17px; padding: 6px 12px; }
.chip-x { border: none; background: none; font-size: 18px; padding: 4px 10px 4px 0; color: #a7232f; }
.word-group { display: flex; flex-direction: column; gap: 6px; }
.word-group .row { justify-content: flex-start; }

@media (max-height: 560px) {
  .prompt { font-size: 26px; min-height: 50px; }
  .num { font-size: 46px; }
  .choice { min-height: 86px; min-width: 96px; }
  .action-btn { width: 120px; height: 120px; }
  .act-icon { font-size: 44px; }
  .jump-btn { width: 80px; height: 80px; right: 160px; }
  .ladder-scene { height: 300px; }
  .rung { height: 34px; font-size: 24px; }
  .panel-body { padding: 10px; gap: 8px; }
}
