:root {
  color-scheme: dark;
  font-family: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 233, 182, 0.2), transparent 30%),
    linear-gradient(180deg, #4f45bb 0%, #8058d8 36%, #ff8dca 72%, #ffe0bd 100%);
  color: #fff6fb;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.cabinet {
  width: min(96vw, 1100px);
  padding: 18px;
  border: 4px solid rgba(255, 238, 255, 0.7);
  background: rgba(58, 32, 92, 0.36);
  box-shadow:
    0 0 0 8px rgba(255, 130, 219, 0.18),
    0 24px 60px rgba(34, 10, 68, 0.42);
  backdrop-filter: blur(8px);
}

.marquee {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.marquee h1,
.marquee p {
  margin: 0;
}

.marquee h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(255, 237, 187, 0.38);
}

.marquee p {
  color: #ffe9f7;
}

.hint {
  max-width: 24rem;
  text-align: right;
}

.arcade-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.arcade-layout.leaderboard-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.playfield {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.intro-overlay {
  position: absolute;
  inset: 4px;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(26, 9, 52, 0.62);
  backdrop-filter: blur(6px);
}

.intro-overlay[hidden] {
  display: none;
}

.intro-card,
.leaderboard-panel {
  border: 3px solid rgba(255, 244, 252, 0.82);
  background: rgba(43, 20, 77, 0.84);
  box-shadow: 0 0 0 4px rgba(255, 130, 219, 0.14);
}

.intro-card {
  width: min(90%, 420px);
  padding: 22px;
  text-align: center;
}

.intro-card h2,
.intro-card p,
.leaderboard-head h2,
.leaderboard-head p {
  margin: 0;
}

.intro-card h2,
.leaderboard-head h2 {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.intro-card p,
.leaderboard-head p {
  color: #ffe8f6;
}

.intro-card p {
  margin-top: 10px;
}

.intro-card input,
.intro-card button {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  border: 3px solid rgba(255, 241, 250, 0.78);
  background: rgba(255, 240, 248, 0.08);
  color: #fff7fd;
  font: inherit;
}

.intro-card input::placeholder {
  color: rgba(255, 226, 244, 0.6);
}

.intro-card input:focus,
.intro-card button:focus {
  outline: 3px solid rgba(255, 232, 141, 0.8);
  outline-offset: 2px;
}

.intro-card button {
  cursor: pointer;
  background: linear-gradient(180deg, #ff98cf 0%, #ff75a8 100%);
  color: #35113f;
  font-weight: 700;
  text-transform: uppercase;
}

.intro-note {
  font-size: 0.92rem;
}

.leaderboard-panel {
  min-height: 548px;
  padding: 14px;
}

.leaderboard-head {
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(255, 233, 250, 0.2);
}

.leaderboard-scroll {
  max-height: 486px;
  overflow: auto;
  padding-top: 12px;
  padding-right: 6px;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-item,
.leaderboard-empty {
  padding: 10px 12px;
  border: 2px solid rgba(255, 240, 250, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.leaderboard-item.is-current-player {
  border-color: rgba(255, 232, 141, 0.58);
  background: rgba(255, 232, 141, 0.08);
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: #fff8ff;
}

.leaderboard-rank {
  color: #ffe98e;
  font-weight: 700;
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #ffe98e;
  font-weight: 700;
}

.leaderboard-meta,
.leaderboard-empty {
  margin-top: 6px;
  color: #f7dff5;
  font-size: 0.92rem;
}

.leaderboard-scroll::-webkit-scrollbar {
  width: 10px;
}

.leaderboard-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
}

.leaderboard-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 233, 141, 0.5);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 4px solid rgba(255, 254, 255, 0.75);
  background: #261247;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
}

.touch-controls {
  display: none;
}

.touch-button {
  appearance: none;
  border: 3px solid rgba(255, 241, 250, 0.82);
  background: linear-gradient(180deg, rgba(255, 176, 223, 0.94) 0%, rgba(255, 126, 184, 0.94) 100%);
  color: #381445;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 10px 20px rgba(39, 10, 71, 0.24);
  padding: 12px 14px;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  touch-action: manipulation;
}

.touch-button:active {
  transform: translateY(1px) scale(0.99);
}

.touch-button-label,
.touch-button-note {
  display: block;
}

.touch-button-label {
  font-size: 1rem;
  font-weight: 700;
}

.touch-button-note {
  margin-top: 4px;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  opacity: 0.82;
}

.touch-button-fire {
  background: linear-gradient(180deg, rgba(255, 232, 163, 0.94) 0%, rgba(255, 171, 104, 0.96) 100%);
  color: #4b2136;
}

.footer-note {
  margin-top: 12px;
  color: #fff0f7;
  text-align: center;
  letter-spacing: 0.06em;
}

@media (max-width: 720px) {
  .shell {
    place-items: start center;
    padding: 10px;
  }

  .cabinet {
    padding: 12px;
    width: min(100vw - 12px, 1100px);
    border-width: 3px;
  }

  .marquee {
    align-items: start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }

  .hint {
    max-width: none;
    text-align: left;
    font-size: 0.95rem;
  }

  .arcade-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .leaderboard-panel {
    min-height: auto;
    padding: 12px;
  }

  .leaderboard-scroll {
    max-height: 260px;
  }

  .intro-card {
    width: min(94%, 390px);
    padding: 18px;
  }

  canvas {
    border-width: 3px;
  }

  .touch-controls {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 10px;
  }

  .touch-button {
    min-height: 68px;
  }

  .footer-note {
    font-size: 0.9rem;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  .shell {
    padding:
      max(8px, env(safe-area-inset-top))
      8px
      calc(12px + env(safe-area-inset-bottom));
  }

  .cabinet {
    padding: 10px;
    box-shadow:
      0 0 0 5px rgba(255, 130, 219, 0.16),
      0 18px 38px rgba(34, 10, 68, 0.34);
  }

  .marquee h1 {
    font-size: clamp(1.6rem, 9vw, 2.35rem);
  }

  .marquee p {
    font-size: 0.92rem;
  }

  .playfield {
    gap: 10px;
  }

  .intro-overlay {
    inset: 3px;
  }

  .leaderboard-head h2 {
    font-size: 1.05rem;
  }

  .leaderboard-head p,
  .leaderboard-meta,
  .leaderboard-empty {
    font-size: 0.84rem;
  }

  .leaderboard-row {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 8px;
    font-size: 0.92rem;
  }

  .leaderboard-scroll {
    max-height: 220px;
  }

  .touch-controls {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 1;
  }

  .touch-button {
    min-height: 72px;
    border-width: 2px;
    border-radius: 14px;
  }

  .footer-note {
    margin-top: 10px;
    font-size: 0.82rem;
    line-height: 1.35;
  }
}
