:root {
  color-scheme: dark;
  --bg: #111111;
  --panel: #212121;
  --panel-2: #262626;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6f7f9;
  --muted: #9ca6b4;
  --accent: #ffbc0e;
  --accent-2: #ff475f;
  --gold: #ffbc0e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 188, 14, 0.13), transparent 28rem),
    linear-gradient(135deg, #101010 0%, #171717 46%, #111111 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  min-height: 100vh;
  padding: 20px;
}

.arena-panel,
.leaderboard {
  background: rgba(33, 33, 33, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.arena-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar,
.hud,
.leaderboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-link {
  color: inherit;
  text-decoration: none;
}

.header-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.brand-centered {
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-align: center;
}

.comeback-logo {
  display: block;
  width: 72px;
  height: 72px;
  filter: brightness(0) invert(1) drop-shadow(0 0 14px rgba(255, 255, 255, 0.16));
}

.comeback-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-name,
.event-name,
.prize span,
.metric span,
.eyebrow {
  display: block;
}

.brand-name {
  font-weight: 800;
  font-size: 1.18rem;
}

.event-name,
.prize span,
.metric span,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.prize {
  text-align: right;
}

.prize strong {
  display: block;
  color: var(--gold);
  font-size: 0.94rem;
}

.leaderboard-prize {
  display: block;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.prize-link {
  color: inherit;
  text-decoration: none;
}

.prize-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.leaderboard-prize strong {
  margin-top: 4px;
  font-size: 1.04rem;
}

.countdown-card {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid rgba(255, 188, 14, 0.22);
  border-radius: 8px;
  background: rgba(255, 188, 14, 0.06);
}

.countdown-card strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 1.36rem;
  letter-spacing: 0;
}

.hud {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  align-items: flex-start;
  justify-content: center;
  gap: clamp(16px, 3vw, 34px);
}

.metric {
  min-width: 92px;
  display: grid;
  grid-template-rows: auto 35px;
  align-items: center;
  gap: 7px;
}

.metric strong {
  font-size: 1.35rem;
  line-height: 1.1;
  align-self: center;
}

.sensitivity-control {
  display: grid;
  gap: 7px;
  width: clamp(220px, 28vw, 320px);
  margin: 0;
  grid-template-rows: auto 35px;
}

.sensitivity-control > span:first-child {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 560px;
}

.mobile-message {
  display: none;
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
  background: #202020;
  background-position: center;
  background-size: cover;
  perspective: 1050px;
  perspective-origin: 50% 50%;
}

.stage.is-playing {
  cursor: none;
}

.room-space {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(1280px, 96%);
  height: min(760px, 90%);
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
  transform-origin: center;
  transition: opacity 120ms ease;
  will-change: transform, opacity;
}

.room-space.is-out-of-view {
  opacity: 0;
}

.room-face,
.target-wall {
  position: absolute;
  border: 1px solid rgba(255, 188, 14, 0.24);
  background:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    rgba(255, 255, 255, 0.018);
  background-size: 44px 44px;
  backface-visibility: hidden;
}

.target-wall {
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 188, 14, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    rgba(255, 255, 255, 0.025);
  background-size: 44px 44px;
  box-shadow: inset 0 0 38px rgba(0, 0, 0, 0.28), 0 0 42px rgba(255, 188, 14, 0.08);
  transform: translateZ(-430px);
}

.room-floor,
.room-ceiling {
  left: 0;
  width: 100%;
  height: 430px;
  transform-origin: center;
}

.room-floor {
  top: 100%;
  transform: rotateX(90deg);
}

.room-ceiling {
  bottom: 100%;
  transform: rotateX(-90deg);
}

.room-left,
.room-right {
  top: 0;
  width: 430px;
  height: 100%;
  transform-origin: center;
}

.room-left {
  right: 100%;
  transform: rotateY(-90deg);
}

.room-right {
  left: 100%;
  transform: rotateY(90deg);
}

.reticle {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.reticle::before,
.reticle::after,
.reticle span::before,
.reticle span::after {
  content: "";
  position: absolute;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 188, 14, 0.74);
}

.reticle::before,
.reticle::after {
  top: 50%;
  width: 24px;
  height: 2px;
  transform: translateY(-50%);
}

.reticle::before {
  left: 0;
}

.reticle::after {
  display: none;
}

.reticle span::before,
.reticle span::after {
  left: 50%;
  width: 2px;
  height: 24px;
  transform: translateX(-50%);
}

.reticle span::before {
  top: 0;
}

.reticle span::after {
  display: none;
}

.reticle span {
  position: absolute;
  inset: 0;
}

.target {
  position: absolute;
  z-index: 2;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 188, 14, 0.96), rgba(218, 140, 0, 0.96)),
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(255, 255, 255, 0.18) 8px 10px);
  box-shadow: 0 0 0 6px rgba(255, 188, 14, 0.11), 0 0 34px rgba(255, 188, 14, 0.38);
  transform: translateZ(0);
  transition: transform 90ms ease, filter 90ms ease;
}

.target:active {
  transform: scale(0.9);
  filter: brightness(1.2);
}

.start-card,
.result-card {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(33, 33, 33, 0.96);
  box-shadow: var(--shadow);
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 12px;
  align-items: center;
  align-self: center;
}

.range-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--accent);
  padding: 0;
  background: transparent;
}

.range-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 188, 14, 0.28);
}

.range-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255, 188, 14, 0.58);
}

.range-row input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 188, 14, 0.28);
}

.range-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255, 188, 14, 0.58);
}

.sensitivity-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
  color: var(--accent);
  font-weight: 800;
}

.sensitivity-field input {
  min-width: 0;
  padding: 7px 6px;
  border-color: rgba(255, 188, 14, 0.3);
  background: rgba(255, 188, 14, 0.08);
  color: var(--accent);
  text-align: right;
  font-weight: 800;
}

.start-card h1,
.result-card h2,
.leaderboard h2 {
  margin: 0;
}

.start-card h1 {
  margin-bottom: 18px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.06;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 12px 13px;
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 188, 14, 0.16);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-error {
  margin: 10px 0 0;
  color: #ff7b7b;
  font-size: 0.86rem;
  font-weight: 700;
}

.captcha-widget {
  margin-top: 14px;
  min-height: 65px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-row a,
.legal-back {
  color: var(--accent);
  font-weight: 800;
}

.primary-button {
  border: 0;
  border-radius: 6px;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 18px;
  padding: 13px 16px;
  background: var(--accent);
  color: #15110a;
}

.result-card {
  text-align: center;
}

.result-card h2 {
  margin-top: 4px;
  font-size: 3rem;
}

.result-card p {
  margin: 8px 0 2px;
  color: var(--muted);
}

.hidden {
  display: none;
}

.leaderboard {
  padding: 18px;
  overflow: hidden;
}

.leaderboard-head {
  margin-bottom: 16px;
}

.live-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
}

#leaderboardList {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.leaderboard-item strong,
.leaderboard-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank {
  color: var(--gold);
  font-weight: 800;
}

.player-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.points {
  color: var(--accent);
  font-weight: 800;
}

.legal-page {
  min-height: 100vh;
  padding: 24px;
}

.legal-panel {
  width: min(980px, 100%);
  margin: 20px auto;
  padding: clamp(20px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(33, 33, 33, 0.96);
  box-shadow: var(--shadow);
}

.legal-panel h1 {
  margin: 0 0 18px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.05;
}

.legal-panel h2 {
  margin: 28px 0 10px;
  color: var(--accent);
  font-size: 1.12rem;
}

.legal-panel p,
.legal-panel li {
  color: #d8dde5;
  line-height: 1.65;
}

.legal-panel ol {
  padding-left: 22px;
}

.legal-note {
  padding: 12px;
  border: 1px solid rgba(255, 188, 14, 0.22);
  border-radius: 8px;
  background: rgba(255, 188, 14, 0.06);
}

.legal-back {
  display: inline-flex;
  margin-left: max(0px, calc((100% - 980px) / 2));
  text-decoration: none;
}

@media (max-width: 980px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .stage-wrap {
    min-height: 62vh;
  }
}

@media (max-width: 1100px), (hover: none) and (pointer: coarse) {
  .game-shell {
    padding: 10px;
  }

  .topbar,
  .hud {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .prize {
    text-align: left;
  }

  .metric {
    min-width: 72px;
  }

  .arena-panel .hud,
  .arena-panel .stage,
  .arena-panel .start-card,
  .arena-panel .result-card {
    display: none !important;
  }

  .stage-wrap {
    display: grid;
    min-height: 56vh;
    place-items: center;
    padding: 24px;
  }

  .mobile-message {
    display: block !important;
    text-align: center;
  }

  .mobile-message h1 {
    margin: 0;
    font-size: clamp(2.3rem, 13vw, 4.5rem);
    line-height: 1;
  }

  .mobile-message p {
    margin: 14px auto 0;
    max-width: 280px;
    color: var(--accent);
    font-weight: 800;
    line-height: 1.3;
  }
}

body.is-mobile-game .arena-panel .hud,
body.is-mobile-game .arena-panel .stage,
body.is-mobile-game .arena-panel .start-card,
body.is-mobile-game .arena-panel .result-card {
  display: none !important;
}

body.is-mobile-game .stage-wrap {
  display: grid;
  min-height: 56vh;
  place-items: center;
  padding: 24px;
}

body.is-mobile-game .mobile-message {
  display: block !important;
  text-align: center;
}
