:root {
  --ink: #eef6f3;
  --muted: #aab8c1;
  --panel: #13212a;
  --panel-2: #1a2d38;
  --line: rgba(238, 246, 243, 0.13);
  --accent: #69f0bd;
  --accent-2: #83b7ff;
  --danger: #ff7d8a;
  --warning: #ffc767;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(105, 240, 189, 0.12), transparent 28rem),
    radial-gradient(circle at 80% 85%, rgba(131, 183, 255, 0.13), transparent 32rem),
    #0b1218;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--warning); outline-offset: 3px; }

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

.game-card {
  width: min(100%, 780px);
  min-height: 690px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(26,45,56,.96), rgba(12,24,31,.98));
  box-shadow: var(--shadow);
}

.game-header,
.game-footer,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-header { padding: 28px 30px 18px; }
.game-footer {
  gap: 10px;
  padding: 18px 30px 24px;
  color: var(--muted);
  font-size: .82rem;
}

h1, h2, p { margin: 0; }
h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  letter-spacing: -.06em;
  line-height: .92;
}
h1 span { color: var(--accent); }
h2 { font-size: clamp(1.4rem, 3.2vw, 2.1rem); letter-spacing: -.04em; }

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 1.35rem;
  transition: background .18s ease, transform .18s ease;
}
.icon-button:hover { background: rgba(238, 246, 243, .08); transform: translateY(-2px); }

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 30px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(5, 13, 18, .25);
}
.stat { padding: 12px 16px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: .73rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.stat strong { display: block; margin-top: 3px; font-size: 1.02rem; }

.intro-panel,
.finish-panel,
.leaderboard-panel { padding: 62px 30px; text-align: center; }
.intro-panel > p:not(.eyebrow):not(.tiny-note),
.finish-panel > p:not(.eyebrow) { max-width: 560px; margin: 16px auto 26px; color: var(--muted); line-height: 1.65; }
.tiny-note { margin-top: 14px; color: var(--muted); font-size: .82rem; line-height: 1.45; }

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 13px;
  padding: 0 18px;
  border: 1px solid transparent;
  font-weight: 800;
  transition: transform .17s ease, box-shadow .17s ease, background .17s ease;
}
.primary-button {
  color: #082319;
  background: var(--accent);
  box-shadow: 0 10px 26px rgba(105, 240, 189, .2);
}
.secondary-button { color: var(--ink); background: transparent; border-color: var(--line); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.primary-button:active, .secondary-button:active { transform: translateY(1px); }

.play-panel { padding: 30px; }
.stage-copy { min-height: 104px; }
.stage-copy h2 { margin-bottom: 8px; }
.stage-copy p:last-child { color: var(--muted); line-height: 1.5; }

.arena {
  position: relative;
  height: 390px;
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid rgba(238, 246, 243, .16);
  border-radius: 20px;
  background:
    linear-gradient(rgba(238, 246, 243, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 246, 243, .035) 1px, transparent 1px),
    #0d1920;
  background-size: 30px 30px;
  touch-action: manipulation;
}
.arena::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 55px rgba(0,0,0,.34);
  content: "";
}

.reaction {
  min-height: 24px;
  margin-top: 14px;
  color: var(--warning);
  font-weight: 700;
  text-align: center;
}

.target {
  position: absolute;
  z-index: 1;
  min-width: 82px;
  min-height: 48px;
  padding: 0 14px;
  border: 2px solid rgba(0,0,0,.18);
  border-radius: 12px;
  color: #071d15;
  background: var(--accent);
  box-shadow: 0 8px 0 rgba(0, 0, 0, .20), 0 12px 20px rgba(0, 0, 0, .2);
  font-weight: 900;
  letter-spacing: .01em;
  transform: translate(-50%, -50%);
  user-select: none;
}
.target:hover { filter: brightness(1.05); }
.target:active { margin-top: 5px; box-shadow: 0 3px 0 rgba(0,0,0,.23), 0 6px 10px rgba(0,0,0,.18); }
.target.blue { color: #061726; background: var(--accent-2); }
.target.danger { color: #2a080d; background: var(--danger); }
.target.warn { color: #241800; background: var(--warning); }
.target.tiny { min-width: 46px; min-height: 46px; padding: 0; border-radius: 50%; font-size: 0; }
.target.tiny::after { content: "•"; font-size: 1.6rem; }
.target.static { transition: none !important; }

.arena-note {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: min(90%, 470px);
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}

.stage-grid {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  gap: 18px;
  align-content: center;
  padding: 30px;
}
.stage-grid.three { grid-template-columns: repeat(3, minmax(64px, 1fr)); }
.stage-grid .target { position: relative; left: auto !important; top: auto !important; width: 100%; transform: none; }

.hold-ring {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: 142px;
  height: 142px;
  border: 8px solid rgba(238,246,243,.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  transition: transform .95s linear;
}
.hold-ring.holding { transform: translate(-50%, -50%) rotate(270deg); }

.progress-pips {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 22px;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
}
.progress-pips span { width: 11px; height: 11px; border: 1px solid var(--line); border-radius: 50%; background: rgba(238,246,243,.06); }
.progress-pips span.filled { background: var(--accent); }

.shake { animation: shake .34s ease; }
.pulse { animation: pulse .65s ease-in-out infinite alternate; }
.fall { transition: top 2.7s linear; }
.rotate { animation: rotate 2.1s linear infinite; }

@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-9px)} 75%{transform:translateX(9px)} }
@keyframes pulse { to { box-shadow: 0 8px 0 rgba(0,0,0,.2), 0 0 0 14px rgba(105,240,189,.09); } }
@keyframes rotate { to { rotate: 360deg; } }

.finish-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.leaderboard-panel { padding-top: 32px; text-align: left; }
.panel-heading { margin-bottom: 20px; }
.panel-heading h2 { font-size: 1.75rem; }
.score-form { margin: 18px 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.12); }
.score-form label { display: block; margin-bottom: 10px; font-weight: 800; }
.score-row { display: flex; gap: 10px; }
.score-row input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; color: var(--ink); background: #0c171d; }
.score-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: scores; }
.score-list li {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.025);
}
.score-list li::before { counter-increment: scores; content: counter(scores); color: var(--accent); font-weight: 900; }
.score-list strong { color: var(--ink); }

[hidden] { display: none !important; }

@media (max-width: 600px) {
  .game-card { min-height: 640px; border-radius: 20px; }
  .game-header { padding: 22px 20px 14px; }
  .hud { margin: 0 20px; }
  .stat { padding: 10px 6px; }
  .stat strong { font-size: .88rem; }
  .intro-panel, .finish-panel, .leaderboard-panel { padding: 48px 20px; }
  .play-panel { padding: 26px 20px; }
  .arena { height: 370px; }
  .game-footer { padding: 16px 20px 20px; justify-content: center; flex-wrap: wrap; }
  .stage-grid { gap: 12px; padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.game-nav-link {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  text-decoration: none;
}
.game-nav-link:hover { color: var(--accent); }
