/* =============================================================================
   VimSurfers 3D - Retro Arcade & Pixel Art Design System
   ============================================================================= */

:root {
  --arcade-bg: #0a0714;
  --cabinet-frame: #181328;
  --cabinet-border: #322650;

  /* Vibrant Retro 8-bit / 16-bit Arcade Colors */
  --pixel-green: #39ff14;
  --pixel-cyan: #00f0ff;
  --pixel-yellow: #ffe600;
  --pixel-magenta: #ff007f;
  --pixel-red: #ff2a4b;
  --pixel-white: #ffffff;
  --pixel-dark: #000000;
  --pixel-gray: #7a7a90;

  --font-pixel: 'Press Start 2P', monospace;
  --font-silk: 'Silkscreen', monospace;
  --font-code: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--arcade-bg);
  color: var(--pixel-white);
  font-family: var(--font-pixel);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 50% 20%, #1f143d 0%, transparent 60%),
    linear-gradient(#07050d, #07050d);
}

/* Arcade Cabinet Container */
.arcade-cabinet {
  width: 95vw;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  border: 4px solid var(--cabinet-border);
  box-shadow: 
    0 0 0 4px #000000,
    0 16px 40px rgba(0, 0, 0, 0.95);
  background: var(--cabinet-frame);
  border-radius: 4px;
}

/* Header Marquee */
.arcade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #110d22;
  border-bottom: 4px solid #000000;
}

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

.pixel-star {
  color: var(--pixel-yellow);
  font-size: 16px;
  animation: pulseStar 1s infinite alternate;
}

@keyframes pulseStar {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(1.2); opacity: 1; text-shadow: 0 0 8px var(--pixel-yellow); }
}

.marquee-title {
  font-family: var(--font-pixel);
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--pixel-yellow);
  text-shadow: 2px 2px 0px #000000, 0 0 10px rgba(255, 230, 0, 0.5);
}

.marquee-badge {
  font-family: var(--font-silk);
  font-size: 10px;
  font-weight: 700;
  background: var(--pixel-magenta);
  color: #fff;
  padding: 3px 6px;
  border: 2px solid #000000;
  box-shadow: 2px 2px 0px #000000;
}

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

/* Chunky Pixel Buttons */
.pixel-btn {
  font-family: var(--font-pixel);
  cursor: pointer;
  border: 3px solid #000000;
  box-shadow: 3px 3px 0px #000000;
  background: #282042;
  color: var(--pixel-white);
  transition: all 0.05s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.pixel-btn:hover {
  filter: brightness(1.15);
}

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

.pixel-btn.sm {
  font-size: 9px;
  padding: 6px 10px;
}

.pixel-btn.lg {
  font-size: 12px;
  padding: 14px 24px;
}

.pixel-btn.primary {
  background: var(--pixel-green);
  color: #000000;
  font-weight: 800;
  box-shadow: 4px 4px 0px #000000;
}

.pixel-btn.primary:hover {
  background: #4eff2a;
}

.pixel-btn.secondary {
  background: var(--pixel-cyan);
  color: #000000;
  font-weight: 800;
  box-shadow: 4px 4px 0px #000000;
}

.pixel-btn.tutorial {
  background: var(--pixel-yellow);
  color: #000000;
  font-weight: 800;
  box-shadow: 4px 4px 0px #000000;
}

.pixel-btn.tutorial:hover {
  background: #fff066;
}

.pixel-btn.danger {
  background: var(--pixel-red);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 3px 3px 0px #000000;
}

.pixel-btn.danger:hover {
  background: #ff4d6a;
}

.pixel-btn.active {
  background: var(--pixel-magenta);
  color: #ffffff;
}

/* 3D Viewport Frame */
.viewport-frame {
  position: relative;
  width: 100%;
  height: 580px;
  background: #000000;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* CRT Scanlines Filter (Disabled by default) */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  z-index: 5;
  display: none; /* Off by default to keep view clean */
}

.crt-overlay.active {
  display: block;
}

/* Arcade Floating Toast (Positioned below header banner to prevent overlap) */
.hud-toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(-15px);
  background: #000000;
  border: 3px solid var(--pixel-green);
  box-shadow: 4px 4px 0px #000000, 0 0 16px var(--pixel-green);
  color: var(--pixel-green);
  padding: 8px 22px;
  font-size: 11px;
  font-family: var(--font-pixel);
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: all 0.18s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  white-space: nowrap;
}

.hud-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Rewind Undo Overlay Banner */
.hud-rewind {
  position: absolute;
  top: 112px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff0055;
  color: #ffffff;
  border: 3px solid #000000;
  box-shadow: 4px 4px 0px #000000, 0 0 25px #ff0055;
  padding: 10px 24px;
  font-family: var(--font-pixel);
  font-size: 12px;
  font-weight: 800;
  z-index: 20;
  letter-spacing: 1px;
  white-space: nowrap;
  animation: rewindPulse 0.35s infinite alternate;
}

.hud-rewind.hidden {
  display: none !important;
}

@keyframes rewindPulse {
  from { opacity: 0.85; transform: translateX(-50%) scale(0.97); }
  to { opacity: 1.0; transform: translateX(-50%) scale(1.03); }
}

/* In-Game Retro HUD */
.retro-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

/* Ensure all HUD interactive elements capture mouse clicks */
.retro-hud button,
.retro-hud .pixel-btn,
#btn-exit-tutorial,
.tut-nav-btn {
  pointer-events: auto !important;
  cursor: pointer;
}

.hud-box {
  background: rgba(0, 0, 0, 0.8);
  border: 3px solid #000000;
  box-shadow: 3px 3px 0px #000000;
  padding: 6px 12px;
}

.hud-tag {
  font-family: var(--font-silk);
  font-size: 9px;
  font-weight: 700;
  color: var(--pixel-gray);
  display: block;
  margin-bottom: 2px;
}

/* Lives */
.pixel-hearts {
  display: flex;
  gap: 6px;
  font-size: 16px;
}

.p-heart.active {
  color: var(--pixel-red);
  text-shadow: 2px 2px 0px #000000;
}

.p-heart.lost {
  color: #383844;
}

/* Streak Multiplier & Tutorial Banner */
.hud-center-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hud-streak {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--pixel-yellow);
  background: #000000;
  border: 3px solid var(--pixel-yellow);
  box-shadow: 3px 3px 0px #000000;
  padding: 6px 14px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.hud-tutorial-banner {
  background: #000000;
  border: 3px solid var(--pixel-cyan);
  box-shadow: 4px 4px 0px #000000, 0 0 16px rgba(0, 240, 255, 0.5);
  color: var(--pixel-white);
  padding: 5px 10px;
  font-size: 10px;
  font-family: var(--font-pixel);
  display: flex;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
  pointer-events: auto;
}

.tut-banner-text {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tut-nav-btn {
  background: #1a162b;
  color: var(--pixel-cyan);
  border: 2px solid var(--pixel-cyan);
  font-family: var(--font-pixel);
  font-size: 11px;
  padding: 4px 8px;
  line-height: 1;
  transition: all 0.1s ease;
}

.tut-nav-btn:hover {
  background: var(--pixel-cyan);
  color: #000000;
  transform: scale(1.08);
}

.tut-nav-btn:active {
  transform: scale(0.95);
}

.hud-tutorial-banner #tut-step-num {
  color: var(--pixel-yellow);
}

.hud-tutorial-banner #tut-step-text {
  color: var(--pixel-cyan);
}

.hud-tutorial-banner.hidden {
  display: none !important;
}

.hud-right-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Prominent Exit Tutorial Button */
#btn-exit-tutorial {
  pointer-events: auto !important;
  cursor: pointer;
  background: #ff0044;
  color: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 4px 4px 0px #000000, 0 0 14px rgba(255, 0, 68, 0.6);
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 800;
  padding: 8px 14px;
  letter-spacing: 0.5px;
  transition: all 0.12s ease;
}

#btn-exit-tutorial:hover {
  background: #ff2a66;
  transform: scale(1.05);
  box-shadow: 5px 5px 0px #000000, 0 0 20px rgba(255, 42, 102, 0.9);
}

#btn-exit-tutorial:active {
  transform: scale(0.96) translate(2px, 2px);
  box-shadow: 2px 2px 0px #000000;
}

#btn-exit-tutorial.hidden {
  display: none !important;
}

/* Score & Collectibles */
.score-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.score-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.score-num {
  font-size: 14px;
  color: var(--pixel-yellow);
  text-shadow: 2px 2px 0px #000000;
}

.coins-line {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 9px;
}

.coin.gold { color: var(--pixel-yellow); }
.coin.ruby { color: var(--pixel-red); }
.coin.diamond { color: var(--pixel-cyan); }

/* Retro Terminal Statusline */
.terminal-statusline {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 28px;
  background: #000000;
  border-top: 3px solid #000000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-code);
  font-size: 11px;
  font-weight: 700;
  z-index: 10;
  padding: 0 8px;
}

.status-sec {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-badge {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 3px 6px;
  border: 1px solid #000000;
}

.mode-badge.normal {
  background: var(--pixel-green);
  color: #000000;
}

.mode-badge.insert {
  background: var(--pixel-yellow);
  color: #000000;
}

.branch-tag { color: var(--pixel-gray); }
.file-tag { color: var(--pixel-white); }
.buffer-tag { color: var(--pixel-yellow); font-family: var(--font-pixel); font-size: 9px; }
.pos-tag { color: var(--pixel-cyan); }

/* Retro Modals */
.retro-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 6, 14, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 25;
}

.retro-modal.hidden {
  display: none !important;
}

.retro-box {
  width: 480px;
  max-width: 90%;
  background: #140f26;
  border: 4px solid var(--pixel-white);
  box-shadow: 
    0 0 0 4px #000000,
    6px 6px 0px #000000;
  padding: 22px 24px;
  text-align: center;
}

.box-decorations {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.d-dot {
  width: 8px;
  height: 8px;
  border: 1px solid #000000;
}
.d-dot.red { background: var(--pixel-red); }
.d-dot.yellow { background: var(--pixel-yellow); }
.d-dot.green { background: var(--pixel-green); }

.game-logo {
  font-size: 20px;
  color: var(--pixel-yellow);
  text-shadow: 3px 3px 0px #000000;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.game-byline {
  font-family: var(--font-silk);
  font-size: 9px;
  color: var(--pixel-cyan);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

/* Persistent High Score Badge on Main Menu */
.menu-highscore-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #1e1438;
  border: 2px solid var(--pixel-yellow);
  box-shadow: 0 0 10px rgba(255, 234, 0, 0.25), 2px 2px 0px #000000;
  padding: 6px 14px;
  margin: 0 auto 16px;
}

.menu-highscore-badge .trophy-icon {
  font-size: 14px;
}

.menu-highscore-badge .trophy-label {
  font-family: var(--font-silk);
  font-size: 8px;
  color: var(--pixel-gray);
  letter-spacing: 1px;
}

.menu-highscore-badge .trophy-score {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--pixel-yellow);
  text-shadow: 1px 1px 0px #000000;
  letter-spacing: 1.5px;
}

.new-high-badge {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: #000000;
  background: var(--pixel-yellow);
  border: 2px solid #ffffff;
  padding: 4px 10px;
  display: inline-block;
  margin-bottom: 10px;
  animation: newHighPulse 0.6s infinite alternate ease-in-out;
}

@keyframes newHighPulse {
  from { transform: scale(0.96); box-shadow: 0 0 4px var(--pixel-yellow); }
  to { transform: scale(1.04); box-shadow: 0 0 14px var(--pixel-yellow); }
}

/* Tier Pills */
.tier-pills {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}

.tier-pill {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 8px 12px;
  background: #221a3a;
  color: var(--pixel-white);
  border: 2px solid #000000;
  box-shadow: 2px 2px 0px #000000;
  cursor: pointer;
  transition: all 0.1s;
}

.tier-pill:hover {
  background: #322654;
}

.tier-pill.selected {
  background: var(--pixel-magenta);
  color: #ffffff;
  border-color: #000000;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px #000000;
}

/* Action Buttons (Only 2) */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.action-buttons .pixel-btn {
  width: 260px;
}

.key-hint {
  font-family: var(--font-silk);
  font-size: 10px;
  color: var(--pixel-gray);
}

kbd {
  font-family: var(--font-pixel);
  font-size: 8px;
  background: #000000;
  color: var(--pixel-yellow);
  padding: 2px 6px;
  border: 1px solid #333344;
}

/* Game Over */
.gameover-title {
  font-size: 22px;
  color: var(--pixel-red);
  text-shadow: 3px 3px 0px #000000;
  margin-bottom: 8px;
}

.gameover-reason {
  font-family: var(--font-silk);
  font-size: 9px;
  color: var(--pixel-gray);
  margin-bottom: 14px;
}

.final-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.f-stat {
  background: #0d091a;
  border: 2px solid #000000;
  padding: 10px;
}

.f-label {
  font-family: var(--font-silk);
  font-size: 8px;
  color: var(--pixel-gray);
  display: block;
  margin-bottom: 4px;
}

.f-val {
  font-size: 14px;
  color: var(--pixel-yellow);
}

.f-coins {
  font-size: 10px;
  color: var(--pixel-cyan);
  margin-bottom: 20px;
}

/* Pause */
.pause-box {
  width: 360px;
}

.pause-title {
  font-size: 18px;
  color: var(--pixel-yellow);
  margin-bottom: 8px;
}

.pause-hint {
  font-family: var(--font-silk);
  font-size: 10px;
  color: var(--pixel-gray);
  margin-bottom: 16px;
}

/* Controls Modal */
.controls-box {
  width: 520px;
  text-align: left;
}

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 2px solid #000000;
  padding-bottom: 8px;
}

.controls-header h3 {
  font-size: 12px;
  color: var(--pixel-yellow);
}

.table-scroll {
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 14px;
}

.retro-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-code);
  font-size: 11px;
}

.retro-table th {
  text-align: left;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--pixel-gray);
  padding: 6px;
  border-bottom: 2px solid #000000;
}

.retro-table td {
  padding: 6px;
  border-bottom: 1px solid #231b3c;
}

.retro-table td:first-child {
  white-space: nowrap;
}

.controls-footer {
  text-align: center;
}
