:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --grass: #8fe05a;
  --gold: #ffd36b;
  --hud-h: 48px;
  --help-h: 20px;
  --pad-h: 0px;
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-weight: 800;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body {
  padding: 10px;
  background:
    radial-gradient(120% 70% at 50% 0%, #1d3040 0%, rgba(15, 16, 32, 0) 60%),
    var(--bg);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid #ffd84a;
  outline-offset: 2px;
}
kbd {
  display: inline-block;
  min-width: 20px;
  margin: 0 1px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--secondary);
  box-shadow: 0 2px 0 #0b0c1a;
  color: #fff;
  font: inherit;
  font-size: 0.9em;
  text-align: center;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* HUD */
.hud {
  width: 100%;
  min-height: var(--hud-h);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.brand-icon {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 3px 6px rgba(255, 90, 110, 0.35));
}
.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff6c9, #ffd23f 50%, #ff8a1f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #7a3a00);
}
.chips {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #26273b, var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 #0a0b16;
}
.chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chip strong {
  display: inline-block;
  min-width: 1.2ch;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.chip-score strong {
  color: var(--grass);
}
.chip-best strong,
.chip-coins strong {
  color: var(--gold);
}
.coin-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc928 45%, #e08a00);
  box-shadow:
    inset 0 0 0 2px #c77700,
    0 2px 0 #7a4a00;
}
.chip.pop strong {
  animation: pop 0.32s cubic-bezier(0.3, 1.8, 0.5, 1);
}
@keyframes pop {
  50% {
    transform: scale(1.4);
  }
}
.hud-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 #15162a;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.icon-btn:hover:not(:disabled) {
  background: #34354b;
}
.icon-btn:active:not(:disabled) {
  transform: translateY(2px);
}
.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.icon-btn .icon-off,
.icon-btn[aria-pressed="true"] .icon-on {
  display: none;
}
.icon-btn[aria-pressed="true"] .icon-off {
  display: block;
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
}
.pill svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.pill:active:not(:disabled) {
  transform: translateY(2px) scale(0.98);
}
.pill-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.25),
    0 4px 0 #3f22b8,
    0 10px 24px rgba(104, 66, 255, 0.4);
}
.pill-primary:hover,
.pill-secondary:hover {
  filter: brightness(1.1);
}
.pill-secondary {
  margin-top: 10px;
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 0 #111224;
}
.pill-big {
  min-height: 56px;
  min-width: 190px;
  font-size: 22px;
}
.pill-reward {
  display: flex;
  max-width: 100%;
  margin: 12px auto 0;
  font-size: 15px;
}
.pill-reward:disabled {
  cursor: progress;
  opacity: 0.75;
}
.pill-reward[hidden],
.ad-note[hidden] {
  display: none;
}
.ad-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* Board */
.stage {
  width: 100%;
  display: flex;
  justify-content: center;
}
.board {
  --board-h: max(
    300px,
    calc(100svh - 20px - var(--hud-h) - var(--help-h) - var(--pad-h) - 24px)
  );
  position: relative;
  width: min(100%, calc(var(--board-h) * 1.2));
  height: var(--board-h);
  border-radius: 22px;
  padding: 6px;
  background: linear-gradient(180deg, #3a5a3a, #1b2c24);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 6px 0 #0b0c1a,
    0 18px 40px rgba(0, 0, 0, 0.45);
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 17px;
  background: #86d157;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
canvas:focus-visible {
  outline: 3px solid rgba(255, 216, 74, 0.8);
  outline-offset: -3px;
}
.board.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes shake {
  20%,
  60% {
    transform: translate(-6px, 2px);
  }
  40%,
  80% {
    transform: translate(6px, -2px);
  }
}

/* Touch hop pad */
.pad {
  display: none;
  gap: 10px;
  justify-content: center;
  width: 100%;
}
.pad-btn {
  display: grid;
  place-items: center;
  width: 56px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 0 #111224;
  cursor: pointer;
  touch-action: manipulation;
}
.pad-btn svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #fff;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pad-up {
  width: 88px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.25),
    0 4px 0 #3f22b8;
}
.pad-btn:active {
  transform: translateY(2px);
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 17px;
  background: rgba(16, 30, 40, 0.42);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}
.overlay[hidden],
.card[hidden] {
  display: none;
}
.card {
  width: min(330px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 16px 14px 18px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #2b2c55, var(--panel));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 8px 0 #0b0c1a,
    0 24px 50px rgba(0, 0, 0, 0.5);
  animation: card-in 0.42s cubic-bezier(0.3, 1.5, 0.5, 1);
}
#card-pause {
  display: flex;
  flex-direction: column;
  align-items: center;
}
#card-pause[hidden] {
  display: none;
}
@keyframes card-in {
  from {
    transform: translateY(24px) scale(0.85);
    opacity: 0;
  }
}
.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.logo,
.card-title {
  margin: 2px 0 8px;
  font-size: clamp(42px, 12vw, 58px);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fffbe0, #ffd23f 45%, #ff8a1f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #8a3b00)
    drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}
.logo {
  animation: logo-hop 0.9s cubic-bezier(0.3, 0, 0.4, 1) infinite alternate;
}
@keyframes logo-hop {
  to {
    transform: translateY(-6px) scaleY(1.04);
  }
}
.card-title {
  font-size: clamp(32px, 9vw, 42px);
}
.over-title {
  background-image: linear-gradient(180deg, #ffe0e6, #ff6b8a 55%, #e2335a);
  filter: drop-shadow(0 4px 0 #6b1530);
}
.over-title.is-best {
  background-image: linear-gradient(180deg, #fffbd0, #ffd21f 48%, #ff8a00);
  filter: drop-shadow(0 4px 0 #9c4a00);
}
#card-pause .card-title {
  background-image: linear-gradient(180deg, #fff, #c8b8ff 55%, #8a6bff);
  filter: drop-shadow(0 4px 0 #2d1a7a);
}
.copy {
  margin: 0 auto 10px;
  max-width: 280px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: #dfe1f0;
  font-size: 13px;
}
.start-best {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 14px;
}
.start-best strong {
  color: var(--gold);
  font-size: 18px;
}
.start-best[hidden] {
  display: none;
}

/* Result panel */
.result {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  margin: 6px 0 14px;
  padding: 12px 12px 14px;
  border-radius: 18px;
  background: var(--panel-2);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}
.score-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.score-row span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.score-row strong {
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  text-shadow: 0 2px 0 #7a4a00;
}
.score-main strong {
  font-size: 42px;
  color: var(--grass);
  text-shadow: 0 3px 0 #1d5e22;
}
.badge {
  position: absolute;
  top: -12px;
  right: -6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, #ffb020);
  color: #3b2400;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 3px 0 #b36b00;
  animation: badge 0.9s ease-in-out infinite alternate;
}
.badge[hidden] {
  display: none;
}
@keyframes badge {
  to {
    transform: scale(1.08) rotate(-4deg);
  }
}

.help {
  margin: 0;
  min-height: var(--help-h);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

@media (pointer: coarse), (max-width: 600px) {
  :root {
    --pad-h: 60px;
    --help-h: 0px;
  }
  .pad {
    display: flex;
  }
  .help {
    display: none;
  }
}
@media (max-width: 600px) and (orientation: portrait) {
  .board {
    width: 100%;
    height: min(var(--board-h), calc((100vw - 20px) * 1.8));
    min-height: calc((100vw - 20px) * 1.2);
  }
}
@media (max-width: 480px) {
  .brand h1 {
    display: none;
  }
  .chip {
    padding: 7px 10px;
  }
}
@media (max-width: 360px) {
  .chip span {
    display: none;
  }
  .pad-btn {
    width: 50px;
  }
  .pad-up {
    width: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
