:root {
  --bg-top: #05070e;
  --bg-mid: #09111f;
  --bg-bottom: #071528;
  --panel: rgba(7, 14, 27, 0.82);
  --panel-border: rgba(76, 143, 255, 0.46);
  --text-main: #d6e6ff;
  --text-soft: #86a6cf;
  --electric: #5ab8ff;
  --electric-strong: #7fe0ff;
  --shadow: rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Courier New", "Lucida Console", monospace;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(25, 74, 151, 0.28), transparent 38%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 48%, var(--bg-bottom));
  overflow-x: hidden;
  overflow-y: auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(90, 184, 255, 0.06), transparent 20%, transparent 80%, rgba(90, 184, 255, 0.05)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.012) 0,
      rgba(255, 255, 255, 0.012) 2px,
      transparent 2px,
      transparent 6px
    );
  pointer-events: none;
}

.page-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px 18px 24px;
}

.hud {
  position: relative;
  z-index: 3;
  margin-bottom: 12px;
}

.hud-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(74, 123, 206, 0.22);
  background: linear-gradient(180deg, rgba(5, 11, 21, 0.8), rgba(6, 17, 31, 0.62));
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.24),
    inset 0 0 0 1px rgba(90, 184, 255, 0.08);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.88rem;
}

.hud-title {
  color: var(--electric-strong);
  text-shadow: 0 0 10px rgba(90, 184, 255, 0.42);
}

.game-shell {
  position: relative;
  border: 1px solid rgba(78, 121, 194, 0.26);
  box-shadow:
    0 22px 50px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(90, 184, 255, 0.06);
  background: linear-gradient(180deg, rgba(3, 7, 16, 0.62), rgba(4, 10, 22, 0.88));
  overflow: hidden;
  touch-action: auto;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 8, 16, 0.34);
  backdrop-filter: blur(3px);
  transition:
    opacity 180ms ease,
    visibility 180ms ease;
  z-index: 4;
  overflow-y: auto;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panel {
  width: min(100%, 460px);
  padding: 26px 28px;
  text-align: center;
  margin: auto;
  border: 1px solid var(--panel-border);
  background:
    linear-gradient(180deg, rgba(8, 15, 28, 0.95), rgba(5, 9, 19, 0.88)),
    var(--panel);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(90, 184, 255, 0.08);
}

.panel h1,
.panel h2,
.panel p {
  margin: 0;
}

.panel h1 {
  margin-top: 6px;
  font-size: clamp(2rem, 5.6vw, 3.2rem);
  color: #f3f8ff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow:
    0 0 12px rgba(95, 176, 255, 0.32),
    0 0 28px rgba(65, 124, 255, 0.12);
}

.panel h2 {
  font-size: clamp(2rem, 6vw, 3.1rem);
  color: #f3f8ff;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.player-form {
  margin-top: 20px;
  text-align: left;
}

.player-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-main);
  font-size: 0.84rem;
}

.instagram-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--panel-border);
  background: #030a15;
  color: var(--electric-strong);
}

.instagram-field:focus-within {
  outline: 2px solid var(--electric);
  outline-offset: 2px;
}

.instagram-field input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-size: 16px;
  touch-action: manipulation;
}

.player-note,
.status-line,
.ranking-summary {
  color: var(--text-soft);
  font-size: 0.72rem;
  line-height: 1.5;
}

.player-form .player-note {
  margin-top: 8px;
}

.player-form .prize-note {
  margin-top: 10px;
  color: var(--electric-strong);
  font-size: 0.75rem;
  line-height: 1.5;
}

.gesture-tutorial {
  display: none;
  width: min(100%, 330px);
  height: auto;
  margin: 16px auto 0;
  user-select: none;
  pointer-events: none;
}

.panel .status-line {
  min-height: 1.5em;
  margin-top: 10px;
  text-align: center;
}

.player-form .arcade-button {
  width: 100%;
  margin-top: 8px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button:focus-visible {
  outline: 2px solid var(--electric-strong);
  outline-offset: 3px;
}

.panel-results {
  width: min(100%, 520px);
  padding: 22px;
}

.panel-results h2 {
  margin-top: 6px;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  letter-spacing: 0.04em;
}

.result-scores {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin-top: 18px;
  font-size: 0.72rem;
  color: var(--text-soft);
}

.result-scores strong {
  display: block;
  margin-top: 4px;
  font-size: 1.8rem;
  color: var(--electric-strong);
}

.leaderboard {
  margin-top: 16px;
  border-top: 1px solid var(--panel-border);
  padding-top: 12px;
  text-align: left;
}

.leaderboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.leaderboard h3 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

.text-button {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--electric);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ranking-scroll {
  max-height: 170px;
  overflow-y: auto;
  margin-top: 10px;
  touch-action: pan-y;
}

.leaderboard table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.leaderboard th,
.leaderboard td {
  padding: 9px 6px;
  border-bottom: 1px solid rgba(90, 184, 255, 0.12);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard th {
  color: var(--text-soft);
  font-size: 0.65rem;
}

.leaderboard th:first-child,
.leaderboard td:first-child {
  width: 32px;
}

.leaderboard th:last-child,
.leaderboard td:last-child {
  width: 78px;
  text-align: right;
}

.leaderboard td:nth-child(2) {
  overflow-wrap: anywhere;
  white-space: normal;
  text-overflow: clip;
}

.leaderboard .current-player {
  color: var(--electric-strong);
  background: rgba(90, 184, 255, 0.08);
}

.share-callout { margin-top: 20px; }
.share-button { width: 100%; }
.share-bonus-note { margin: 8px 0 0; color: var(--electric-strong); font-size: 0.72rem; }
.share-options { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 10px; }
.share-options[hidden] { display: none; }
.share-option {
  flex: 1; min-height: 44px; padding: 10px; border: 1px solid var(--panel-border);
  background: rgba(26, 59, 118, 0.35); color: var(--electric-strong); font: inherit;
  font-size: 0.72rem; text-decoration: none; cursor: pointer;
}
.share-option:focus-visible, .share-message:focus-visible { outline: 2px solid var(--electric-strong); outline-offset: 3px; }
.share-message {
  width: 100%; min-height: 90px; resize: none; border: 1px solid var(--panel-border);
  background: #071127; color: var(--text-soft); padding: 10px; font: inherit; font-size: 0.72rem;
}
.share-help { margin: 0; font-size: 0.7rem; line-height: 1.5; color: var(--text-soft); }

.artist-callout {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.artist-callout a {
  color: var(--electric-strong);
  text-underline-offset: 3px;
}

.artist-callout .instagram-button {
  display: block;
  margin-top: 12px;
  padding: 12px 16px;
  min-height: 44px;
  border: 1px solid var(--panel-border);
  background: rgba(26, 59, 118, 0.35);
  text-decoration: none;
  letter-spacing: 0.08em;
}

.instagram-button:hover {
  background: rgba(26, 59, 118, 0.65);
}

.artist-callout a:focus-visible {
  outline: 2px solid var(--electric-strong);
  outline-offset: 3px;
}

.overlay {
  touch-action: pan-y;
}

.eyebrow,
.helper,
.track-line,
.artist-line {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--text-soft);
  font-size: 0.72rem;
}

.track-line {
  margin-top: 12px;
  color: var(--electric-strong);
}

.artist-line {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 0.78rem;
}

.helper {
  margin-top: 14px;
  color: var(--text-soft);
  font-size: 0.75rem;
  line-height: 1.5;
}

.arcade-button {
  appearance: none;
  border: 1px solid rgba(127, 224, 255, 0.52);
  background: linear-gradient(180deg, rgba(26, 59, 118, 0.9), rgba(11, 26, 58, 0.95));
  color: var(--text-main);
  font: inherit;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.arcade-button {
  margin-top: 22px;
  padding: 14px 22px;
  min-width: 180px;
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.24),
    0 0 16px rgba(90, 184, 255, 0.12);
}

.arcade-button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 12px 22px rgba(0, 0, 0, 0.3),
    0 0 18px rgba(90, 184, 255, 0.18);
}

.arcade-button:active {
  transform: translateY(1px);
}

@media (max-width: 720px), (pointer: coarse) {
  body {
    overflow: hidden;
  }

  .page-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 0;
  }

  .game-shell {
    width: 100%;
    height: 100%;
    border: 0;
    box-shadow: none;
  }

  #gameCanvas {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  .hud {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    margin: 0;
    pointer-events: none;
  }

  .hud-line {
    gap: 8px 12px;
    padding: 10px 12px;
    font-size: 0.75rem;
  }

  .panel {
    padding: 22px 18px;
  }

  .helper {
    font-size: 0.68rem;
  }

  .overlay {
    z-index: 10;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(5, 8, 16, 0.28);
    backdrop-filter: none;
  }

  .gesture-tutorial {
    display: block;
  }

  .keyboard-helper {
    display: none;
  }

}

@media (max-height: 480px) and (pointer: coarse) {
  .hud-line {
    gap: 6px 12px;
    padding: 6px 10px;
    font-size: 0.65rem;
  }

  .panel {
    padding: 12px 18px;
  }

  .arcade-button {
    margin-top: 12px;
    padding: 10px 22px;
  }
}
