:root {
  color-scheme: dark;
  --bg: #050713;
  --panel: rgba(9, 14, 34, 0.86);
  --cyan: #25f4ff;
  --pink: #ff3df2;
  --yellow: #ffdf5d;
  --text: #eef6ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Arial Narrow", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(37, 244, 255, 0.20), transparent 28rem),
    radial-gradient(circle at 80% 0%, rgba(255, 61, 242, 0.18), transparent 24rem),
    linear-gradient(135deg, #050713, #0b1024 55%, #10081b);
}

.shell {
  width: min(1120px, 96vw);
  padding: 22px;
}

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

h1, h2, p { margin: 0; }
h1 {
  font-size: clamp(30px, 5vw, 54px);
  letter-spacing: -0.06em;
  text-shadow: 0 0 22px rgba(37, 244, 255, 0.42);
}
.eyebrow {
  color: var(--cyan);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.22em;
  margin-bottom: 4px;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}
.hud span {
  padding: 9px 12px;
  border: 1px solid rgba(37, 244, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 18px rgba(37, 244, 255, 0.08);
}
.hud b { color: var(--yellow); }
.hud-toggle {
  align-self: stretch;
  padding: 9px 14px;
  border: 1px solid rgba(255, 223, 93, 0.35);
  color: var(--yellow);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 18px rgba(255, 223, 93, 0.08);
  font-size: 13px;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(37, 244, 255, 0.35);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 48px rgba(37, 244, 255, 0.16);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 30px;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 61, 242, 0.20), transparent 18rem),
    radial-gradient(circle at 82% 16%, rgba(37, 244, 255, 0.18), transparent 16rem),
    linear-gradient(rgba(5, 7, 19, 0.48), rgba(5, 7, 19, 0.74));
  backdrop-filter: blur(3px) saturate(1.18);
}
.overlay.hidden { display: none; }
.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 5px),
    linear-gradient(90deg, transparent, rgba(37,244,255,0.10), transparent);
  mix-blend-mode: screen;
  opacity: 0.34;
}
.home-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.home-scene::before {
  content: "";
  position: absolute;
  inset: auto 0 36px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(37,244,255,0.95), transparent);
  box-shadow: 0 0 24px rgba(37,244,255,0.64), 0 22px 45px rgba(255,61,242,0.16);
}
.home-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(37,244,255,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,244,255,0.10) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, transparent, black 18%, black 78%, transparent);
  opacity: 0.5;
}
.scene-orb,
.scene-square,
.scene-shot,
.scene-player {
  position: absolute;
  display: block;
  z-index: 1;
}
.scene-orb {
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,0.68);
  box-shadow: 0 0 26px currentColor, inset -12px -18px 28px rgba(5,7,19,0.42), inset 8px 8px 18px rgba(255,255,255,0.36);
  animation: float-orb 4.8s ease-in-out infinite;
}
.scene-orb::before {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  left: 22%;
  top: 18%;
  border-radius: 50%;
  background: rgba(255,255,255,0.78);
  filter: blur(1px);
}
.scene-orb-a {
  width: 112px;
  height: 112px;
  left: 8%;
  top: 14%;
  color: #25f4ff;
  background: radial-gradient(circle at 30% 24%, #e8ffff, #25f4ff 34%, #126bdc 74%, #061134);
}
.scene-orb-b {
  width: 72px;
  height: 72px;
  right: 10%;
  top: 24%;
  color: #ff3df2;
  background: radial-gradient(circle at 32% 24%, #fff0fb, #ff3df2 38%, #9415d4 78%, #190826);
  animation-delay: -1.4s;
}
.scene-orb-c {
  width: 54px;
  height: 54px;
  left: 21%;
  bottom: 22%;
  color: #ffdf5d;
  background: radial-gradient(circle at 32% 24%, #fffceb, #ffdf5d 42%, #ff8c34 78%, #2b1202);
  animation-delay: -2.7s;
}
.scene-square {
  width: 46px;
  height: 46px;
  background: #ff4eea;
  border: 3px solid rgba(255,255,255,0.82);
  box-shadow: 0 0 24px rgba(255,61,242,0.85), inset 0 0 0 6px rgba(29,5,42,0.34);
  animation: roll-square 3.6s linear infinite;
}
.scene-square::before,
.scene-square::after {
  content: "";
  position: absolute;
  background: #210b28;
  inset: 50% 8px auto;
  height: 3px;
  transform: translateY(-50%);
}
.scene-square::after {
  inset: 8px auto 8px 50%;
  width: 3px;
  height: auto;
  transform: translateX(-50%);
}
.scene-square-a { left: 5%; bottom: 46px; }
.scene-square-b { right: 7%; bottom: 46px; animation-delay: -1.8s; }
.scene-shot {
  width: 7px;
  height: 62px;
  bottom: 62px;
  border-radius: 999px;
  background: #dfffff;
  box-shadow: 0 0 18px #25f4ff, 0 0 34px rgba(37,244,255,0.58);
  animation: shot-rise 1.55s linear infinite;
}
.scene-shot-a { left: 44%; }
.scene-shot-b { left: 56%; animation-delay: -0.72s; }
.scene-player {
  left: 50%;
  bottom: 38px;
  width: 76px;
  height: 42px;
  transform: translateX(-50%);
  filter: drop-shadow(0 0 20px rgba(255,61,242,0.86));
}
.scene-player::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 76px;
  height: 38px;
  background: #ff3df2;
  clip-path: polygon(50% 0, 66% 50%, 100% 100%, 0 100%, 34% 50%);
}
.scene-player::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 28px;
  width: 10px;
  height: 34px;
  border-radius: 999px 999px 3px 3px;
  transform: translateX(-50%);
  background: #25f4ff;
  box-shadow: 0 0 18px rgba(37,244,255,0.86);
}
.overlay-card {
  position: relative;
  z-index: 2;
  display: grid;
  gap: clamp(6px, 1.1vh, 9px);
  justify-items: center;
  width: min(560px, 94%);
  padding: clamp(12px, 2.2vw, 18px);
  border: 1px solid rgba(37,244,255,0.38);
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(255,61,242,0.16), transparent 38%),
    linear-gradient(180deg, rgba(7,10,28,0.76), rgba(5,7,19,0.88));
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.08),
    0 24px 84px rgba(0,0,0,0.56),
    0 0 54px rgba(37,244,255,0.20);
}
.overlay h2 {
  font-size: clamp(36px, 6.4vw, 56px);
  line-height: 0.9;
  letter-spacing: -0.08em;
  color: white;
  text-shadow: 0 0 18px var(--pink), 0 0 48px var(--cyan);
}
.overlay p {
  max-width: 560px;
  margin: 0 auto;
  font-size: clamp(12px, 1.55vw, 14px);
  line-height: 1.2;
  color: #c8d7ff;
}
.score-panel {
  width: min(100%, 344px);
  margin: 0 auto;
  padding: 6px 9px 7px;
  border: 2px solid rgba(255, 223, 93, 0.42);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 61, 242, 0.12), rgba(37, 244, 255, 0.06)),
    rgba(7, 10, 24, 0.88);
  box-shadow:
    inset 0 0 0 1px rgba(37, 244, 255, 0.18),
    0 0 30px rgba(255, 61, 242, 0.14),
    0 0 42px rgba(37, 244, 255, 0.12);
}
.score-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 5px;
}
.score-panel-head .played-counter {
  padding: 3px 7px;
  border: 1px solid rgba(37,244,255,0.42);
  border-radius: 999px;
  background: rgba(37,244,255,0.08);
  color: var(--yellow);
  text-shadow: 0 0 10px rgba(255,223,93,0.58);
}
.score-panel-title {
  margin: 0;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(255, 223, 93, 0.52);
}
.played-counter {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(37, 244, 255, 0.42);
}
.played-counter-home {
  display: grid;
  gap: 2px;
  min-width: 190px;
  margin-top: -4px;
  padding: 6px 14px;
  border: 2px solid rgba(255, 223, 93, 0.72);
  border-radius: 999px;
  color: var(--yellow);
  font: 900 16px "Courier New", Courier, monospace;
  letter-spacing: 0.08em;
  background:
    radial-gradient(circle at 50% 0, rgba(255,255,255,0.18), transparent 48%),
    linear-gradient(135deg, rgba(255,61,242,0.28), rgba(37,244,255,0.12));
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.12),
    0 0 20px rgba(255,223,93,0.30),
    0 0 34px rgba(37,244,255,0.20);
  text-shadow: 0 0 12px rgba(255,223,93,0.7);
}
.played-counter-home::before {
  content: "TOTAL PLAYS";
  color: var(--cyan);
  font: 900 9px "Trebuchet MS", Arial, sans-serif;
  letter-spacing: 0.32em;
  text-shadow: 0 0 10px rgba(37,244,255,0.7);
}
.score-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
  font-family: "Courier New", Courier, monospace;
}
.score-list li {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 8px;
  min-height: 17px;
  padding: 1px 8px;
  border: 1px solid rgba(37, 244, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  letter-spacing: 0.14em;
  font-size: 12px;
  line-height: 1.08;
  color: #f6fbff;
  text-shadow: 0 0 10px rgba(37, 244, 255, 0.24);
}
.score-rank {
  color: var(--cyan);
  font-weight: 900;
}
.score-name {
  text-align: left;
  color: #f6fbff;
  font-weight: 900;
}
.score-wave {
  text-align: right;
  color: #8ff6ff;
  font-weight: 900;
}
.score-value {
  text-align: right;
  color: #ffe982;
  font-weight: 900;
}
.name-entry {
  width: min(100%, 342px);
  margin: -2px auto 0;
  display: grid;
  gap: 5px;
  text-align: left;
}
.name-entry.hidden {
  display: none;
}
.name-entry label {
  text-align: center;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.name-entry-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.name-entry input {
  min-width: 0;
  padding: 9px 14px;
  border: 1px solid rgba(37, 244, 255, 0.34);
  border-radius: 999px;
  background: rgba(5, 11, 28, 0.92);
  color: #f6fbff;
  font: 900 16px "Courier New", Courier, monospace;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-align: center;
  box-shadow: inset 0 0 18px rgba(37, 244, 255, 0.14);
}
.name-entry input:focus-visible,
.hud-toggle:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(37, 244, 255, 0.9);
  outline-offset: 3px;
}
.overlay small {
  display: block;
  font-size: 11px;
  line-height: 1.12;
}
button {
  justify-self: center;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 9px 22px;
  color: #06101a;
  background: linear-gradient(135deg, var(--cyan), var(--yellow));
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 0 26px rgba(37, 244, 255, 0.48);
}
small { color: #8fa4cf; }

@keyframes float-orb {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  45% { transform: translate3d(14px, -18px, 0) scale(1.04); }
  70% { transform: translate3d(-8px, 10px, 0) scale(0.98); }
}

@keyframes roll-square {
  from { transform: rotate(0deg) translateX(0); }
  to { transform: rotate(360deg) translateX(0); }
}

@keyframes shot-rise {
  0% { transform: translateY(28px) scaleY(0.35); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translateY(-280px) scaleY(1); opacity: 0; }
}

@media (max-width: 720px) {
  header { align-items: start; flex-direction: column; }
  .hud { justify-content: flex-start; }
  .shell { padding: 12px; }
  .stage-wrap { min-height: min(75vh, 650px); }
  canvas {
    height: min(75vh, 650px);
    min-height: 520px;
    aspect-ratio: auto;
    object-fit: fill;
  }
  .overlay { padding: 12px; }
  .overlay-card {
    gap: 5px;
    padding: 10px 9px;
    border-radius: 22px;
  }
  .overlay h2 {
    font-size: clamp(30px, 11vw, 46px);
  }
  .overlay p {
    font-size: 12px;
    line-height: 1.18;
  }
  .played-counter-home {
    min-width: 170px;
    padding: 5px 12px;
    font-size: 14px;
  }
  .score-panel {
    padding: 7px 8px 8px;
  }
  .score-panel-head {
    margin-bottom: 7px;
  }
  .score-list {
    gap: 2px;
  }
  .score-list li {
    grid-template-columns: 28px 1fr auto auto;
    gap: 5px;
    min-height: 17px;
    padding: 2px 7px;
    font-size: 10px;
  }
  .overlay small {
    font-size: 10px;
    line-height: 1.15;
  }
  .scene-orb-a { left: -8%; }
  .scene-orb-b { right: -8%; }
  .name-entry-row {
    grid-template-columns: 1fr;
  }
}
