:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --sun: #ffd21f;
  --hud-h: 48px;
  --help-h: 22px;
  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%, #1d1b44 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;
  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, 190, 30, 0.35));
}
.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff6b8, var(--sun) 55%, #ff9d1a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chips {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.chip {
  display: flex;
  align-items: baseline;
  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(--sun);
}
.chip-best strong {
  color: #9fe7ff;
}
.chip.pop strong {
  animation: pop 0.28s 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: 42px;
  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 {
  filter: brightness(1.08);
}
.pill-big {
  min-height: 56px;
  min-width: 190px;
  font-size: 22px;
}

/* Board */
.stage {
  width: 100%;
  display: flex;
  justify-content: center;
}
.board {
  position: relative;
  width: min(
    100%,
    max(
      240px,
      calc((100svh - 20px - var(--hud-h) - var(--help-h) - 38px) * 0.75)
    )
  );
  aspect-ratio: 3 / 4;
  max-height: calc(100svh - 20px - var(--hud-h) - var(--help-h) - 24px);
  border-radius: 22px;
  padding: 6px;
  background: linear-gradient(180deg, #2c2d52, #1b1c34);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    0 6px 0 #0b0c1a,
    0 18px 40px rgba(0, 0, 0, 0.45);
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 17px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
canvas:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: -2px;
}

/* Get-ready hint (click-through) */
.hint {
  position: absolute;
  inset: 6px;
  pointer-events: none;
  text-align: center;
}
.hint[hidden] {
  display: none;
}
.hint-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 17%;
  font-size: clamp(34px, 11vw, 52px);
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #fff9c4, #ffd21f 50%, #ff8a00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #9c4a00)
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
  animation: bob 1.1s ease-in-out infinite alternate;
}
.hint-tap {
  position: absolute;
  left: 50%;
  top: 65%;
  translate: -50% 0;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 16px;
  background: rgba(20, 30, 70, 0.45);
  color: #fff;
  font-size: 14px;
}
.hint-tap svg {
  width: 44px;
  height: 44px;
  animation: tap 0.9s ease-in-out infinite;
}
.hint-ring {
  fill: rgba(255, 255, 255, 0.2);
  stroke: #fff;
  stroke-width: 2.5;
}
.hint-hand {
  fill: #fff;
  stroke: #2a2b3d;
  stroke-width: 2;
  stroke-linejoin: round;
}
@keyframes bob {
  to {
    transform: translateY(-6px);
  }
}
@keyframes tap {
  50% {
    transform: scale(0.86);
  }
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 17px;
  background: rgba(12, 12, 40, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.overlay[hidden],
.card[hidden] {
  display: none;
}
.card {
  width: min(340px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 18px 16px 20px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #282a52, 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.4s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@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 6px;
  font-size: clamp(40px, 12vw, 58px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fffbd0, #ffd21f 48%, #ff8a00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #9c4a00)
    drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}
.card-title {
  font-size: clamp(34px, 10vw, 46px);
}
.over-title {
  background-image: linear-gradient(180deg, #ffe0e6, #ff6b8a 55%, #e2335a);
  filter: drop-shadow(0 4px 0 #6b1530);
}
#card-pause .card-title {
  background-image: linear-gradient(180deg, #fff, #c8b8ff 55%, #8a6bff);
  filter: drop-shadow(0 4px 0 #2d1a7a);
}
.copy {
  margin: 0 auto 14px;
  max-width: 270px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}
.start-best {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 14px;
}
.start-best strong {
  color: #9fe7ff;
  font-size: 18px;
}
.start-best[hidden] {
  display: none;
}

/* Result panel */
.result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 6px 0 10px;
  padding: 12px;
  border-radius: 18px;
  background: var(--panel-2);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}
.medal-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 84px;
}
.medal-label,
.score-row span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.medal {
  width: 72px;
  height: 72px;
  --m1: #3a3c55;
  --m2: #2c2e45;
  --m3: #1f2034;
  --mi: #34365a;
  --ms: #4a4d6e;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35));
}
.medal .m-stop-1 {
  stop-color: var(--m1);
}
.medal .m-stop-2 {
  stop-color: var(--m2);
}
.medal .m-stop-3 {
  stop-color: var(--m3);
}
.medal .m-disc {
  fill: url(#medal-g);
  stroke: rgba(0, 0, 0, 0.25);
  stroke-width: 2;
}
.medal .m-inner {
  fill: none;
  stroke: var(--mi);
  stroke-width: 3;
}
.medal .m-star {
  fill: var(--ms);
}
.medal .m-shine {
  fill: rgba(255, 255, 255, 0);
}
.medal[data-medal] .m-shine {
  fill: rgba(255, 255, 255, 0.55);
}
.medal[data-medal] {
  animation: medal-in 0.7s 0.15s cubic-bezier(0.3, 1.7, 0.5, 1) both;
}
@keyframes medal-in {
  from {
    transform: scale(0.2) rotate(-40deg);
    opacity: 0;
  }
}
.medal[data-medal="bronze"] {
  --m1: #ffd1a1;
  --m2: #d98a4e;
  --m3: #8f4d1f;
  --mi: #ffcf9e;
  --ms: #fff0de;
}
.medal[data-medal="silver"] {
  --m1: #ffffff;
  --m2: #c9d3e2;
  --m3: #7e8aa3;
  --mi: #eef3fb;
  --ms: #ffffff;
}
.medal[data-medal="gold"] {
  --m1: #fff7b0;
  --m2: #ffc61a;
  --m3: #c27a00;
  --mi: #fff0a0;
  --ms: #fffbe0;
}
.medal[data-medal="platinum"] {
  --m1: #ffffff;
  --m2: #b8f1ff;
  --m3: #5aa6d6;
  --mi: #e3fbff;
  --ms: #ffffff;
}
.medal-name {
  font-size: 13px;
  font-weight: 900;
}
.scores {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.score-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.05;
}
.score-row strong {
  font-size: 34px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 #3f22b8;
}
.score-row + .score-row strong {
  font-size: 24px;
  color: #9fe7ff;
  text-shadow: 0 2px 0 #1b3f6b;
}
.badge {
  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(-3deg);
  }
}
.next-medal {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.next-medal:empty {
  display: none;
}
.pill-reward {
  display: flex;
  margin: 10px auto 0;
  max-width: 100%;
  min-height: 38px;
  padding: 0 14px;
  color: inherit;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
  font-size: 14px;
  white-space: nowrap;
}
/* Make room for the optional offer inside the short game-over card. */
.card-over:has(#continue:not([hidden])) .next-medal {
  display: none;
}
.pill-reward:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}
.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;
}

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

@media (max-width: 600px) and (orientation: portrait) {
  .board {
    width: 100%;
    aspect-ratio: auto;
    height: min(
      calc(100svh - 20px - var(--hud-h) - var(--help-h) - 24px),
      calc((100vw - 20px) * 1.85)
    );
    min-height: calc((100vw - 20px) * 4 / 3);
    max-height: none;
  }
}
@media (max-width: 480px) {
  .brand h1 {
    display: none;
  }
  .chip {
    padding: 7px 10px;
  }
}
@media (max-width: 340px) {
  .chip span {
    display: none;
  }
}
@media (pointer: coarse) {
  .kbd-only {
    display: none;
  }
  .help {
    display: none;
  }
}

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