/* Tafelpret — browser version. Same look as the iOS app: sky, chunky 3D buttons, white cards. */

:root {
  --ink: #33295c;
  --ink-60: rgba(51, 41, 92, 0.6);
  --ink-12: rgba(51, 41, 92, 0.12);
  --good: #38c261;
  --bad: #ff6166;
  --sun: #ffcc29;
  --mascot: #8c6bff;
  --sky-top: #66c7ff;
  --sky-bottom: #bdedff;
  --hill: #73d166;
  --card: #ffffff;
  --font: ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', 'Varela Round', system-ui, sans-serif;
  --content: 600px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; }

/* ---------- Sky ---------- */

.sky { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.cloud {
  position: absolute;
  left: 0;
  width: 160px;
  height: 70px;
  animation: drift linear infinite;
}
.cloud span { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.85); }
@keyframes drift {
  from { transform: translateX(-200px) scale(var(--s)); }
  to { transform: translateX(calc(100vw + 40px)) scale(var(--s)); }
}
.hill { position: absolute; border-radius: 50%; }
.hill.back { width: 130vw; height: 220px; left: -50vw; bottom: -150px; background: #96dc8c; }
.hill.front { width: 140vw; height: 200px; left: 20vw; bottom: -160px; background: var(--hill); }

/* ---------- Layout ---------- */

#app { position: relative; z-index: 1; min-height: 100%; }

.screen {
  position: relative;
  max-width: var(--content);
  margin: 0 auto;
  padding: 8px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: screen-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.screen.game { min-height: 100dvh; padding-bottom: 16px; gap: 14px; }
@keyframes screen-in { from { opacity: 0; transform: translateX(30px); } }

.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--ink-60); }
.small { font-size: 13px; }

.card {
  background: var(--card);
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 6px 0 rgba(51, 41, 92, 0.15);
}
.card > h2 { margin: 0 0 14px; font-size: 22px; font-weight: 900; }
.chip-bg {
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 4px 0 rgba(51, 41, 92, 0.12);
}

/* ---------- Chunky button ---------- */

.chunky {
  --c: var(--good);
  --depth: 6px;
  --radius: 22px;
  position: relative;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(color-mix(in srgb, var(--c), white 12%), var(--c));
  color: #fff;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  box-shadow: 0 var(--depth) 0 color-mix(in srgb, var(--c), black 28%);
  margin-bottom: var(--depth);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.12s;
}
.chunky.outline {
  background: #fff;
  color: var(--c);
  text-shadow: none;
  border-color: color-mix(in srgb, var(--c), transparent 50%);
  box-shadow: 0 var(--depth) 0 color-mix(in srgb, var(--c), white 35%);
}
.chunky:active:not(:disabled) {
  transform: translateY(var(--depth));
  box-shadow: 0 0 0 color-mix(in srgb, var(--c), black 28%);
}
.chunky:disabled { cursor: default; background: linear-gradient(#c9c9c9, #b8b8b8); box-shadow: 0 var(--depth) 0 #8f8f8f; color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.chunky.outline:disabled { background: #fff; color: #b8b8b8; border-color: #dcdcdc; box-shadow: 0 var(--depth) 0 #e2e2e2; }
.chunky:focus-visible, .plain:focus-visible, .stage-btn:focus-visible { outline: 4px solid var(--mascot); outline-offset: 3px; }
.plain { background: none; border: 0; padding: 0; cursor: pointer; }

.icon-btn { width: 44px; height: 44px; --radius: 16px; --depth: 4px; padding: 0; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Title ---------- */

.rainbow { display: flex; justify-content: center; margin: 0; font-weight: 900; line-height: 1.1; white-space: nowrap; }
.rainbow span {
  display: inline-block;
  text-shadow:
    2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff,
    0 6px 0 rgba(51, 41, 92, 0.25);
  animation: wave 1.6s ease-in-out infinite;
}
@keyframes wave { 0%, 100% { transform: translateY(4px); } 50% { transform: translateY(-4px); } }

/* ---------- Mascot ---------- */

.mascot { position: relative; flex: none; display: grid; place-items: center; }
.mascot-body { position: relative; width: 100%; height: 100%; display: grid; place-items: center; transform-origin: 50% 100%; }
.mascot-breathe { width: 100%; height: 100%; display: grid; place-items: center; transform-origin: 50% 100%; animation: breathe 1.4s ease-in-out infinite alternate; }
.mascot.sways .mascot-breathe { animation: sway 1.4s ease-in-out infinite alternate; }
/* The artwork is drawn 1.4× the frame (the character fills ~60% of it), centred exactly on the frame. */
.mascot-breathe { position: relative; }
.mascot img {
  position: absolute; left: 50%; top: 50%; width: 140%; height: 140%;
  transform: translate(-50%, -50%);
  object-fit: contain; pointer-events: none; -webkit-user-drag: none;
}
.mascot img.mood-in { animation: mood-in-centred 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes mood-in-centred { from { transform: translate(-50%, -50%) scale(0.7); opacity: 0.3; } }
.mascot .accessory {
  position: absolute; left: 50%; top: 50%;
  width: 1.2em; height: 1.2em; display: flex; align-items: center; justify-content: center;
  pointer-events: none; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.2)); line-height: 1;
}
.mascot .glow {
  position: absolute; inset: -10%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 204, 41, 0.55) 25%, rgba(255, 204, 41, 0) 70%);
}
.mascot .sparkles { position: absolute; inset: 0; animation: spin 9s linear infinite; }
.mascot .sparkles i { position: absolute; left: 50%; top: 50%; color: #fff; font-style: normal; }
.mascot .snore { position: absolute; color: #fff; font-weight: 900; text-shadow: 0 1px 0 rgba(51, 41, 92, 0.4); animation: snore 2.4s linear infinite; opacity: 0; }
@keyframes breathe { from { transform: scale(1.03, 0.97); } to { transform: scale(0.98, 1.02); } }
@keyframes sway { from { transform: rotate(-6deg) scale(1.03, 0.97); } to { transform: rotate(6deg) scale(0.98, 1.02); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes snore {
  0% { opacity: 1; transform: translate(0, 0) scale(0.7); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(14px, -40px) scale(1.3); }
}
.hop { animation: hop 0.6s ease-out; }
@keyframes hop {
  0% { transform: scale(1, 1) translateY(0); }
  16% { transform: scale(1.18, 0.82) translateY(0); }
  45% { transform: scale(0.88, 1.12) translateY(-28%); }
  70% { transform: scale(1.1, 0.9) translateY(0); }
  100% { transform: scale(1, 1) translateY(0); }
}
.headshake { animation: headshake 0.6s ease-out; }
@keyframes headshake {
  0% { transform: rotate(0); } 13% { transform: rotate(-9deg); } 33% { transform: rotate(9deg); }
  53% { transform: rotate(-6deg); } 70% { transform: rotate(4deg); } 100% { transform: rotate(0); }
}
.mood-in { animation: mood-in 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes mood-in { from { transform: scale(0.7); opacity: 0.3; } }

/* ---------- Speech bubble ---------- */

.bubble {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(51, 41, 92, 0.15);
  min-width: 0;
}
.bubble::before {
  content: '';
  position: absolute;
  left: -12px;
  bottom: 10px;
  border-style: solid;
  border-width: 0 0 14px 16px;
  border-color: transparent transparent #fff transparent;
}

/* ---------- Bars, badges ---------- */

.bar { position: relative; height: var(--h, 18px); border-radius: 99px; background: rgba(255, 255, 255, 0.7); box-shadow: inset 0 0 0 2px var(--ink-12); overflow: hidden; }
.bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  min-width: var(--h, 18px);
  border-radius: 99px;
  background: linear-gradient(color-mix(in srgb, var(--c, var(--sun)), white 15%), var(--c, var(--sun)));
  transition: width 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.bar > i::after { content: ''; position: absolute; left: 30%; right: 30%; top: 18%; height: 25%; border-radius: 99px; background: rgba(255, 255, 255, 0.4); }
.bar > i.empty { opacity: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 12px; border-radius: 99px;
  color: #fff; font-size: 20px; font-weight: 900;
  background: var(--c, #bfbfbf);
  white-space: nowrap;
}
.pill svg { width: 18px; height: 18px; }
.pill .mult { font-size: 14px; padding: 1px 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.3); }
.pop { animation: pop 0.45s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes pop { 30% { transform: scale(1.35); } }

.level-badge {
  position: relative; flex: none;
  width: var(--size, 64px); height: var(--size, 64px);
  border-radius: 50%;
  background: linear-gradient(#ffd95c, var(--sun));
  box-shadow: inset 0 0 0 4px #fff, 0 4px 0 rgba(51, 41, 92, 0.2);
  display: grid; place-content: center; text-align: center; line-height: 0.95;
}
.level-badge small { font-size: calc(var(--size, 64px) * 0.15); font-weight: 900; }
.level-badge b { font-size: calc(var(--size, 64px) * 0.44); font-weight: 900; }

.ring { position: relative; width: 40px; height: 40px; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 900; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .track { stroke: var(--ink-12); }
.ring .fill { stroke: var(--good); stroke-linecap: round; transition: stroke-dashoffset 0.6s; }

/* ---------- Home ---------- */

.home-header { display: flex; align-items: center; z-index: 2; }
.parent-gate { position: relative; width: 40px; height: 40px; display: grid; place-items: center; color: rgba(51, 41, 92, 0.35); cursor: pointer; background: none; border: 0; padding: 0; touch-action: none; flex: none; }
.parent-gate svg { width: 16px; height: 16px; }
.parent-gate .hold-ring { position: absolute; inset: 2px; width: 36px; height: 36px; transform: rotate(-90deg); }
.parent-gate .hold-ring circle { fill: none; stroke: var(--mascot); stroke-width: 3; stroke-dasharray: 101; stroke-dashoffset: 101; }
.parent-gate.holding .hold-ring circle { transition: stroke-dashoffset 1.5s linear; stroke-dashoffset: 0; }
.gate-hint {
  position: absolute; left: 0; top: 40px; white-space: nowrap;
  background: #fff; color: var(--ink); border-radius: 99px; padding: 4px 8px; font-size: 12px; font-weight: 900;
  box-shadow: 0 2px 0 var(--ink-12);
}

.stats-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.stats-row .divider { width: 2px; height: 32px; background: rgba(51, 41, 92, 0.1); flex: none; }
.stats-row .streak { text-align: center; line-height: 1.1; font-size: 16px; }
.stats-row .streak.off span { filter: grayscale(1); }
.stats-row .title { font-size: 16px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.menu-bar { display: flex; padding: 6px 0; }
.menu-bar button {
  flex: 1; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: rgba(51, 41, 92, 0.75); font-size: 12px; font-weight: 900;
}
.menu-bar img { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15)); transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1); }
.menu-bar button:active img { transform: scale(0.88); }

.table-picker { padding: 14px; }
.table-picker header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 18px; font-weight: 900; }
.table-picker header button { color: var(--mascot); font-size: 14px; font-weight: 900; }
.table-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.table-chip {
  position: relative; min-height: 44px; border-radius: 14px; border: 0;
  background: rgba(51, 41, 92, 0.06); color: rgba(51, 41, 92, 0.7);
  font-size: 20px; font-weight: 900; cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1), background 0.2s;
}
.table-chip[aria-pressed='true'] { background: var(--mascot); color: #fff; }
.table-chip:active { transform: scale(0.92); }
.table-chip .done {
  position: absolute; right: -4px; top: -4px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--good); border: 2px solid #fff; color: #fff; display: grid; place-items: center;
}
.table-chip .done svg { width: 10px; height: 10px; }

.play-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 32px 16px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(189, 237, 255, 0), rgba(189, 237, 255, 0.95) 45%, var(--sky-bottom));
  pointer-events: none;
}
.play-dock > * { pointer-events: auto; max-width: var(--content); margin: 0 auto; display: flex; width: 100%; }
.play-btn { --radius: 26px; padding: 10px 24px; justify-content: space-between; text-align: left; }
.play-btn .big { font-size: 28px; display: block; }
.play-btn .sub { font-size: 14px; font-weight: 800; opacity: 0.9; display: block; }
.play-btn svg { width: 28px; height: 28px; flex: none; }
.start-btn { font-size: 30px; padding: 16px; --radius: 26px; --depth: 7px; }

/* ---------- Adventure map ---------- */

.world { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.world-banner { display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.world-banner .emoji { font-size: 30px; }
.world-banner h3 { margin: 0; font-size: 20px; font-weight: 900; }
.world-banner p { margin: 0; font-size: 13px; opacity: 0.6; }
.world-banner .stars { font-size: 15px; color: var(--ink-60); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.world-banner .stars svg { width: 15px; height: 15px; }
.trail { position: relative; }
.trail > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.stage {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.stage-btn { --radius: 50%; --depth: 6px; padding: 0; }
.stage-btn img { width: 68%; height: 68%; object-fit: contain; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.2)); }
.stage-btn svg { width: 34%; height: 34%; }
.stage .crown { position: absolute; top: -26px; font-size: 30px; pointer-events: none; }
.stage .pulse-ring {
  position: absolute; border-radius: 50%; border: 6px solid color-mix(in srgb, var(--c), transparent 40%);
  animation: pulse-ring 1.6s ease-in-out infinite;
  pointer-events: none;
}
.stage.current .stage-btn { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse-ring { 0%, 100% { transform: scale(0.95); opacity: 0.9; } 50% { transform: scale(1.12); opacity: 0.2; } }
@keyframes pulse { 50% { transform: scale(1.05); } }
.stage .label { font-size: 12px; font-weight: 900; padding: 2px 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.7); white-space: nowrap; }
.stage.locked .label { color: rgba(51, 41, 92, 0.45); }
.stage .play-tag { font-size: 14px; color: #fff; background: var(--good); padding: 3px 10px; border-radius: 99px; }
.stage .map-stars { display: flex; gap: 1px; }
.stage .map-stars svg { width: 16px; height: 16px; filter: drop-shadow(0 1.5px 0 rgba(51, 41, 92, 0.3)); }
.stage .side-mascot { position: absolute; top: 0; pointer-events: none; }

/* ---------- Pages ---------- */

.page-header { display: flex; align-items: center; gap: 12px; }
.page-header .rainbow { flex: 1; font-size: 34px; min-width: 0; overflow: hidden; }
.page-header .spacer { width: 44px; flex: none; }

.overlay-page:focus { outline: none; }
.overlay-page { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: linear-gradient(var(--sky-top), var(--sky-bottom)); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.hstack { display: flex; gap: 10px; }
.hstack > * { flex: 1; }

.game-tile { flex-direction: column; gap: 3px; min-height: 112px; padding: 8px 4px; --radius: 20px; text-align: center; }
.game-tile img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15)); }
.game-tile .t { font-size: 16px; }
.game-tile .s { font-size: 11px; font-weight: 800; opacity: 0.85; }
.game-tile.outline { transform: scale(0.96); }

.table-bubble { flex-direction: column; height: 62px; --radius: 20px; --depth: 5px; font-size: 26px; padding: 0; gap: 3px; }
.table-bubble .stars { display: flex; }
.table-bubble .stars svg { width: 9px; height: 9px; }

.mode-tile { flex-direction: column; padding: 12px 4px; gap: 5px; --radius: 20px; text-align: center; }
.mode-tile .e { font-size: 24px; }
.mode-tile .t { font-size: 19px; }
.mode-tile .s { font-size: 11px; font-weight: 800; opacity: 0.85; }

/* ---------- Game ---------- */

.top-bar { display: flex; align-items: center; gap: 10px; position: relative; z-index: 3; }
.top-bar .bar { flex: 1; --h: 22px; }
.floating-gain {
  position: absolute; right: 8px; top: 48px;
  color: #fff; font-size: 30px; font-weight: 900; text-shadow: 0 3px 0 rgba(51, 41, 92, 0.5);
  pointer-events: none; opacity: 0;
}
.floating-gain.go { animation: float-up 0.9s ease-out; }
@keyframes float-up {
  0% { opacity: 1; transform: translateY(0) scale(0.6); }
  20% { transform: translateY(-14px) scale(1.25); }
  65% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-70px) scale(1); }
}

.question-card {
  background: #fff;
  border-radius: 32px;
  border: 5px solid var(--border, var(--c));
  box-shadow: 0 8px 0 color-mix(in srgb, var(--border, var(--c)), black 20%);
  padding: 28px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: transform 0.3s cubic-bezier(0.3, 1.8, 0.5, 1), border-color 0.2s;
  animation: card-in 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes card-in { from { transform: scale(0.6); opacity: 0; } }
.question-card.correct { transform: scale(1.06); }
.equation { display: flex; align-items: center; gap: 10px; font-size: clamp(36px, 12vw, 56px); font-weight: 900; white-space: nowrap; }
.question-card.picture .equation { font-size: clamp(30px, 10vw, 44px); }
.slot { min-width: 70px; padding: 0 6px; text-align: center; border-radius: 16px; border: 4px dashed color-mix(in srgb, var(--c), transparent 50%); color: color-mix(in srgb, var(--c), transparent 40%); }
.slot.typed { color: var(--ink); }
.wrong-given { font-size: 34px; color: color-mix(in srgb, var(--bad), transparent 30%); text-decoration: line-through; text-decoration-color: var(--bad); }
.shake { animation: shake 0.45s linear; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  17% { transform: translateX(12px); } 33% { transform: translateX(-12px); }
  50% { transform: translateX(12px); } 67% { transform: translateX(-12px); } 83% { transform: translateX(8px); }
}

.choice-grid { display: grid; gap: 14px; }
.choice-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.choice-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.choice-grid .chunky { height: 84px; font-size: 40px; --radius: 26px; --depth: 7px; transition: transform 0.25s cubic-bezier(0.3, 1.8, 0.5, 1), opacity 0.2s, box-shadow 0.12s; }
.choice-grid.many .chunky { height: 72px; font-size: 34px; }
.choice-grid .dim { opacity: 0.4; }
.choice-grid .lit { transform: scale(1.05); }
.choice-grid.locked { pointer-events: none; }

.number-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.number-pad .chunky { height: 58px; font-size: 30px; --radius: 18px; --depth: 5px; }
.number-pad svg { width: 28px; height: 28px; }

.dot-groups { display: flex; flex-direction: column; align-items: center; gap: calc(var(--dot) * 0.75); }
.dot-groups .line { display: flex; gap: calc(var(--dot) * 0.75); }
.dot-group {
  display: flex; flex-direction: column; gap: calc(var(--dot) * 0.25);
  padding: calc(var(--dot) * 0.5);
  border-radius: calc(var(--dot) * 0.8);
  background: color-mix(in srgb, var(--c), transparent 88%);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c), transparent 50%);
}
.dot-group .dots { display: flex; gap: calc(var(--dot) * 0.25); }
.dot-group i { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--c); }

.hint-card { background: #fff; border-radius: 28px; padding: 16px; box-shadow: 0 6px 0 rgba(51, 41, 92, 0.15); display: flex; flex-direction: column; align-items: center; gap: 12px; animation: card-in 0.4s cubic-bezier(0.3, 1.4, 0.5, 1); }
.hint-card .explain { font-size: 18px; text-align: center; }
.hint-card .conclusion { font-size: 20px; color: var(--good); }
.hint-card .steps { width: 100%; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.hint-card .steps-title { text-align: center; font-size: 14px; color: #ff9429; }
.hint-card .step { padding: 6px 12px; border-radius: 12px; background: color-mix(in srgb, var(--c), transparent 88%); text-align: center; font-size: 16px; transition: opacity 0.3s, transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.hint-card .step.last { background: var(--c); color: #fff; font-size: 19px; }
.hint-card .step.hidden { opacity: 0; transform: translateY(8px); }
.hint-card .jumps { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.hint-card .jumps span { text-align: center; padding: 5px 0; border-radius: 99px; color: var(--c); background: color-mix(in srgb, var(--c), transparent 88%); font-size: 17px; }
.hint-card .jumps span.last { background: var(--c); color: #fff; }
.hint-card .turnaround { display: flex; align-items: center; gap: 8px; }
.hint-card > .chunky { width: 100%; font-size: 22px; padding: 10px; --radius: 20px; --depth: 5px; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; }

/* ---------- Result ---------- */

.star-row { display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
.star-row svg { filter: drop-shadow(0 4px 0 rgba(51, 41, 92, 0.25)); transition: transform 0.4s cubic-bezier(0.3, 1.8, 0.5, 1); }
.star-row svg.off { transform: scale(0.8) rotate(-20deg); }
.score-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.score-card .headline { font-size: 26px; }
.score-card hr { width: 100%; border: 0; height: 1px; background: var(--ink-12); margin: 0; }
.reveal { transition: transform 0.5s cubic-bezier(0.3, 1.8, 0.5, 1), opacity 0.4s; }
.reveal.hidden { transform: scale(0.4); opacity: 0; }
.reward-row { display: flex; align-items: center; gap: 14px; }
.reward-row .icon { font-size: 40px; width: 56px; text-align: center; }
.reward-row b { display: block; font-size: 22px; }
.reward-row span { font-size: 15px; color: var(--ink-60); }
.mistake-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.mistake-grid span { text-align: center; padding: 8px 12px; border-radius: 99px; background: color-mix(in srgb, var(--c), transparent 80%); font-size: 17px; }
.result-buttons { display: flex; flex-direction: column; gap: 12px; }
.result-buttons .chunky { font-size: 22px; padding: 12px; --radius: 24px; }
.result-buttons .chunky.main { font-size: 26px; padding: 14px; --depth: 7px; }

/* ---------- Stickers, wardrobe, chart, parents ---------- */

.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 16px 10px; }
.sticker { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.sticker .disc {
  position: relative; width: var(--size, 64px); height: var(--size, 64px); border-radius: 50%;
  display: grid; place-items: center; font-size: calc(var(--size, 64px) * 0.46);
  background: linear-gradient(color-mix(in srgb, var(--c), white 15%), var(--c));
  box-shadow: inset 0 0 0 4px #fff, 0 4px 0 rgba(51, 41, 92, 0.2);
  transform: rotate(-6deg);
}
.sticker.locked .disc { background: #e0e0e0; transform: none; }
.sticker.locked .disc span { filter: grayscale(1); opacity: 0.35; }
.sticker .lock { position: absolute; right: 8%; bottom: 8%; width: 20%; color: rgba(51, 41, 92, 0.5); }
.sticker .name { font-size: 12px; font-weight: 800; }
.sticker.locked .name { opacity: 0.5; }
.sticker-in { animation: sticker-in 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes sticker-in { from { transform: scale(0.1) rotate(-90deg); } }

.wardrobe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.wardrobe-tile { flex-direction: column; padding: 10px 4px; gap: 4px; --radius: 20px; --depth: 5px; min-height: 104px; }
.wardrobe-tile .e { font-size: 34px; line-height: 1.1; }
.wardrobe-tile .t { font-size: 14px; }
.wardrobe-tile .s { font-size: 11px; font-weight: 800; opacity: 0.85; }
.wardrobe-tile.locked .e { filter: grayscale(1); opacity: 0.45; }

.chart { display: grid; grid-template-columns: 24px repeat(10, minmax(0, 1fr)); gap: 3px; font-size: clamp(9px, 2.6vw, 14px); }
.chart > div { min-width: 0; aspect-ratio: 1; display: grid; place-items: center; border-radius: 7px; font-weight: 900; }
.chart .head { color: var(--ink-60); }
.chart .cell { background: rgba(51, 41, 92, 0.06); color: transparent; }
.chart .cell.l0 { background: rgba(255, 97, 102, 0.35); }
.chart .cell.l1 { background: rgba(255, 204, 41, 0.55); }
.chart .cell.mastered { background: var(--c); color: #fff; }
.chart .cell.turn { background: #fff; color: var(--c); outline: 2px dashed color-mix(in srgb, var(--c), transparent 30%); outline-offset: -2px; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--ink); margin-top: 16px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }

.week { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.week .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 12px; }
.week .day i { width: 100%; border-radius: 8px; background: var(--mascot); min-height: 4px; }
.week .day.goal i { background: var(--good); }
.week .day.empty i { background: var(--ink-12); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-grid div { background: rgba(51, 41, 92, 0.05); border-radius: 16px; padding: 10px; text-align: center; }
.stat-grid b { display: block; font-size: 24px; }
.stat-grid span { font-size: 12px; color: var(--ink-60); }
.fact-list { display: flex; flex-wrap: wrap; gap: 8px; }
.fact-list span { padding: 6px 10px; border-radius: 99px; background: color-mix(in srgb, var(--c), transparent 80%); }
.text { font-weight: 700; font-size: 15px; line-height: 1.4; margin: 0; }

.dialog-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(51, 41, 92, 0.4); display: grid; place-items: center; padding: 16px; animation: fade 0.2s; }
.dialog { background: #fff; border-radius: 28px; padding: 20px; max-width: 380px; width: 100%; display: flex; flex-direction: column; gap: 12px; text-align: center; animation: card-in 0.3s cubic-bezier(0.3, 1.4, 0.5, 1); }
.dialog h3 { margin: 0; font-size: 22px; }
.dialog .chunky { padding: 12px; font-size: 18px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Arcade games (shared) ---------- */

.play-field { position: relative; flex: 1; min-height: 300px; border-radius: 28px; overflow: hidden; touch-action: none; }
.countdown { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; pointer-events: none; }
.countdown span { font-size: 140px; font-weight: 900; color: #fff; text-shadow: 0 8px 0 rgba(51, 41, 92, 0.3); animation: count-pop 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes count-pop { from { transform: scale(0.2); opacity: 0; } 70% { opacity: 1; } to { transform: scale(1); opacity: 0.9; } }

@media (max-width: 380px) {
  .screen { padding-left: 12px; padding-right: 12px; }
  .choice-grid .chunky { height: 72px; font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
  .cloud, .mascot-breathe, .rainbow span, .stage .pulse-ring, .stage.current .stage-btn, .mascot .sparkles { animation: none !important; }
  .mascot .snore { display: none; }
}

/* ---------- Game: shared (arcade + fill-in screens) ---------- */

.game-header { display: flex; flex-direction: column; gap: 10px; }
.game-center { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; }
.number-pad .chunky:disabled { filter: grayscale(1); opacity: 0.55; }
.enter { animation: card-in 0.4s cubic-bezier(0.3, 1.6, 0.5, 1); }

/* ---------- Game: sequence ---------- */

.row-card {
  background: #fff; border-radius: 28px; padding: 16px;
  border: 4px solid var(--c);
  box-shadow: 0 7px 0 color-mix(in srgb, var(--c), black 20%);
  display: flex; flex-direction: column; gap: 12px;
}
.row-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-card-title { font-size: 24px; font-weight: 900; color: var(--c); }
.row-card-step {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 17px; font-weight: 900; color: #fff; background: var(--c);
  padding: 6px 12px; border-radius: 99px; white-space: nowrap;
}
.row-card-step svg { width: 16px; height: 16px; }
.row-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 8px; }
.seq-slot { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.seq-slot small { font-size: 11px; font-weight: 800; color: rgba(51, 41, 92, 0.5); }
.seq-box {
  width: 100%; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: clamp(16px, 5vw, 22px); font-weight: 900; color: var(--ink);
  background: rgba(51, 41, 92, 0.05);
  transition: transform 0.3s cubic-bezier(0.3, 1.8, 0.5, 1), background 0.3s;
}
.seq-box.filled { color: #fff; }
.seq-box.current { background: color-mix(in srgb, var(--c), transparent 88%); outline: 3px dashed var(--c); outline-offset: -3px; transform: scale(1.08); }
.seq-box.current.empty { color: color-mix(in srgb, var(--c), transparent 40%); }

/* ---------- Game: grid ---------- */

.grid-card { padding: 12px; }
.x-grid { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
.x-label { min-height: 34px; display: grid; place-items: center; font-size: 15px; font-weight: 900; }
.x-cell {
  min-height: 38px; min-width: 0; padding: 0; border: 0; border-radius: 8px; cursor: pointer;
  background: rgba(51, 41, 92, 0.05); color: var(--ink);
  font-size: clamp(10px, 3vw, 14px); font-weight: 900;
  transition: transform 0.3s cubic-bezier(0.3, 1.8, 0.5, 1), background 0.3s;
}
.x-cell:disabled { cursor: default; }
.x-cell.selected { background: color-mix(in srgb, var(--c), transparent 88%); outline: 2.5px dashed var(--c); outline-offset: -2.5px; transform: scale(1.12); position: relative; z-index: 1; }
.x-cell.is-given { background: color-mix(in srgb, var(--c), transparent 75%); }
.x-cell.is-correct { background: var(--good); color: #fff; }
.x-cell.is-revealed { background: #ff9429; color: #fff; }
.x-cell:focus-visible { outline: 3px solid var(--mascot); outline-offset: 1px; }

/* ---------- Game: catcher ---------- */

.catch-board {
  background: #fff; border-radius: 28px; padding: 14px;
  box-shadow: 0 7px 0 color-mix(in srgb, var(--c), black 20%);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.catch-title { font-size: 24px; font-weight: 900; color: var(--c); text-align: center; }
.catch-grid { width: 100%; display: grid; gap: 6px; }
.catch-cell {
  min-height: 42px; min-width: 0; padding: 0; border: 0; border-radius: 10px; cursor: pointer;
  background: rgba(51, 41, 92, 0.06); color: var(--ink);
  font-size: clamp(12px, 4vw, 17px); font-weight: 900;
  transition: transform 0.3s cubic-bezier(0.3, 1.8, 0.5, 1), background 0.25s, opacity 0.6s ease-in-out;
}
.catch-cell.found { background: var(--c); color: #fff; transform: scale(1.06); }
.catch-cell.wrong { background: color-mix(in srgb, var(--bad), transparent 85%); color: var(--bad); }
.catch-cell.faded { opacity: 0.25; }
.catch-cell:focus-visible { outline: 3px solid var(--mascot); outline-offset: 1px; }
.catch-footer { font-size: 17px; font-weight: 800; color: rgba(51, 41, 92, 0.7); text-align: center; }

/* ---------- Game: coloring ---------- */

.color-canvas {
  width: 100%; max-width: 330px; margin: 0 auto;
  display: grid; gap: 3px; padding: 6px;
  background: #fff; border-radius: 22px; box-shadow: 0 6px 0 rgba(51, 41, 92, 0.18);
}
.color-tile {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden;
  display: grid; cursor: pointer; background: #ededed;
}
.color-tile i { display: block; transition: background 0.5s ease-in-out; }
.color-tile:disabled { cursor: default; }
.color-sum {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 4px;
  font-size: clamp(11px, 3.6vw, 16px); font-weight: 900; color: rgba(51, 41, 92, 0.7); white-space: nowrap;
}
.color-tile.selected { outline: 3px dashed var(--c); outline-offset: -3px; }
.color-tile.selected .color-sum { color: var(--c); font-size: clamp(14px, 4.5vw, 20px); }
.color-tile:focus-visible { box-shadow: 0 0 0 3px var(--mascot); }

/* ---------- Game: timeRace ---------- */

.race-timer { position: relative; }
.race-seconds {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 17px; font-weight: 900; color: var(--ink); pointer-events: none;
}
.race-bonus {
  position: fixed; left: 50%; top: 80px; z-index: 26;
  transform: translate(-50%, -40px); opacity: 0; pointer-events: none;
  padding: 10px 20px; border-radius: 99px; background: #ff9429; color: #fff;
  font-size: 30px; font-weight: 900; white-space: nowrap;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.3s;
}
.race-bonus.shown { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Game: balloons ---------- */

.balloon-game { max-width: 700px; }
.hearts { display: flex; gap: 4px; }
.heart { color: rgba(255, 255, 255, 0.6); transform: scale(0.8); filter: drop-shadow(0 3px 0 rgba(51, 41, 92, 0.2)); transition: transform 0.3s cubic-bezier(0.3, 1.8, 0.5, 1), color 0.3s; }
.heart.full { color: var(--bad); transform: none; }
.balloon-banner { display: flex; justify-content: center; }
.balloon-question {
  display: flex; gap: 8px; align-items: center;
  font-size: 40px; font-weight: 900; padding: 10px 28px; border-radius: 99px;
  background: #fff; border: 4px solid var(--c);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c), black 20%);
  animation: card-in 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.balloon-intro { font-size: 24px; font-weight: 900; padding: 18px 0; }
.balloon-sky { min-height: 360px; }
.balloon {
  position: absolute; left: 0; top: 0; width: 80px; height: 130px;
  display: flex; flex-direction: column; align-items: center;
  padding: 0; border: 0; background: none; cursor: pointer; will-change: transform;
  touch-action: none;
}
.balloon[hidden] { display: none; }
.balloon-body {
  position: relative; width: 78px; height: 92px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(color-mix(in srgb, var(--c), white 15%), var(--c));
}
.balloon-body b { font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.balloon-shine { position: absolute; width: 14px; height: 24px; left: 14px; top: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); transform: rotate(25deg); }
.balloon-knot { width: 14px; height: 8px; background: color-mix(in srgb, var(--c), black 20%); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.balloon:focus-visible .balloon-body { outline: 4px solid var(--mascot); outline-offset: 3px; }
.balloon-burst {
  position: absolute; transform: translate(-50%, -50%) scale(0.6);
  font-size: 30px; font-weight: 900; pointer-events: none;
  text-shadow: 2px 2px 0 #fff;
  animation: burst 0.6s ease-out forwards;
}
.balloon-burst.good { color: var(--sun); }
.balloon-burst.bad { color: var(--bad); font-size: 44px; }
@keyframes burst { to { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } }

/* ---------- Fit the games on short phone screens ----------
   Sizes follow the visible height (dvh), so the number pad and answers stay on screen without scrolling.
   On tall screens every clamp() reaches its maximum, which is the original size. */
.screen.game { gap: clamp(8px, 1.6dvh, 14px); padding-top: clamp(4px, 1dvh, 8px); }
.number-pad { gap: clamp(6px, 1.3dvh, 12px); }
.number-pad .chunky { height: clamp(40px, 7.4dvh, 58px); font-size: clamp(22px, 4.2dvh, 30px); }
.choice-grid { gap: clamp(8px, 1.8dvh, 14px); }
.choice-grid .chunky { height: clamp(54px, 11dvh, 84px); }
.choice-grid.many .chunky { height: clamp(48px, 9.5dvh, 72px); }
.question-card { padding: clamp(12px, 3.2dvh, 28px) 16px; gap: clamp(6px, 1.4dvh, 12px); }
.equation { font-size: clamp(32px, min(12vw, 7.5dvh), 56px); }
.question-card.picture .equation { font-size: clamp(28px, min(10vw, 6dvh), 44px); }
.color-canvas { max-width: min(330px, 40dvh); }
@media (max-height: 760px) {
  .screen.game .mascot { zoom: 0.78; }
  .screen.game .bubble { font-size: 15px !important; padding: 8px 12px; }
}
@media (max-height: 620px) {
  .screen.game .mascot { zoom: 0.66; }
  .color-canvas { max-width: min(330px, 36dvh); }
  .hint-card { padding: 10px 12px; gap: 6px; }
  .hint-card .explain { font-size: 15px; }
  .hint-card .step { padding: 3px 10px; font-size: 14px; }
  .hint-card .step.last { font-size: 16px; }
  .hint-card .conclusion { font-size: 17px; }
  .hint-card .dot-groups { zoom: 0.75; }
  .hint-card > .chunky { font-size: 19px; padding: 6px; }
}
