:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-hi: #8c6dff;
  --text: #fff;
  --muted: #aaadbe;
  --secondary: #2a2b3d;
  font-family:
    "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
    "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  padding: 10px;
  overflow-x: hidden;
}
.bb-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.bb {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* ---------- side / HUD ---------- */
.bb-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand actions"
    "hud hud";
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.bb-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.bb-logo {
  width: 34px;
  height: 34px;
  flex: none;
  filter: drop-shadow(0 3px 6px rgb(0 0 0 / 0.45));
}
.bb-brand h1 {
  margin: 0;
  overflow: hidden;
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: linear-gradient(180deg, #fff 30%, #c9bcff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bb-hud {
  grid-area: hud;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.chip {
  display: grid;
  justify-items: center;
  min-width: 0;
  padding: 5px 4px 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.07),
    0 4px 10px rgb(0 0 0 / 0.25);
}
.chip span {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.chip strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-score {
  background: linear-gradient(180deg, #7b5cff, #5230e6);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.25),
    0 4px 14px rgb(104 66 255 / 0.4);
}
.chip-score span {
  color: #e2dbff;
}
.chip-lives strong {
  color: #ff6b8b;
}
.chip.bump strong {
  animation: bump 0.32s ease-out;
}
.chip.warn {
  animation: warn 0.6s ease-out;
}
@keyframes bump {
  40% {
    transform: scale(1.28);
  }
}
@keyframes warn {
  30% {
    background: linear-gradient(180deg, #ff5a6e, #c61f3b);
    transform: scale(1.08);
  }
}

.bb-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.pill:hover:not(:disabled) {
  filter: brightness(1.12);
}
.pill:active:not(:disabled) {
  transform: translateY(2px) scale(0.98);
}
.pill:disabled {
  opacity: 0.45;
  cursor: default;
}
.pill-primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.25),
    0 5px 0 #4424c4,
    0 10px 22px rgb(104 66 255 / 0.45);
}
.pill-secondary {
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.08),
    0 4px 0 #1b1c2a;
}
.pill-big {
  min-height: 54px;
  min-width: 190px;
  font-size: 1.2rem;
}
.pill-icon-only {
  width: 44px;
  min-height: 44px;
  padding: 0;
}
.pill-icon-only .pill-label {
  display: none;
}
button:focus-visible,
canvas:focus-visible {
  outline: 3px solid #ffd84a;
  outline-offset: 3px;
}

.bb-legend,
.bb-help {
  display: none;
}
.bb-legend {
  margin: 0;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--panel);
  list-style: none;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
}
.bb-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: #d9dbea;
  font-size: 0.8rem;
  font-weight: 800;
}
.cap {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 16px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 900;
  text-shadow: 0 1px 1px rgb(0 0 0 / 0.45);
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.4),
    inset 0 -2px 0 rgb(0 0 0 / 0.2),
    0 2px 6px rgb(0 0 0 / 0.35);
}
.cap-wide {
  background: linear-gradient(180deg, #7aa6ff, #2f63f0);
}
.cap-multi {
  background: linear-gradient(180deg, #6ff0ff, #0fa9d6);
}
.cap-laser {
  background: linear-gradient(180deg, #ff7a8e, #e0163e);
}
.cap-slow {
  background: linear-gradient(180deg, #ffc46b, #f07d0c);
}
.cap-sticky {
  background: linear-gradient(180deg, #7dff9f, #19b14b);
}
.cap-life {
  background: linear-gradient(180deg, #ff9be4, #e02fb4);
}
.bb-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.6;
}
.bb-help span {
  display: block;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--secondary);
  box-shadow: 0 2px 0 #14151f;
  color: #fff;
  font: inherit;
  font-size: 0.72rem;
  text-align: center;
}

/* ---------- stage ---------- */
.bb-stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  border-radius: 22px;
  overflow: hidden;
  background: #121330;
  box-shadow:
    0 0 0 2px #2a2c55,
    0 0 30px rgb(104 66 255 / 0.25),
    0 18px 40px rgb(0 0 0 / 0.5);
}
.bb-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: none;
  -webkit-user-select: none;
  user-select: none;
}
.bb-stage.menu canvas {
  cursor: default;
}

.bb-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow-y: auto;
  background: radial-gradient(
    circle at 50% 40%,
    rgb(40 30 110 / 0.7),
    rgb(10 10 25 / 0.9)
  );
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.bb-overlay[hidden] {
  display: none;
}
.bb-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 100%;
  max-width: 330px;
  padding: 20px 16px 22px;
  border-radius: 26px;
  background: linear-gradient(180deg, #25264a, #1a1b28);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.1),
    0 20px 50px rgb(0 0 0 / 0.55);
  text-align: center;
  animation: card-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes card-in {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}
.bb-card-art {
  width: 150px;
  height: 64px;
  filter: drop-shadow(0 6px 10px rgb(0 0 0 / 0.45));
  animation: float 2.6s ease-in-out infinite;
}
.bb-card-art[hidden] {
  display: none;
}
@keyframes float {
  50% {
    transform: translateY(-5px);
  }
}
.bb-card h2 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #fff 35%, #c7b8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bb-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
}
.bb-card-actions {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 4px;
}
.bb-card-actions .pill-secondary {
  min-width: 150px;
}
.bb-card-actions [hidden] {
  display: none;
}
.bb-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin: 2px 0 4px;
}
.bb-results[hidden] {
  display: none;
}
.bb-results div {
  display: grid;
  padding: 8px 6px;
  border-radius: 16px;
  background: #14152a;
}
.bb-results span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.bb-results strong {
  font-size: 1.3rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.bb-results .badge {
  grid-column: 1 / -1;
  padding: 6px;
  background: linear-gradient(180deg, #ffd84a, #ff9f1a);
  color: #3b2200;
  font-weight: 900;
}

.bb-level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.bb-level-grid[hidden] {
  display: none;
}
.lvl {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  color: #fff;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(180deg, #8c6dff, #5a36f0);
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.25),
    0 4px 0 #3b1fb0;
  transition: transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.lvl:active:not(:disabled) {
  transform: translateY(2px);
}
.lvl.done {
  background: linear-gradient(180deg, #4fe39a, #18a95c);
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.3),
    0 4px 0 #0e6e3a;
}
.lvl.done::after {
  content: "★";
  position: absolute;
  top: 2px;
  right: 6px;
  color: #fff4a8;
  font-size: 0.7rem;
}
.lvl:disabled {
  background: #22233a;
  box-shadow: inset 0 0 0 2px #2c2e48;
  color: #5d6080;
  cursor: default;
}
.lvl svg {
  width: 16px;
  height: 16px;
}

/* ---------- wide layout ---------- */
@media (min-width: 700px) {
  body {
    padding: 12px 16px;
  }
  .bb {
    grid-template-columns: 220px minmax(0, 420px);
    justify-content: center;
    align-items: start;
    gap: 22px;
    max-width: 680px;
  }
  .bb-side {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: none;
    gap: 12px;
    padding-top: 4px;
  }
  .bb-brand,
  .bb-hud,
  .bb-actions {
    grid-area: auto;
  }
  .bb-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .bb-logo {
    width: 50px;
    height: 50px;
  }
  .bb-brand h1 {
    font-size: 1.8rem;
  }
  .bb-hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .chip {
    padding: 7px 6px 8px;
    border-radius: 18px;
  }
  .chip strong {
    font-size: 1.2rem;
  }
  .bb-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .pill-icon-only {
    width: auto;
    padding: 0 12px;
  }
  .pill-icon-only .pill-label {
    display: inline;
  }
  .bb-legend,
  .bb-help {
    display: block;
  }
  .bb-stage {
    max-width: 420px;
  }
}

@media (max-width: 360px) {
  .bb-brand h1 {
    font-size: 1.1rem;
  }
  .chip strong {
    font-size: 0.9rem;
  }
  .pill-big {
    min-width: 160px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
