/* Typhoon of Steel — the operations desk.
   Everything around the sheet is canvas and blackout; the map is the only lit
   surface on the page, and the contact board is set like a message pad. */

:root {
  --black: #14170f;
  --canvas: #232720;
  --canvas-2: #2c3128;
  --paper: #e8dcc0;
  --ink: #2b2418;
  --brass: #b08a3c;
  --brass-dim: #7d6229;
  --signal: #a53a2c;
  --us: #6f9e7e;
  --ja: #c98a80;
  --line: rgba(232, 220, 192, 0.16);
  --display: "DejaVu Sans Condensed", "Liberation Sans Narrow", "TeX Gyre Heros Cn", "Arial Narrow", Arial, sans-serif;
  --body: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --pad: "DejaVu Sans Mono", "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--black);
  color: var(--paper);
  font-family: var(--body);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
}

/* ------------------------------------------------------------------ bar */

#bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #2c3128 0%, #1d211a 100%);
  border-bottom: 2px solid var(--brass-dim);
  flex-wrap: wrap;
}

.brand { display: flex; flex-direction: column; line-height: 1.1; }

.mark {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper);
}

.sub {
  font-family: var(--pad);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--brass);
  text-transform: uppercase;
}

.readout {
  display: flex;
  gap: 16px;
  flex: 1;
  font-family: var(--pad);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: rgba(232, 220, 192, 0.82);
  flex-wrap: wrap;
}

.readout span { white-space: nowrap; }
.readout #phase { color: var(--brass); }

.acts { display: flex; gap: 8px; }

button {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  font-weight: 700;
  border-radius: 2px;
  border: 1px solid var(--brass-dim);
  background: transparent;
  color: var(--paper);
  padding: 8px 12px;
  cursor: pointer;
}

button:hover { border-color: var(--brass); color: var(--brass); }
button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
button.primary { background: var(--brass); color: #17190f; border-color: var(--brass); }
button.primary:hover { background: #c99e48; color: #17190f; }
button.primary:disabled { background: #4a4534; border-color: #4a4534; color: #8b8474; cursor: default; }
button.ghost { border-color: var(--line); }
button.ghost:disabled { border-color: var(--line); color: rgba(232, 220, 192, 0.34); cursor: default; }
button.danger-action { background: var(--signal); border-color: var(--signal); color: #fff1e7; }
button.danger-action:hover { background: #bd4939; border-color: #bd4939; color: #fff; }

/* ----------------------------------------------------------------- body */

main {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr) 288px;
  flex: 1;
  min-height: 0;
}

.panel {
  background: var(--canvas);
  border-right: 1px solid var(--line);
  padding: 12px 14px 20px;
  overflow-y: auto;
}

#right { border-right: none; border-left: 1px solid var(--line); }

.panel h3 {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 4px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

/* The canvas is taken out of the flow: sized in pixels from its box, it can
   otherwise outgrow that box and lay itself over the ledger. */
#board { position: relative; background: #0f120d; min-height: 320px; overflow: hidden; }
#map { position: absolute; top: 0; left: 0; touch-action: none; cursor: crosshair; }

.chip {
  position: absolute;
  display: none;
  padding: 3px 7px;
  background: rgba(20, 23, 15, 0.92);
  border: 1px solid var(--brass-dim);
  color: var(--paper);
  font-family: var(--pad);
  font-size: 11px;
  pointer-events: none;
  white-space: nowrap;
}

.chip.on { display: block; }

/* ------------------------------------------------------------ unit card */

.unit-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.unit-head strong { font-family: var(--display); font-size: 15px; letter-spacing: 0.05em; }

.tag {
  font-family: var(--pad);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid currentColor;
}
.tag.us { color: var(--us); }
.tag.ja { color: var(--ja); }

.grid {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 3px 8px;
  font-size: 12.5px;
  margin-bottom: 12px;
}
.grid .k { font-family: var(--pad); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(232, 220, 192, 0.55); padding-top: 2px; }
.grid .v { color: var(--paper); }

.orders { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.order { padding: 7px 9px; font-size: 11px; }
.order.on { background: var(--brass); color: #17190f; border-color: var(--brass); }
.order.off { opacity: 0.35; cursor: default; }
.order.off:hover { border-color: var(--brass-dim); color: var(--paper); }

.discipline { border-top: 1px solid var(--line); padding-top: 10px; }
.label {
  display: block;
  font-family: var(--pad);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(232, 220, 192, 0.5);
  margin-bottom: 6px;
}

.pill { padding: 6px 10px; font-size: 11px; margin: 0 5px 5px 0; }
.pill.on { background: var(--brass); color: #17190f; border-color: var(--brass); }

.hint, .fine { font-size: 11.5px; color: rgba(232, 220, 192, 0.55); line-height: 1.45; }
.fine { font-family: var(--pad); font-size: 10.5px; }
.message { min-height: 18px; font-size: 12px; color: var(--brass); margin-top: 10px; }

/* --------------------------------------------------------- command status */

.command-status { margin-bottom: 18px; }

.command-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.command-stat {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: rgba(232, 220, 192, 0.025);
}

.command-stat .command-label {
  display: block;
  color: rgba(232, 220, 192, 0.5);
  font-family: var(--pad);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.command-stat strong {
  display: block;
  margin: 2px 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.04em;
}

.command-stat small {
  display: block;
  overflow: hidden;
  color: rgba(232, 220, 192, 0.52);
  font-family: var(--pad);
  font-size: 8.5px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.force-meter {
  height: 4px;
  margin: 7px 0 10px;
  background: rgba(232, 220, 192, 0.1);
  overflow: hidden;
}
.force-meter span { display: block; height: 100%; }
.force-meter .good { background: var(--us); }
.force-meter .warn { background: var(--brass); }
.force-meter .danger { background: var(--signal); }

.objective-list { display: grid; gap: 3px; }

.objective-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 0;
  font-family: var(--pad);
  font-size: 10px;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
}
.objective-row strong { color: var(--signal); font-size: 9px; text-transform: uppercase; }
.objective-row.ours { border-left: 3px solid var(--us); }
.objective-row.ours strong { color: var(--us); }
.objective-row.theirs { border-left: 3px solid var(--signal); }

.command-advice {
  margin: 9px 0 0;
  padding: 8px 9px;
  border-left: 3px solid var(--brass);
  background: rgba(176, 138, 60, 0.08);
  color: rgba(232, 220, 192, 0.72);
  font-size: 10.5px;
  line-height: 1.42;
}
.command-advice strong {
  display: block;
  margin-bottom: 3px;
  color: var(--brass);
  font-family: var(--pad);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --------------------------------------------------- the contact board */

.contact {
  display: block;
  width: 100%;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--pad);
  border: none;
  border-left: 3px solid var(--signal);
  border-bottom: 1px solid var(--line);
  background: rgba(165, 58, 44, 0.08);
  padding: 7px 9px;
  margin-bottom: 5px;
  border-radius: 0;
}
.contact:hover { background: rgba(165, 58, 44, 0.18); color: var(--paper); border-left-color: var(--signal); }
.contact strong { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.contact .meta { display: block; font-size: 10.5px; color: rgba(232, 220, 192, 0.6); margin-top: 2px; }
.contact.stale { border-left-style: dashed; opacity: 0.78; }
.contact.seen { border-left-width: 4px; }

.strip { margin-top: 16px; }
.disc-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--pad);
  font-size: 11px;
  padding: 5px 7px;
  margin-bottom: 3px;
  border: 1px solid var(--line);
  border-radius: 0;
}
.disc-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disc-row .od { color: var(--brass); }
.disc-row.hold .od { color: #8fa4b4; }
.disc-row.free .od { color: var(--signal); }
.disc-row.on { border-color: var(--brass); }
.disc-row .seen-mark { color: var(--signal); font-size: 10px; }

/* -------------------------------------------------------------- ledger */

footer {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  background: #1a1e16;
  border-top: 1px solid var(--brass-dim);
  max-height: 116px;
  overflow: hidden;
}

#ledger { max-height: 116px; overflow-y: auto; padding: 8px 16px; }

.entry {
  display: flex;
  gap: 10px;
  font-family: var(--pad);
  font-size: 11.5px;
  padding: 2px 0;
  color: rgba(232, 220, 192, 0.78);
}
.entry .turn { color: var(--brass-dim); min-width: 30px; }
.entry.opfire .txt, .entry.fire .txt { color: #d9a08c; }
.entry.kill .txt, .entry.breach .txt { color: var(--signal); }
.entry.morale .txt { color: #c9b06a; }
.entry.naval .txt, .entry.call .txt { color: #86a8bd; }
.entry.verdict .txt { color: var(--brass); font-weight: 700; }

/* --------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 8, 0.86);
  padding: 20px;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal.cover-open {
  background:
    linear-gradient(rgba(8, 11, 8, 0.84), rgba(8, 11, 8, 0.94)),
    url('../assets/cover.png') center 44% / cover no-repeat;
}

.card {
  background: var(--canvas);
  border: 1px solid var(--brass-dim);
  border-top: 4px solid var(--brass);
  max-width: 720px;
  width: 100%;
  padding: 26px 28px 22px;
  max-height: 92vh;
  overflow-y: auto;
}

.opening-card {
  display: grid;
  grid-template-columns: minmax(250px, 0.72fr) minmax(430px, 1.28fr);
  gap: 0;
  max-width: 1040px;
  padding: 0;
  overflow: hidden;
}

.cover-panel {
  position: relative;
  min-height: 610px;
  background: #11160f;
  border-right: 1px solid var(--brass-dim);
  overflow: hidden;
}

.cover-art {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 610px;
  object-fit: cover;
}

.cover-facts {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
}

.cover-facts span,
.doctrine span {
  border: 1px solid rgba(201, 155, 63, 0.58);
  background: rgba(10, 14, 10, 0.84);
  color: var(--paper);
  font-family: var(--pad);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  padding: 5px 8px;
  text-transform: uppercase;
}

.setup-panel { padding: 25px 28px 20px; overflow-y: auto; }

.eyebrow {
  display: block;
  color: var(--brass);
  font-family: var(--pad);
  font-size: 10px;
  letter-spacing: 0.18em;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.doctrine {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: -4px 0 17px;
}

.doctrine span { background: rgba(176, 138, 60, 0.1); }

.title {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.lede { font-size: 13.5px; line-height: 1.5; color: rgba(232, 220, 192, 0.8); margin: 0 0 18px; }

.choices { display: grid; gap: 8px; margin-bottom: 16px; }

.choice {
  display: block;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  padding: 11px 13px;
  border-color: var(--line);
}
.choice strong { display: block; font-family: var(--display); font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }
.choice .meta { display: block; font-family: var(--pad); font-size: 10.5px; color: var(--brass); margin: 3px 0 4px; }
.choice .blurb { display: block; font-size: 12px; line-height: 1.45; color: rgba(232, 220, 192, 0.62); }
.choice.on { border-color: var(--brass); background: rgba(176, 138, 60, 0.12); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.row.end { justify-content: flex-end; margin-top: 16px; margin-bottom: 6px; }
.row .label { margin: 0 4px 0 0; }

.turn-check { max-width: 620px; }
.ready-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  max-height: 42vh;
  overflow-y: auto;
}
.ready-row {
  display: block;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--us);
  border-radius: 0;
  font-family: var(--pad);
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
}
.ready-row strong,
.ready-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ready-row strong { color: var(--paper); font-size: 11px; }
.ready-row span { margin-top: 2px; color: rgba(232, 220, 192, 0.55); font-size: 9.5px; }

/* -------------------------------------------------------------- narrow */

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 56vh) auto auto; }
  #board { order: -1; min-height: 300px; }
  .panel { border: none; border-top: 1px solid var(--line); max-height: none; }
  #bar { gap: 10px; padding: 8px 12px; }
  .mark { font-size: 17px; }
  .readout { font-size: 11px; gap: 10px; }
  footer, #ledger { max-height: 90px; }
  .opening-card { grid-template-columns: minmax(190px, 0.68fr) minmax(360px, 1.32fr); }
  .cover-panel, .cover-art { min-height: 560px; }
  .setup-panel { padding: 22px; }
}

@media (max-width: 680px) {
  .modal { align-items: flex-start; padding: 10px; }
  .opening-card { display: block; max-height: none; overflow: visible; }
  .cover-panel { min-height: 0; border-right: 0; border-bottom: 1px solid var(--brass-dim); }
  .cover-art { width: 100%; height: auto; min-height: 0; max-height: 52vh; object-position: center 25%; }
  .cover-facts { bottom: 10px; }
  .setup-panel { overflow: visible; padding: 20px 18px 16px; }
  .title { font-size: 25px; }
  .ready-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
