:root {
  color-scheme: dark;
  --ink: #050711;
  --panel: rgba(8, 13, 27, 0.9);
  --cyan: #36e8ff;
  --violet: #9d5cff;
  --green: #55ff9a;
  --red: #ff426d;
  --yellow: #ffe05a;
  --muted: #72809f;
  --text: #effcff;
  --wheel-size: min(74vw, 64vh, 570px);
  font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 300px;
  min-height: 100svh;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 43%, rgba(31, 73, 122, 0.16), transparent 31%),
    linear-gradient(135deg, rgba(157, 92, 255, 0.055), transparent 35%),
    #050711;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(54, 232, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(54, 232, 255, 0.025) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle, #000, transparent 84%);
}

button, input { font: inherit; }
button { color: inherit; }

.scanlines {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0, 0, 0, 0.22) 3px 4px);
}

.ambient {
  position: fixed;
  width: 38vw;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.1;
  pointer-events: none;
}

.ambient-one { top: -24vw; left: -10vw; background: var(--violet); }
.ambient-two { right: -18vw; bottom: -27vw; background: var(--cyan); }

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  min-height: 100svh;
  isolation: isolate;
}

.scoreboard {
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 92px;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 64px) 12px;
}

.brand-mark {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.22em;
}
.brand-mark span { color: var(--cyan); }

.score-cluster {
  display: flex;
  align-items: baseline;
  justify-content: center;
  min-width: 150px;
  text-shadow: 0 0 24px rgba(54, 232, 255, 0.3);
}

.score {
  font-size: clamp(3.4rem, 8vw, 6.6rem);
  font-weight: 900;
  font-stretch: condensed;
  line-height: 0.8;
  letter-spacing: -0.07em;
}

.rank, .gap {
  margin-left: 0.72rem;
  font-size: clamp(0.75rem, 1.7vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.08em;
}
.rank { color: var(--green); text-shadow: 0 0 12px rgba(85, 255, 154, 0.8); }
.gap { color: var(--red); text-shadow: 0 0 12px rgba(255, 66, 109, 0.65); }

.icon-button {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(54, 232, 255, 0.25);
  border-radius: 4px;
  background: rgba(8, 15, 29, 0.7);
  cursor: pointer;
}
.icon-button:hover, .icon-button:focus-visible { border-color: var(--cyan); outline: none; box-shadow: 0 0 18px rgba(54, 232, 255, 0.18); }

.sound-bars { display: flex; align-items: end; gap: 3px; height: 15px; }
.sound-bars i { display: block; width: 3px; background: var(--cyan); animation: bars 0.8s ease-in-out infinite alternate; }
.sound-bars i:nth-child(1) { height: 7px; }
.sound-bars i:nth-child(2) { height: 15px; animation-delay: -0.25s; }
.sound-bars i:nth-child(3) { height: 10px; animation-delay: -0.5s; }
.icon-button[aria-pressed="true"] .sound-bars i { height: 3px; animation: none; background: var(--muted); }

.arena {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 0;
}

.wheel-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--wheel-size);
  aspect-ratio: 1;
  transition: filter 180ms ease, transform 180ms ease;
}
.wheel-frame.hit { animation: wheel-hit 280ms ease-out; }
.wheel-frame.fail { animation: wheel-fail 420ms ease-out; filter: hue-rotate(120deg) saturate(1.8); }

.orbit {
  position: absolute;
  inset: -3.5%;
  border: 1px solid rgba(54, 232, 255, 0.12);
  border-radius: 50%;
  pointer-events: none;
}
.orbit::before, .orbit::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 14px var(--cyan);
}
.orbit::before { top: 13%; left: 13%; }
.orbit::after { right: 4%; bottom: 30%; }
.orbit-one { animation: orbit 18s linear infinite; }
.orbit-two { inset: 2%; border-style: dashed; animation: orbit 26s linear infinite reverse; opacity: 0.5; }

.wheel { width: 100%; height: 100%; overflow: visible; touch-action: none; user-select: none; }
.wheel-rail { fill: none; stroke: rgba(54, 232, 255, 0.18); stroke-width: 2; stroke-dasharray: 2 9; }

.segment {
  fill: rgba(22, 35, 60, 0.76);
  stroke: rgba(76, 174, 210, 0.55);
  stroke-width: 2;
  cursor: pointer;
  transition: fill 55ms linear, stroke 55ms linear, opacity 80ms linear;
  outline: none;
}
.segment:hover { fill: rgba(31, 54, 83, 0.94); stroke: rgba(54, 232, 255, 0.85); }
.segment:focus-visible { stroke: #fff; stroke-width: 4; }
.segment.target-green {
  fill: rgba(48, 255, 135, 0.78);
  stroke: #afffd0;
  filter: url(#green-glow);
}
.segment.decoy-yellow { fill: rgba(255, 213, 55, 0.86); stroke: #fff2a8; filter: url(#soft-glow); }
.segment.decoy-red { fill: rgba(255, 44, 96, 0.88); stroke: #ffafc2; filter: url(#soft-glow); }
.segment.after-cyan { fill: rgba(35, 255, 215, 0.82); stroke: #b7fff1; filter: url(#green-glow); }
.wheel.pulsing .segment:not(.target-green):not(.decoy-yellow):not(.decoy-red):not(.after-cyan) { animation: sector-pulse 0.72s ease-in-out infinite alternate; }
.wheel.pulsing .segment.pulse-0 { animation-delay: 0s; }
.wheel.pulsing .segment.pulse-1 { animation-delay: -0.13s; }
.wheel.pulsing .segment.pulse-2 { animation-delay: -0.26s; }
.wheel.pulsing .segment.pulse-3 { animation-delay: -0.39s; }
.wheel.pulsing .segment.pulse-4 { animation-delay: -0.52s; }
.wheel.pulsing .segment.pulse-5 { animation-delay: -0.65s; }
.wheel.pulsing .segment.pulse-6 { animation-delay: -0.78s; }
.wheel.pulsing .segment.pulse-7 { animation-delay: -0.91s; }

.hub { pointer-events: none; }
.hub-ring { fill: #070b17; stroke: rgba(54, 232, 255, 0.7); stroke-width: 2; filter: url(#soft-glow); }
.hub-core { fill: #0b1020; stroke: rgba(157, 92, 255, 0.45); stroke-width: 1; }
.hub-dot { fill: var(--cyan); filter: url(#soft-glow); }

.phase-label {
  min-height: 1.2em;
  margin: clamp(7px, 1.4vh, 16px) 0 0;
  color: var(--muted);
  font-size: clamp(0.62rem, 1.5vw, 0.77rem);
  font-weight: 800;
  letter-spacing: 0.26em;
}
.phase-label.live { color: var(--green); text-shadow: 0 0 12px rgba(85, 255, 154, 0.55); }

.reaction-meter {
  width: min(58vw, 390px);
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(114, 128, 159, 0.12);
  opacity: 0;
  transition: opacity 70ms linear;
}
.reaction-meter.active { opacity: 0.72; }
.reaction-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(85, 255, 154, 0.28), var(--green));
  box-shadow: 0 0 9px rgba(85, 255, 154, 0.6);
  transform: scaleX(1);
  transform-origin: left center;
}

.overlay {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  width: min(90vw, 470px);
  padding: clamp(24px, 5vw, 42px);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(54, 232, 255, 0.36);
  border-radius: 2px;
  background: linear-gradient(145deg, rgba(12, 18, 36, 0.97), rgba(5, 8, 19, 0.96));
  box-shadow: 0 0 0 1px rgba(157, 92, 255, 0.12), 0 25px 90px rgba(0, 0, 0, 0.75), 0 0 60px rgba(54, 232, 255, 0.08);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
}
.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(54, 232, 255, 0.055), transparent);
  transform: translateX(-100%);
  animation: panel-scan 4.5s ease-in-out infinite;
}
.overlay.hidden { opacity: 0; visibility: hidden; transform: translate(-50%, -47%) scale(0.98); }
.panel-edge { position: absolute; top: -1px; left: 38px; width: 90px; height: 3px; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); }
.eyebrow { color: var(--cyan); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.2em; }
.overlay h1 { margin: 12px 0 6px; font-size: clamp(2.5rem, 10vw, 4.4rem); line-height: 0.86; letter-spacing: -0.065em; font-weight: 950; }
.overlay h1 span { color: transparent; -webkit-text-stroke: 1px var(--cyan); text-shadow: 0 0 24px rgba(54, 232, 255, 0.25); }
.overlay-copy { margin: 0 0 24px; color: #9ba8c0; font-size: 0.84rem; line-height: 1.5; }

.start-form label { display: block; margin: 0 0 8px; color: var(--muted); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.19em; }
.input-wrap { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; border: 1px solid rgba(114, 128, 159, 0.4); background: rgba(2, 5, 13, 0.7); }
.input-wrap:focus-within { border-color: var(--cyan); box-shadow: inset 3px 0 var(--cyan), 0 0 18px rgba(54, 232, 255, 0.08); }
.input-wrap span { color: var(--cyan); font-weight: 900; }
.input-wrap input { flex: 1; min-width: 0; border: 0; outline: 0; color: #fff; background: transparent; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.input-wrap input::placeholder { color: #4f5a71; }
.form-message { min-height: 1.25em; margin: 7px 0; color: var(--red); font-size: 0.68rem; }
.privacy-note { margin: 10px 0 0; color: #8996b2; font-size: 0.62rem; font-weight: 650; line-height: 1.5; letter-spacing: 0.01em; }
.privacy-note a { color: var(--cyan); text-underline-offset: 3px; }
.privacy-note a:hover, .privacy-note a:focus-visible { color: var(--green); }

.primary-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid var(--green);
  background: linear-gradient(90deg, rgba(85, 255, 154, 0.18), rgba(85, 255, 154, 0.04));
  color: #dffff0;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  cursor: pointer;
  box-shadow: inset 3px 0 var(--green), 0 0 22px rgba(85, 255, 154, 0.08);
}
.primary-button:hover, .primary-button:focus-visible { outline: none; background: var(--green); color: #031008; box-shadow: 0 0 28px rgba(85, 255, 154, 0.32); }
.primary-button:disabled { cursor: wait; opacity: 0.48; }

.audio-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  margin-top: 9px;
  border: 1px solid rgba(114, 128, 159, 0.3);
  background: rgba(4, 8, 18, 0.58);
  color: #8c9ab5;
  font-size: 0.61rem;
  font-weight: 900;
  letter-spacing: 0.17em;
  cursor: pointer;
}
.audio-button:hover, .audio-button:focus-visible { border-color: var(--cyan); color: var(--text); outline: none; }
.audio-button[aria-pressed="true"] .sound-bars i { height: 3px; animation: none; background: var(--muted); }

.leader-chip { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-top: 22px; padding-top: 15px; border-top: 1px solid rgba(114, 128, 159, 0.18); }
.leader-chip span { grid-column: 1 / -1; color: var(--muted); font-size: 0.56rem; font-weight: 800; letter-spacing: 0.2em; }
.leader-chip strong { overflow: hidden; font-size: 0.78rem; letter-spacing: 0.12em; text-overflow: ellipsis; white-space: nowrap; }
.leader-chip em { color: var(--yellow); font-size: 0.8rem; font-style: normal; font-weight: 900; }

.legal-page { min-height: 100vh; min-height: 100svh; padding: clamp(16px, 4vw, 48px); overflow-x: hidden; overflow-y: auto; }
.legal-shell { position: relative; width: min(850px, 100%); margin: 0 auto; border: 1px solid rgba(54, 232, 255, 0.34); background: rgba(5, 9, 21, 0.96); box-shadow: 0 0 50px rgba(54, 232, 255, 0.1), inset 3px 0 var(--cyan); }
.legal-header { padding: clamp(26px, 6vw, 56px); border-bottom: 1px solid rgba(114, 128, 159, 0.25); background: linear-gradient(135deg, rgba(157, 92, 255, 0.15), rgba(54, 232, 255, 0.06)); }
.legal-header .legal-kicker { margin: 0 0 12px; color: var(--green); font-size: 0.62rem; font-weight: 900; letter-spacing: 0.2em; }
.legal-header h1 { margin: 0; font-size: clamp(2.8rem, 10vw, 5.7rem); line-height: 0.9; letter-spacing: -0.055em; }
.legal-header h1 span { color: transparent; -webkit-text-stroke: 1px var(--cyan); text-shadow: 0 0 24px rgba(54, 232, 255, 0.2); }
.legal-header p:last-child { max-width: 650px; margin: 18px 0 0; color: #a8b4cb; line-height: 1.6; }
.legal-content { padding: clamp(24px, 5vw, 48px); }
.legal-content section + section { margin-top: 28px; padding-top: 25px; border-top: 1px solid rgba(114, 128, 159, 0.22); }
.legal-content h2 { margin: 0 0 11px; color: var(--cyan); font-size: 1rem; letter-spacing: 0.1em; }
.legal-content p { color: #c8d3e7; font-weight: 500; line-height: 1.7; }
.legal-content a, .legal-footer a { color: var(--green); text-underline-offset: 3px; }
.legal-content code { padding: 0.12rem 0.38rem; border: 1px solid rgba(54, 232, 255, 0.35); background: #02050d; color: var(--cyan); }
.legal-footer { padding: 19px clamp(24px, 5vw, 48px); display: flex; flex-wrap: wrap; gap: 10px 22px; border-top: 1px solid rgba(114, 128, 159, 0.25); color: var(--muted); font-size: 0.68rem; letter-spacing: 0.04em; }

.result { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0 16px; margin: 18px 0 22px; padding: 12px 16px; border-left: 3px solid var(--violet); background: rgba(157, 92, 255, 0.08); }
.result-label { color: var(--muted); font-size: 0.58rem; font-weight: 800; letter-spacing: 0.18em; }
.result strong { grid-row: 1 / 3; grid-column: 2; font-size: 2.4rem; line-height: 0.9; }
.result-rank { color: var(--green); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.13em; }

.callouts { position: fixed; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.callout { position: absolute; top: 28%; left: 8vw; color: var(--cyan); font-size: clamp(1rem, 3vw, 1.8rem); font-style: italic; font-weight: 950; letter-spacing: 0.12em; text-shadow: 0 0 16px currentColor; animation: callout-left 680ms cubic-bezier(.16,.84,.3,1) forwards; }
.callout.lane-1 { top: 42%; left: 12vw; }
.callout.lane-2 { top: 58%; left: 6vw; }
.callout.lane-3 { top: 71%; left: 10vw; }
.callout.right { left: auto; right: 8vw; color: var(--violet); animation-name: callout-right; }
.callout.right.lane-1 { right: 12vw; }
.callout.right.lane-2 { right: 6vw; }
.callout.right.lane-3 { right: 10vw; }

.game-footer { z-index: 5; display: flex; justify-content: space-between; gap: 20px; padding: 10px clamp(18px, 4vw, 64px) max(14px, env(safe-area-inset-bottom)); color: #4d5971; font-size: 0.56rem; font-weight: 800; letter-spacing: 0.16em; }

@keyframes bars { to { height: 4px; } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes sector-pulse { from { fill: rgba(19, 40, 73, 0.72); stroke: rgba(54, 232, 255, 0.45); } to { fill: rgba(72, 29, 104, 0.82); stroke: rgba(190, 91, 255, 0.88); } }
@keyframes wheel-hit { 50% { transform: scale(1.015); filter: drop-shadow(0 0 15px rgba(85, 255, 154, 0.35)); } }
@keyframes wheel-fail { 35% { transform: scale(0.98) rotate(-0.8deg); } 65% { transform: scale(1.01) rotate(0.8deg); } }
@keyframes panel-scan { 0%, 35% { transform: translateX(-110%); } 65%, 100% { transform: translateX(110%); } }
@keyframes callout-left { 0% { opacity: 0; transform: translate(-25px, 12px) skewX(-10deg); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-45vw, -22px) skewX(-10deg); } }
@keyframes callout-right { 0% { opacity: 0; transform: translate(25px, 12px) skewX(-10deg); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(45vw, -22px) skewX(-10deg); } }

@media (max-width: 680px) {
  :root { --wheel-size: min(91vw, 55vh, 470px); }
  .scoreboard { min-height: 76px; padding-inline: 18px; }
  .brand-mark { font-size: 0.55rem; }
  .game-footer span:first-child { display: none; }
  .game-footer { justify-content: center; }
  .overlay {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    left: 50%;
    max-height: calc(100svh - 32px);
    padding: 27px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    transform: translateX(-50%);
    transition: opacity 120ms linear, visibility 120ms linear;
  }
  .overlay::-webkit-scrollbar { display: none; }
  .overlay.hidden { transform: translateX(-50%); }
  .overlay::before { animation: none; }
  .reaction-meter { width: min(70vw, 330px); }
}

@media (pointer: coarse) and (max-height: 650px) {
  .overlay {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    max-height: calc(100svh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-50%);
    transition: opacity 120ms linear, visibility 120ms linear;
  }
  .overlay.hidden { transform: translateX(-50%); }
}

@media (max-height: 650px) and (orientation: landscape) {
  :root { --wheel-size: min(49vw, 65vh); }
  .scoreboard { min-height: 64px; padding-top: 10px; }
  .score { font-size: 3rem; }
  .game-footer { display: none; }
  .phase-label { position: absolute; bottom: 0; }
  .overlay { width: min(76vw, 600px); padding: 20px 28px; }
  .overlay h1 { font-size: 2.8rem; }
  .overlay-copy { margin-bottom: 12px; }
  .leader-chip { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .ambient, .scanlines, .overlay::before, .orbit, .sound-bars i { animation: none; }
}
