:root {
  color-scheme: dark;
  --ink: #080b12;
  --paper: #edf2eb;
  --acid: #c7ff42;
  --cyan: #5ceeff;
  --red: #ff4b50;
  --line: rgba(237, 242, 235, 0.16);
  --card: rgba(14, 21, 37, 0.7);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 75% 15%, rgba(92, 238, 255, 0.12), transparent 32rem),
    radial-gradient(circle at 12% 80%, rgba(199, 255, 66, 0.08), transparent 28rem),
    var(--ink);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

/* Page shell & header */
.shell, main {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 32px;
}

.topbar, .site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.back-link, .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--paper);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.back-link:hover, .brand:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(92, 238, 255, 0.08);
}

.back-arrow {
  font-size: 15px;
  line-height: 1;
}

.topbar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.game-badge, .kicker, .eyebrow {
  margin: 0;
  color: var(--cyan);
  font: 800 10px/1 ui-monospace, monospace;
  letter-spacing: 0.22em;
}

.brand-title {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--paper);
  text-shadow: 0 0 15px rgba(92, 238, 255, 0.4);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--paper);
  background: rgba(255, 255, 255, 0.04);
  font: 800 11px/1 ui-monospace, monospace;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-button:hover {
  border-color: var(--acid);
  color: var(--acid);
  background: rgba(199, 255, 66, 0.08);
}

.pause {
  display: none;
}

.pause.visible {
  display: inline-flex;
}

/* Game frame & HUD */
.game-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.score-row, .hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  width: 100%;
  max-width: 520px;
  padding: 12px 20px;
  background: rgba(12, 18, 32, 0.85);
  border: 1px solid rgba(92, 238, 255, 0.25);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.score-stat {
  display: flex;
  flex-direction: column;
}

.stat-chain {
  align-items: center;
  text-align: center;
}

.stat-best {
  align-items: flex-end;
  text-align: right;
}

.stat-label, .hud span {
  color: rgba(237, 242, 235, 0.5);
  font: 800 9px/1 ui-monospace, monospace;
  letter-spacing: 0.2em;
}

.stat-value, .hud strong {
  margin-top: 4px;
  font: 900 20px/1 ui-monospace, monospace;
  letter-spacing: 0.08em;
  color: var(--cyan);
}

.stat-chain .stat-value {
  color: var(--acid);
}

/* Canvas stage & cabinet */
.canvas-wrap, .screen-wrap, .cabinet {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: min(68vh, 580px);
  min-height: 440px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 20px;
  border: 2px solid rgba(92, 238, 255, 0.35);
  background: #04070c;
  box-shadow: 0 0 35px rgba(92, 238, 255, 0.15), 0 20px 50px rgba(0, 0, 0, 0.7);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Overlays (Start Screen & Game Over) */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  background: radial-gradient(circle at center, rgba(8, 11, 18, 0.9) 0%, rgba(4, 7, 12, 0.98) 85%);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  overflow-y: auto;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pulse-logo {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  color: var(--ink);
  background: var(--acid);
  border-radius: 16px;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 0 25px rgba(199, 255, 66, 0.6);
  animation: pulse 2s infinite;
}

.game-over-icon {
  font-size: 46px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 15px rgba(255, 75, 80, 0.6));
}

.signal {
  margin: 0 0 8px;
  color: var(--acid);
  font: 800 10px/1 ui-monospace, monospace;
  letter-spacing: 0.24em;
}

.signal.danger {
  color: var(--red);
}

.overlay h2 {
  margin: 0 0 10px;
  font-size: clamp(24px, 4.5vw, 34px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.04em;
  color: var(--paper);
}

.overlay p:not(.signal):not(.key-hint) {
  max-width: 330px;
  margin: 0;
  color: rgba(237, 242, 235, 0.72);
  font-size: 13px;
  line-height: 1.55;
}

.how-to-play {
  display: flex;
  gap: 8px;
  margin: 14px 0 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.signal-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(199, 255, 66, 0.12);
  border: 1px solid rgba(199, 255, 66, 0.4);
  color: var(--acid);
}

.noise-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 75, 80, 0.12);
  border: 1px solid rgba(255, 75, 80, 0.4);
  color: var(--red);
}

/* HIGH-VISIBILITY START & RESTART BUTTON */
.primary-button, .primary, #start-button, #restart-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 12px !important;
  min-width: 230px !important;
  min-height: 52px !important;
  margin-top: 22px !important;
  padding: 16px 36px !important;
  border: 2px solid #c7ff42 !important;
  border-radius: 999px !important;
  color: #080b12 !important;
  background: #c7ff42 !important;
  font-family: inherit !important;
  font-size: 15px !important;
  font-weight: 900 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
  cursor: pointer !important;
  box-shadow: 0 0 28px rgba(199, 255, 66, 0.55), 0 4px 0 #8abf1b !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.primary-button:hover, .primary:hover, #start-button:hover, #restart-button:hover {
  transform: translateY(-2px) !important;
  background: #d8ff68 !important;
  box-shadow: 0 0 40px rgba(199, 255, 66, 0.8), 0 6px 0 #8abf1b !important;
}

.primary-button:active, .primary:active, #start-button:active, #restart-button:active {
  transform: translateY(2px) !important;
  box-shadow: 0 0 16px rgba(199, 255, 66, 0.35), 0 2px 0 #8abf1b !important;
}

.btn-arrow {
  font-size: 13px;
  line-height: 1;
}

.key-hint {
  margin: 14px 0 0;
  color: rgba(237, 242, 235, 0.42);
  font: 800 9px/1 ui-monospace, monospace;
  letter-spacing: 0.2em;
}

/* Controls helper bar */
.controls-bar, .tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(237, 242, 235, 0.45);
  font: 600 11px/1.6 ui-monospace, monospace;
  text-align: center;
  margin-top: 4px;
}

.controls-bar b, .tip b {
  color: var(--cyan);
}

.separator {
  color: rgba(237, 242, 235, 0.25);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(199, 255, 66, 0.6);
  }
  50% {
    box-shadow: 0 0 0 16px rgba(199, 255, 66, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(199, 255, 66, 0);
  }
}

/* Responsive queries */
@media (max-width: 600px) {
  .shell, main {
    width: calc(100% - 20px);
    padding: 10px 0 24px;
  }

  .topbar, .site-header {
    height: 56px;
    margin-bottom: 12px;
  }

  .back-link, .brand {
    font-size: 11px;
    padding: 6px 12px;
  }

  .brand-title {
    font-size: 15px;
  }

  .icon-button {
    padding: 6px 10px;
    font-size: 10px;
  }

  .score-row, .hud {
    padding: 10px 14px;
  }

  .stat-value, .hud strong {
    font-size: 17px;
  }

  .canvas-wrap, .screen-wrap, .cabinet {
    height: calc(100svh - 220px);
    min-height: 400px;
    border-radius: 16px;
  }

  .overlay {
    padding: 18px 14px;
  }

  .overlay h2 {
    font-size: 24px;
  }

  .primary-button, .primary, #start-button, #restart-button {
    min-width: 200px !important;
    padding: 14px 28px !important;
    font-size: 14px !important;
  }

  .controls-bar, .tip {
    font-size: 10px;
    flex-wrap: wrap;
    gap: 6px 8px;
  }
}

@media (max-height: 650px) {
  .canvas-wrap, .screen-wrap, .cabinet {
    min-height: 350px;
    height: 60vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


