/* ==========================================================================
   WOPR — CRT green-phosphor terminal styling
   ========================================================================== */

@font-face {
  font-family: 'VT323';
  src: url('https://fonts.gstatic.com/s/vt323/v17/pxiKyp0ihIEF2isfFJU.woff2') format('woff2');
  font-display: swap;
}

:root {
  --phosphor: #33ff66;
  --phosphor-dim: #1aaa3d;
  --phosphor-bright: #a6ffc2;
  --phosphor-amber: #ffb347;
  --phosphor-red: #ff4d4d;
  --bg: #020602;
  --bg-mid: #061006;
  --scanline: rgba(0, 0, 0, 0.28);
  --glow: 0 0 2px var(--phosphor), 0 0 6px rgba(51, 255, 102, 0.55);
  --glow-strong: 0 0 3px var(--phosphor-bright), 0 0 10px rgba(166, 255, 194, 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'VT323', 'Courier New', ui-monospace, monospace;
  color: var(--phosphor);
}

body.crt {
  background:
    radial-gradient(ellipse at center, #071207 0%, #020602 65%, #000 100%);
  text-shadow: var(--glow);
  -webkit-font-smoothing: none;
  font-smooth: never;
  cursor: default;
  user-select: none;
}

/* Scanlines overlay */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background:
    repeating-linear-gradient(
      to bottom,
      var(--scanline) 0px,
      var(--scanline) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: multiply;
}

/* CRT vignette + curvature suggestion */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgba(0, 0, 0, 0.55) 90%,
    rgba(0, 0, 0, 0.9) 100%
  );
}

/* subtle flicker */
.flicker {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9996;
  background: var(--phosphor);
  opacity: 0;
  mix-blend-mode: overlay;
  animation: flicker 7s infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 0; }
  47% { opacity: 0; }
  48% { opacity: 0.03; }
  49% { opacity: 0; }
  77% { opacity: 0; }
  78% { opacity: 0.05; }
  79% { opacity: 0; }
}

/* Main screen */
.screen {
  position: relative;
  z-index: 1;
  height: 100vh;
  width: 100vw;
  padding: clamp(16px, 3vw, 48px);
  font-size: clamp(16px, 1.8vw, 22px);
  line-height: 1.25;
  letter-spacing: 0.02em;
  overflow-y: auto;
  overflow-x: hidden;
}
.screen::-webkit-scrollbar { width: 8px; }
.screen::-webkit-scrollbar-thumb { background: var(--phosphor-dim); }
.screen::-webkit-scrollbar-track { background: transparent; }

/* Output lines from the terminal */
.tline {
  white-space: pre-wrap;
  margin: 0;
  min-height: 1.25em;
}
.tline.dim { color: var(--phosphor-dim); text-shadow: 0 0 2px rgba(26, 170, 61, 0.5); }
.tline.bright { color: var(--phosphor-bright); text-shadow: var(--glow-strong); }
.tline.amber { color: var(--phosphor-amber); text-shadow: 0 0 4px rgba(255, 179, 71, 0.7); }
.tline.red { color: var(--phosphor-red); text-shadow: 0 0 4px rgba(255, 77, 77, 0.7); }
.tline.center { text-align: center; }

/* blinking cursor */
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--phosphor);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s steps(2, start) infinite;
  box-shadow: var(--glow);
}
@keyframes blink { to { visibility: hidden; } }

/* Input prompt styling */
.prompt {
  display: inline;
  color: var(--phosphor);
}
.input-line input {
  background: transparent;
  border: 0;
  color: var(--phosphor);
  font: inherit;
  text-shadow: var(--glow);
  outline: none;
  width: 20ch;
  caret-color: var(--phosphor);
  letter-spacing: inherit;
}

/* Menu list */
.menu {
  list-style: none;
  padding: 0;
  margin: 0.5em 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.1em 3em;
  max-width: 120ch;
}
.menu li {
  padding: 0.05em 0;
  white-space: nowrap;
}
.menu .num { color: var(--phosphor-dim); margin-right: 0.6em; }
.menu .coming { color: var(--phosphor-dim); font-size: 0.85em; margin-left: 0.5em; }

/* Chess board */
.chess-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1em;
  margin-top: 0.5em;
}
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 2.1ch);
  grid-template-rows: repeat(8, 1.6em);
  border: 1px solid var(--phosphor-dim);
  font-size: 1.3em;
  line-height: 1.6em;
}
.chess-sq {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chess-sq.light { background: rgba(51, 255, 102, 0.08); }
.chess-sq.dark  { background: rgba(51, 255, 102, 0.02); }
.chess-sq.sel { outline: 1px solid var(--phosphor-bright); outline-offset: -2px; }
.chess-sq.hint::after {
  content: '·';
  color: var(--phosphor-bright);
  font-size: 1.4em;
}
.chess-sq.last { background: rgba(255, 179, 71, 0.15); }
.chess-coords {
  display: flex;
  gap: 1.6em;
  font-size: 0.9em;
  color: var(--phosphor-dim);
  margin-top: 0.2em;
}
.chess-log {
  max-height: 10em;
  overflow-y: auto;
  border: 1px solid var(--phosphor-dim);
  padding: 0.4em 0.8em;
  width: 28ch;
  font-size: 0.95em;
}
.chess-hud {
  display: flex;
  gap: 2em;
  align-items: flex-start;
}

/* GTNW map */
.gtnw-wrap {
  display: grid;
  grid-template-columns: 1fr 32ch;
  gap: 1em;
  height: calc(100vh - 4em);
  min-height: 500px;
}
.gtnw-map {
  border: 1px solid var(--phosphor-dim);
  position: relative;
  overflow: hidden;
}
.gtnw-map svg {
  width: 100%;
  height: 100%;
  display: block;
}
.gtnw-side {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  overflow: hidden;
}
.gtnw-panel {
  border: 1px solid var(--phosphor-dim);
  padding: 0.5em 0.8em;
}
.gtnw-panel h3 {
  margin: 0 0 0.3em 0;
  font-weight: normal;
  font-size: 1em;
  color: var(--phosphor-bright);
  letter-spacing: 0.1em;
}
.gtnw-log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.9em;
}
.gtnw-scoreboard {
  font-size: 0.9em;
}
.gtnw-scoreboard table { width: 100%; border-collapse: collapse; }
.gtnw-scoreboard th, .gtnw-scoreboard td {
  text-align: left;
  padding: 0.1em 0.3em;
  font-weight: normal;
}
.gtnw-scoreboard th { color: var(--phosphor-bright); border-bottom: 1px solid var(--phosphor-dim); }
.gtnw-scoreboard td.num { text-align: right; font-variant-numeric: tabular-nums; }

.scenario-pick {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin-top: 0.5em;
}
.scenario-pick button,
.action-btn {
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor);
  font: inherit;
  padding: 0.25em 0.8em;
  text-shadow: var(--glow);
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.05em;
}
.scenario-pick button:hover,
.action-btn:hover {
  background: rgba(51, 255, 102, 0.1);
  color: var(--phosphor-bright);
  text-shadow: var(--glow-strong);
}

/* Hide until ready */
.hidden { display: none !important; }

/* Small screens */
@media (max-width: 900px) {
  .menu { columns: 1; }
  .gtnw-wrap { grid-template-columns: 1fr; height: auto; }
  .gtnw-map { min-height: 50vh; }
}
