:root {
  --bg-dark: #0e0b16;
  --cabinet-border: #2a2438;
  --neon-yellow: #ffe600;
  --neon-red: #ff2a54;
  --neon-cyan: #00f5d4;
  --neon-green: #38ef7d;
  --panel-bg: rgba(16, 14, 28, 0.92);
  --pixel-font: 'Press Start 2P', monospace;
  --mono-font: 'VT323', monospace;
}

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

body {
  background-color: #07050c;
  background-image:
    radial-gradient(circle at 50% 30%, #1d1536 0%, #07050c 75%);
  color: #ffffff;
  font-family: var(--pixel-font);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.crt-wrapper {
  position: relative;
  width: 1288px;
  max-width: 98vw;
  background: #14111f;
  border: 4px solid #3c345c;
  box-shadow:
    0 0 0 4px #000,
    0 18px 50px rgba(0, 0, 0, 0.85),
    0 0 35px rgba(0, 245, 212, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

/* Optional CRT Scanline Effect */
.crt-wrapper.crt-on::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px,
    rgba(0, 0, 0, 0.22) 4px
  );
  pointer-events: none;
  z-index: 50;
}

/* Arcade Header */
.arcade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #1b122c 0%, #26173e 50%, #1b122c 100%);
  border-bottom: 4px solid #3c345c;
  padding: 10px 16px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.antenna-icon {
  font-size: 20px;
  animation: pulseGlow 1.5s infinite alternate;
}

.brand-badge h1 {
  font-size: 13px;
  color: var(--neon-yellow);
  text-shadow: 2px 2px 0px #c0002a;
  letter-spacing: 0.5px;
}

.hud-Telemetry {
  display: flex;
  gap: 14px;
}

.hud-box {
  background: #0b0812;
  border: 2px solid #493f6e;
  padding: 5px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 92px;
}

.hud-label {
  font-size: 8px;
  color: #9e93c4;
  margin-bottom: 4px;
}

.hud-value {
  font-size: 12px;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px rgba(0, 245, 212, 0.45);
}

.hud-boost-box {
  min-width: 108px;
  padding: 4px 10px;
}

.hud-boost-box.boosting {
  border-color: var(--neon-yellow);
  box-shadow: 0 0 10px rgba(255, 230, 0, 0.45);
}

.nos-bottles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 22px;
}

.nos-bottle {
  width: 15px;
  height: 22px;
  overflow: visible;
  filter: drop-shadow(0 0 3px rgba(0, 180, 255, 0.55));
  transition: filter 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.nos-bottle .nos-valve {
  fill: #ff2a54;
}

.nos-bottle .nos-neck {
  fill: #d8e2ef;
}

.nos-bottle .nos-shoulder {
  fill: #0096ff;
}

.nos-bottle .nos-body {
  fill: #0077e6;
}

.nos-bottle .nos-shine {
  fill: #6ce5ff;
}

.nos-bottle .nos-label-bg {
  fill: #ff6b00;
}

.nos-bottle .nos-text {
  fill: #ffffff;
  font-family: var(--pixel-font);
  font-size: 3.4px;
  font-weight: bold;
}

.nos-bottle .nos-base {
  fill: #004e9e;
}

.nos-bottle.used {
  filter: grayscale(100%);
  opacity: 0.55;
}

.nos-bottle.used .nos-valve {
  fill: #666666;
}

.nos-bottle.used .nos-neck {
  fill: #888888;
}

.nos-bottle.used .nos-shoulder {
  fill: #6e6e6e;
}

.nos-bottle.used .nos-body {
  fill: #595959;
}

.nos-bottle.used .nos-shine {
  fill: #7a7a7a;
}

.nos-bottle.used .nos-label-bg {
  fill: #474747;
}

.nos-bottle.used .nos-text {
  fill: #9e9e9e;
}

.nos-bottle.used .nos-base {
  fill: #424242;
}

.hud-banana-box {
  min-width: 112px;
  padding: 4px 10px;
}

.banana-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 22px;
}

.banana-icon {
  width: 18px;
  height: 18px;
  overflow: visible;
  filter: drop-shadow(0 0 3px rgba(255, 230, 0, 0.55));
  transition: filter 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.banana-icon .b-stem {
  fill: #5c3a1d;
}

.banana-icon .b-body {
  fill: #ffe600;
}

.banana-icon .b-shine {
  fill: #fff8a6;
}

.banana-icon .b-flap {
  fill: #e6be00;
}

.banana-icon.used {
  filter: grayscale(100%);
  opacity: 0.45;
}

.banana-icon.used .b-stem,
.banana-icon.used .b-body,
.banana-icon.used .b-shine,
.banana-icon.used .b-flap {
  fill: #666666;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.retro-btn {
  font-family: var(--pixel-font);
  font-size: 10px;
  background: #ff2a54;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 3px 3px 0px #000;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.08s;
  text-transform: uppercase;
}

.retro-btn:hover {
  background: #ff476c;
  transform: translate(-1px, -1px);
}

.retro-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px #000;
}

.retro-btn.small {
  font-size: 9px;
  padding: 6px 9px;
  background: #2b2345;
  border-color: #7c6eb0;
}

.retro-btn.secondary {
  background: #0077b6;
  border-color: var(--neon-cyan);
}

.retro-btn.catapult-on {
  background: #1d7a36;
  border-color: var(--neon-green);
  color: #ffffff;
}

.retro-btn.catapult-off {
  background: #352a56;
  border-color: #7c6eb0;
  color: #b4a7d6;
}

.retro-btn.mini {
  padding: 4px 8px;
  font-size: 10px;
  background: #352a56;
}

/* Cabinet Body (Game Viewport + Side Chat) */
.cabinet-body {
  display: flex;
  align-items: stretch;
}

/* Main Viewport */
.viewport-container {
  position: relative;
  width: 1000px;
  height: 720px;
  flex-shrink: 0;
  background: #214019;
}

#gameCanvas {
  display: block;
  width: 1000px;
  height: 720px;
  image-rendering: pixelated;
}

/* Overlays */
.overlay-panel {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(8, 6, 15, 0.68);
  backdrop-filter: blur(2px);
  z-index: 20;
  padding: 18px;
}

.overlay-panel.hidden {
  display: none;
}

/* Title Splash Screen Overlay */
.splash-overlay {
  background: radial-gradient(circle at center, rgba(16, 12, 28, 0.78) 0%, rgba(5, 4, 10, 0.94) 100%);
  z-index: 30;
  cursor: pointer;
}

.splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: #0d0a16;
  border: 4px solid var(--neon-yellow);
  box-shadow:
    0 0 0 4px #000,
    0 18px 50px rgba(0, 0, 0, 0.95),
    0 0 35px rgba(255, 230, 0, 0.25);
  padding: 16px 20px 18px;
  max-width: 680px;
}

.splash-image-frame {
  width: 540px;
  height: 540px;
  background: #07050c;
  border: 3px solid #3c345c;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.splash-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
}

.splash-cta-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.splash-enter-btn {
  font-size: 13px;
  padding: 12px 24px;
  background: linear-gradient(180deg, #ff2a54 0%, #c80032 100%);
  border: 3px solid var(--neon-yellow);
  color: #ffffff;
  text-shadow: 2px 2px 0 #000;
  animation: splashPulse 1.1s infinite alternate;
}

.splash-subprompt {
  font-size: 9px;
  color: var(--neon-cyan);
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 #000;
}

@keyframes splashPulse {
  from {
    transform: scale(1);
    box-shadow: 3px 3px 0px #000, 0 0 10px rgba(255, 42, 84, 0.5);
  }
  to {
    transform: scale(1.03);
    box-shadow: 3px 3px 0px #000, 0 0 22px rgba(255, 230, 0, 0.75);
  }
}

.panel-card {
  width: 910px;
  max-height: 685px;
  background: var(--panel-bg);
  border: 4px solid var(--neon-cyan);
  box-shadow:
    0 0 0 4px #000,
    0 12px 35px rgba(0, 0, 0, 0.9);
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-title-banner {
  text-align: center;
  background: linear-gradient(90deg, #161029, #311b52, #161029);
  border: 2px solid #594480;
  padding: 10px;
}

.panel-title-banner.gold {
  background: linear-gradient(90deg, #2b1d05, #5e4107, #2b1d05);
  border-color: var(--neon-yellow);
}

.panel-title-banner h2 {
  font-size: 18px;
  color: var(--neon-yellow);
  text-shadow: 3px 3px 0px #000;
  margin-bottom: 6px;
}

.panel-title-banner .subtitle {
  font-size: 9px;
  color: #cfc6eb;
  letter-spacing: 0.8px;
}

/* Lobby Callsign + Host bar */
.lobby-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #141022;
  border: 2px solid #382e5c;
  padding: 10px 14px;
}

.callsign-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  color: var(--neon-cyan);
}

.callsign-group input {
  font-family: var(--pixel-font);
  font-size: 11px;
  background: #08060e;
  color: var(--neon-yellow);
  border: 2px solid #6b5b95;
  padding: 6px 10px;
  width: 180px;
  text-transform: uppercase;
  outline: none;
}

.callsign-group input:focus {
  border-color: var(--neon-yellow);
}

.host-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bot-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #e0d8ff;
}

#botCountLabel {
  color: var(--neon-yellow);
  min-width: 16px;
  text-align: center;
}

/* Truck Selection Grid (4x2 for 8 distinct RC cars) */
.truck-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.truck-card {
  background: #181429;
  border: 3px solid #3c3260;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
}

.truck-card:hover {
  border-color: #8c7ae6;
  background: #211b38;
}

.truck-card.selected {
  border-color: var(--neon-yellow);
  background: #261e3f;
  box-shadow: inset 0 0 14px rgba(255, 230, 0, 0.22);
}

.truck-preview-canvas {
  width: 56px;
  height: 82px;
  background: transparent;
  border: none;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.truck-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.truck-name {
  font-size: 9px;
  color: #ffffff;
  line-height: 1.25;
}

.truck-desc {
  font-family: var(--mono-font);
  font-size: 15px;
  color: #a99ec7;
  line-height: 1.1;
}

.truck-picked-badge {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 8px;
  background: var(--neon-yellow);
  color: #000;
  padding: 2px 5px;
}

/* Roster Section */
.roster-section {
  background: #120e1e;
  border: 2px solid #362c54;
  padding: 10px 12px;
}

.roster-header {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #9e91c7;
  margin-bottom: 8px;
}

.controls-hint {
  color: var(--neon-green);
}

.roster-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.roster-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e1833;
  border: 2px solid #4e4178;
  padding: 5px 10px;
  font-size: 9px;
}

.roster-pill.is-me {
  border-color: var(--neon-cyan);
}

.roster-pill.is-host::before {
  content: "★ HOST";
  background: var(--neon-yellow);
  color: #000;
  padding: 2px 4px;
  font-size: 7px;
}

.color-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border: 1px solid #fff;
}

/* Double-G Start Banner */
.start-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: linear-gradient(90deg, #1b0c1a, #3b0d2c, #1b0c1a);
  border: 3px solid var(--neon-red);
  padding: 12px 16px;
}

.g-key-indicator {
  display: flex;
  gap: 6px;
}

.keycap {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  background: #251f38;
  border: 3px solid #75689e;
  box-shadow: 0 3px 0 #000;
  font-size: 12px;
  color: #887bb0;
  transition: all 0.12s;
}

.keycap.lit {
  background: var(--neon-yellow);
  color: #000;
  border-color: #fff;
  transform: translateY(2px);
  box-shadow: 0 1px 0 #000, 0 0 12px var(--neon-yellow);
}

.start-text {
  font-size: 11px;
  color: #fff;
  line-height: 1.5;
}

.start-text strong {
  color: var(--neon-yellow);
}

/* Podium & Trophies */
.podium-stage {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 20px;
  padding: 12px 10px 4px;
  min-height: 220px;
}

.podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 220px;
}

.trophy-card {
  width: 100%;
  background: #19142b;
  border: 3px solid #554882;
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.podium-spot.place-1 .trophy-card {
  border-color: #ffd700;
  background: #282009;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.28);
}

.podium-spot.place-2 .trophy-card {
  border-color: #d8e2ef;
  background: #1c222e;
}

.podium-spot.place-3 .trophy-card {
  border-color: #e08d44;
  background: #26180f;
}

.trophy-canvas {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
}

.podium-driver {
  font-size: 11px;
  color: #fff;
}

.podium-time {
  font-family: var(--mono-font);
  font-size: 20px;
  color: var(--neon-cyan);
}

.podium-pillar {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  color: #000;
  font-weight: bold;
  border: 3px solid #fff;
  border-top: none;
}

.place-1 .podium-pillar {
  height: 54px;
  background: linear-gradient(180deg, #ffe600, #c89600);
}

.place-2 .podium-pillar {
  height: 38px;
  background: linear-gradient(180deg, #e2ebf5, #8c9bae);
}

.place-3 .podium-pillar {
  height: 28px;
  background: linear-gradient(180deg, #f3a157, #a4561c);
}

/* Results Table */
.results-table-wrap {
  max-height: 175px;
  overflow-y: auto;
  border: 2px solid #3c3260;
  background: #100c1c;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.results-table th {
  background: #231b3d;
  color: var(--neon-yellow);
  padding: 8px;
  text-align: left;
  border-bottom: 2px solid #483b75;
}

.results-table td {
  padding: 8px;
  border-bottom: 1px solid #261e40;
  color: #e4def7;
}

.results-table tr.highlight-me td {
  background: rgba(0, 245, 212, 0.15);
  color: var(--neon-cyan);
}

@keyframes pulseGlow {
  from { transform: scale(1); filter: drop-shadow(0 0 2px var(--neon-cyan)); }
  to { transform: scale(1.12); filter: drop-shadow(0 0 8px var(--neon-yellow)); }
}

/* Side Player Chat Panel */
.chat-sidebar {
  width: 280px;
  height: 720px;
  flex-shrink: 0;
  background: #100c1c;
  border-left: 4px solid #3c345c;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(90deg, #1b122c, #291a44);
  border-bottom: 2px solid #493f6e;
}

.chat-title {
  font-size: 9px;
  color: var(--neon-yellow);
  letter-spacing: 0.4px;
}

.chat-channel {
  font-size: 8px;
  background: #0b0812;
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  padding: 3px 6px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: text;
}

.chat-system-msg {
  font-family: var(--mono-font);
  font-size: 15px;
  color: #8f82b8;
  background: rgba(56, 46, 92, 0.25);
  border-left: 2px solid var(--neon-cyan);
  padding: 4px 8px;
  line-height: 1.25;
}

.chat-msg {
  background: #181329;
  border: 1px solid #332952;
  padding: 6px 8px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.chat-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  gap: 6px;
}

.chat-sender {
  font-size: 8px;
  color: var(--neon-cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  font-family: var(--mono-font);
  font-size: 13px;
  color: #6f6394;
  flex-shrink: 0;
}

.chat-text {
  font-family: var(--mono-font);
  font-size: 17px;
  color: #f2eeff;
  line-height: 1.2;
}

.chat-form {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: #161126;
  border-top: 2px solid #493f6e;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono-font);
  font-size: 17px;
  background: #08060e;
  color: #ffffff;
  border: 2px solid #5c4e88;
  padding: 5px 8px;
  outline: none;
  user-select: text;
}

.chat-form input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 6px rgba(0, 245, 212, 0.3);
}

