:root {
  --red: #f4212e;
  --deep-red: #8e0815;
  --pink: #ff4fb8;
  --cyan: #18d8ff;
  --gold: #ffd65a;
  --ink: #130b14;
  --paper: #fff8f4;
  --glass: rgba(255, 255, 255, 0.78);
  --line: rgba(255, 255, 255, 0.42);
  --shadow: 0 24px 70px rgba(70, 0, 20, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.85) 0 7%, transparent 8%),
    radial-gradient(circle at 82% 10%, rgba(24, 216, 255, 0.42) 0 10%, transparent 11%),
    linear-gradient(135deg, #ff2d38 0%, #ff6aa7 42%, #10cdec 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-playing-locked {
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1800px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(6px, 1vw, 14px);
}

.game-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(255, 238, 245, 0.54));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hud {
  position: relative;
  z-index: 45;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) repeat(4, minmax(92px, 0.7fr)) minmax(104px, 0.62fr) minmax(74px, 0.44fr);
  gap: 10px;
  align-items: stretch;
}

.brand,
.meter,
.registration {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 30px rgba(120, 0, 35, 0.12);
}

.brand {
  padding: 10px 14px;
  background: linear-gradient(120deg, #f91e2b, #ff4fb8 54%, #10cdec);
  color: white;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.brand-kicker,
.eyebrow,
.panel-kicker,
.meter span,
label span {
  display: block;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1,
.start-panel h2,
.result-panel h2,
.registration h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: clamp(1.65rem, 3vw, 3rem);
  line-height: 0.9;
}

.registration .panel-kicker {
  color: #171319;
  font-size: clamp(1.18rem, 2.1vw, 1.85rem);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: 0;
}

.meter {
  display: grid;
  place-items: center;
  padding: 9px;
  text-align: center;
}

.meter span {
  color: #932039;
}

.meter strong {
  color: #1b0c14;
  font-size: clamp(1.05rem, 2.3vw, 2rem);
  line-height: 1;
}

.misses strong {
  color: var(--red);
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(0.82rem, 1.55vw, 1.25rem);
  white-space: nowrap;
}

.hud-audio {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.audio-toggle {
  position: relative;
  display: grid;
  gap: 1px;
  place-items: center;
  min-width: 0;
  min-height: 56px;
  padding: 5px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: #fff;
  font-weight: 950;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.65),
    0 10px 30px rgba(120, 0, 35, 0.12);
  transition: filter 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.audio-toggle:hover {
  transform: translateY(-1px);
}

.audio-icon {
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  line-height: 1;
}

.audio-icon svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.se-audio .audio-icon svg,
.audio-menu-toggle .audio-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.se-audio .audio-icon svg path:first-child,
.audio-menu-toggle .audio-icon svg path:first-child {
  fill: currentColor;
  stroke: none;
}

.se-audio .se-wave,
.audio-menu-toggle .se-wave {
  display: inline;
}

.audio-menu-toggle {
  display: none;
}

.audio-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 70;
  display: none;
  min-width: 156px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(120, 0, 35, 0.22);
}

.audio-menu.active {
  display: grid;
  gap: 6px;
}

.audio-menu button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(255, 244, 248, 0.86);
  color: #171319;
  font-size: 0.76rem;
  font-weight: 900;
  text-align: left;
}

.audio-label {
  color: #932039;
  font-size: 0.6rem;
  line-height: 1;
  text-transform: uppercase;
}

.audio-toggle strong {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.audio-toggle[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 231, 240, 0.86));
  color: #1f1a1d;
}

.audio-toggle[aria-pressed="false"] {
  background: rgba(255, 255, 255, 0.45);
  color: #8d858d;
  filter: grayscale(1);
  opacity: 0.6;
}

.audio-toggle[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  width: 72%;
  height: 2px;
  border-radius: 999px;
  background: #6c626b;
  transform: rotate(-24deg);
}

.audio-toggle[aria-pressed="false"] .audio-label {
  color: #6c626b;
}

.quit-button {
  display: none;
  min-width: 0;
  min-height: 56px;
  padding: 5px 8px;
  border: 1px solid rgba(23, 19, 25, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #000;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  box-shadow: 0 10px 24px rgba(120, 0, 35, 0.1);
}

body.is-game-playing .quit-button {
  display: grid;
  place-items: center;
}

.quit-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
}

.quit-confirm-overlay {
  position: absolute;
  inset: 0;
  z-index: 58;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(255, 244, 248, 0.48);
  backdrop-filter: blur(3px);
}

.quit-confirm-overlay.active {
  display: flex;
}

.quit-confirm-panel {
  width: min(360px, 88%);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 54px rgba(120, 0, 35, 0.22);
  text-align: center;
}

.quit-confirm-panel p {
  margin: 0 0 16px;
  color: #171319;
  font-size: 1rem;
  font-weight: 900;
}

.quit-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.se-audio[aria-pressed="false"] .se-wave {
  display: none;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #ffe2d9;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
  aspect-ratio: 16 / 9;
  width: min(92%, 1640px);
  max-width: 100%;
  margin-inline: auto;
  touch-action: auto;
  overscroll-behavior: auto;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: auto;
}

body.is-game-playing .stage-wrap,
body.is-game-playing #gameCanvas {
  touch-action: none;
  overscroll-behavior: none;
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: clamp(58px, 6vw, 88px);
  z-index: 5;
  display: grid;
  justify-items: center;
  gap: 2px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
  text-shadow: 0 2px 10px rgba(120, 0, 28, 0.32);
  pointer-events: none;
  opacity: 1;
  animation: scrollCueFloat 1.45s ease-in-out infinite;
  transition: opacity 420ms ease, transform 420ms ease;
}

.scroll-cue span {
  font-size: clamp(0.58rem, 1.3vw, 0.78rem);
  font-weight: 900;
  letter-spacing: 0;
}

.scroll-cue strong {
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 0.75;
}

.scroll-cue.is-hidden,
body.is-game-playing .scroll-cue {
  opacity: 0;
  transform: translate(-50%, 8px);
  animation-play-state: paused;
}

@keyframes scrollCueFloat {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, -10px);
  }
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: linear-gradient(120deg, rgba(255, 35, 51, 0.16), rgba(20, 220, 255, 0.12));
}

.overlay.active {
  display: flex;
}

.overlay.peeking {
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: none;
  pointer-events: none;
}

.start-panel,
.result-panel {
  width: min(560px, 92%);
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  text-align: center;
  box-shadow: 0 22px 60px rgba(100, 0, 28, 0.26);
}

.result-panel {
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

.overlay.peeking .result-panel {
  opacity: 0.08;
  filter: blur(1px);
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
}

.backdrop-peek-hint {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(244, 33, 46, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: #c41429;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  box-shadow: 0 10px 26px rgba(100, 0, 28, 0.15);
}

.backdrop-peek-hint.is-floating {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 80;
}

.overlay.peeking .backdrop-peek-hint {
  background: rgba(255, 255, 255, 0.94);
  color: #202536;
  pointer-events: auto;
}

.backdrop-peek-hint.is-floating {
  background: rgba(255, 255, 255, 0.94);
  color: #202536;
}

.overlay.input-locked .result-panel,
.overlay.input-locked .backdrop-peek-hint {
  pointer-events: none;
}

.overlay.input-locked .result-panel {
  opacity: 0.92;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 5px;
  color: #c41429;
}

.start-panel h2,
.result-panel h2 {
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 0.92;
  color: var(--red);
  text-shadow: 0 3px 0 white, 0 7px 18px rgba(244, 33, 46, 0.22);
}

.tagline,
.fineprint,
#resultLine {
  margin: 10px 0 0;
  color: #4c2630;
  font-size: 0.9rem;
  line-height: 1.45;
}

.personal-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin: 12px 0 0;
  padding: 8px 16px;
  border: 2px solid rgba(244, 33, 46, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 231, 241, 0.9));
  color: #c41429;
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  font-weight: 950;
  line-height: 1.15;
  box-shadow: 0 10px 24px rgba(244, 33, 46, 0.14);
}

.best-result {
  margin: 8px 0 0;
  color: #31131d;
  font-size: 0.95rem;
  font-weight: 900;
}

.result-entry-info {
  display: grid;
  gap: 4px;
  width: min(420px, 94%);
  margin: 10px auto 0;
  padding: 9px 12px;
  border: 1px solid rgba(244, 33, 46, 0.18);
  border-radius: 8px;
  background: rgba(255, 244, 248, 0.72);
  color: #5b3039;
  font-size: 0.74rem;
  font-weight: 850;
  line-height: 1.35;
}

.result-entry-info.is-hidden {
  display: none;
}

.personal-result.is-hidden {
  display: none;
}

.result-entry-info span {
  display: block;
}

.hero-picker {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  margin: 16px 0;
}

.result-picker {
  margin: 8px 0 4px;
}

.result-picker-label {
  margin-top: 14px;
}

.hero-token {
  display: grid;
  place-items: center;
  height: 54px;
  border: 2px solid rgba(244, 33, 46, 0.16);
  border-radius: 8px;
  background: linear-gradient(#fff, #ffe9ef);
}

.hero-token.selected {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(24, 216, 255, 0.24);
}

.hero-token img {
  max-width: 88%;
  max-height: 48px;
  object-fit: contain;
}

.primary,
.secondary,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 950;
  letter-spacing: 0;
}

.primary {
  padding: 0 18px;
  background: linear-gradient(135deg, #f4212e, #ff4fb8 54%, #18d8ff);
  color: white;
  box-shadow: 0 10px 24px rgba(244, 33, 46, 0.26);
}

.secondary,
.icon-button {
  padding: 0 14px;
  background: #fff;
  color: #c41429;
  border: 1px solid rgba(244, 33, 46, 0.22);
}

.icon-button.is-hidden {
  display: none;
}

.primary:disabled,
.secondary:disabled,
.entry-button:disabled {
  opacity: 0.5;
  cursor: default;
}

input[readonly] {
  color: #6f676d;
  background: rgba(247, 247, 248, 0.82);
  border-color: rgba(120, 110, 118, 0.18);
  cursor: default;
}

.side-panel {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
}

.registration {
  padding: 14px;
}

.registration h2 {
  font-size: 1.25rem;
}

.registration-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-button {
  min-height: 30px;
  border: 1px solid rgba(25, 18, 23, 0.72);
  border-radius: 4px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.78);
  color: #171319;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
}

.admin-button:hover,
.admin-button[aria-expanded="true"] {
  background: #171319;
  color: #fff;
}

.admin-button.is-hidden,
.admin-panel.is-hidden,
.admin-login.is-hidden,
.admin-actions.is-hidden {
  display: none;
}

form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 4px;
}

label span {
  color: #742033;
}

label span em {
  color: #9a8f96;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 800;
  text-transform: none;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(244, 33, 46, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.85);
  color: #1c0c13;
  outline: none;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(24, 216, 255, 0.18);
}

.entry-actions {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.entry-button {
  min-height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f4212e, #ff4fb8);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 10px 24px rgba(244, 33, 46, 0.18);
}

.entry-status {
  min-height: 1rem;
  margin: 0;
  color: #c41429;
  font-size: 0.72rem;
  font-weight: 850;
}

.admin-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(244, 33, 46, 0.16);
}

.admin-login,
.admin-actions {
  display: grid;
  gap: 8px;
}

.admin-action-button {
  min-height: 36px;
  border: 1px solid rgba(25, 18, 23, 0.72);
  border-radius: 6px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.84);
  color: #171319;
  font-size: 0.76rem;
  font-weight: 950;
}

.admin-action-button:hover,
.admin-action-button.is-holding {
  background: #171319;
  color: #fff;
}

.hold-button.is-holding {
  box-shadow: inset 0 -4px 0 rgba(16, 205, 236, 0.72), 0 0 0 3px rgba(16, 205, 236, 0.16);
}

.admin-status {
  min-height: 1rem;
  margin: 0;
  color: #742033;
  font-size: 0.7rem;
  font-weight: 850;
}

.panel-title,
.result-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.result-actions {
  justify-content: center;
  margin-top: 18px;
}

@media (max-width: 1040px) {
  .side-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    width: 100%;
    padding: 6px;
  }

  .game-card {
    padding: 6px;
    gap: 6px;
    border-radius: 8px;
  }

  .hud {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
  }

  .brand {
    grid-column: 1 / -1;
    padding: 7px 10px;
  }

  .brand h1 {
    font-size: 1.7rem;
  }

  .meter {
    grid-column: span 1;
    min-height: 44px;
    padding: 6px 3px;
  }

  .score-meter {
    grid-column: span 2;
  }

  .meter span {
    font-size: 0.58rem;
  }

  .meter strong {
    font-size: 1rem;
  }

  .misses strong {
    font-size: 0.92rem;
  }

  .hud-audio {
    grid-column: span 1;
    display: block;
  }

  .bgm-audio,
  .se-audio {
    display: none;
  }

  .audio-menu-toggle {
    display: grid;
    aspect-ratio: 1 / 1;
    width: 100%;
  }

  .quit-button {
    grid-column: 7 / 8;
    grid-row: 2;
    min-height: 44px;
    padding: 4px 2px;
    font-size: 0.62rem;
  }

  .stage-wrap {
    aspect-ratio: auto;
    width: 96%;
    height: calc(100svh - 140px);
    min-height: 360px;
    margin-top: 0;
  }

  body.is-game-playing .stage-wrap {
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 0;
  }

  .audio-toggle {
    min-height: 44px;
    padding: 4px 2px;
  }

  .audio-menu-toggle .audio-label {
    display: none;
  }

  .audio-menu {
    min-width: 132px;
  }

  .audio-icon {
    font-size: 1rem;
  }

  .audio-label {
    font-size: 0.52rem;
  }

  .start-panel,
  .result-panel {
    width: min(94vw, 520px);
    max-height: none;
    overflow: visible;
    padding: 14px;
  }

  .overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    border-radius: 8px;
    background: linear-gradient(120deg, rgba(255, 35, 51, 0.2), rgba(20, 220, 255, 0.18));
    backdrop-filter: blur(6px);
  }

  #startOverlay {
    inset: 0;
  }

  .backdrop-peek-hint {
    right: 10px;
    top: 10px;
    min-height: 32px;
    padding: 7px 10px;
    font-size: 0.66rem;
  }

  .backdrop-peek-hint.is-floating {
    position: absolute;
    right: 10px;
    top: 10px;
  }

  .start-panel h2,
  .result-panel h2 {
    font-size: clamp(1.8rem, 11vw, 3.1rem);
  }

  .tagline,
  .fineprint,
  #resultLine {
    font-size: 0.82rem;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  body.is-game-playing .side-panel {
    display: none;
  }

  .hero-picker {
    grid-template-columns: repeat(5, 1fr);
  }

  .result-actions {
    flex-direction: column;
  }

  .primary,
  .secondary {
    width: 100%;
  }
}
