:root {
  --bg: #07090f;
  --panel: #101522;
  --panel-border: #25324d;
  --accent-gold: #ffd23f;
  --accent-red: #ff3b30;
  --accent-cyan: #38e8ff;
  --text: #e6edf7;
  --muted: #8ea0bd;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #141c30 0%, var(--bg) 72%);
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  overflow-x: hidden;
}

.cabinet {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(300px, auto) 290px;
  gap: 20px;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-badge {
  background: linear-gradient(135deg, #1b2540 0%, #0d1220 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 0 24px rgba(255, 210, 63, 0.14);
}

.brand-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(255, 210, 63, 0.55), 2px 2px 0 #8a1c1c;
}

.brand-sub {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--accent-cyan);
}

.panel-card {
  background: rgba(16, 21, 34, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.panel-card h2 {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--accent-cyan);
  margin-bottom: 10px;
  border-bottom: 1px solid #1e2a42;
  padding-bottom: 6px;
}

.controls-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
}

.controls-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.controls-list span {
  color: var(--muted);
}

kbd {
  background: #1b253b;
  border: 1px solid #3c4f76;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 11px;
  color: var(--text);
}

.hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 8px;
}

.hint:last-child {
  margin-bottom: 0;
}

.hint strong {
  color: var(--text);
}

.red-text {
  color: var(--accent-red);
  font-weight: 700;
}

.toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.arcade-btn {
  background: #172136;
  color: var(--text);
  border: 1px solid #3b4f78;
  border-radius: 6px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.arcade-btn:hover {
  background: #21304f;
  border-color: var(--accent-cyan);
}

.arcade-btn:active {
  transform: translateY(1px);
}

.arcade-btn.primary {
  background: linear-gradient(180deg, #ff4b3e 0%, #b81d18 100%);
  border-color: #ff8b80;
  color: #fff;
}

.arcade-btn.primary:hover {
  background: linear-gradient(180deg, #ff6357 0%, #cc241e 100%);
}

.screen-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.bezel {
  background: linear-gradient(145deg, #1b2130, #0c1018);
  padding: 14px;
  border-radius: 16px;
  border: 3px solid #2d3852;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), inset 0 0 18px rgba(0, 0, 0, 0.85);
}

.crt-wrapper {
  position: relative;
  width: min(672px, calc(100vh - 110px) * 224 / 288);
  aspect-ratio: 224 / 288;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(56, 232, 255, 0.15);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.crt-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    radial-gradient(circle at 50% 50%, transparent 65%, rgba(0, 0, 0, 0.42) 100%);
  background-size: 100% 3px, 100% 100%;
  transition: opacity 0.2s ease;
}

.crt-wrapper.crt-on .crt-scanlines {
  opacity: 1;
}

.touch-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(92vw, 440px);
  padding: 6px 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 42px);
  gap: 4px;
}

.dpad-btn {
  background: #1a253d;
  color: var(--text);
  border: 1px solid #415785;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dpad-btn:active,
.dpad-btn.pressed {
  background: var(--accent-cyan);
  color: #07090f;
}

.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.right { grid-column: 3; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 3; }

.touch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
}

.fire-btn {
  padding: 12px 8px;
  font-size: 12px;
  line-height: 1.2;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.zapper-btn {
  border-color: var(--accent-cyan);
}

.blaster-btn {
  border-color: var(--accent-gold);
}

.fire-btn.pressed {
  background: var(--accent-cyan);
  color: #07090f;
}

.start-btn {
  grid-column: 1 / -1;
  touch-action: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  background: #0b101b;
  border: 1px solid #1e2a42;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat .label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
}

.stat .value {
  font-size: 16px;
  font-weight: 800;
}

.value.gold { color: var(--accent-gold); }
.value.red { color: var(--accent-red); }
.value.cyan { color: var(--accent-cyan); }

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  border-bottom: 1px solid #1e2a42;
  padding-bottom: 6px;
}

.leaderboard-header h2 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.mini-btn {
  background: #172136;
  color: var(--accent-cyan);
  border: 1px solid #2e4063;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 410px;
  overflow-y: auto;
  font-size: 12px;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 28px 46px 1fr 48px;
  align-items: center;
  padding: 5px 7px;
  border-radius: 5px;
  background: rgba(11, 16, 27, 0.75);
}

.leaderboard-list li.top-1 { color: var(--accent-gold); border: 1px solid rgba(255, 210, 63, 0.35); }
.leaderboard-list li.top-2 { color: #e2e8f0; }
.leaderboard-list li.top-3 { color: #f59e0b; }

.leaderboard-list .score-col {
  text-align: right;
  font-weight: 700;
}

.leaderboard-list .area-col {
  text-align: right;
  font-size: 10px;
  color: var(--muted);
}

.modal {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-box {
  width: 100%;
  max-width: 320px;
  background: #101726;
  border: 2px solid var(--accent-gold);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 0 36px rgba(255, 210, 63, 0.25);
}

.modal-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent-red);
  margin-bottom: 8px;
}

.modal-stats {
  font-size: 13px;
  color: var(--accent-gold);
  margin-bottom: 14px;
}

#score-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#score-form label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
}

#initials-input {
  background: #070b14;
  border: 2px solid var(--accent-cyan);
  border-radius: 6px;
  color: var(--accent-gold);
  font-family: inherit;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 10px;
  text-align: center;
  text-transform: uppercase;
  padding: 8px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.score-feedback {
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent-cyan);
  min-height: 16px;
}

@media (max-width: 1120px) {
  .cabinet {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .side-panel {
    width: min(560px, 100%);
  }
  .crt-wrapper {
    width: min(92vw, 480px);
  }
}
