/* BattleFleet Mars */
:root {
  --space: #070b16;
  --panel: #111a2c;
  --panel2: #17223a;
  --line: #2a3a5c;
  --ink: #e6ecf7;
  --dim: #9aa8c4;
  --amber: #ffc857;
  --con: #8fc3ff;
  --con-deep: #2c5d9c;
  --hol: #ff8a50;
  --hol-deep: #a8401a;
  --good: #7fe0a0;
  --bad: #ff6b6b;
  --focus: #ffe08a;
  --fs: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--space); color: var(--ink); font: var(--fs)/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; min-height: 32px; }
button:hover:not(:disabled) { border-color: var(--amber); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: #3a2a0c; border-color: var(--amber); color: var(--amber); font-weight: 600; }
button.warn { border-color: var(--bad); color: #ffd0d0; }
button.on { background: #2b3b5e; border-color: var(--amber); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.con { color: var(--con); } .hol { color: var(--hol); }
.muted { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
h2 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); margin: 12px 0 6px; font-weight: 600; }
h3 { font-size: 13px; margin: 8px 0 4px; }

#app { display: grid; height: 100vh; height: 100dvh; grid-template-columns: 290px 1fr 300px; grid-template-rows: auto 1fr; grid-template-areas: "top top top" "info board controls"; }
#top { grid-area: top; display: flex; align-items: center; gap: 14px; padding: 6px 12px; background: #0c1324; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#top h1 { font-size: 18px; margin: 0; letter-spacing: 0.04em; white-space: nowrap; }
#top h1 .ver { font-size: 12px; color: var(--dim); font-weight: 400; margin-left: 6px; }
#turninfo { color: var(--amber); white-space: nowrap; }
#willbars { display: flex; gap: 10px; flex: 1; min-width: 330px; }
body.tac-on #board { }
.will { flex: 1; min-width: 90px; }
.will .lab { font-size: 11px; display: flex; justify-content: space-between; }
.bar { height: 8px; background: #0a0f1c; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; }
.topbtns { display: flex; gap: 6px; }
#info, #controls { background: var(--panel); overflow-y: auto; padding: 8px 12px 16px; }
#info { grid-area: info; border-right: 1px solid var(--line); }
#controls { grid-area: controls; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
#board { grid-area: board; position: relative; overflow: hidden; background: var(--space); min-height: 200px; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#map.drag { cursor: grabbing; }
#tacwrap { position: absolute; inset: 0; display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 4px; padding: 4px; }
#tacwrap[hidden] { display: none; }
#tacwrap .tv { position: relative; min-height: 0; overflow: hidden; }
#tacwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; background: #060a14; border: 1px solid var(--line); border-radius: 4px; cursor: crosshair; }
.mapctl { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; }
.mapctl button { width: 36px; padding: 4px; }
#hint { position: absolute; left: 8px; bottom: 8px; right: 140px; font-size: 12px; color: var(--dim); pointer-events: none; text-shadow: 0 1px 2px #000; }
#busy { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: #3a2a0c; border: 1px solid var(--amber); color: var(--amber); padding: 4px 12px; border-radius: 12px; font-size: 13px; }
#busy[hidden] { display: none; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 8px; }
.tabs button { flex: 1; padding: 4px 6px; font-size: 12px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 6px 0; }
.row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.row + .row { margin-top: 4px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 3px 0; border-bottom: 1px solid #1d2842; display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.chip { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.chip.C { background: var(--con-deep); color: #eaf4ff; }
.chip.H { background: var(--hol-deep); color: #fff2ea; }
.hullbar { width: 50px; height: 6px; background: #0a0f1c; border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; }
.hullbar i { display: block; height: 100%; background: var(--good); }
#log { font-size: 12px; max-height: 240px; overflow-y: auto; }
#log p { margin: 2px 0; padding-left: 8px; border-left: 2px solid var(--line); }
#log p.C { border-left-color: var(--con); } #log p.H { border-left-color: var(--hol); }
.grow { flex: 1; }
#endbtn { margin-top: auto; }
.endwrap { margin-top: auto; padding-top: 10px; }
.endwrap button { width: 100%; min-height: 44px; font-size: 15px; }
.transit { border-color: var(--amber); }
.transit b { color: var(--amber); }
.btnrow { display: flex; gap: 4px; flex-wrap: wrap; }
.btnrow button { flex: 1; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.pad button { padding: 4px; }
kbd { background: #0a0f1c; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; font-size: 11px; }

.sheet { position: fixed; inset: 0; background: rgba(4, 7, 14, 0.82); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.sheet[hidden] { display: none; }
.sheet .paper { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; max-width: 760px; width: 100%; max-height: 92vh; overflow-y: auto; padding: 18px 22px; box-shadow: 0 10px 40px #000; }
#cover { background: radial-gradient(ellipse at 70% 40%, #3a1a10 0%, #0b0f1d 55%, #05070d 100%); }
#cover .paper { background: rgba(12, 18, 32, 0.92); max-width: 820px; }
.titleblock { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.titleblock canvas { width: 180px; height: 180px; flex: none; }
.titleblock > div { flex: 1; min-width: 260px; }
.titleblock h1 { font-size: 34px; margin: 0; letter-spacing: 0.05em; }
.titleblock h1 .ver { font-size: 14px; color: var(--dim); font-weight: 400; }
.titleblock .sub { color: var(--amber); letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.choice { text-align: left; padding: 10px; }
.choice.on { outline: 2px solid var(--amber); }
.choice small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }
table.rec { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rec th, table.rec td { border-bottom: 1px solid var(--line); padding: 3px 6px; text-align: left; }
table.rec th { color: var(--amber); font-weight: 600; font-size: 12px; }
.recsheet { background: #f3ecd8; color: #1b1a17; border-radius: 6px; padding: 12px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.recsheet h3 { font-family: inherit; letter-spacing: 0.1em; border-bottom: 2px solid #1b1a17; padding-bottom: 4px; }
.recsheet table.rec th { color: #6b3a10; }
.recsheet table.rec td, .recsheet table.rec th { border-bottom-color: #c9bda0; }
.recsheet .lost { color: #a01818; text-decoration: line-through; }
.dieface { display: inline-block; width: 22px; height: 22px; border: 2px solid #1b1a17; border-radius: 4px; text-align: center; line-height: 18px; font-weight: 700; background: #fff; }
.rules p, .rules li { color: #d7deee; }
.rules h3 { color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 1100px) {
  #app { grid-template-columns: 240px 1fr 260px; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 58vh auto auto; grid-template-areas: "top" "board" "controls" "info"; }
  #turninfo { white-space: normal; font-size: 13px; }
  .will { min-width: 0; }
  #tacwrap { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  #board { height: 58vh; }
  #info, #controls { border: 0; border-top: 1px solid var(--line); overflow: visible; }
  #top h1 { font-size: 16px; }
  #willbars { order: 5; flex-basis: 100%; }
  #hint { display: none; }
  .titleblock canvas { width: 120px; height: 120px; }
  .titleblock h1 { font-size: 26px; }
}

.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.site { padding: 4px 0; border-bottom: 1px solid #1d2842; }
.site:last-child { border-bottom: 0; }
.sheet.veil { background: #05070d; }
canvas.chart { width: 100%; height: 150px; display: block; border-radius: 4px; }
