:root {
  --ph: #33ff66;
  --ph-dim: #00aa44;
  --ph-dark: #003318;
  --ph-glow: 0 0 8px rgba(51,255,102,0.65);
  --bg: #000;
  --ocean: #00060f;
  --red: #ff3333;
  --amber: #ffaa00;
}

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

body {
  background: var(--bg);
  color: var(--ph);
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
}

/* CRT scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.07) 2px,
    rgba(0,0,0,0.07) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ── Intro / Terminal ────────────────────────────────────── */
#screen-intro {
  padding: 2rem 3rem;
  overflow: hidden;
  background: #000;
  gap: 0.8rem;
}

#terminal-output {
  flex: 1;
  overflow: hidden;
  font-size: clamp(0.65rem, 1.4vw, 0.95rem);
  line-height: 1.65;
}

.tline { color: var(--ph); text-shadow: var(--ph-glow); }
.tline.dim { color: var(--ph-dim); text-shadow: none; }
.tline.input { color: #ffffff; text-shadow: 0 0 6px rgba(255,255,255,0.5); }

#terminal-choices {
  display: none;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

.choice-btn {
  background: transparent;
  border: 1px solid var(--ph);
  color: var(--ph);
  font-family: 'Courier New', monospace;
  font-size: clamp(0.75rem, 1.4vw, 1rem);
  letter-spacing: 0.15em;
  padding: 0.5rem 2rem;
  cursor: pointer;
  text-shadow: var(--ph-glow);
  box-shadow: 0 0 10px rgba(51,255,102,0.2);
  transition: all 0.2s;
}
.choice-btn:hover {
  background: rgba(51,255,102,0.1);
  box-shadow: 0 0 18px rgba(51,255,102,0.5);
}

/* ── Game Screen ─────────────────────────────────────────── */
#game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 1rem;
  border-bottom: 1px solid var(--ph-dark);
  background: #000;
  flex-shrink: 0;
}

#header-title {
  font-size: clamp(0.6rem, 1.1vw, 0.85rem);
  letter-spacing: 0.18em;
  text-shadow: var(--ph-glow);
}

#defcon-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.6rem, 1vw, 0.8rem);
  letter-spacing: 0.1em;
}
.dlabel { color: var(--ph-dim); }

#defcon-bars { display: flex; gap: 3px; align-items: center; }

.defcon-bar {
  width: 13px;
  height: 11px;
  border: 1px solid var(--ph-dark);
  transition: all 0.4s;
}

#defcon-num {
  font-size: clamp(0.75rem, 1.3vw, 1rem);
  font-weight: bold;
  min-width: 1.2rem;
  text-align: center;
  transition: all 0.4s;
}

#header-time {
  font-size: clamp(0.55rem, 0.95vw, 0.75rem);
  color: var(--ph-dim);
  letter-spacing: 0.08em;
  min-width: 10ch;
  text-align: right;
}

#game-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.panel {
  width: clamp(150px, 18vw, 220px);
  display: flex;
  flex-direction: column;
  background: #000;
  padding: 0.5rem 0.6rem;
  overflow: hidden;
  flex-shrink: 0;
}
#panel-left { border-right: 1px solid var(--ph-dark); }
#panel-right { border-left: 1px solid var(--ph-dark); }

.panel-title {
  font-size: clamp(0.55rem, 0.9vw, 0.75rem);
  letter-spacing: 0.22em;
  border-bottom: 1px solid var(--ph-dark);
  padding-bottom: 0.3rem;
  margin-bottom: 0.4rem;
  color: var(--ph);
  text-shadow: var(--ph-glow);
  flex-shrink: 0;
}

#missile-count {
  font-size: clamp(0.5rem, 0.85vw, 0.7rem);
  color: var(--ph-dim);
  margin-bottom: 0.4rem;
  flex-shrink: 0;
}

#target-list, #enemy-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
#target-list::-webkit-scrollbar,
#enemy-list::-webkit-scrollbar { width: 3px; }
#target-list::-webkit-scrollbar-thumb,
#enemy-list::-webkit-scrollbar-thumb { background: var(--ph-dark); }

.target-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.18rem 0.3rem;
  margin-bottom: 0.12rem;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: clamp(0.48rem, 0.82vw, 0.67rem);
  color: var(--ph-dim);
  transition: all 0.12s;
}
.target-item:hover { border-color: var(--ph-dark); background: rgba(51,255,102,0.04); color: var(--ph); }
.target-item.selected { color: var(--amber); border-color: rgba(255,170,0,0.3); }
.target-item.destroyed { color: var(--red); opacity: 0.6; text-decoration: line-through; cursor: default; }

.t-pips { color: var(--amber); letter-spacing: 1px; font-size: 0.6rem; }

.launch-btn {
  margin-top: 0.5rem;
  background: transparent;
  border: 2px solid var(--amber);
  color: var(--amber);
  font-family: 'Courier New', monospace;
  font-size: clamp(0.65rem, 1.1vw, 0.82rem);
  letter-spacing: 0.2em;
  padding: 0.4rem 0.3rem;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(255,170,0,0.7);
  box-shadow: 0 0 8px rgba(255,170,0,0.2);
  transition: all 0.2s;
  flex-shrink: 0;
}
.launch-btn:hover:not(:disabled) {
  background: rgba(255,170,0,0.12);
  box-shadow: 0 0 18px rgba(255,170,0,0.6);
}
.launch-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.launch-btn.armed {
  border-color: var(--red);
  color: var(--red);
  text-shadow: 0 0 10px rgba(255,50,50,0.9);
  box-shadow: 0 0 12px rgba(255,50,50,0.4);
  animation: pulse-red 0.9s ease-in-out infinite;
}
@keyframes pulse-red { 50% { box-shadow: 0 0 22px rgba(255,50,50,0.8); } }

#casualties-display {
  margin-top: 0.5rem;
  border-top: 1px solid var(--ph-dark);
  padding-top: 0.4rem;
  flex-shrink: 0;
}
.cas-label {
  font-size: clamp(0.48rem, 0.78vw, 0.62rem);
  color: var(--ph-dim);
  letter-spacing: 0.1em;
  margin-bottom: 0.15rem;
}
#casualties-count {
  font-size: clamp(0.72rem, 1.2vw, 0.95rem);
  color: var(--red);
  text-shadow: 0 0 8px rgba(255,50,50,0.6);
}

.enemy-item {
  padding: 0.18rem 0.3rem;
  margin-bottom: 0.1rem;
  font-size: clamp(0.48rem, 0.82vw, 0.67rem);
  border-left: 2px solid var(--red);
  color: var(--ph-dim);
}
.enemy-item.destroyed { opacity: 0.5; text-decoration: line-through; }

#map-container {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow: hidden;
}
#map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#game-footer {
  border-top: 1px solid var(--ph-dark);
  padding: 0.3rem 1rem;
  background: #000;
  flex-shrink: 0;
}
#status-bar {
  font-size: clamp(0.55rem, 0.95vw, 0.78rem);
  letter-spacing: 0.1em;
  color: var(--ph);
  text-shadow: var(--ph-glow);
}

/* ── End Screen ──────────────────────────────────────────── */
#screen-end {
  justify-content: center;
  align-items: center;
  background: #000;
  padding: 2rem;
}
#end-content {
  max-width: 680px;
  width: 100%;
}
#end-results {
  margin-bottom: 2.5rem;
}
.end-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--ph-dark);
  font-size: clamp(0.65rem, 1.2vw, 0.9rem);
  gap: 1rem;
}
.lbl { color: var(--ph-dim); }
.val { color: var(--ph); text-align: right; }
.red { color: var(--red); text-shadow: 0 0 8px rgba(255,50,50,0.6); }

#famous-quote {
  font-size: clamp(0.85rem, 1.8vw, 1.35rem);
  color: var(--ph);
  text-shadow: var(--ph-glow);
  letter-spacing: 0.05em;
  line-height: 1.7;
  min-height: 4.5em;
  margin-bottom: 2.5rem;
  white-space: pre-wrap;
}

#end-buttons { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }

.end-btn {
  background: transparent;
  border: 1px solid var(--ph);
  color: var(--ph);
  font-family: 'Courier New', monospace;
  font-size: clamp(0.65rem, 1.1vw, 0.85rem);
  letter-spacing: 0.15em;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  text-shadow: var(--ph-glow);
  box-shadow: 0 0 8px rgba(51,255,102,0.2);
  transition: all 0.2s;
}
.end-btn:hover {
  background: rgba(51,255,102,0.08);
  box-shadow: 0 0 16px rgba(51,255,102,0.5);
}
.chess-btn {
  border-color: var(--ph-dim);
  color: var(--ph-dim);
  text-shadow: none;
  box-shadow: none;
  font-size: clamp(0.55rem, 0.9vw, 0.72rem);
}
