:root {
  --bg-1: #08101f;
  --bg-2: #1a1340;
  --panel: #132544;
  --panel-2: #1a2f56;
  --panel-3: #0c1b34;
  --line: rgba(255,255,255,0.10);
  --text: #f7fbff;
  --muted: rgba(255,255,255,0.76);
  --green-1: #4effb0;
  --green-2: #0fd27e;
  --blue-1: #58c8ff;
  --blue-2: #257dff;
  --yellow-1: #ffd95b;
  --orange-1: #ff8f1f;
  --red-1: #ff554a;
  --shadow: 0 18px 60px rgba(0,0,0,0.35);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --header-h: 72px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 28%, rgba(88,200,255,0.18), transparent 18%),
    radial-gradient(circle at 82% 22%, rgba(255,217,91,0.16), transparent 16%),
    radial-gradient(circle at 50% 100%, rgba(78,255,176,0.12), transparent 26%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.45), transparent 85%);
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 13, 27, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 30px rgba(0,0,0,0.28);
}

.topbar-inner {
  width: min(1240px, calc(100% - 24px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #102038;
  background: linear-gradient(135deg, #ffffff, #7edcff 55%, #5dffb0);
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
}

.brand-text strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.brand-text span {
  display: block;
  margin-top: 3px;
  font-size: 0.88rem;
  color: var(--muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-nav {
  height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  transition: 0.16s ease;
}

.btn-nav:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.16);
}

.page {
  min-height: 100vh;
  padding-top: calc(var(--header-h) + 20px);
  padding-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-shell {
  width: min(1240px, calc(100% - 24px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: stretch;
}

.arcade {
  position: relative;
  border-radius: 38px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)),
    linear-gradient(135deg, #172b4b, #0c1830);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 680px;
}

.arcade::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 30%, rgba(88,200,255,0.16), transparent 18%),
    radial-gradient(circle at 78% 26%, rgba(255,217,91,0.18), transparent 20%),
    radial-gradient(circle at 50% 100%, rgba(78,255,176,0.12), transparent 30%);
}

.arcade-frame {
  position: relative;
  z-index: 1;
  height: 100%;
  border-radius: 28px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(13,32,58,0.92), rgba(8,20,39,0.96));
  border: 3px solid rgba(93,255,176,0.25);
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.05),
    inset 0 0 40px rgba(88,200,255,0.08),
    0 0 0 10px rgba(255,255,255,0.02);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
}

.panel-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.lights,
.lights.right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.lights.right {
  justify-content: flex-end;
}

.light {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 0 16px currentColor;
  opacity: 0.9;
  animation: blink 1.6s infinite alternate;
}

.light.l1 { color: #5dffb0; background: #5dffb0; }
.light.l2 { color: #58c8ff; background: #58c8ff; animation-delay: .2s; }
.light.l3 { color: #ffd95b; background: #ffd95b; animation-delay: .4s; }
.light.l4 { color: #ff7b59; background: #ff7b59; animation-delay: .6s; }

@keyframes blink {
  from { transform: scale(0.95); opacity: 0.65; }
  to { transform: scale(1.08); opacity: 1; }
}

.game-title-box {
  text-align: center;
  padding: 10px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,217,91,0.16), rgba(88,200,255,0.14));
  border: 1px solid rgba(255,255,255,0.10);
}

.game-title-box strong {
  display: block;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  letter-spacing: -0.02em;
}

.game-title-box span {
  display: block;
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.instructions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.instructions strong {
  display: block;
  font-size: 1.02rem;
}

.instructions span {
  display: block;
  margin-top: 4px;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.45;
}

.goal-pill {
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1rem;
  color: #0e2039;
  background: linear-gradient(135deg, var(--yellow-1), #fff0a4);
  box-shadow: 0 8px 22px rgba(255,217,91,0.20);
  white-space: nowrap;
}

.play-area {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 24px;
  padding: 10px 0 0;
}

.display-wrap {
  width: min(760px, 100%);
  padding: 20px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(93,255,176,0.12), rgba(88,200,255,0.08)),
    rgba(5,12,24,0.82);
  border: 3px solid rgba(93,255,176,0.20);
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.04),
    inset 0 0 60px rgba(93,255,176,0.08),
    0 12px 40px rgba(0,0,0,0.24);
}

.display-screen {
  position: relative;
  border-radius: 24px;
  padding: 32px 18px;
  background:
    linear-gradient(180deg, rgba(5,10,20,0.94), rgba(15,25,46,0.94));
  border: 2px solid rgba(255,255,255,0.06);
  text-align: center;
  box-shadow: inset 0 0 50px rgba(0,0,0,0.45);
  overflow: hidden;
}

.display-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), transparent 35%);
}

.display-label {
  position: relative;
  z-index: 1;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.64);
  margin-bottom: 10px;
}

.display-number {
  position: relative;
  z-index: 1;
  font-family: "Arial Black", Impact, Inter, sans-serif;
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 0.95;
  letter-spacing: 0.06em;
  color: #ff9c2f;
  text-shadow:
    0 0 10px rgba(255,156,47,0.55),
    0 0 24px rgba(255,156,47,0.30),
    0 4px 0 rgba(91,35,0,0.55);
  user-select: none;
}

.display-target {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  font-weight: 800;
  color: rgba(255,255,255,0.82);
  font-size: 1rem;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
}

.arcade-btn {
  min-width: 180px;
  height: 72px;
  padding: 0 26px;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  box-shadow: 0 12px 24px rgba(0,0,0,0.24);
}

.arcade-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.arcade-btn:active {
  transform: translateY(1px);
}

.arcade-btn.primary {
  color: #102038;
  background: linear-gradient(180deg, #fff2a8, var(--yellow-1));
  box-shadow: 0 14px 30px rgba(255,217,91,0.20);
}

.arcade-btn.stop {
  color: #fff;
  background: linear-gradient(180deg, #ff886d, var(--red-1));
  box-shadow: 0 14px 30px rgba(255,85,74,0.25);
}

.arcade-btn.secondary {
  color: #fff;
  background: linear-gradient(180deg, #63d5ff, #2f80ff);
  box-shadow: 0 14px 30px rgba(47,128,255,0.20);
}

.result-box {
  width: min(760px, 100%);
  min-height: 120px;
  padding: 18px 18px 20px;
  border-radius: 24px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
  display: grid;
  align-content: center;
  gap: 8px;
}

.result-state {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.result-detail {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.result-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  margin: 4px auto 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  font-weight: 900;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.side-card {
  border-radius: 28px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: var(--shadow);
}

.side-card h3 {
  margin: 0 0 12px;
  font-size: 1.06rem;
}

.player-box {
  margin-bottom: 12px;
  padding: 11px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.player-box strong {
  display: block;
  font-size: 0.98rem;
}

.player-box span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.player-box a {
  text-decoration: underline;
}

.stat-list {
  display: grid;
  gap: 10px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.stat-row span {
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-row strong {
  font-size: 0.98rem;
}

.top-mini {
  display: grid;
  gap: 10px;
}

.mini-rank {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.mini-rank b {
  width: 30px;
  height: 30px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.08);
}

.mini-rank span {
  font-size: 0.9rem;
  color: var(--muted);
}

.mini-rank strong {
  font-size: 0.92rem;
}

.status-idle { color: #fff3ae; }
.status-good { color: #8fffd0; }
.status-bad { color: #ffb8a8; }

.pulse-idle {
  animation: idleGlow 2.2s infinite ease-in-out;
}

@keyframes idleGlow {
  0%, 100% { box-shadow: inset 0 0 60px rgba(93,255,176,0.06), 0 12px 40px rgba(0,0,0,0.24); }
  50% { box-shadow: inset 0 0 80px rgba(93,255,176,0.14), 0 12px 40px rgba(0,0,0,0.24); }
}

@media (max-width: 1080px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: 1fr 1fr;
  }

  .arcade {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  :root {
    --header-h: 66px;
  }

  .topbar-inner,
  .game-shell {
    width: min(100% - 16px, 1240px);
  }

  .brand-text span {
    display: none;
  }

  .arcade {
    padding: 12px;
    border-radius: 24px;
  }

  .arcade-frame {
    padding: 14px;
    border-radius: 20px;
    gap: 14px;
  }

  .panel-top,
  .instructions {
    grid-template-columns: 1fr;
  }

  .lights,
  .lights.right {
    justify-content: center;
  }

  .display-screen {
    padding: 24px 12px;
  }

  .arcade-btn {
    width: 100%;
    min-width: 0;
    height: 64px;
    font-size: 1.08rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .nav-actions .btn-nav {
    padding: 0 12px;
  }
}
