:root {
  --ink: #23324a;
  --ink-soft: #4d5f7a;
  --panel: rgba(255, 255, 255, 0.92);
  --accent: #ff7a3d;
  --accent-dark: #e05a1e;
  --good: #2fb36b;
  --gold: #ffc23a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7fd3ff; color: var(--ink); font-family: "Baloo 2", "Trebuchet MS", system-ui, sans-serif; user-select: none; touch-action: none; }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
[hidden] { display: none !important; }

.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 460px); max-height: 92dvh; overflow: auto;
  padding: 20px 18px; border-radius: 26px; background: var(--panel);
  box-shadow: 0 14px 0 rgba(35, 50, 74, 0.18), 0 20px 40px rgba(35, 50, 74, 0.25);
  text-align: center; display: grid; gap: 12px; touch-action: manipulation;
}
h1 { margin: 0; font-size: clamp(2.2rem, 10vw, 3.2rem); line-height: 1; color: var(--ink); letter-spacing: 0.5px; }
h1 span { color: var(--accent); }
h2 { margin: 0; font-size: 1.8rem; }
.sub { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  font: inherit; font-weight: 800; font-size: 1.15rem; color: #fff; cursor: pointer;
  background: var(--accent); border: 0; border-radius: 16px; padding: 10px 20px; min-height: 48px;
  box-shadow: 0 5px 0 var(--accent-dark); transition: transform 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-dark); }
.btn.big { font-size: 1.5rem; padding: 12px 28px; }
.btn.alt { background: #4aa8ff; box-shadow: 0 5px 0 #2a7fd0; }
.btn.ghost { background: none; color: var(--ink-soft); box-shadow: none; text-decoration: underline; font-size: 1rem; min-height: 40px; }
.btn:disabled { background: #b8c2cf; box-shadow: 0 5px 0 #98a3b2; cursor: default; }

.animals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.animal {
  border: 3px solid transparent; border-radius: 18px; background: #eef7ff; padding: 6px 2px 4px;
  cursor: pointer; display: grid; justify-items: center; gap: 2px; font: inherit; color: var(--ink); font-weight: 800;
}
.animal canvas { position: static; width: 64px; height: 64px; }
.animal[aria-checked="true"] { border-color: var(--accent); background: #fff3ea; }
.power-text { margin: 0; min-height: 2.6em; color: var(--ink-soft); font-size: 1rem; }
.wallet { margin: 0; font-weight: 800; }

.upgrades { display: grid; gap: 8px; }
.upgrade { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; text-align: left; background: #eef7ff; border-radius: 16px; padding: 10px 12px; }
.upgrade b { font-size: 1.1rem; }
.upgrade small { color: var(--ink-soft); grid-column: 1; }
.pips { grid-column: 1; display: flex; gap: 4px; }
.pips i { width: 16px; height: 8px; border-radius: 4px; background: #c9d6e6; }
.pips i.on { background: var(--good); }
.upgrade .btn { grid-column: 2; grid-row: 1 / span 3; font-size: 1rem; padding: 8px 12px; }

.big-num { margin: 0; font-size: 3.4rem; font-weight: 800; line-height: 1; }
.earned { margin: 0; font-size: 1.6rem; font-weight: 800; color: #b07a00; }

#hud { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; pointer-events: none; text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7); }
.hud-dist { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.hud-best { color: var(--ink-soft); font-weight: 600; }
.hud-right { text-align: right; }
.hud-coins { font-size: 1.5rem; font-weight: 800; }
.hud-power { font-weight: 800; color: var(--accent-dark); }
.hint { position: fixed; left: 50%; bottom: calc(18% + env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; padding: 8px 16px; border-radius: 999px; background: rgba(255, 255, 255, 0.9); font-weight: 800; font-size: 1.15rem; pointer-events: none; white-space: nowrap; }
.sound { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.85); font-size: 1.3rem; cursor: pointer; }

.coin { display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.25em; vertical-align: -0.1em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe38a, #ffc23a 55%, #d99a00); box-shadow: inset 0 0 0 2px #b07a00; }

.other-game { display: block; color: var(--ink-soft); font-weight: 800; text-decoration: none; }
.other-game:hover { text-decoration: underline; }
