:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-hi: #8a6bff;
  --text: #fff;
  --muted: #aaadbe;
  --line: #2e3048;
  --heart: #ff4d7a;
  --gold: #ffd23f;
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-width: 0;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body {
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

/* ---------- HUD ---------- */
.as-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.as-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.as-logo-mark {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 3px 0 #3a1fb0);
}
.as-hud {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  min-width: 62px;
  padding: 4px 12px 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 3px 0 #0a0b16;
  text-align: center;
  line-height: 1.05;
}
.chip span {
  display: block;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.chip-level {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 3px 0 #3a1fb0;
}
.chip-level span {
  color: #e2dcff;
}
.chip.bump strong {
  animation: chip-pop 0.35s ease-out;
}
.chip-lives strong {
  display: flex;
  gap: 3px;
  justify-content: center;
  padding-top: 3px;
}
.heart {
  width: 15px;
  height: 14px;
  display: inline-block;
  background: var(--heart);
  clip-path: path(
    "M7.5 13.5 1.6 7.7A3.9 3.9 0 0 1 7.5 2.6a3.9 3.9 0 0 1 5.9 5.1Z"
  );
  filter: drop-shadow(0 0 0 #000);
  transition:
    transform 0.25s ease,
    opacity 0.25s ease,
    background 0.25s ease;
}
.heart.lost {
  background: #3a3c55;
  transform: scale(0.8);
}
.heart.breaking {
  animation: heart-break 0.5s ease-out;
}

/* ---------- Stage ---------- */
.as-stage {
  position: relative;
  width: min(100%, var(--board-size, 480px));
  aspect-ratio: 1;
  perspective: 900px;
}
.as-board {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  touch-action: manipulation;
  cursor: pointer;
  outline: none;
}
#board:focus-visible {
  box-shadow:
    0 0 0 3px var(--bg),
    0 0 0 6px var(--accent-hi);
}

/* ---------- Buttons ---------- */
.as-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.12s ease,
    box-shadow 0.12s ease;
}
.btn svg {
  width: 20px;
  height: 20px;
}
.btn:active {
  transform: translateY(3px);
}
.btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn-primary {
  background: linear-gradient(180deg, #8a6bff, var(--accent) 60%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #3a1fb0,
    0 10px 24px rgba(104, 66, 255, 0.4);
}
.btn-primary:active {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 1px 0 #3a1fb0;
}
.btn-secondary {
  background: linear-gradient(180deg, #34364c, #2a2b3d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 0 #15162a;
}
.btn-secondary:active {
  box-shadow: 0 1px 0 #15162a;
}
.btn-icon {
  padding: 0;
  width: 44px;
}
.btn-big {
  min-height: 56px;
  min-width: 200px;
  font-size: 20px;
}
#btn-hint.glow {
  animation: hint-glow 1.6s ease-in-out infinite;
}
#btn-sound .snd-off {
  display: none;
}
#btn-sound[aria-pressed="false"] .snd-off {
  display: inline;
}
#btn-sound[aria-pressed="false"] .snd-wave {
  display: none;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 22px;
  background: rgba(10, 11, 24, 0.72);
  backdrop-filter: blur(4px);
  animation: fade-in 0.25s ease-out;
}
.overlay[hidden] {
  display: none;
}
.card {
  width: min(360px, 100%);
  padding: 20px 18px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #26283d, var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 6px 0 #0a0b16,
    0 24px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: card-pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.card h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
}
.card .card-kicker {
  color: #c9bcff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.card .card-stats {
  color: #fff;
  font-size: 16px;
}
.card-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.start-art {
  position: relative;
  width: 150px;
  height: 64px;
}
.sa {
  position: absolute;
  height: 18px;
  border-radius: 9px;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.35),
    0 4px 0 rgba(0, 0, 0, 0.35);
}
.sa::after {
  content: "";
  position: absolute;
  right: -14px;
  top: -8px;
  border-left: 22px solid currentColor;
  border-top: 17px solid transparent;
  border-bottom: 17px solid transparent;
}
.sa-1 {
  left: 6px;
  top: 4px;
  width: 64px;
  background: #ff4d8d;
  color: #ff4d8d;
  animation: slide-demo 2.4s ease-in infinite;
}
.sa-2 {
  left: 36px;
  top: 38px;
  width: 44px;
  background: #3fa7ff;
  color: #3fa7ff;
  animation: slide-demo 2.4s 0.6s ease-in infinite;
}
.sa-3 {
  left: 94px;
  top: 20px;
  width: 30px;
  background: #ffd23f;
  color: #ffd23f;
  animation: slide-demo 2.4s 1.2s ease-in infinite;
}
.stars-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.big-star {
  width: 52px;
  height: 50px;
  background: #3a3c55;
  clip-path: polygon(
    50% 0,
    62% 35%,
    100% 37%,
    70% 59%,
    81% 96%,
    50% 75%,
    19% 96%,
    30% 59%,
    0 37%,
    38% 35%
  );
}
.big-star:nth-child(2) {
  width: 64px;
  height: 62px;
}
.big-star.on {
  background: linear-gradient(180deg, #fff2a8, var(--gold) 45%, #f0a500);
  animation: star-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.big-star.on:nth-child(2) {
  animation-delay: 0.18s;
}
.big-star.on:nth-child(3) {
  animation-delay: 0.36s;
}

.overlay-map {
  place-items: stretch;
}
.card-map {
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  padding: 14px 12px 12px;
  gap: 10px;
}
.map-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.map-head h2 {
  font-size: 22px;
  margin-right: auto;
}
.map-total {
  font-weight: 900;
  color: var(--gold);
}
.map-grid {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  padding: 4px 4px 8px;
  overscroll-behavior: contain;
}
.lvl {
  position: relative;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  font-weight: 900;
  font-size: 17px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #34364c, #2a2b3d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 3px 0 #15162a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 4px 0;
}
.lvl small {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--gold);
  margin-top: 3px;
}
.lvl small .off {
  color: #4a4c66;
}
.lvl.current {
  background: linear-gradient(180deg, #8a6bff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 3px 0 #3a1fb0;
}
.lvl:disabled {
  cursor: default;
  color: #5d6080;
  background: #1c1d2c;
  box-shadow: inset 0 0 0 2px #25263a;
}
.lvl:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ---------- Animations ---------- */
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes card-pop {
  from {
    transform: scale(0.8) translateY(12px);
    opacity: 0;
  }
}
@keyframes star-pop {
  0% {
    transform: scale(0) rotate(-40deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}
@keyframes chip-pop {
  40% {
    transform: scale(1.35);
    color: var(--gold);
  }
}
@keyframes heart-break {
  30% {
    transform: scale(1.5) rotate(-12deg);
    background: #fff;
  }
}
@keyframes hint-glow {
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      0 4px 0 #15162a,
      0 0 0 4px rgba(255, 210, 63, 0.55),
      0 0 22px rgba(255, 210, 63, 0.5);
  }
}
@keyframes slide-demo {
  0%,
  30% {
    transform: translateX(0);
    opacity: 1;
  }
  60% {
    transform: translateX(120px);
    opacity: 0;
  }
  61% {
    transform: translateX(-10px);
    opacity: 0;
  }
  80%,
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (max-width: 520px) {
  body {
    padding: 6px;
  }
  .as-top {
    justify-content: center;
  }
  .as-logo {
    font-size: 19px;
  }
  .chip {
    min-width: 54px;
    padding: 4px 8px 5px;
  }
  .chip strong {
    font-size: 16px;
  }
  .btn {
    padding: 0 14px;
    font-size: 14px;
  }
  .btn-icon {
    padding: 0;
  }
}
@media (max-width: 360px) {
  .as-actions .btn span {
    display: none;
  }
  .as-actions .btn {
    width: 52px;
    padding: 0;
  }
  .chip {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.btn[hidden] {
  display: none;
}
