:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --sun: #ffc65c;
  --coral: #ff7a59;
  --lime: #a6f76a;
  --hud-h: 48px;
  --help-h: 22px;
  --controls-h: 0px;
  --aspect: 600 / 262;
  --aspect-num: 2.29;
  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(110% 70% at 50% 0%, #3a1f4f 0%, rgba(15, 16, 32, 0) 62%),
    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: 1.6em;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--secondary);
  box-shadow: 0 2px 0 #121322;
  color: #fff;
  font: inherit;
  font-size: 0.92em;
  text-align: center;
}

.shell {
  width: min(980px, 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 1 auto;
  min-width: 0;
}
.brand-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  filter: drop-shadow(0 3px 6px rgba(166, 247, 106, 0.3));
}
.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff3b0, var(--sun) 50%, var(--coral));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #6b2a3a);
}
.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: 8px 13px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a2b40, 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;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0.04em;
}
.chip-score strong {
  color: var(--sun);
}
.chip.pop {
  animation: chip-flash 0.6s ease;
}
.chip.pop strong {
  animation: pop 0.35s cubic-bezier(0.3, 1.8, 0.5, 1);
}
@keyframes pop {
  50% {
    transform: scale(1.35);
  }
}
@keyframes chip-flash {
  0%,
  40% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 3px 0 #0a0b16,
      0 0 0 3px rgba(255, 198, 92, 0.7),
      0 0 18px rgba(255, 198, 92, 0.6);
  }
}
.hud-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  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,
    background 0.12s ease;
}
.icon-btn:hover:not(:disabled) {
  background: #36374e;
}
.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;
}
#sound .mute,
#sound[aria-pressed="false"] .wave {
  display: none;
}
#sound[aria-pressed="false"] .mute {
  display: inline;
}

/* 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:active {
  transform: translateY(2px) scale(0.98);
}
.pill svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.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.45);
}
.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(
      280px,
      calc(
        (
            100svh - 20px - var(--hud-h) - var(--help-h) - var(--controls-h) -
              44px
          ) *
          var(--aspect-num)
      )
    )
  );
  aspect-ratio: var(--aspect);
  border-radius: 22px;
  padding: 6px;
  background: linear-gradient(180deg, #4a2a5e, #231a3a);
  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);
}
.board.shake {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes shake {
  10%,
  90% {
    transform: translate(-2px, 1px);
  }
  20%,
  80% {
    transform: translate(4px, -2px);
  }
  30%,
  50%,
  70% {
    transform: translate(-6px, 2px);
  }
  40%,
  60% {
    transform: translate(6px, -1px);
  }
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
canvas:focus-visible {
  outline: 2px solid rgba(255, 216, 74, 0.45);
  outline-offset: 3px;
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 16px;
  background: radial-gradient(
    70% 80% at 50% 50%,
    rgba(20, 10, 40, 0.35),
    rgba(12, 8, 30, 0.6)
  );
}
.overlay[hidden] {
  display: none;
}
.card {
  width: min(380px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 16px 18px 14px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #2b2450, 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.38s cubic-bezier(0.3, 1.5, 0.5, 1);
  scrollbar-width: none;
}
@keyframes card-in {
  from {
    transform: scale(0.8) translateY(10px);
    opacity: 0;
  }
}
.card-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.card-title {
  margin: 2px 0 4px;
  font-size: clamp(32px, 8vw, 46px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff6c2, var(--sun) 45%, #ff6a5a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #7a2440);
}
.card.lost .card-title {
  background-image: linear-gradient(180deg, #ffe0e6, #ff6b8a 55%, #e2335a);
  filter: drop-shadow(0 3px 0 #6b1530);
}
.card.paused .card-title {
  background-image: linear-gradient(180deg, #fff, #c8b8ff 55%, #8a6bff);
  filter: drop-shadow(0 3px 0 #2d1a7a);
}
.card-copy {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}
.card-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.final {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 0 0 10px;
}
.final[hidden],
.badge[hidden] {
  display: none;
}
.pill-reward {
  display: flex;
  max-width: 100%;
  margin: 10px auto 0;
  color: inherit;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
  font-size: 15px;
}
.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: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.final-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.final-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.final-score,
.final-best {
  font-size: 46px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 0 #3f22b8;
}
.final-best {
  color: var(--sun);
  text-shadow: 0 4px 0 #8a3a1c;
}
.badge {
  display: table;
  margin: 0 auto 12px;
  padding: 4px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, #ffb020);
  color: #3b2400;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 3px 0 #b36b00;
  animation: badge 0.9s ease-in-out infinite alternate;
}
@keyframes badge {
  to {
    transform: scale(1.08) rotate(-2deg);
  }
}

/* Touch controls */
.touch-controls {
  display: none;
  width: 100%;
  max-width: 560px;
  gap: 10px;
}
.ctrl {
  flex: 1 1 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 20px;
  font-size: 19px;
  font-weight: 900;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.08s ease;
}
.ctrl svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}
.ctrl-jump {
  flex-grow: 1.6;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.25),
    0 5px 0 #3f22b8;
}
.ctrl-duck {
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 5px 0 #15162a;
}
.ctrl.held {
  transform: translateY(4px);
  box-shadow: none;
}

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

@media (pointer: coarse), (max-width: 700px) {
  :root {
    --controls-h: 66px;
  }
  .touch-controls {
    display: flex;
  }
}
@media (max-width: 560px) {
  :root {
    --aspect: 600 / 400;
    --aspect-num: 1.5;
  }
  .help {
    font-size: 12px;
  }
}
@media (max-width: 440px) {
  .brand h1 {
    display: none;
  }
  .chip {
    padding: 8px 10px;
    gap: 4px;
  }
  .chip span {
    font-size: 10px;
  }
  .chip strong {
    font-size: 16px;
  }
}
@media (max-width: 350px) {
  body {
    padding: 8px;
  }
  .brand {
    display: none;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
