/* CONTRA: HARDFORCE - SEGA 16-BIT RETRO STYLES */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --arcade-bg: #0a0c10;
  --sega-blue: #0050d0;
  --sega-gold: #ffcc00;
  --contra-red: #e62020;
  --contra-orange: #ff6600;
  --alien-green: #00ff66;
  --hud-bg: rgba(8, 12, 20, 0.85);
  --border-color: #334466;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--arcade-bg);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-image: 
    radial-gradient(circle at 50% 20%, rgba(20, 30, 60, 0.4) 0%, transparent 60%),
    linear-gradient(180deg, #05070a 0%, #0d1117 100%);
}

/* Master Wrapper */
#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 1280px;
  max-height: 720px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 50px rgba(0, 80, 208, 0.25), 0 0 20px rgba(0, 0, 0, 0.8);
  border: 4px solid #1a2233;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

/* Header Bar */
#top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: rgba(10, 14, 24, 0.95);
  border-bottom: 2px solid #223355;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 10px;
  z-index: 50;
  letter-spacing: 1px;
}

.logo-badge {
  color: var(--sega-gold);
  text-shadow: 2px 2px 0 #000, 0 0 8px rgba(255, 204, 0, 0.6);
  font-weight: bold;
}

.top-controls {
  display: flex;
  gap: 12px;
}

.top-btn {
  background: #1e293b;
  border: 1px solid #475569;
  color: #cbd5e1;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.top-btn:hover {
  background: #334155;
  color: #fff;
  border-color: var(--sega-gold);
}

.top-btn.active {
  background: var(--contra-red);
  border-color: #ff8888;
  color: #fff;
}

/* Canvas Viewport */
#canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* CRT Scanline Overlay */
#crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 4px, 6px 100%;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6);
  opacity: 1;
  transition: opacity 0.2s ease;
}

#crt-overlay.disabled {
  opacity: 0;
}

/* Touch Controls (Mobile Friendly) */
#mobile-controls {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  height: 160px;
  pointer-events: none;
  z-index: 40;
  display: none;
  padding: 10px 24px;
  justify-content: space-between;
  align-items: flex-end;
}

@media (pointer: coarse), (max-width: 900px) {
  #mobile-controls {
    display: flex;
  }
}

.touch-group {
  pointer-events: auto;
  position: relative;
}

/* Virtual D-Pad */
.dpad {
  width: 140px;
  height: 140px;
  position: relative;
}

.dpad-btn {
  position: absolute;
  background: rgba(30, 45, 75, 0.75);
  border: 2px solid rgba(100, 150, 255, 0.5);
  border-radius: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  user-select: none;
}

.dpad-btn:active, .dpad-btn.pressed {
  background: rgba(0, 130, 255, 0.85);
  border-color: #fff;
}

.dpad-up { top: 0; left: 46px; width: 48px; height: 48px; }
.dpad-down { bottom: 0; left: 46px; width: 48px; height: 48px; }
.dpad-left { top: 46px; left: 0; width: 48px; height: 48px; }
.dpad-right { top: 46px; right: 0; width: 48px; height: 48px; }
.dpad-center { top: 46px; left: 46px; width: 48px; height: 48px; background: rgba(15, 25, 45, 0.6); border: none; border-radius: 4px; }

/* Action Buttons */
.action-cluster {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.action-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 9px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  user-select: none;
}

.btn-fire {
  background: radial-gradient(circle, #ff4444, #990000);
  border-color: #ff9999;
}
.btn-jump {
  background: radial-gradient(circle, #00ccff, #005599);
  border-color: #99eeff;
}
.btn-dash {
  background: radial-gradient(circle, #ffaa00, #996600);
  border-color: #ffdd88;
}

.action-btn:active, .action-btn.pressed {
  transform: scale(0.92);
  filter: brightness(1.3);
}

/* Modals & Overlays */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
  text-align: center;
}

.overlay-screen.hidden {
  display: none !important;
}

.arcade-title {
  font-size: clamp(20px, 4.2vw, 36px);
  color: var(--sega-gold);
  text-shadow: 
    3px 3px 0 var(--contra-red),
    -2px -2px 0 var(--sega-blue),
    0 0 20px rgba(255, 204, 0, 0.8);
  margin-bottom: 6px;
  letter-spacing: 2px;
  animation: titleGlow 2s ease-in-out infinite alternate;
}

.arcade-subtitle {
  font-size: clamp(9px, 1.8vw, 13px);
  color: #38bdf8;
  letter-spacing: 3px;
  margin-bottom: 20px;
}

@keyframes titleGlow {
  0% { text-shadow: 3px 3px 0 var(--contra-red), -2px -2px 0 var(--sega-blue), 0 0 15px rgba(255, 204, 0, 0.5); }
  100% { text-shadow: 4px 4px 0 var(--contra-red), -2px -2px 0 var(--sega-blue), 0 0 30px rgba(255, 100, 0, 0.9); }
}

.menu-box {
  background: rgba(15, 23, 42, 0.95);
  border: 3px solid #3b82f6;
  border-radius: 8px;
  padding: 20px 28px;
  max-width: 580px;
  width: 92%;
  box-shadow: 0 0 30px rgba(0, 100, 255, 0.3);
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  text-align: left;
  font-size: clamp(8px, 1.2vw, 10px);
  line-height: 1.8;
  margin: 14px 0 20px 0;
  background: rgba(0, 0, 0, 0.5);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #334155;
}

.key-badge {
  background: #334155;
  color: var(--sega-gold);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid #64748b;
  font-weight: bold;
}

.start-btn {
  background: linear-gradient(180deg, #ff4444 0%, #b30000 100%);
  color: #fff;
  border: 2px solid #ff9999;
  padding: 12px 26px;
  font-family: inherit;
  font-size: clamp(11px, 2vw, 14px);
  cursor: pointer;
  border-radius: 6px;
  text-shadow: 1px 1px 0 #000;
  box-shadow: 0 0 20px rgba(255, 50, 50, 0.6);
  transition: all 0.15s ease;
  animation: pulseBtn 1.5s infinite;
}

@keyframes pulseBtn {
  0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(255, 50, 50, 0.5); }
  50% { transform: scale(1.04); box-shadow: 0 0 25px rgba(255, 80, 80, 0.8); }
}

.start-btn:hover {
  background: linear-gradient(180deg, #ff6666 0%, #cc0000 100%);
  transform: scale(1.06);
}

.stats-table {
  width: 100%;
  margin: 16px 0;
  font-size: 11px;
  line-height: 2;
  text-align: left;
}
.stats-table td:last-child {
  text-align: right;
  color: var(--sega-gold);
}

/* Footer Credits */
#footer-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 22px;
  background: rgba(10, 14, 24, 0.95);
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #64748b;
  z-index: 50;
  letter-spacing: 1px;
}
