:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --gold: #ffcf3a;
  --blue: #3b9bff;
  --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: 8px;
  background:
    radial-gradient(120% 70% at 50% 0%, #1d2350 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;
}
[hidden] {
  display: none !important;
}

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

/* HUD */
.hud {
  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(59, 155, 255, 0.45));
}
.brand h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-style: italic;
  white-space: nowrap;
  background: linear-gradient(180deg, #e8f6ff, #7cc6ff 50%, #3b7dff);
  -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: center;
  gap: 5px;
  min-width: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #27283d, 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 {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.chip-coins strong {
  color: var(--gold);
}
.chip-level strong {
  color: #9fd3ff;
}
.coin {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.chip.pop strong {
  animation: pop 0.32s cubic-bezier(0.3, 1.8, 0.5, 1);
}
@keyframes pop {
  50% {
    transform: scale(1.35);
  }
}

/* Pills */
.pill {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 0.12s,
    filter 0.12s;
}
.pill:active {
  transform: translateY(2px) scale(0.98);
}
.pill:disabled {
  opacity: 0.45;
  cursor: default;
}
.pill-primary {
  background: linear-gradient(180deg, #8a6bff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    0 4px 0 #3b1fb3,
    0 10px 24px rgba(104, 66, 255, 0.45);
}
.pill-primary:hover {
  filter: brightness(1.08);
}
.pill-secondary {
  background: linear-gradient(180deg, #34364c, var(--secondary));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 3px 0 #0a0b16;
}
.pill-big {
  min-width: 200px;
  min-height: 58px;
  font-size: 23px;
}
.icon-button {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
#sound[aria-pressed="false"] .wave {
  opacity: 0.15;
}

/* Stage */
.stage {
  position: relative;
  width: 100%;
  height: clamp(
    340px,
    calc(100svh - 16px - var(--hud-h) - var(--help-h) - 16px),
    820px
  );
  border-radius: 20px;
  overflow: hidden;
  background: #7fd4ff;
  box-shadow:
    0 0 0 3px #2c2d52,
    0 16px 40px rgba(0, 0, 0, 0.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  outline: none;
}
.stage > canvas:active {
  cursor: grabbing;
}
.stage > canvas:focus-visible {
  box-shadow: inset 0 0 0 3px #ffd84a;
}

.progress {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: min(300px, 70%);
}
.progress-num {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
  background: linear-gradient(180deg, #8a6bff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 3px 0 #3b1fb3;
}
.progress-num.next {
  background: linear-gradient(180deg, #ffffff, #d7dcf2);
  color: #2b2c4a;
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.12),
    0 3px 0 rgba(40, 40, 80, 0.4);
}
.progress-bar {
  flex: 1;
  height: 12px;
  border-radius: 99px;
  background: rgba(20, 22, 50, 0.45);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.progress-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(180deg, #ffe680, #ffb321);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.banner {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.02em;
  color: #fff;
  white-space: nowrap;
  text-shadow:
    0 3px 0 #3b1fb3,
    0 6px 18px rgba(20, 10, 80, 0.5);
}
.banner small {
  display: block;
  font-size: 0.42em;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffe680;
}
.banner.show {
  animation: banner 1.6s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}
@keyframes banner {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(0.96);
  }
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: radial-gradient(
    80% 70% at 50% 50%,
    rgba(15, 16, 40, 0.35),
    rgba(15, 16, 40, 0.72)
  );
  overflow-y: auto;
}
.card {
  width: min(460px, 100%);
  padding: 20px 18px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(
    180deg,
    rgba(38, 39, 62, 0.94),
    rgba(26, 27, 40, 0.96)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 6px 0 #0a0b16,
    0 24px 48px rgba(0, 0, 0, 0.45);
  animation: card-in 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes card-in {
  from {
    transform: translateY(16px) scale(0.92);
    opacity: 0;
  }
}
.card h2 {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 900;
}
.menu-card {
  background: transparent;
  box-shadow: none;
  padding: 8px 4px;
}
.logo {
  margin: 0 0 4px !important;
  font-size: clamp(44px, 11vw, 70px) !important;
  font-weight: 900;
  font-style: italic;
  line-height: 0.95;
  letter-spacing: -0.03em;
  transform: rotate(-4deg);
}
.logo span {
  display: inline-block;
  padding: 0 4px;
  -webkit-text-stroke: 2px #1a1466;
  paint-order: stroke fill;
  filter: drop-shadow(0 5px 0 #1a1466)
    drop-shadow(0 10px 16px rgba(10, 10, 60, 0.45));
}
.logo-a {
  color: #5fc0ff;
}
.logo-b {
  color: #ffd23f;
}
.tag {
  margin: 10px 0 16px;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(10, 10, 50, 0.6);
}
#play {
  animation: breathe 1.6s ease-in-out infinite;
}
.play-level {
  font-size: 14px;
  opacity: 0.85;
  display: block;
  margin-top: -2px;
}
#play {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  padding: 6px 30px;
  min-height: 64px;
}
@keyframes breathe {
  50% {
    transform: scale(1.05);
  }
}
.upgrades {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.upg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 108px;
  padding: 10px 6px 8px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  background: linear-gradient(180deg, #34366a, #242552);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 4px 0 #10113a,
    0 10px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s;
}
.upg:active {
  transform: translateY(2px) scale(0.97);
}
.upg.cant {
  filter: saturate(0.4) brightness(0.8);
}
.upg.bought {
  animation: pop 0.35s cubic-bezier(0.3, 1.8, 0.5, 1);
}
.upg-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.upg-icon-crowd {
  background:
    radial-gradient(circle at 30% 30%, #9fdcff 0 20%, transparent 22%),
    radial-gradient(circle at 50% 55%, #3b9bff 0 44%, transparent 46%);
  box-shadow:
    -9px 5px 0 -5px #3b9bff,
    9px 5px 0 -5px #3b9bff;
}
.upg-icon-coin {
  background: radial-gradient(
    circle at 40% 35%,
    #fff2a8,
    #ffd23f 45%,
    #e79a12 75%
  );
}
.upg-icon-skin {
  background: conic-gradient(
    #ff5d8f,
    #ffd23f,
    #3fe08a,
    #3b9bff,
    #a56bff,
    #ff5d8f
  );
}
.upg-title {
  font-size: 12px;
  color: #c9ccec;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.upg-val {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
}
.upg-cost {
  margin-top: 2px;
  padding: 3px 10px 3px 24px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 900;
  color: #3a2600;
  background:
    radial-gradient(
      circle at 12px 50%,
      #ffd23f 0 6px,
      #e79a12 6.5px 8px,
      transparent 8.5px
    ),
    linear-gradient(180deg, #fff1a6, #ffc53a);
}
.upg-cost-plain {
  padding: 3px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.skins-card h2 {
  margin-bottom: 14px;
}
.skin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.skin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 112px;
  padding: 8px 4px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  background: linear-gradient(180deg, #303254, #22233d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 3px 0 #0a0b16;
}
.skin canvas {
  width: 36px;
  height: 54px;
}
.skin[aria-pressed="true"] {
  box-shadow:
    inset 0 0 0 3px #ffd23f,
    0 3px 0 #0a0b16;
}
.skin span {
  font-size: 13px;
}
.skin small {
  font-size: 12px;
  color: var(--muted);
}
.skin .price {
  color: var(--gold);
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.end-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.end-card h2 {
  font-size: 32px;
  margin: 2px 0 12px;
}
.end-card.win h2 {
  color: #ffe45a;
  text-shadow: 0 3px 0 #b86a00;
}
.end-card.lose h2 {
  color: #ff7a8a;
}
.end-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.end-stats div {
  padding: 8px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}
.end-stats span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.end-stats strong {
  font-size: 22px;
  font-weight: 900;
}
.end-coins {
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 30px;
  font-weight: 900;
  color: var(--gold);
}
.end-coins .coin {
  width: 30px;
  height: 30px;
}

.help {
  margin: 0;
  min-height: var(--help-h);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
kbd {
  display: inline-block;
  min-width: 20px;
  margin: 0 1px;
  padding: 1px 5px;
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
  background: var(--panel-2);
  box-shadow: 0 2px 0 #0a0b16;
}

@media (max-width: 620px) {
  .brand h1 {
    display: none;
  }
  .help {
    display: none;
  }
  .stage {
    height: clamp(340px, calc(100svh - 16px - var(--hud-h) - 8px), 820px);
  }
}
@media (max-width: 400px) {
  body {
    padding: 6px;
  }
  .brand {
    display: none;
  }
  .chip {
    padding: 7px 9px;
  }
  .chip span {
    display: none;
  }
  .chip .sr-only {
    display: inline;
  }
  .upg-title {
    font-size: 10px;
  }
  .card {
    padding: 16px 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #play,
  .card,
  .upg.bought,
  .chip.pop strong {
    animation: none;
  }
  .banner.show {
    animation: banner-fade 1.6s linear forwards;
  }
  @keyframes banner-fade {
    0%,
    80% {
      opacity: 1;
      transform: translate(-50%, -50%);
    }
    100% {
      opacity: 0;
      transform: translate(-50%, -50%);
    }
  }
}
