:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6dff;
  --text: #fff;
  --muted: #aaadbe;
  --line: rgba(255, 255, 255, 0.08);
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body {
  padding: 8px;
}
button {
  font: inherit;
}
.be-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.be-shell {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* HUD */
.be-hud {
  width: 100%;
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.be-chip {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #26273a, var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 10px rgba(0, 0, 0, 0.25);
  line-height: 1.05;
}
.be-chip > span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.be-chip strong {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 19px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.be-chip.is-bump {
  animation: be-bump 0.35s ease;
}
.be-chip.is-warn strong {
  color: #ff5d6c;
}
.be-hearts {
  color: #ff4d6d;
  letter-spacing: 1px;
}
.be-hearts .is-lost {
  color: #3a3b52;
}
.be-chip-wind {
  flex-grow: 1.2;
}
.be-wind-arrow {
  width: 18px;
  height: 18px;
  fill: #6ee7ff;
  transition: transform 0.3s ease;
  flex: 0 0 auto;
}
.be-wind-arrow.is-left {
  transform: scaleX(-1);
}
.be-wind-arrow.is-calm {
  opacity: 0.25;
}
.be-icon-button {
  flex: 0 0 auto;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: #2a2b3d;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 10px rgba(0, 0, 0, 0.25);
}
.be-icon-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.be-icon-button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Stage */
.be-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 22px;
  overflow: hidden;
  background: #7fd3ff;
  box-shadow:
    0 0 0 1px var(--line),
    0 18px 40px rgba(0, 0, 0, 0.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.be-stage.is-shake {
  animation: be-shake 0.35s ease;
}
#be-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  outline: none;
}
.be-stage:has(#be-canvas:focus-visible) {
  box-shadow:
    0 0 0 3px var(--accent-2),
    0 18px 40px rgba(0, 0, 0, 0.45);
}

/* Overlays */
.be-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow-y: auto;
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(24, 16, 60, 0.5),
    rgba(8, 8, 20, 0.8)
  );
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.be-overlay[hidden] {
  display: none;
}
.be-card {
  width: min(360px, 100%);
  text-align: center;
  padding: 18px 18px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, #262740, var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 20px 50px rgba(0, 0, 0, 0.5);
  animation: be-pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.be-logo {
  display: grid;
  place-items: center;
  margin: -2px auto 6px;
}
.be-logo-ring {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 34% 28%,
      rgba(255, 255, 255, 0.6) 0 6%,
      transparent 22%
    ),
    radial-gradient(
      circle,
      #ffd23f 0 17%,
      #ff4757 17% 34%,
      #2e86ff 34% 51%,
      #262a3a 51% 68%,
      #f7f7fb 68% 100%
    );
  box-shadow:
    0 0 0 3px #fff,
    0 10px 22px rgba(255, 71, 87, 0.35);
  animation: be-bounce 1.4s ease-in-out infinite;
}
.be-title {
  margin: 0;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1;
  background: linear-gradient(180deg, #fff 30%, #ffe08a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #b3261e)
    drop-shadow(0 8px 14px rgba(0, 0, 0, 0.4));
}
.be-title-small {
  font-size: 32px;
  margin-bottom: 14px;
}
.be-lead {
  margin: 8px 0 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.35;
}
.be-modes,
.be-actions {
  display: grid;
  gap: 9px;
}
.be-actions {
  grid-template-columns: 1fr 1fr;
}
.be-button {
  min-height: 46px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: #2a2b3d;
  color: var(--text);
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 4px 0 #17182a,
    0 8px 16px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.1s ease,
    box-shadow 0.1s ease,
    filter 0.15s ease;
}
.be-button:hover {
  filter: brightness(1.1);
}
.be-button:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 1px 0 #17182a;
}
.be-button-primary {
  background: linear-gradient(180deg, #8163ff, var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #3f22b8,
    0 8px 18px rgba(104, 66, 255, 0.4);
}
.be-button-red {
  background: linear-gradient(180deg, #ff6b6b, #e5383b);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #9d1c20,
    0 8px 18px rgba(229, 56, 59, 0.35);
}
.be-button-blue {
  background: linear-gradient(180deg, #3fb8ff, #1c86e8);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #0f5aa3,
    0 8px 18px rgba(28, 134, 232, 0.35);
}
.be-mode {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  text-align: left;
  min-height: 54px;
  padding: 7px 12px 7px 20px;
}
.be-mode-name {
  font-size: 17px;
  line-height: 1.1;
}
.be-mode-sub {
  grid-row: 2;
  font-size: 11px;
  font-weight: 800;
  opacity: 0.8;
}
.be-mode-best {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}
.be-keys {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  border-radius: 6px;
  background: #2a2b3d;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  font: inherit;
  font-weight: 900;
  color: var(--text);
}
.be-over-kicker {
  margin: 0;
  font-weight: 900;
  font-size: 22px;
  color: #ffe08a;
}
.be-medal {
  display: block;
  width: 84px;
  height: 84px;
  margin: 4px auto 0;
  animation: be-medal-in 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) 0.1s both;
}
.be-over-medal {
  margin: 0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.be-over-score {
  margin: 2px 0 0;
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 4px 0 #3f22b8,
    0 10px 24px rgba(104, 66, 255, 0.55);
}
.be-newbest {
  display: inline-block;
  margin: 8px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, #ffb800);
  color: #4a2c00;
  font-weight: 900;
  font-size: 13px;
  animation: be-bump 0.6s ease 0.2s both;
}
.be-newbest[hidden] {
  display: none;
}
.be-over-stats {
  margin: 8px 0 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.be-help {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}
.be-help-keys {
  margin-left: 6px;
  white-space: nowrap;
}

button:focus-visible {
  outline: 3px solid #b9a8ff;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .be-stage {
    aspect-ratio: 5 / 6;
  }
  .be-chip strong {
    font-size: 16px;
  }
  .be-chip > span {
    font-size: 9px;
  }
  .be-hud {
    gap: 4px;
  }
  .be-icon-button {
    width: 40px;
    min-height: 40px;
  }
  .be-help-keys {
    display: none;
  }
}
@media (max-width: 360px) {
  .be-chip {
    padding: 4px 3px;
  }
  .be-chip strong {
    font-size: 14px;
  }
  .be-wind-arrow {
    width: 14px;
    height: 14px;
  }
  .be-title {
    font-size: 34px;
  }
}

@keyframes be-bump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes be-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(2px);
  }
}
@keyframes be-pop-in {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes be-bounce {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-6px) rotate(8deg);
  }
}
@keyframes be-medal-in {
  from {
    transform: scale(0.2) rotate(-40deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

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