/* Second Commission - the plot table. Three type roles and no more:
   Georgia for anything printed on the chart, Courier for the reckoner
   because a damage table is typed, and the system sans for the panels. */

:root {
  --deep: #16303d;
  --dark: #0b1a22;
  --darker: #071219;
  --panel: #102630;
  --panel-2: #14303c;
  --rule: rgba(142,167,174,0.28);
  --paper: #e8e1cf;
  --ink: #1a1c18;
  --mine: #5bb094;
  --foe: #c86844;
  --brass: #c9a227;
  --quiet: #94aab2;
  --text: #dce7ea;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--darker);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
}

#app { height: 100%; }

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 0.3em;
}

h1 {
  font-size: clamp(28px, 5vw, 46px);
  color: var(--paper);
  letter-spacing: 0.06em;
}

.sub {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--brass);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 12px;
  margin: 0 0 1.4rem;
}

.quiet { color: var(--quiet); font-size: 13px; margin: 0.35rem 0; }
.warn { color: var(--brass); }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #1b3d4b; border-color: var(--brass); }
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

input[type="text"] {
  font: inherit;
  background: var(--darker);
  color: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.4rem 0.6rem;
  width: 100%;
  max-width: 320px;
}

input[type="range"] { width: 100%; max-width: 420px; accent-color: var(--brass); }

/* ------------------------------------------------------------ title */

#screen-title, #screen-buy, #screen-over {
  overflow-y: auto;
  padding: clamp(1rem, 4vw, 3rem);
  align-items: center;
}

/* The after-action sheet is four lines long. Left at flex-start it sat in
   the top-left corner of an otherwise empty screen. Safe centring puts it
   on the eye line and degrades to flex-start where it is not understood. */
#screen-over { justify-content: safe center; }

.sheetish {
  width: 100%;
  max-width: 940px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
}

@media (min-width: 860px) {
  .two-up { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
}

.block {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  min-width: 0;
}

.block h2 {
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 0.7rem;
}

.choice-row { display: grid; gap: 0.5rem; }

.choice {
  text-align: left;
  display: block;
  width: 100%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
}
.choice small { display: block; color: var(--quiet); font-family: system-ui, sans-serif; font-size: 12px; }
.choice.on { border-color: var(--brass); background: #1b3d4b; color: var(--paper); }

.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--quiet); margin-bottom: 0.3rem; }

.big-figure {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  color: var(--paper);
}

.hist { display: flex; gap: 0.6rem; font-size: 13px; padding: 0.25rem 0; border-bottom: 1px solid rgba(142,167,174,0.12); }
.hist-sea { flex: 1 1 auto; min-width: 0; color: var(--paper); }
.hist-lv { color: var(--quiet); }
.hist-won { color: var(--mine); }
.hist-lost { color: var(--foe); }
.hist-notch { color: var(--brass); width: 2.4rem; text-align: right; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

.primary { background: var(--brass); color: #1a1600; border-color: var(--brass); font-weight: 600; }
.primary:hover:not(:disabled) { background: #dfb733; color: #1a1600; }

/* -------------------------------------------------------------- yard */

.yard-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(142,167,174,0.14);
  align-items: center;
}
.yard-head { grid-column: 1; display: flex; align-items: baseline; gap: 0.5rem; }
.yard-cls { font-family: "Courier New", monospace; color: var(--brass); font-weight: 700; }
.yard-name { font-family: Georgia, serif; color: var(--paper); }
.yard-cost { color: var(--quiet); font-size: 13px; margin-left: auto; }
.yard-stats { grid-column: 1; display: flex; flex-wrap: wrap; gap: 0.7rem; font-size: 12px; color: var(--quiet); }
.yard-note { grid-column: 1; margin: 0.2rem 0 0; font-size: 13px; color: #b8c8ce; }
.yard-ctrl { grid-column: 2; grid-row: 1 / span 3; display: flex; align-items: center; gap: 0.4rem; }
.yard-count { font-family: "Courier New", monospace; width: 1.6rem; text-align: center; color: var(--paper); }

.chip { padding: 0.3rem 0.55rem; font-size: 13px; }
.chip.wide { display: block; width: 100%; text-align: left; margin-bottom: 0.35rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* -------------------------------------------------------------- plot */

#screen-plot { display: flex; }

#hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  align-items: baseline;
  padding: 0.5rem 0.9rem;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}
#hud-turn { font-family: Georgia, serif; color: var(--paper); }
#hud-score { font-family: "Courier New", monospace; font-size: 20px; color: var(--brass); }
#hud .sm { font-size: 13px; color: var(--quiet); }

#plot-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(180px, 1fr) minmax(0, auto);
}

@media (min-width: 900px) {
  #plot-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 350px);
    grid-template-rows: minmax(0, 1fr);
  }
}

#chart { position: relative; min-width: 0; min-height: 0; background: var(--darker); }
#sheet { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

#zoomers { position: absolute; right: 0.5rem; bottom: 0.5rem; display: flex; gap: 0.3rem; }
#zoomers button { background: rgba(11,26,34,0.85); }

#panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--rule);
  padding: 0.7rem 0.8rem 1.2rem;
}
@media (max-width: 899px) {
  #panel { border-left: none; border-top: 1px solid var(--rule); max-height: 42vh; }
}

/* On a phone the hud wraps to two lines and the order bar takes another
   ninety pixels, so a panel at 46vh left the plot itself under a third of
   the screen and the counters came out too small to aim. The panel scrolls;
   the chart cannot, so the chart gets the room. */
@media (max-width: 520px) {
  #panel { max-height: 36vh; }
  #hud { font-size: 13px; }
}

.pane { margin-bottom: 0.9rem; }
.pane > h3 {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.2rem;
}

.card-head { display: flex; align-items: baseline; gap: 0.5rem; }
.card-cls { font-family: "Courier New", monospace; font-weight: 700; color: var(--brass); font-size: 18px; }
.card-name { font-family: Georgia, serif; color: var(--paper); font-size: 17px; }
.card-facts { display: flex; flex-wrap: wrap; gap: 0.6rem; font-size: 12px; color: var(--quiet); margin: 0.3rem 0 0.5rem; }

.hull-bar { height: 8px; background: rgba(7,18,25,0.8); border: 1px solid var(--rule); border-radius: 2px; margin-top: 0.4rem; overflow: hidden; }
.hull-fill { height: 100%; background: var(--paper); }
.hull-fill.half { background: #e5c15c; }
.hull-fill.low { background: var(--foe); }

/* ------------------------------------------------- the ready-reckoner */

.reckoner {
  border-collapse: collapse;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 13px;
  border: 2px solid var(--brass);
}
.reckoner th, .reckoner td {
  border: 1px solid rgba(26,28,24,0.25);
  text-align: center;
  padding: 2px 0;
  width: 11%;
}
.reckoner th { background: #d8cfb6; font-weight: 700; }
.reckoner .corner { background: var(--brass); }
.reckoner td.nil { color: rgba(26,28,24,0.35); }
.reckoner td.lit-row { background: rgba(64,150,120,0.45); }
.reckoner td.lit-col { background: rgba(200,104,68,0.34); }
.reckoner td.lit {
  background: var(--brass);
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--ink);
}
#reckoner-note { font-size: 12px; color: var(--quiet); margin: 0.4rem 0 0; }

/* ----------------------------------------------------- running sheet */

#running { max-height: 30vh; overflow-y: auto; }
.line { font-size: 12.5px; padding: 0.18rem 0; border-bottom: 1px solid rgba(142,167,174,0.10); display: flex; gap: 0.5rem; }
.line-turn { color: var(--quiet); width: 1.6rem; text-align: right; font-family: "Courier New", monospace; }
.line-text { flex: 1 1 auto; min-width: 0; }
.line.ours .line-text { color: var(--text); }
.line.theirs .line-text { color: #d9b6a6; }

#bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  background: var(--panel);
  border-top: 1px solid var(--rule);
  align-items: center;
}
#bar .spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------ battle */

#screen-battle { overflow-y: auto; padding: clamp(0.8rem, 3vw, 2rem); align-items: center; }

.battle-lines {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
}
@media (min-width: 720px) {
  .battle-lines { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.tile {
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--mine);
  border-radius: 3px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.45rem;
}
.tile.theirs { border-left-color: var(--foe); }
.tile-cls { font-family: "Courier New", monospace; color: var(--brass); font-weight: 700; margin-right: 0.4rem; }
.tile-name { font-family: Georgia, serif; color: var(--paper); }
.tile-hull { font-size: 12px; color: var(--quiet); }
.tile-read { display: block; font-size: 12px; color: var(--quiet); margin-top: 0.15rem; }

#battle-events { max-height: 26vh; overflow-y: auto; margin-top: 0.6rem; }
#battle-events .line { color: #cfe0e5; }


/* Section 56. The manifest declared reduced_motion: true and there was no
   such query anywhere in this sheet - a claim the portal takes on trust
   and cannot check by inspecting code. Either the rule exists or the flag
   is false; it is now the former, and the validator asserts the pair. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
