/* War Table: a war-room chart table. Deep blue-grey sea with a faint
   graticule, flat muted land by owner, dark translucent plotting boards
   around it. One accent: brass, for the action that moves the game on. */
:root {
  --sea: #2a3841;
  --sea-2: #314451;
  --sea-line: rgba(176, 202, 214, .085);
  --sea-border: rgba(176, 202, 214, .3);
  --border: #161b1c;
  --paper: #e8e3d5;
  --paper-2: #bdb8aa;
  --paper-3: #8f8b80;
  --panel: rgba(20, 27, 31, .9);
  --panel-solid: #182025;
  --panel-2: rgba(255, 255, 255, .045);
  --rule: rgba(232, 227, 213, .11);
  --brass: #c9a55e;
  --brass-hi: #dcbd7c;
  --brass-ink: #22190a;
  --danger: #d56b55;
  --dest: #f2e3a2;
  --load: #7fd3c8;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --cond: "Roboto Condensed", "Arial Narrow", "Helvetica Neue Condensed", "Avenir Next Condensed", "DejaVu Sans Condensed", "Liberation Sans Narrow", var(--font);
  --tap: 40px;
  --r: 6px;
  --side-w: 336px;
  --top-h: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sea);
  color: var(--paper);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body[data-screen="start"] { overflow: auto; }
#app { height: 100%; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--paper-3); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, .11); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--brass-ink);
  font-weight: 650;
}
.btn.primary:hover:not(:disabled) { background: var(--brass-hi); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #1d0c08; font-weight: 650; }
.btn.danger:hover:not(:disabled) { background: #e3826d; }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; }
.btn.big { min-height: 48px; padding: 0 26px; font-size: 16px; }
.btn.icon { width: var(--tap); padding: 0; font-weight: 700; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.stepper output, .casstep output { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.step {
  width: var(--tap); height: var(--tap);
  border: 0; background: rgba(255, 255, 255, .05); cursor: pointer; font-size: 17px;
}
.step:hover:not(:disabled) { background: rgba(255, 255, 255, .12); }
.step:disabled { opacity: .3; cursor: default; }

.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); }

/* ---- the game shell ----------------------------------------------------------- */
.game {
  display: grid;
  grid-template-columns: 1fr var(--side-w);
  grid-template-rows: var(--top-h) 1fr;
  height: 100%;
}
.topbar { grid-column: 1 / -1; }
.board { position: relative; overflow: hidden; min-width: 0; }
.side { grid-row: 2; grid-column: 2; }
.info { display: flex; flex-direction: column; min-height: 0; flex: 1; border-top: 1px solid var(--rule); }
/* When the dock is tall (the purchase list) the powers and the foot may not
   fit under it at 720 px: the column scrolls rather than hiding Leave. */
.side > .info { overflow-y: auto; scrollbar-width: thin; }
.side > .info .log { min-height: 60px; }

/* ---- top bar: whose turn and the phase ---------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 10px 0 0;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 5;
}
.topbar::after { /* the turn's colour along the bottom edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--pc);
}
.who { display: flex; align-items: stretch; height: 100%; min-width: 0; }
.who-flag { width: 10px; flex: none; }
.who-text { display: flex; flex-direction: column; justify-content: center; padding: 0 14px 0 12px; min-width: 0; }
.who-text b { font-family: var(--cond); font-size: 16px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { color: var(--paper-3); font-size: 11.5px; }
.phases { list-style: none; display: flex; margin: 0; padding: 0; gap: 2px; flex: 1; min-width: 0; align-items: center; }
.phases li {
  position: relative;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--paper-3);
  white-space: nowrap;
  border-radius: 4px;
}
.phases li.done { color: var(--paper-2); }
.phases li.done::before { content: "\2713\00a0"; color: var(--paper-3); }
.phases li.now {
  color: var(--paper);
  font-weight: 650;
  background: color-mix(in srgb, var(--pc) 42%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pc) 85%, white 0%);
}
.phases li + li:not(.next)::after { content: none; }
.phases li.next { margin-left: 8px; display: flex; gap: 6px; align-items: center; border-left: 1px solid var(--rule); border-radius: 0; padding-left: 12px; }
.phases li.next::before { content: "Next"; color: var(--paper-3); font-size: 11px; }
.phases .dot, .others .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.phases .short { display: none; }
.top-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.top-actions .end { min-width: 128px; }
.side-toggle { display: none; }

/* ---- side panel: powers and the war diary ---------------------------------------- */
.side {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel-solid);
  border-left: 1px solid var(--rule);
}
.side-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 14px 6px;
  font-family: var(--cond); font-size: 13px; color: var(--paper-2); letter-spacing: .03em;
}
.powers { list-style: none; margin: 0; padding: 0 8px 6px; }
.pw {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center;
  padding: 7px 8px; border-radius: 4px;
}
.pw .swatch { background: var(--pc); }
.pw.now { background: color-mix(in srgb, var(--pc) 24%, transparent); }
.pw-name { display: flex; flex-direction: column; font-size: 13.5px; min-width: 0; }
.pw-name small { color: var(--paper-3); font-size: 11.5px; }
.pw-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
/* Completed research, one pip each; an achievement is a brass diamond. */
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 7px; height: 7px; border-radius: 50%; background: var(--paper-2); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.pips i.ach { background: var(--brass-hi); border-radius: 1px; transform: rotate(45deg); }
.pw-cash { font-family: var(--cond); font-size: 18px; font-variant-numeric: tabular-nums; }
.log {
  list-style: none; margin: 0; padding: 0 10px 10px 14px;
  overflow-y: auto; flex: 1; min-height: 0;
  font-size: 12.5px; color: var(--paper-2);
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.lg { padding: 3px 0 3px 9px; border-left: 2px solid color-mix(in srgb, var(--pc) 80%, transparent); margin: 2px 0; }
.lg.phase { margin-top: 12px; color: var(--paper); font-weight: 600; border-left-width: 4px; }
.lg.rolled { color: var(--paper-3); }
.lg.captured, .lg.capitalTaken, .lg.victory { color: var(--paper); }
.side-foot { border-top: 1px solid var(--rule); padding: 6px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; justify-content: space-between; }
.check { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--paper-2); min-height: 34px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brass); }

/* ---- the map --------------------------------------------------------------------- */
.map-host { position: absolute; inset: 0; }
.map-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.map-svg.panning { cursor: grabbing; }
.map-svg.panning .coast { filter: none; } /* cheaper while dragging */
.sea-bg { fill: var(--sea); }
.grat { pointer-events: none; }
.grat-line { stroke: var(--sea-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.seas path {
  fill: rgba(0, 0, 0, 0);
  stroke: var(--sea-border); stroke-width: .8; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke;
  cursor: pointer; transition: fill .15s;
}
.seas path:hover { fill: rgba(255, 255, 255, .035); }
.lands path {
  stroke: var(--border); stroke-width: .9; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill .5s ease;
}
.ice { fill: #c9d4d8; fill-opacity: .2; stroke: rgba(214, 226, 230, .35); stroke-width: .7; vector-effect: non-scaling-stroke; pointer-events: none; }
.preview-svg .ice { fill-opacity: .22; stroke: none; }
.backdrop { fill: #5f5c53; stroke: var(--border); stroke-width: .9; vector-effect: non-scaling-stroke; }
.hatches path { fill: url(#hatch); pointer-events: none; }
/* Desert: a warm tint and a sand stipple over the owner's colour. */
.terrain path { pointer-events: none; }
.terrain .t-desert { fill: url(#sand); }
#sand .sand-tint { fill: rgba(226, 184, 104, .26); }
#sand circle { fill: rgba(250, 226, 168, .7); }
.terrain path.t-desert { stroke: none; }
/* Devastated land (state.fallout): a hazard hatch and a warning outline. */
.fallout path { fill: url(#hazard); stroke: #f0b13c; stroke-width: 1.6; vector-effect: non-scaling-stroke; pointer-events: none; }
.fallout path.fresh { animation: fade-in .6s 1.6s both; }
@keyframes fade-in { from { opacity: 0; } }
.hazard-a { fill: rgba(240, 177, 60, .42); }
.hazard-b { fill: rgba(20, 16, 10, .32); }
/* The strike: an arc drawn out, then a flash and a ring at the target. */
.strike { pointer-events: none; }
.strike-arc { fill: none; stroke: #ffb37a; stroke-width: 3.4; filter: drop-shadow(0 0 3px rgba(255,140,80,.8)); stroke-linecap: round; vector-effect: non-scaling-stroke; }
.strike .go .strike-arc { stroke-dasharray: 1; stroke-dashoffset: 1; animation: arc .95s cubic-bezier(.5,0,.9,.6) forwards, fade .5s 1.9s forwards; }
.strike-flash { fill: #fff2d6; opacity: 0; transform-box: fill-box; transform-origin: center; }
.strike .go .strike-flash { animation: flash 1s .9s ease-out forwards; }
.strike-ring { fill: none; stroke: #ff9a5c; stroke-width: 3; vector-effect: non-scaling-stroke; opacity: 0; transform-box: fill-box; transform-origin: center; }
.strike .go .strike-ring { animation: shock 1.2s .95s ease-out forwards; }
.strike .still .strike-arc { stroke-dasharray: 6 5; opacity: .8; }
.strike .still .strike-ring { opacity: .9; }
@keyframes arc { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 0; } }
@keyframes flash { 0% { opacity: .95; transform: scale(.2); } 40% { opacity: .75; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }
@keyframes shock { 0% { opacity: 1; transform: scale(.3); } 100% { opacity: 0; transform: scale(1.8); } }
.hatch-line { stroke: rgba(20, 18, 14, .35); stroke-width: 1.4; }
.hl path { fill: none; pointer-events: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.hl .hov { stroke: rgba(255, 255, 255, .55); stroke-width: 1.4; fill: rgba(255, 255, 255, .06); }
.hl .sel { stroke: var(--paper); stroke-width: 2.4; fill: rgba(255, 255, 255, .1); }
.hl .dest, .hl .place { stroke: var(--dest); stroke-width: 2.2; fill: rgba(242, 227, 162, .16); animation: pulse 1.6s ease-in-out infinite; }
.hl .fight { stroke: #e38e7a; stroke-width: 2.6; fill: rgba(227, 142, 122, .12); }
.hl .strike { stroke: #ff7a4d; stroke-width: 2.4; fill: rgba(255, 106, 61, .2); animation: pulse 1.1s ease-in-out infinite; }
.hl .launch-from { stroke: #ff7a4d; stroke-width: 3; stroke-dasharray: 2 4; fill: none; }
.hl .load, .hl .unload { stroke: var(--load); stroke-width: 2.2; stroke-dasharray: 6 4; fill: rgba(127, 211, 200, .14); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { stroke-opacity: .45; fill-opacity: .5; } }
.route-line { fill: none; stroke: var(--dest); stroke-width: 2.4; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; pointer-events: none; stroke-linecap: round; }
.route-end { fill: var(--dest); pointer-events: none; }

.labels { pointer-events: none; }
.lbl .name {
  font-family: var(--cond); font-weight: 600; letter-spacing: .07em;
  fill: rgba(17, 18, 16, .82);
  paint-order: stroke; stroke: rgba(255, 255, 255, .14); stroke-width: 2px;
}
.lbl.sea .name { fill: rgba(196, 214, 222, .5); stroke: none; font-style: italic; font-weight: 500; letter-spacing: .1em; }
.lbl.focus .name { fill: #111; stroke: rgba(255, 255, 255, .45); }
.lbl .cap { fill: #f3ead1; stroke: #222; stroke-width: 1; }
.lbl .prod rect { fill: rgba(16, 20, 22, .8); }
.lbl .prod text { fill: var(--paper); font: 600 9.5px var(--cond); }
.lbl .fac { fill: rgba(16, 20, 22, .85); }

.stack { cursor: pointer; }
.chip circle:first-child { stroke-width: 1.3; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.5)); }
.chip .ico { pointer-events: none; }
.glyph-letter { font: 700 10px var(--cond); }
.chip .badge rect, .chip-svg .badge circle { fill: #f0ead9; stroke: rgba(0,0,0,.45); stroke-width: .8; }
.chip .badge text, .chip-svg .badge text { font: 700 9px var(--cond); fill: #16130d; }
.chip.compact circle:first-child { stroke: #f0ead9; stroke-width: 1.6; }
.stack.focus .chip circle:first-child { stroke: rgba(255,255,255,.75); }
.stack.sel .chip circle:first-child { stroke: var(--paper); stroke-width: 2; }
.cargo circle { stroke-width: .8; }
.slide-ghost { pointer-events: none; opacity: .92; }
.battle-mark { cursor: pointer; }
.battle-mark circle { fill: #7a2a20; stroke: #f0d8c8; stroke-width: 1.2; }
.battle-mark .ring { fill: none; stroke: #e38e7a; stroke-width: 2; animation: ring 1.8s ease-out infinite; transform-origin: center; transform-box: fill-box; }
.battle-mark path { stroke: #f6ebdf; stroke-width: 1.8; stroke-linecap: round; fill: none; }
@keyframes ring { from { transform: scale(.85); opacity: .9; } to { transform: scale(1.45); opacity: 0; } }

/* The hover card: everything in one territory. */
.map-card {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  min-width: 170px; max-width: 280px; padding: 8px 10px 9px;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); backdrop-filter: blur(3px);
  font-size: 12.5px;
}
.map-card[hidden] { display: none; }
.mc-head { display: flex; align-items: center; gap: 8px; font: 600 15px var(--cond); letter-spacing: .02em; }
.mc-head .tprod { margin-left: auto; }
.mc-sub { color: var(--paper-3); font-size: 11.5px; margin-bottom: 4px; }
.mc-owner { border-top: 1px solid var(--rule); padding-top: 5px; margin-top: 5px; }
.mc-who { display: flex; align-items: center; gap: 7px; color: var(--paper-2); }
.mc-n { margin-left: auto; font: 600 13px var(--cond); color: var(--paper); }
.mc-units { display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 4px; }
.mc-u { display: inline-flex; align-items: center; gap: 3px; }
.mc-u b { font: 600 13px var(--cond); font-variant-numeric: tabular-nums; }
.mc-cargo { color: var(--paper-3); font-size: 11.5px; margin-top: 3px; }
.mc-terrain { color: #dcc48e; font-size: 11.5px; margin-bottom: 3px; }
.mc-fallout { color: #f0b13c; font-size: 11.5px; margin-bottom: 3px; font-weight: 600; }
.mc-extra { color: var(--dest); font-size: 12px; margin-bottom: 3px; }

.map-ctrl {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 4px; z-index: 2;
}
.map-ctrl button {
  width: var(--tap); height: var(--tap);
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--panel); cursor: pointer; font-size: 19px; line-height: 1;
  display: grid; place-items: center;
}
.map-ctrl button:hover { background: var(--panel-solid); }

/* ---- the dock: what to do now (top of the orders column) ---------------------------- */
.dock {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; max-height: 68%; min-height: 0; flex: none;
}
.panel {
  min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel + .panel { border-top: 1px solid var(--rule); padding-top: 10px; }
.panel:last-child { flex-shrink: 1; }
.panel-head { margin-bottom: 8px; }
.thead { display: flex; align-items: center; gap: 9px; }
.tname { font-family: var(--cond); font-size: 17px; font-weight: 600; letter-spacing: .02em; flex: 1; min-width: 0; }
.tprod { font: 600 12px var(--cond); background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 3px; }
.x { width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer; font-size: 20px; color: var(--paper-3); border-radius: 4px; }
.x:hover { color: var(--paper); background: rgba(255,255,255,.07); }
.hint { margin: 8px 0 0; color: var(--paper-2); font-size: 13px; }
.warn { margin: 8px 0 0; color: #f0b9a5; font-size: 13px; }
.others { display: flex; align-items: center; gap: 7px; margin: 6px 0 0; font-size: 12.5px; color: var(--paper-2); }
.stack-body { overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.cat { font-family: var(--cond); font-size: 12px; color: var(--paper-3); margin: 8px 0 2px; letter-spacing: .04em; }
.srow { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.srow-pick {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; text-align: left;
  min-height: var(--tap); padding: 2px 6px; border: 0; border-radius: var(--r); background: transparent; cursor: pointer;
}
.srow-pick:hover { background: rgba(255,255,255,.06); }
.srow.on .srow-pick { background: rgba(242, 227, 162, .08); }
.srow-name { display: flex; flex-direction: column; font-size: 14px; }
.srow-name small { color: var(--paper-3); font-size: 11.5px; }
.chip-svg { display: block; flex: none; overflow: visible; }
.chip-svg .glyph-letter { font-size: 10px; }

.buy-head { display: flex; justify-content: space-between; align-items: flex-start; }
.big { font-family: var(--cond); font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.big small { font-size: 13px; color: var(--paper-3); font-weight: 400; }
.meter { height: 4px; background: rgba(255,255,255,.08); border-radius: 2px; margin: 8px 0 10px; overflow: hidden; }
.meter { display: flex; }
.meter i { display: block; height: 100%; transition: width .2s; }
.meter i.r { background: repeating-linear-gradient(135deg, var(--brass) 0 3px, rgba(201,165,94,.45) 3px 6px); }
/* The purchase list scrolls inside the dock; a fade and a label at the
   bottom say there is more while there is. */
.tabs { align-self: flex-start; margin-bottom: 6px; flex: none; }
.buy-head, .meter, .panel > .hint { flex: none; }
.tabs button { min-height: 32px; }
.buy-wrap { position: relative; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.buy-scroll { overflow-y: auto; min-height: 0; flex: 1 1 auto; padding-right: 2px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.buy-scroll > .cat:first-child { margin-top: 0; }
.more-cue {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34px; pointer-events: none;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 2px;
  font: 600 11px var(--cond); letter-spacing: .06em; text-transform: uppercase; color: var(--paper-2);
  background: linear-gradient(transparent, var(--panel-solid) 75%);
  opacity: 0; transition: opacity .15s;
}
.more-cue::after { content: "\2193"; margin-left: 5px; }
.buy-wrap.more .more-cue { opacity: 1; }
.ucards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
}
.ucard { position: relative; }
.ucard-add {
  width: 100%; height: 100%; min-height: 70px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  padding: 5px 6px 5px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel-2); cursor: pointer;
}
.ucard-add:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.ucard-add:disabled { opacity: .38; cursor: default; }
.ucard.on .ucard-add { border-color: rgba(201, 165, 94, .65); background: rgba(201, 165, 94, .1); }
.ucard-top { display: flex; width: 100%; justify-content: space-between; align-items: flex-start; }
.ucard-name { font-size: 12px; font-weight: 600; line-height: 1.1; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ucard-stats { font: 11px var(--cond); color: var(--paper-3); letter-spacing: .04em; }
.ucard-note {
  font: 10.5px/1.15 var(--cond); color: var(--paper-2); max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ucard-note.why { color: var(--brass-hi); }
.ucard.locked .ucard-add:disabled { opacity: 1; background: transparent; border-style: dashed; }
.ucard.locked .ucard-name, .ucard.locked .ucard-stats, .ucard.locked .cost { opacity: .5; }
.ucard .cost { font: 600 15px var(--cond); color: var(--brass-hi); }
.ucard.on .cost { margin-right: 24px; }
.ucard-less {
  position: absolute; right: 0; top: 0; width: 32px; height: 32px;
  border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--paper);
  display: grid; place-items: center;
}
.ucard-less::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: rgba(0,0,0,.45); z-index: -1; }
.ucard-less { z-index: 0; }
.legend { margin: 6px 0 0; }

/* Research rows (purchase phase, Research tab). */
.rs { padding: 8px 2px 9px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 4px; }
.rs:last-child { border-bottom: 0; }
.rs-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rs-name { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.rs-tag { font: 600 9.5px var(--cond); letter-spacing: .08em; text-transform: uppercase; color: var(--brass-ink); background: var(--brass); padding: 1px 5px; border-radius: 3px; }
.rs-num { font: 600 13px var(--cond); font-variant-numeric: tabular-nums; color: var(--paper-2); white-space: nowrap; }
.rs-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; display: flex; }
.rs-bar i { display: block; height: 100%; background: var(--paper-2); transition: width .2s; }
.rs-bar i.staged { background: repeating-linear-gradient(135deg, var(--brass) 0 3px, rgba(201,165,94,.5) 3px 6px); }
.rs.done .rs-bar i { background: #8fb27a; }
.rs-line { font-size: 12px; color: var(--paper-3); }
.rs.locked .rs-name, .rs.locked .rs-num { color: var(--paper-3); }
.rs-pay { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.rs-pay .step { width: 34px; height: 32px; }
.rs-pay output { min-width: 30px; }
.rs-done { font-size: 12.5px; color: #a9c99a; }
.rs-done::before { content: "\2713\00a0"; }

/* A missile ready to fire, in the stack panel. */
.launch { display: flex; align-items: center; gap: 9px; margin: 8px 0 2px; padding: 6px 8px; border-radius: var(--r);
  border: 1px solid rgba(213,107,85,.45); background: rgba(213,107,85,.08); }
.launch .srow-name { flex: 1; min-width: 0; }
.launch.armed { background: rgba(213,107,85,.2); border-color: var(--danger); }
.terrain-note { margin: 4px 0 0; color: #dcc48e; }
.blist { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; overflow-y: auto; }
.brow {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px;
  min-height: 48px; padding: 4px 6px 4px 10px; text-align: left;
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel-2); cursor: pointer;
}
.brow:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.brow:disabled { opacity: .45; cursor: default; }
.brow-name { display: flex; flex-direction: column; font-weight: 600; }
.brow-name small { font-weight: 400; color: var(--paper-3); font-size: 11.5px; }
.brow-odds { color: var(--paper-2); font-size: 13px; }
.as { display: inline-flex; align-items: center; }

/* ---- battle board ---------------------------------------------------------------------- */
.battle-host:empty { display: none; }
.battle-back {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(8, 12, 14, .55);
  display: grid; place-items: center; padding: 14px;
}
.battle {
  width: min(980px, 100%); max-height: 100%;
  display: flex; flex-direction: column;
  background: var(--panel-solid);
  border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  overflow: hidden;
}
.battle-head { display: flex; align-items: baseline; gap: 14px; padding: 14px 18px 10px; }
.battle-head h2 { font-family: var(--cond); font-size: 22px; letter-spacing: .02em; }
.round { color: var(--paper-3); }
.bsides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0; overflow-y: auto; min-height: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.vs { align-self: center; color: var(--paper-3); font: italic 14px var(--cond); padding: 0 4px; }
.bside { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 16%, transparent), transparent 120px); }
.bside h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.bside h3 small { color: var(--paper-3); font-weight: 400; font-size: 12px; }
.bcols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.bcol { border-radius: 5px; background: rgba(255,255,255,.035); padding: 4px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 120px; }
.bcol.empty { opacity: .55; }
.bcol-head { font: 600 20px var(--cond); color: var(--paper-2); line-height: 1; padding-top: 2px; }
.bcol-head::before { content: "\2264"; font-size: 13px; color: var(--paper-3); margin-right: 1px; }
.bcol-units { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.bcol-dice { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: auto; }
.bunit { display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 6px; padding: 2px; }
.bunit.marked { background: rgba(213, 107, 85, .25); box-shadow: inset 0 0 0 1px rgba(213, 107, 85, .7); }
.casstep { display: flex; align-items: center; }
.casstep .step { width: 30px; height: var(--tap); }
.casstep output { min-width: 16px; }
.bzero { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pre { display: flex; flex-direction: column; gap: 4px; }
.pre-roll { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.pre-roll .dice { display: flex; gap: 3px; flex-wrap: wrap; }
.lost { margin: 0; font-size: 12.5px; color: #e6a796; }
.die { display: inline-block; width: 24px; height: 24px; }
.die svg { display: block; }
.die rect { fill: #ece6d6; stroke: rgba(0,0,0,.4); }
.die circle { fill: #2a2620; }
.die.hit rect { fill: #b8452f; stroke: #f2c9bb; }
.die.hit circle { fill: #fff3ea; }
.die.tumble { animation: tumble .5s cubic-bezier(.2,.8,.3,1.2) both; }
@keyframes tumble {
  from { transform: translateY(-14px) rotate(-200deg) scale(.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.battle-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 18px; flex-wrap: wrap; }
.battle-foot .row { flex-wrap: wrap; }
.result-line { font-family: var(--cond); font-size: 19px; font-weight: 600; }
.battle-foot.result { background: rgba(201, 165, 94, .1); }
.battle-foot.result.defender .result-line { color: #e6b9aa; }
.btn.roll { min-width: 150px; }
.odds { font: 600 14px var(--cond); letter-spacing: .02em; color: var(--dest); margin-bottom: 2px; }

/* ---- overlays ----------------------------------------------------------------------- */
.modal-back { position: fixed; inset: 0; background: rgba(6, 9, 11, .6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal {
  background: var(--panel-solid); border: 1px solid var(--rule); border-radius: 10px;
  padding: 18px 20px; width: min(440px, 100%); max-height: 100%; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal h2 { font-family: var(--cond); font-size: 21px; margin-bottom: 8px; }
.modal p { color: var(--paper-2); margin: 0 0 14px; }
.modal.help { width: min(760px, 100%); }
.modal.danger { border-top: 4px solid var(--danger); }
.help .lede { color: var(--paper); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 18px; margin-bottom: 12px; }
.help-phase { border-top: 2px solid var(--brass); padding-top: 6px; }
.help-phase h3 { font-family: var(--cond); font-size: 15px; margin-bottom: 2px; }
.help-phase p { font-size: 13px; margin: 0; }
.toasts { position: fixed; left: 50%; top: calc(var(--top-h) + 10px); transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(520px, calc(100% - 24px)); }
.toast {
  background: #2c1b17; border: 1px solid #8a4535; color: #f6e2da;
  padding: 10px 14px; border-radius: 6px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toast-in .2s ease-out;
}
.toast.info { background: var(--panel-solid); border-color: var(--rule); color: var(--paper); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } }
.over-host:empty { display: none; }
/* Research banner: across the top of the map in the power's colour. */
.banner-host { position: absolute; left: 0; right: 0; top: 14px; z-index: 15; display: flex; justify-content: center; pointer-events: none; }
.banner-host:empty { display: none; }
.banner {
  position: relative; overflow: hidden; pointer-events: auto; cursor: pointer; text-align: center;
  padding: 10px 22px 12px; min-width: 300px; max-width: min(620px, calc(100% - 32px));
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 55%, var(--panel-solid)), var(--panel-solid));
  border: 1px solid color-mix(in srgb, var(--pc) 70%, white 10%); border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5); animation: drop-in .35s ease-out;
}
.banner.out { opacity: 0; transform: translateY(-10px); transition: opacity .3s, transform .3s; }
.banner-kicker { font: 600 11px var(--cond); letter-spacing: .14em; text-transform: uppercase; color: var(--brass-hi); position: relative; }
.banner-title { font: 600 19px/1.15 var(--cond); letter-spacing: .02em; margin-top: 2px; position: relative; }
.banner-body { font-size: 12.5px; color: var(--paper-2); margin-top: 3px; position: relative; }
.banner.big { padding: 18px 34px 20px; border-width: 2px; border-color: var(--brass); animation: drop-in .35s ease-out, glow 2.4s ease-in-out .4s 2; }
.banner.big .banner-kicker { font-size: 13px; }
.banner.big .banner-kicker::before, .banner.big .banner-kicker::after { content: "\2726"; margin: 0 9px; }
.banner.big .banner-title { font-size: 30px; }
.banner.big .rays {
  position: absolute; left: 50%; top: 50%; width: 900px; height: 900px; margin: -450px 0 0 -450px;
  background: repeating-conic-gradient(rgba(220,189,124,.13) 0 6deg, transparent 6deg 18deg);
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow { 50% { box-shadow: 0 16px 40px rgba(0,0,0,.5), 0 0 0 6px rgba(220,189,124,.25), 0 0 40px rgba(220,189,124,.35); } }
/* End of game: a banner across the top of the map, which stays visible. */
.endgame { position: absolute; left: 0; right: 0; top: 0; z-index: 20; display: flex; justify-content: center; padding: 16px; pointer-events: none; }
.endgame-card {
  pointer-events: auto; text-align: center; padding: 16px 26px 18px;
  background: var(--panel-solid); border: 1px solid var(--rule); border-top: 4px solid var(--pc);
  border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.55);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  animation: drop-in .35s ease-out;
}
.endgame-kicker { font: 600 12px var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--brass-hi); }
.endgame h2 { font-family: var(--cond); font-size: 36px; line-height: 1.05; }
.endgame p { margin: 0; color: var(--paper-2); }
.endgame.folded .endgame-card { flex-direction: row; padding: 8px 12px 8px 18px; gap: 14px; }
.endgame.folded h2 { font-size: 20px; }
.endgame.folded .endgame-kicker { display: none; }
@keyframes drop-in { from { transform: translateY(-16px); opacity: 0; } }

/* The dock while a computer plays. */
.cpu { border-left: 3px solid var(--pc); padding-left: 10px; }
.cpu .hint.thinking::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-radius: 50%; background: var(--brass); animation: blink 1s ease-in-out infinite; vertical-align: middle; }
@keyframes blink { 50% { opacity: .2; } }
.cpu-ctrl { margin-top: 10px; }
.level-pick:empty { display: none; }
.rules-pick { align-items: flex-start; font-size: 14px; color: var(--paper); }
.rules-pick input { margin-top: 2px; }
.rules-pick span { display: flex; flex-direction: column; }
.rules-pick small { color: var(--paper-3); font-size: 12px; }

/* ---- start screen --------------------------------------------------------------------- */
.start { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 460px); }
.start-preview { position: relative; padding: 28px; display: grid; place-items: center; background:
  linear-gradient(var(--sea-line) 1px, transparent 1px) 0 0 / 48px 48px,
  linear-gradient(90deg, var(--sea-line) 1px, transparent 1px) 0 0 / 48px 48px, var(--sea); }
.preview-svg { width: 100%; max-height: calc(100vh - 56px); border-radius: 4px; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.preview-svg .pv-land { stroke: var(--border); stroke-width: 1.2; }
.preview-svg .pv-sea { fill: none; stroke: var(--sea-border); stroke-dasharray: 3 4; }
.start-panel { background: var(--panel-solid); border-left: 1px solid var(--rule); padding: 30px 28px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.brand h1 { font-family: var(--cond); font-size: 44px; font-weight: 700; letter-spacing: .01em; line-height: 1; }
.brand p { color: var(--paper-2); margin: 10px 0 0; max-width: 36ch; }
.start-panel h2 { font-family: var(--cond); font-size: 16px; color: var(--paper-2); margin-top: 10px; border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.scen-list { display: flex; flex-direction: column; gap: 6px; }
.scen {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left;
  padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--rule); background: var(--panel-2); cursor: pointer;
}
.scen.on { border-color: var(--brass); background: rgba(201,165,94,.09); }
.scen:disabled { cursor: default; opacity: .5; }
.scen-name { font-weight: 650; font-size: 15px; }
.scen-meta { color: var(--paper-3); font-size: 12px; align-self: center; }
.scen-blurb { grid-column: 1 / -1; color: var(--paper-2); font-size: 13px; }
.power-pick { display: flex; flex-direction: column; gap: 4px; }
.pp { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; min-height: var(--tap); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.seg button { min-height: 36px; padding: 0 12px; border: 0; background: transparent; cursor: pointer; font-size: 13px; }
.seg button.on { background: rgba(232,227,213,.14); font-weight: 600; }
.seg button:disabled { opacity: .4; cursor: default; }
.saves { display: flex; flex-direction: column; gap: 6px; }
.save { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.save-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.save-text small { color: var(--paper-3); }

/* ---- smaller screens ------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .phases .long { display: none; }
  .phases .short { display: inline; }
  .phases li.next .long { display: none; }
}
@media (max-width: 900px), (max-height: 520px) {
  :root { --side-w: 300px; --top-h: 46px; }
  /* Powers and diary become a drawer over the map; the orders stay put. */
  .info {
    position: fixed; right: 0; top: var(--top-h); bottom: 0; width: min(300px, 80vw); z-index: 30;
    background: var(--panel-solid); border-left: 1px solid var(--rule);
    transform: translateX(100%); transition: transform .2s ease; box-shadow: -10px 0 30px rgba(0,0,0,.4);
  }
  .info.open { transform: none; }
  .dock { max-height: none; flex: 1; overflow-y: auto; padding: 8px; }
  .side-toggle { display: inline-block; }
  .who-text small { display: none; }
  .top-actions .end { min-width: 0; }
  .battle-head { padding: 8px 12px 6px; }
  .bside { padding: 8px 10px; }
  .bcol { min-height: 80px; }
  .battle-foot { padding: 8px 12px; }
  .start { grid-template-columns: 1fr; }
  .start-preview { display: none; }
}
@media (max-width: 640px) {
  :root { --side-w: 0px; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; max-height: 46%; z-index: 20; border-top: 1px solid var(--rule); }
  .game { grid-template-columns: 1fr; }
}
@media (max-height: 520px) {
  .phases li { padding: 4px 7px; }
  .battle-back { padding: 6px; }
  .battle-head h2 { font-size: 17px; }
  .bsides { grid-template-columns: 1fr 1fr; }
  .vs { display: none; }
}

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

/* ---- online: lobby, join, in-game strip (js/ui/lobby.js, netpanel.js) ---------------- */
.lobby-left { align-content: center; }
.lobby-left-inner { width: min(720px, 100%); display: flex; flex-direction: column; gap: 22px; align-items: stretch; }
.lobby-map .preview-svg { max-height: 44vh; }
.code-card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 22px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.code-card p { margin: 8px 0 0; color: var(--paper-2); max-width: 60ch; }
.code-card.small { box-shadow: none; padding: 14px 16px; margin-bottom: 10px; }
.code-kicker { font-family: var(--cond); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--brass); }
.code-big {
  font: 700 clamp(56px, 9vw, 108px)/1 ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  letter-spacing: .14em; color: var(--paper); margin: 8px 0 4px; user-select: all;
}
.code-card.small .code-big { font-size: 52px; }
.code-big.dim { color: var(--paper-3); }
.link-row { display: flex; gap: 8px; margin-top: 12px; }
.link-row input { flex: 1; min-width: 0; }
.lobby input[type="text"], .link-row input, .blob, .chat-in, .seat-pick {
  background: rgba(0,0,0,.25); color: var(--paper); border: 1px solid var(--rule); border-radius: var(--r);
  font: inherit; padding: 0 10px; min-height: 36px;
}
.lobby input[type="text"]:focus, .blob:focus, .chat-in:focus, .seat-pick:focus { outline: 2px solid var(--brass-hi); outline-offset: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--paper-2); }
.field input { font-size: 15px; }
.code-input { font: 700 30px/1 ui-monospace, "DejaVu Sans Mono", Menlo, monospace !important; letter-spacing: .25em; text-transform: uppercase; min-height: 54px !important; width: 9.2em; }
.seat-pick { min-width: 150px; }
.seat-pick option { background: var(--panel-solid); }
.pp.mine .pp-name { font-weight: 650; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.players li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; min-height: 36px; }
.pl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ndot { width: 10px; height: 10px; border-radius: 50%; background: #6d6a62; box-shadow: 0 0 0 2px rgba(0,0,0,.3); flex: none; }
.ndot.on { background: #7fc47a; }
.ndot.cpu { background: transparent; border: 2px solid var(--paper-3); }
.problem { color: #f0a08c; margin: 0; }
.manual { display: flex; flex-direction: column; gap: 6px; }
.blob { width: 100%; padding: 8px 10px; font: 12px/1.35 ui-monospace, "DejaVu Sans Mono", monospace; resize: vertical; word-break: break-all; }
.hint.waiting { color: var(--brass-hi); }
.online-blurb { margin: 0; }

.net { border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.net[hidden] { display: none; }
.net .side-head .btn { min-height: 28px; }
.net-seats { list-style: none; margin: 0; padding: 0 8px; }
.np { display: grid; grid-template-columns: 12px auto 1fr 12px; gap: 8px; align-items: center; min-height: 28px; padding: 0 6px; border-radius: 4px; font-size: 13px; }
.np .swatch { background: var(--pc); }
.np.now { background: color-mix(in srgb, var(--pc) 22%, transparent); }
.np-who { color: var(--paper-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-note { margin: 6px 12px 0; padding: 8px 10px; border-radius: var(--r); background: rgba(213,107,85,.12); border: 1px solid rgba(213,107,85,.35); }
.net-note p { margin: 0 0 6px; font-size: 13px; }
.chat { padding: 4px 12px 0; }
.chat-log { list-style: none; margin: 0 0 4px; padding: 0; font-size: 12.5px; color: var(--paper-2); }
.chat-log b { color: var(--paper); font-weight: 600; }
.chat-in { width: 100%; min-height: 30px; font-size: 13px; }
.panel.waiting .hint { color: var(--paper); font-size: 14px; border-left: 3px solid var(--pc); padding-left: 10px; }
.countdown { font-variant-numeric: tabular-nums; color: var(--brass-hi); }
.modal.invite { width: min(560px, 100%); }
.modal.invite h3 { font-family: var(--cond); font-size: 15px; color: var(--paper-2); margin: 14px 0 6px; }
@media (max-width: 640px) {
  .code-big { font-size: 56px; }
  .net-seats .np { min-height: 24px; }
  .chat { display: none; }
}
.net-sync { padding: 4px 14px 0; font-size: 11px; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  /* The start screen hides its map preview here; the lobby's code card must stay. */
  .start-preview.lobby-left { display: grid; padding: 16px; }
  .lobby-map { display: none; }
}
