/* Fall of Shot: Admiralty paper and brass over a grey North Sea (SPEC §12). */
:root {
  color-scheme: light;
  --paper: rgba(242, 234, 214, .93);
  --paper-solid: #f2ead6;
  --edge: rgba(60, 50, 34, .25);
  --ink: #2a2622;
  --dim: #6f6656;
  --red: #a8321f;
  --blue: #2d5f8a;
  --brass: #b08d3c;
  --serif: "Cormorant Garamond", Georgia, serif;
  --mono: "Courier Prime", "Courier New", ui-monospace, monospace;
  --st: env(safe-area-inset-top, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --panel: 410px;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #b9c3c6; color: var(--ink); font-family: var(--serif); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#view, #hud { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#view { touch-action: none; cursor: grab; }
#hud { pointer-events: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
kbd { font: 700 11px var(--mono); background: rgba(42, 38, 34, .08); border: 1px solid rgba(42, 38, 34, .3); border-radius: 3px; padding: 0 4px; white-space: nowrap; }
.card { box-sizing: border-box; background: var(--paper); border: 1px solid var(--edge); border-radius: 3px; padding: 10px 12px; box-shadow: 0 2px 10px rgba(30, 30, 30, .22); }
.k { font: 700 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.v { font: 700 15px var(--mono); font-variant-numeric: tabular-nums; }
.v.small { font-size: 12px; }
.hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
h3 { font: 700 18px/1 var(--serif); margin: 0 0 8px; }
h3 .k { font-size: 9px; }

#status { position: fixed; top: calc(40px + var(--st)); left: calc(10px + var(--sl)); width: 250px; padding: 8px 11px; }
#status .ship { font: 700 18px/1.1 var(--serif); margin-bottom: 4px; }
#status .row { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
#status .row .v { margin-right: 6px; font-size: 13px; }
.damage { font: 12px/1.3 var(--mono); color: var(--red); margin-top: 3px; }
.damage:empty { display: none; }

#log { position: fixed; top: calc(40px + var(--st)); left: calc(275px + var(--sl)); right: calc(var(--panel) + 20px); display: flex; flex-direction: column; align-items: flex-start; gap: 3px; pointer-events: none; }
#log .line { font: 13px/1.3 var(--mono); background: rgba(242, 234, 214, .88); padding: 3px 8px; border-left: 3px solid var(--dim); border-radius: 2px; max-width: 100%; transition: opacity 1s; }
#log .line b { font-weight: 700; color: var(--dim); }
#log .line.spot { border-left-color: var(--blue); }
#log .line.enemy, #log .line.damage { border-left-color: var(--red); }
#log .line.damage { color: #6b1d10; }
#log .line.order { border-left-color: var(--brass); }
#log .line.end { border-left-color: var(--ink); font-weight: 700; }
#log .line.old { opacity: 0; }

#viewbar { position: fixed; bottom: calc(12px + var(--sb)); left: 50%; transform: translateX(calc(-50% - var(--panel) / 2)); display: flex; gap: 4px; }
#viewbar button, .buttons button, .stepper button, .steps button, .telegraph button, .setting button, #rfbar button {
  background: var(--paper); border: 1px solid rgba(42, 38, 34, .35); border-radius: 3px; padding: 7px 11px; font: 700 12px var(--mono); }
#viewbar button.on, .buttons button.on, .steps button.on, .telegraph button.on, .setting button.on { background: var(--ink); color: var(--paper-solid); border-color: var(--ink); }
.buttons button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.buttons { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
button:active { transform: translateY(1px); }

/* the stations: a column on the right on a wide screen */
#stations { position: fixed; top: calc(40px + var(--st)); right: calc(10px + var(--sr)); bottom: calc(10px + var(--sb)); width: var(--panel); display: flex; flex-direction: column; gap: 8px; overflow-y: auto; pointer-events: none; }
#stations > * { pointer-events: auto; }
#tabs { display: none; }
.station { padding: 8px 12px; }
#stations .buttons { margin: 3px 0; }
#stations .grid { margin: 4px 0 0; }
#stations h3 { margin-bottom: 5px; }
@media (min-width: 1000px) and (max-height: 960px) { .station { padding: 6px 10px; } #ts .ts-row { margin-top: 4px; } }
#conn { position: fixed; left: calc(10px + var(--sl)); bottom: calc(10px + var(--sb)); width: 300px; }
#plot { width: 100%; height: 160px; display: block; border: 1px solid var(--edge); }
.ts-row { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
#dumaresq { width: 120px; height: 120px; flex: none; }
.ts-controls { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper .v { min-width: 44px; text-align: center; }
.stepper button { padding: 6px 8px; min-width: 34px; }
button.wide { background: transparent; border: 1px dashed rgba(42, 38, 34, .45); border-radius: 3px; padding: 6px; font: 700 11px var(--mono); margin-top: 3px; }
.grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 8px; align-items: baseline; margin: 8px 0 2px; }
#ts .grid { grid-template-columns: auto 1fr; }
.turrets { display: flex; gap: 6px; }
.turret { flex: 1; text-align: center; border: 1px solid var(--edge); border-radius: 3px; padding: 2px 0 3px; background: rgba(255, 255, 255, .25); }
.turret .n { font: 700 14px var(--mono); }
.turret .lamps { display: flex; justify-content: center; gap: 4px; margin-top: 3px; }
.lamp { width: 13px; height: 13px; border-radius: 50%; background: #9a958a; position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.lamp.ready { background: #3d8a3a; }
.lamp.loading { background: #c8a050; }
.lamp .fill { position: absolute; left: 0; bottom: 0; width: 100%; background: #3d8a3a; }
.turret.blind { opacity: .45; }
.turret.out { background: rgba(168, 50, 31, .2); border-color: var(--red); }
.turret.out .n { color: var(--red); text-decoration: line-through; }
.turret.jam .n { color: #a06b16; }
.turret .why { font: 9px var(--mono); color: var(--dim); height: 10px; }
.spotting { border-top: 1px dashed var(--edge); margin-top: 6px; padding-top: 6px; }
.steps { display: flex; gap: 4px; margin: 4px 0; }
.steps button { flex: 1; padding: 5px 0; }
.arrows button { flex: 1 1 17%; padding-left: 4px; padding-right: 4px; }
.suggest { width: 100%; background: #f7e7b5; border: 1px solid var(--brass); border-radius: 3px; padding: 8px; font: 700 12px var(--mono); margin-top: 2px; }
.shoot { display: block; width: 100%; margin-top: 6px; padding: 11px; background: var(--red); color: #fff; border: 0; border-radius: 3px; font: 700 18px var(--mono); letter-spacing: .25em; text-transform: uppercase; box-shadow: 0 2px 0 #6b1d10; }
.shoot.ready { animation: ready 1.2s infinite; }
@keyframes ready { 50% { background: #c4402c; } }
.shoot.float { position: fixed; width: 104px; height: 104px; border-radius: 50%; padding: 0; right: calc(14px + var(--sr)); bottom: calc(66px + var(--sb)); font-size: 15px; letter-spacing: .1em; }
.telegraph { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 8px; }
.telegraph button { padding: 6px 2px; font-size: 11px; }
.helm input { width: 100%; accent-color: var(--ink); margin: 6px 0 0; }
.helm .scale { display: flex; justify-content: space-between; font: 9px var(--mono); color: var(--dim); }
#conn .row { display: flex; gap: 8px; align-items: baseline; }
.target-row { margin: -2px 0 6px; }
.dc { border-top: 1px dashed var(--edge); margin-top: 6px; padding-top: 5px; }
.parties { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }
.party { display: inline-flex; align-items: center; gap: 3px; }
.party button, #c-cf { background: var(--paper); border: 1px solid rgba(42, 38, 34, .35); border-radius: 3px; padding: 3px 7px; font: 700 11px var(--mono); }
#c-mags button { width: 100%; margin: 3px 0; padding: 10px; background: #6b1d10; color: #fff; border: 0; border-radius: 3px; font: 700 13px var(--mono); animation: ready .6s infinite; }
.seed { font: 11px var(--mono); color: var(--dim); margin: 8px 0 0; }
.sheet.review { width: min(900px, 100%); }
#rv-canvas { width: 100%; height: min(62vh, 620px); display: block; border: 1px solid var(--edge); }
.rv-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.rv-bar input { flex: 1; accent-color: var(--ink); }
.rv-bar button { background: var(--paper); border: 1px solid rgba(42, 38, 34, .35); border-radius: 3px; padding: 7px 12px; font: 700 12px var(--mono); }
#debug { position: fixed; left: calc(10px + var(--sl)); top: calc(160px + var(--st)); margin: 0; padding: 6px 8px; background: rgba(20, 20, 20, .78); color: #d8f0c0; font: 11px/1.35 var(--mono); border-radius: 3px; pointer-events: none; z-index: 5; white-space: pre; }
.signals { border-top: 1px dashed var(--edge); margin-top: 6px; padding-top: 6px; }
.signals .buttons button { padding: 5px 7px; font-size: 10.5px; }
.flying { color: var(--red); text-transform: none; letter-spacing: 0; }
button.argo { border-style: solid; border-color: var(--blue); color: var(--blue); }
.comb { width: 100%; margin: 2px 0 6px; padding: 10px; background: #c4402c; color: #fff; border: 0; border-radius: 3px; font: 700 13px var(--mono); letter-spacing: .08em; animation: ready 1s infinite; }

#rfbar { position: fixed; left: 50%; top: calc(150px + var(--st)); transform: translateX(calc(-50% - var(--panel) / 2)); text-align: center; width: min(480px, calc(100vw - 20px)); }
#rfbar .drum { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 6px 0; }
#rfbar .drum .v { min-width: 84px; font-size: 18px; }
#rfbar .buttons { justify-content: center; }
#rfbar button.primary { background: var(--blue); color: #fff; border-color: var(--blue); padding: 8px 26px; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; background: rgba(150, 162, 166, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; z-index: 10; }
.sheet { width: min(600px, 100%); padding: 22px 26px; max-height: calc(100vh - 32px); overflow-y: auto; }
.sheet.small { width: min(360px, 100%); }
.sheet h1 { font: 700 54px/1 var(--serif); margin: 4px 0 10px; letter-spacing: -.01em; }
.sheet h2 { font: 700 32px/1 var(--serif); margin: 2px 0 14px; }
.eyebrow { font: 700 11px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--red); }
.lede { font-size: 18px; line-height: 1.45; margin: 0 0 16px; }
.note { font-size: 15px; line-height: 1.45; color: var(--dim); font-style: italic; margin: 8px 0 0; }
.scenarios { display: grid; gap: 8px; margin-bottom: 14px; }
.group { font: 700 11px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); margin: 14px 0 6px; border-bottom: 1px solid var(--edge); padding-bottom: 3px; }
.campaign { display: grid; gap: 4px; }
.campaign .act { display: flex; align-items: baseline; gap: 10px; text-align: left; background: rgba(255, 255, 255, .35); border: 1px solid var(--edge); border-radius: 3px; padding: 8px 12px; }
.campaign .act:disabled { opacity: .45; cursor: default; }
.campaign .act .d { font: 11px var(--mono); color: var(--dim); min-width: 150px; }
.campaign .act .t { font: 700 17px var(--serif); flex: 1; }
.campaign .act .r { font: 700 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.campaign .act .r.victory { color: #3d7a3a; } .campaign .act .r.defeat { color: var(--red); }
.campaign .reset { justify-self: end; background: none; border: 0; font: 11px var(--mono); color: var(--dim); text-decoration: underline; }
.scenario { text-align: left; background: rgba(255, 255, 255, .4); border: 1px solid var(--edge); border-radius: 3px; padding: 10px 14px; }
.scenario:hover { border-color: var(--ink); background: rgba(255, 255, 255, .65); }
.scenario .t { font: 700 21px/1.1 var(--serif); }
.scenario .d { font-size: 15px; line-height: 1.35; margin-top: 3px; }
.scenario .best { font: 11px var(--mono); color: var(--blue); margin-top: 4px; }
.setting { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.setting .k { margin-right: 2px; }
.keys-box { margin-top: 14px; }
.keys-box summary { cursor: pointer; padding: 4px 0; }
.how { font-size: 15px; line-height: 1.45; padding-left: 20px; }
.how li { margin-bottom: 5px; }
.keys { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.35; }
.keys td { padding: 4px 0; border-top: 1px dashed var(--edge); vertical-align: top; }
.keys td:first-child { width: 140px; padding-right: 8px; }
.report { border-collapse: collapse; width: 100%; font: 14px/1.4 var(--mono); }
.report td { padding: 4px 0; border-top: 1px dashed var(--edge); }
.report td:last-child { text-align: right; font-weight: 700; }

#lesson { position: fixed; left: calc(10px + var(--sl)); top: calc(160px + var(--st)); width: 300px; border-left: 4px solid var(--brass); }
#lesson .text { font-size: 17px; line-height: 1.4; margin: 3px 0 4px; }
#lesson .text kbd { font-size: 12px; }
#lesson.done { animation: lessonDone .9s; }
@keyframes lessonDone { 30% { background: #e6f0d8; } }
#lesson .skip { background: none; border: 0; padding: 0; font: 11px var(--mono); color: var(--dim); text-decoration: underline; }

/* a phone or a narrow window: the stations become a sheet over the bottom, opened by tabs */
@media (max-width: 999px), (pointer: coarse) and (max-height: 600px) {
  :root { --panel: 0px; }
  #status { top: calc(8px + var(--st)); width: auto; max-width: 54vw; padding: 6px 8px; }
  #status .ship { font-size: 15px; }
  #status .row .v { font-size: 11px; }
  #status .k { font-size: 8.5px; }
  #log { left: calc(8px + var(--sl)); right: calc(124px + var(--sr)); top: auto; bottom: calc(66px + var(--sb)); align-items: flex-start; }
  #log .line { font-size: 11.5px; }
  #viewbar { left: auto; right: calc(8px + var(--sr)); top: calc(8px + var(--st)); bottom: auto; transform: none; flex-wrap: wrap; justify-content: flex-end; max-width: 44vw; }
  #viewbar button { padding: 6px 7px; font-size: 10.5px; }
  #stations { top: auto; left: calc(6px + var(--sl)); right: calc(6px + var(--sr)); bottom: calc(6px + var(--sb)); width: auto; max-height: 58vh; overflow: visible; flex-direction: column-reverse; gap: 4px; }
  #tabs { display: flex; gap: 4px; }
  #tabs button { flex: 1; background: var(--paper); border: 1px solid rgba(42, 38, 34, .35); border-radius: 3px; padding: 11px 0; font: 700 13px var(--mono); }
  #tabs button.on { background: var(--ink); color: var(--paper-solid); }
  .station { display: none; max-height: calc(58vh - 50px); overflow-y: auto; }
  .station.open { display: block; }
  #conn { position: static; width: auto; }
  #plot { height: 170px; }
  #dumaresq { width: 128px; height: 128px; }
  #guns .shoot { display: none; }
  .shoot.float { bottom: calc(60px + var(--sb)); }
  body.sheet-open .shoot.float { bottom: auto; top: calc(96px + var(--st)); width: 80px; height: 80px; font-size: 13px; }
  body.sheet-open #log { bottom: auto; top: calc(110px + var(--st)); right: calc(100px + var(--sr)); align-items: flex-start; }
  #rfbar { left: 50%; transform: translateX(-50%); top: auto; bottom: calc(60px + var(--sb)); }
  #lesson { left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); width: auto; transform: none; top: calc(96px + var(--st)); bottom: auto; padding: 7px 10px; }
  #lesson .text { font-size: 14.5px; }
  body.lesson #log { display: none; }
  .sheet h1 { font-size: 42px; }
  .sheet { padding: 18px; }
}
