@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
  --phosphor: #33ff66;
  --phosphor-dim: #1a8f3a;
  --bg: #05130a;
  --red: #ff4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  height: 100%;
}

body {
  font-family: 'VT323', 'Courier New', monospace;
  color: var(--phosphor);
  font-size: 20px;
}

.crt-wrap {
  position: relative;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #08210f 0%, var(--bg) 70%, #000 100%);
  overflow: hidden;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 2px
  );
  z-index: 10;
}

.flicker {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: rgba(51, 255, 102, 0.02);
  z-index: 9;
  animation: flicker 6s infinite;
}

@keyframes flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.85; }
  98% { opacity: 1; }
}

.content {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
  /* Doug 2026-07-23: THE inversion (after 3 blur reports). The global
     phosphor glow smears every body-size surface; it survives only on
     large headings. So the DEFAULT is now crisp, and the glow is added
     back ONLY to the big-text selectors below. No more per-surface
     whack-a-mole — new surfaces are crisp automatically. */
}

/* the glow lives here and nowhere else — headings, logo, titles, the
   large ASCII faces (which keep their own currentColor glow) */
.topbar .brand, h1, h2, .chart-title, .decision-title, .enc-name,
.enc-title, .ship-name, .dock-title, .decision-title {
  text-shadow: 0 0 4px var(--phosphor);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--phosphor-dim);
  padding-bottom: 10px;
  margin-bottom: 20px;
}

.topbar .brand {
  font-size: 28px;
  letter-spacing: 2px;
}

.topbar nav a {
  margin-left: 20px;
}

a { color: var(--phosphor); text-decoration: none; border-bottom: 1px dotted var(--phosphor-dim); }
a:hover { color: #fff; text-shadow: 0 0 8px var(--phosphor); }

.panel {
  border: 1px solid var(--phosphor-dim);
  padding: 20px;
  margin-bottom: 20px;
  background: rgba(51, 255, 102, 0.03);
}

.ascii {
  white-space: pre-wrap;
  font-size: 18px;
  line-height: 1.3;
}

button {
  font-family: inherit;
  font-size: 20px;
  background: transparent;
  color: var(--phosphor);
  border: 1px solid var(--phosphor);
  padding: 8px 16px;
  cursor: pointer;
  margin-right: 10px;
  margin-top: 10px;
}

button:hover {
  background: var(--phosphor);
  color: #000;
}

input {
  font-family: inherit;
  font-size: 20px;
  background: #000;
  color: var(--phosphor);
  border: 1px solid var(--phosphor-dim);
  padding: 4px 8px;
}

.deliver-btn {
  border-color: #ffb000 !important;
  color: #ffb000 !important;
  font-weight: bold;
}
.deliver-btn:hover { background: #ffb000 !important; color: #000 !important; }

.nav-readout {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.4;
  color: #ffb000;                 /* amber — the contract wayfinding colour */
  border-top: 1px solid rgba(255,176,0,0.3);
  padding-top: 5px;
}
.nav-readout .nav-arrived { color: #aaffcc; }
.nav-readout div { margin-top: 2px; }

.back-to-port {
  display: inline-block;
  border: 1px solid var(--phosphor);
  padding: 6px 14px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.back-to-port:hover { background: var(--phosphor); color: #000; }

.hidden { display: none !important; }

.hud {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--phosphor-dim);
  padding: 6px 14px;
  margin-bottom: 6px;
  font-size: 18px;
}

#game-canvas {
  width: 100%;
  border: 1px solid var(--phosphor-dim);
  background: #010902;
  display: block;
}

table.board {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

table.board th, table.board td {
  border-bottom: 1px solid var(--phosphor-dim);
  padding: 6px 10px;
  text-align: left;
}

ol { padding-left: 24px; }

/* ---- game layout: viewport left, console column right (spec §0.7) ---- */

.game-layout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* Doug 2026-07-22: the viewport matches the side column's height exactly
   (VESSEL + CONSOLE + LOCAL MAP). The wrap is a column flexbox; the canvas
   flexes to fill it, and object-fit keeps the simulation undistorted
   (letterboxed into the void-black frame when aspect differs). */
.viewport-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#game-canvas {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  object-fit: contain;
}

/* the HELM bar across the top of the navigation window (Doug 2026-07-22) */
.helm-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  border: 1px solid var(--phosphor-dim);
  background: rgba(51, 255, 102, 0.03);
  padding: 4px 12px;
  margin-bottom: 6px;
  font-size: 15px;
  letter-spacing: 1px;
  color: #3dbb6e;
  text-shadow: none;
}
.helm-bar b { color: var(--phosphor); font-weight: normal; }

.chart-overlay {
  /* fixed, not absolute: the chart is now a top-level overlay so it can be
     opened from the DOCK as well as in flight (Doug 2026-07-23) */
  position: fixed;
  inset: 4vh 5vw;
  background: rgba(1, 9, 2, 0.94);
  border: 1px solid var(--phosphor-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  z-index: 4;
}

.chart-close {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;                      /* above the chart canvas within the overlay */
  min-width: 64px;
  min-height: 44px;
  padding: 4px 14px;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--phosphor);
  background: rgba(1, 9, 2, 0.85);
  border: 1px solid var(--phosphor);
  text-shadow: 0 0 4px var(--phosphor);
  touch-action: manipulation;      /* no double-tap zoom delay */
  cursor: pointer;
}
.chart-close:hover, .chart-close:active { background: var(--phosphor); color: #000; text-shadow: none; }

.chart-title {
  color: #aaffcc;
  font-size: 20px;
  letter-spacing: 3px;
}

#chart-canvas { display: block; width: 100%; flex: 1 1 auto; min-height: 0; }

.chart-hint { font-size: 14px; letter-spacing: 1px; }

.side-column {
  flex: 0 0 288px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-panel {
  border: 1px solid var(--phosphor-dim);
  background: rgba(51, 255, 102, 0.03);
  padding: 10px 12px;
  /* Doug 2026-07-22: the whole column read fuzzy — the CRT glow doesn't
     survive small text. The side column renders crisp; the glow lives on
     the big surfaces. (.field.warn keeps its own alarm glow.) */
  text-shadow: none;
}

.side-heading {
  color: #3dbb6e;   /* a step brighter than phosphor-dim — crisp, still quiet */
  font-size: 16px;
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-shadow: none;
}

.side-panel .field { font-size: 19px; line-height: 1.35; }
.field.warn { color: #ffee55; text-shadow: 0 0 6px #ffee55; }

#decisions button {
  display: block;
  width: 100%;
  text-align: left;
  margin: 6px 0 0 0;
  padding: 5px 10px;
  font-size: 18px;
}

.decision-title { font-size: 18px; color: #aaffcc; }

.console-log {
  margin-top: 8px;
  font-size: 15px;
  color: var(--phosphor-dim);
  min-height: 96px;
}

#map-canvas { display: block; width: 100%; background: #010902; cursor: crosshair; }

.map-chart-btn {
  display: block;
  width: 100%;
  margin: 8px 0 0 0;
  padding: 5px 10px;
  font-size: 16px;
  text-align: left;
}

.dim { color: var(--phosphor-dim); }

/* ---- layout: column fills the viewport height, console absorbs slack --- */

.game-layout { align-items: stretch; }
.side-column .side-panel:nth-child(2) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* Doug 2026-07-22: the console read as a blurry smear — the global
   phosphor glow (text-shadow) on small dim text is what does it. Kill
   the glow in the console + decision hints, raise size and contrast. */
.console-log {
  min-height: 40px;
  max-height: none;
  flex: 1 1 auto;
  overflow-y: auto;
  text-shadow: none;
  font-size: 17px;
  line-height: 1.4;
  color: #4ddb85;
}
.console-log div { text-shadow: none; }
#decisions, #decisions .dim, #decisions .decision-title {
  text-shadow: none;
  font-size: 17px;
}

/* ---- encounter overlay (contacts hail ON the viewport — Doug) ---------- */

.enc-overlay {
  position: absolute;
  inset: 0;
  background: rgba(1, 9, 2, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.enc-box {
  border: 2px solid var(--phosphor);
  background: #03170d;
  box-shadow: 0 0 30px rgba(51, 255, 102, 0.25);
  padding: 18px 26px;
  max-width: 480px;
  width: 88%;
  text-align: center;
}

.enc-title {
  color: #aaffcc;
  font-size: 19px;
  letter-spacing: 2px;
}

.enc-face {
  font-family: 'VT323', monospace;
  font-size: 15px;
  line-height: 1.12;
  white-space: pre;
  margin: 10px auto 4px;
  text-shadow: 0 0 7px currentColor;
}

.enc-name {
  font-size: 21px;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.enc-text { font-size: 18px; line-height: 1.4; color: #bdf5cf; margin: 6px 0 4px; }

.enc-choices { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.enc-choices button { margin: 0; }

/* ---- the port terminal: menu left, active bay right (Doug) ---- */

.port-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.port-menu { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; flex: 0 0 auto; }
.port-menu button { margin: 2px 0; min-width: 320px; text-align: left; }

#port-sub { flex: 1 1 auto; min-width: 0; }
#port-sub .sub-panel {
  border: 1px dashed var(--phosphor-dim);
  padding: 12px 14px;
}
#port-sub .sub-panel button { margin-top: 8px; margin-right: 8px; }

.atm-row { margin-top: 10px; font-size: 18px; }

/* v1.1 trade ledger — CRT table of the pilot's own price sightings */
.ledger-table {
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 17px;
  width: 100%;
}
.ledger-table th, .ledger-table td {
  border: 1px solid var(--phosphor-dim);
  padding: 4px 10px;
  text-align: left;
}
.ledger-table th { color: var(--phosphor-dim); letter-spacing: 1px; }
.ledger-here td { color: #aaffcc; }

.atm-input {
  width: 120px;
  font-size: 18px;
  padding: 3px 8px;
}

@media (max-width: 900px) {
  .port-layout { flex-direction: column; }
  #port-sub { width: 100%; }
}

/* ---- topbar auth ---- */

.pilot-tag { margin-left: 20px; color: #aaffcc; }

.inline-form { display: inline; }

button.linklike {
  border: none;
  background: transparent;
  color: var(--phosphor);
  padding: 0;
  margin: 0 0 0 20px;
  font-size: inherit;
  border-bottom: 1px dotted var(--phosphor-dim);
}
button.linklike:hover { background: transparent; color: #fff; }

/* ---- auth panels ---- */

.auth-panel { max-width: 520px; }

.auth-panel form p { margin: 12px 0; }

.auth-panel label { display: block; margin-bottom: 4px; }

.auth-panel input {
  width: 100%;
}

.auth-panel .errorlist {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  color: #ffee55;
  font-size: 17px;
}

.auth-panel .helptext { display: block; color: var(--phosphor-dim); font-size: 16px; }

/* ---- shipyard registry ---- */

.ship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.ship-card {
  border: 1px solid var(--phosphor-dim);
  background: rgba(51, 255, 102, 0.03);
  padding: 12px;
}

.ship-card canvas { display: block; margin: 0 auto 8px; background: #010902; }

.ship-name { font-size: 22px; letter-spacing: 1px; }

.ship-blurb { font-size: 16px; min-height: 40px; margin: 2px 0 8px; }

.ship-stats div, .ship-price {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  border-bottom: 1px dotted rgba(26, 143, 58, 0.4);
}

.ship-price { color: #aaffcc; margin-top: 4px; }

@media (max-width: 900px) {
  .game-layout { flex-direction: column; }
  .side-column { flex-basis: auto; width: 100%; }
}

/* ---- the deep space wire + top pilots row ---- */

.panel-row {
  display: flex;
  gap: 20px;
  align-items: stretch;
}

.panel-row .panel { flex: 1 1 0; margin-bottom: 20px; }

#wire { flex: 2 1 0; }

.wire-feed {
  font-size: 17px;
  line-height: 1.5;
  min-height: 120px;
  max-height: 260px;
  overflow-y: auto;
}

.wire-line[data-kind="wreck"] { color: var(--phosphor); }
.wire-line[data-kind="trace"] { color: #aaffcc; }
.wire-line[data-kind="beacon"] { color: var(--phosphor-dim); }

h3 { letter-spacing: 1px; margin-top: 24px; }

@media (max-width: 900px) {
  .panel-row { flex-direction: column; }
}

/* ---- touch controls (Doug 2026-07-24: mobile flight) -------------------
   Hidden by default; shown ONLY on touch-primary devices via
   pointer: coarse — a desktop keyboard+mouse session (pointer: fine) never
   sees them, a touch laptop does. Keyed off the input device, not viewport
   width, so a narrow desktop window keeps its keyboard-only clarity. */
.touch-controls { display: none; }

@media (pointer: coarse) {
  /* Doug 2026-07-24: its OWN box under the navigation window, not an
     overlay on the viewport. On mobile .game-layout stacks column, so this
     sits directly beneath the flight canvas, above the info panels. */
  .touch-controls {
    display: block;
    border: 1px solid var(--phosphor-dim);
    background: rgba(51, 255, 102, 0.03);
    padding: 8px 10px 10px;
    margin-top: 6px;
  }
  /* leave room for the controls box beneath the flight view on a phone,
     so both are on-screen at once (Doug 2026-07-24: controls under nav) */
  #game-canvas { max-height: 52vh; }

  .touch-pad {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
  }
  .touch-move {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    gap: 6px;
  }
  .tb-thrust { grid-column: 2; grid-row: 1; }
  .tb-left   { grid-column: 1; grid-row: 2; }
  .tb-right  { grid-column: 3; grid-row: 2; }
  .tb-brake  { grid-column: 2; grid-row: 3; }
  .touch-act { display: flex; flex-direction: column; gap: 8px; }

  .touch-btn {
    pointer-events: auto;
    touch-action: none;            /* no scroll/zoom gestures from the pad */
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-width: 52px;
    min-height: 52px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 20px;
    letter-spacing: 1px;
    color: var(--phosphor);
    background: rgba(1, 9, 2, 0.72);
    border: 1px solid var(--phosphor);
    text-shadow: 0 0 4px var(--phosphor);
  }
  .touch-act .touch-btn { min-width: 74px; }
  .tb-mine { color: #ffb000; border-color: #ffb000; text-shadow: 0 0 4px #ffb000; }
  .touch-btn.pressed { background: var(--phosphor); color: #000; text-shadow: none; }
  .tb-mine.pressed { background: #ffb000; color: #000; }
}

