/* Sea Wolf (1976 Retro Arcade Replica) Styling */

@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;700&family=Press+Start+2P&family=Share+Tech+Mono&display=swap');

:root {
  --bg-dark: #0a0c10;
  --cabinet-bezel: #1b1e24;
  --cabinet-border: #2d333f;
  --cabinet-accent: #3a4252;
  --ocean-blue: #081a2e;
  --led-red: #ff2a2a;
  --led-red-glow: rgba(255, 42, 42, 0.7);
  --led-amber: #ffb700;
  --led-amber-glow: rgba(255, 183, 0, 0.7);
  --led-green: #00ff66;
  --led-green-glow: rgba(0, 255, 102, 0.7);
  --periscope-green: #00ffaa;
  --text-gold: #ffd700;
  --font-retro: 'Press Start 2P', monospace;
  --font-led: 'Share Tech Mono', monospace;
  --font-tech: 'Chakra Petch', sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 50% 30%, #151c28 0%, #06080c 100%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.3) 2px, rgba(0,0,0,0.3) 4px);
  color: #fff;
  font-family: var(--font-tech);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  padding: 10px;
}

/* Outer Arcade Cabinet Frame */
.arcade-cabinet {
  position: relative;
  width: 100%;
  max-width: 960px;
  background: linear-gradient(180deg, #252a34 0%, #14171d 100%);
  border: 4px solid var(--cabinet-border);
  border-radius: 16px;
  box-shadow: 
    0 0 30px rgba(0, 0, 0, 0.9),
    inset 0 2px 4px rgba(255, 255, 255, 0.1),
    inset 0 -10px 20px rgba(0, 0, 0, 0.6);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Marquee Header */
.cabinet-marquee {
  background: linear-gradient(180deg, #11151c 0%, #080a0e 100%);
  border: 3px solid #333a48;
  border-radius: 8px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0,0,0,0.5);
}

.marquee-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.marquee-title h1 {
  font-family: var(--font-retro);
  font-size: 1.5rem;
  color: #ff3b3b;
  text-shadow: 
    0 0 5px #ff0000,
    0 0 10px #ff3b3b,
    2px 2px 0px #000;
  letter-spacing: 2px;
}

.marquee-subtitle {
  font-family: var(--font-led);
  font-size: 0.85rem;
  color: var(--text-gold);
  letter-spacing: 3px;
  text-transform: uppercase;
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

/* Cabinet Digital LED Status Bar */
.led-scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: #0d0f14;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid #222733;
}

.led-panel {
  background: #05070a;
  border: 2px solid #1a202c;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
}

.led-label {
  font-family: var(--font-retro);
  font-size: 0.55rem;
  color: #7a889b;
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.led-value {
  font-family: var(--font-led);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.led-value.red {
  color: var(--led-red);
  text-shadow: 0 0 8px var(--led-red-glow);
}

.led-value.amber {
  color: var(--led-amber);
  text-shadow: 0 0 8px var(--led-amber-glow);
}

.led-value.green {
  color: var(--led-green);
  text-shadow: 0 0 8px var(--led-green-glow);
}

/* Torpedo Ready Indicator Lights */
.torpedo-lights {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.torpedo-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #200808;
  border: 1px solid #401010;
  transition: all 0.15s ease;
}

.torpedo-light.ready {
  background: var(--led-green);
  border-color: #aaffcc;
  box-shadow: 0 0 10px var(--led-green-glow);
}

.torpedo-light.reloading {
  background: var(--led-amber);
  border-color: #ffe680;
  box-shadow: 0 0 8px var(--led-amber-glow);
  animation: pulse-reload 0.4s infinite alternate;
}

@keyframes pulse-reload {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* Screen Frame & CRT Display Container */
.screen-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #02060d;
  border: 6px solid #10141c;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 
    0 0 20px rgba(0, 0, 0, 0.9),
    inset 0 0 15px rgba(0, 0, 0, 0.8);
}

canvas#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* CRT Overlay Shader Effect */
.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%),
    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.7);
  border-radius: 6px;
  z-index: 10;
}

/* Periscope Viewport Bezel Mask (Authentic Submarine Sight) */
.periscope-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  box-shadow: inset 0 0 120px 40px rgba(0, 5, 10, 0.85);
  border-radius: 50% / 10%;
  z-index: 11;
  transition: opacity 0.3s ease;
}

.periscope-mask.disabled {
  opacity: 0;
}

/* Cabinet Control Panel */
.cabinet-controls {
  background: linear-gradient(180deg, #181d26 0%, #0e1117 100%);
  border: 2px solid #2a3140;
  border-radius: 8px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.control-instructions {
  font-family: var(--font-led);
  font-size: 0.85rem;
  color: #8a99ad;
  display: flex;
  gap: 15px;
  align-items: center;
}

.key-badge {
  background: #252d3c;
  border: 1px solid #45536c;
  color: #00ffaa;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: bold;
  box-shadow: 0 2px 0 #12161f;
}

.btn-group {
  display: flex;
  gap: 10px;
}

.arcade-btn {
  font-family: var(--font-retro);
  font-size: 0.65rem;
  padding: 10px 16px;
  border: 2px solid #fff;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.6);
}

.arcade-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.btn-primary {
  background: linear-gradient(180deg, #ff4444 0%, #cc0000 100%);
  border-color: #ff9999;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #ff6666 0%, #dd1111 100%);
  box-shadow: 0 0 12px rgba(255, 68, 68, 0.6);
}

.btn-secondary {
  background: linear-gradient(180deg, #3a4659 0%, #1e2530 100%);
  border-color: #5c6c87;
  color: #00ffaa;
  text-shadow: 0 1px 2px #000;
}

.btn-secondary:hover {
  background: linear-gradient(180deg, #4b5a73 0%, #2b3545 100%);
  box-shadow: 0 0 10px rgba(0, 255, 170, 0.3);
}

/* Modals & Overlay Screens (Attract Mode, Game Over, High Scores) */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 12, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-card {
  background: linear-gradient(180deg, #161b24 0%, #0b0e14 100%);
  border: 3px solid var(--periscope-green);
  box-shadow: 0 0 30px rgba(0, 255, 170, 0.3), inset 0 0 15px rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  padding: 30px 40px;
  max-width: 520px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.modal-card h2 {
  font-family: var(--font-retro);
  font-size: 1.4rem;
  color: var(--text-gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
  letter-spacing: 2px;
}

.modal-card p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #c0cedf;
}

.arcade-blink {
  animation: arcade-flash 1s infinite alternate;
  font-family: var(--font-retro);
  font-size: 0.8rem;
  color: #ff3b3b;
  margin-top: 10px;
}

@keyframes arcade-flash {
  0% { opacity: 0.2; }
  100% { opacity: 1; text-shadow: 0 0 8px #ff0000; }
}

.score-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  width: 100%;
  background: #07090e;
  border: 1px solid #232c3b;
  padding: 12px 18px;
  border-radius: 6px;
  font-family: var(--font-led);
  font-size: 1.1rem;
}

.score-summary-grid .label {
  color: #8899aa;
  text-align: left;
}

.score-summary-grid .val {
  color: var(--led-amber);
  text-align: right;
  font-weight: bold;
}

/* Initial Input for High Score */
.initials-input-container {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 5px;
}

.initial-box {
  width: 45px;
  height: 50px;
  background: #05070a;
  border: 2px solid var(--periscope-green);
  border-radius: 6px;
  color: var(--periscope-green);
  font-family: var(--font-retro);
  font-size: 1.4rem;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  box-shadow: 0 0 10px rgba(0, 255, 170, 0.2);
}

.initial-box:focus {
  border-color: #ffffff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

/* High Scores Table */
.high-scores-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #05070a;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #1c2432;
  font-family: var(--font-led);
  font-size: 1rem;
}

.high-score-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-bottom: 1px dashed #1a2230;
}

.high-score-row:last-child {
  border-bottom: none;
}

.high-score-row .rank { color: #5a6b82; }
.high-score-row .name { color: var(--text-gold); font-weight: bold; }
.high-score-row .score { color: var(--led-green); }

/* Responsive adjustments */
@media (max-width: 768px) {
  .arcade-cabinet {
    padding: 10px;
    gap: 10px;
  }
  .marquee-title h1 {
    font-size: 1.1rem;
  }
  .led-scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }
  .led-value {
    font-size: 1.4rem;
  }
  .control-instructions {
    font-size: 0.75rem;
    flex-wrap: wrap;
  }
  .arcade-btn {
    font-size: 0.55rem;
    padding: 8px 12px;
  }
}
