:root {
  color-scheme: dark;
  --background: #091416;
  --panel: #101d20;
  --edge: #2b4144;
  --quiet: #aabdc0;
  --text: #eef5f1;
  --cyan: #9beac8;
  --gold: #ffc579;
  --red: #ffa28f;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(ellipse at 48% -8%, #223736 0, transparent 54%), var(--background);
  min-height: 100svh;
}
a { color: inherit }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent }
button:disabled { cursor: default }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px }
[hidden] { display: none !important }
.top, main, footer { margin: 0 auto; width: min(1160px, calc(100% - 64px)) }
.top { height: 68px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #355052 }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font: 750 12px system-ui; letter-spacing: .2em }
.mark { display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid #718c8a; font-size: 15px; color: var(--cyan); letter-spacing: 0 }
.back { color: var(--quiet); letter-spacing: .1em }
.headline { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 26px 0 23px }
h1 { margin: 0; font: 850 clamp(2.5rem, 5.6vw, 4.75rem)/.92 Inter, system-ui, sans-serif; letter-spacing: -.081em }
h1 span { color: var(--gold) }
.headline p { margin: 12px 0 0; color: var(--quiet); font-size: 14px }
.campaign { width: 272px; flex-shrink: 0 }
.campaign-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 7px; font: 650 10px ui-monospace, monospace; letter-spacing: .12em; color: var(--quiet) }
.campaign-head strong { color: var(--cyan); font-size: 12px }
#stages { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px }
.stage {
  min-height: 34px; border-radius: 4px; border: 1px solid var(--edge); background: #152528; padding: 0;
  color: var(--quiet); font: 700 12px ui-monospace, monospace;
}
.stage:disabled { background: #101c20; color: #698083 }
.stage[data-cleared="true"] { color: var(--cyan); border-color: #43695f }
.stage[aria-current="step"] { color: var(--background); background: var(--gold); border-color: var(--gold) }
.workstation { display: grid; grid-template-columns: 1.05fr 1fr; align-items: start; gap: 18px }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 13px; overflow: hidden }
.switchboard { padding: 16px clamp(14px, 2.05vw, 25px) }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px }
.eyebrow, .move-counter span, .readout span, .view-label, .view-status {
  font: 700 10px ui-monospace, monospace; letter-spacing: .14em; color: var(--quiet);
}
.eyebrow { margin: 1px 0 4px; color: var(--gold) }
.panel-head h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.05; letter-spacing: -.035em }
.brief { color: var(--quiet); margin: 9px 0 13px; font-size: 13px; line-height: 1.4 }
.move-counter { display: grid; justify-items: center; min-width: 58px; border-left: 1px solid var(--edge); padding-left: 12px }
.move-counter strong { color: var(--cyan); font: 650 24px/1.1 ui-monospace, monospace }
.grid-wrap { border: 1px solid #2e484b; border-radius: 8px; background: #080f12; padding: 6px }
.board { display: grid; grid-template-columns: repeat(var(--size, 4), 1fr); gap: 3px; max-width: 450px; margin: auto }
.tile {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; min-width: 0; padding: 0;
  border-radius: 5px; border: 1px solid #365257;
  background: linear-gradient(145deg, #263d3e, #152629);
  box-shadow: inset 0 1px 0 #ffffff12, inset 0 -2px 0 #0004;
}
.tile:not(button) { cursor: inherit }
.tile.empty { background: repeating-linear-gradient(135deg, #0f1c1f 0 4px, #101e21 4px 8px); border-color: #1c2e32; box-shadow: none }
.tile.fixed { background: #1c2829; border-color: #6c604a }
.tile[data-flood] { background: repeating-linear-gradient(135deg, #2f2525 0 6px, #251f22 6px 12px); border-color: #593b3a; color: var(--red) }
.tile[data-short] { background: repeating-linear-gradient(135deg, #642926 0 6px, #382022 6px 12px); border-color: var(--red) }
.tile[data-live] { background: radial-gradient(circle at 55% 50%, #35594c, #1c3431 72%); border-color: #587d6b }
.tile[data-hint] { outline: 2px solid var(--gold); outline-offset: -3px; z-index: 2 }
.tile:focus-visible { outline-offset: -2px; z-index: 3 }
.tile svg { display: block; width: calc(100% + 2px); height: calc(100% + 2px); position: absolute; inset: -1px; overflow: visible; pointer-events: none }
.conduit { fill: none; stroke: #101b20; stroke-width: 14; stroke-linecap: butt }
.conductor { fill: none; stroke: #74918f; stroke-width: 6; stroke-linecap: butt }
.tile[data-live] .conductor { stroke: var(--cyan); filter: drop-shadow(0 0 4px #71e6aa88) }
.joint { fill: #a0b6b0; stroke: #0e191c; stroke-width: 2 }
.tile[data-live] .joint { fill: var(--cyan); stroke: #236052 }
.open-cap { stroke: #ff9a7c; stroke-width: 3; fill: #442c2a }
.tile .symbol circle { fill: #14262b; stroke: var(--gold); stroke-width: 3 }
.tile .symbol path { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round }
.tile[data-live] .symbol circle { fill: #244936; stroke: var(--cyan) }
.tile[data-live] .symbol path { stroke: var(--cyan) }
.tile .floodmark { fill: none; stroke: #f6a391; stroke-width: 3; stroke-linecap: round }
.controls { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px }
.quiet, .primary {
  padding: 7px 11px; min-height: 36px; border: 1px solid #3b5356; border-radius: 5px;
  background: #1a2b2e; color: var(--text); font-weight: 690; font-size: 12px;
}
.quiet:disabled { color: #718a8c; background: #122022; border-color: #2b4144 }
.direction { margin-left: auto; min-width: 63px; color: var(--cyan) }
.prompt { min-height: 22px; margin-top: 8px; color: var(--quiet); font-size: 12px; line-height: 1.4 }
.completion { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #16392f; border: 1px solid #3e6e5b; border-radius: 7px; padding: 10px; margin-top: 3px }
.completion strong { color: var(--cyan); font-size: 14px }
.completion p { margin: 2px 0 0; font-size: 12px; color: #c4ded0 }
.primary { color: #19221d; background: var(--gold); border-color: var(--gold); flex-shrink: 0 }
.primary span { margin-left: 3px }
.view { height: clamp(230px, 32vw, 348px); position: relative; background: #070f19; isolation: isolate }
#harbour { width: 100%; height: 100%; display: block }
.view-label, .view-status { position: absolute; padding: 6px 8px; border: 1px solid #53666b; border-radius: 4px; background: #0d181dec; color: #e4ede9; line-height: 1.1 }
.view-label { top: 12px; left: 12px }
.view-status { bottom: 12px; left: 12px; display: flex; align-items: center; gap: 6px }
.view-status span { width: 7px; height: 7px; background: var(--red); box-shadow: 0 0 8px #fbad84; border-radius: 50% }
.lookout[data-powered] .view-status span { background: var(--cyan); box-shadow: 0 0 8px #9edec1 }
.readout { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--edge) }
.readout > div { display: grid; gap: 4px; padding: 12px 13px }
.readout > div + div { border-left: 1px solid var(--edge) }
.readout strong { color: var(--cyan); font: 690 19px ui-monospace, monospace }
.readout strong[data-warn] { color: var(--red) }
.manual { padding: 14px 17px }
.manual h2 { margin: 0; font-size: 15px }
.manual p { margin: 5px 0 10px; font-size: 13px; line-height: 1.45; color: var(--quiet) }
.manual p b { color: var(--text) }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 9px 16px }
.legend li { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--quiet) }
.key { width: 19px; height: 19px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 4px; color: var(--gold); font: 750 14px/1 system-ui }
.key.fault { color: var(--red) }
.manual .keys { margin: 10px 0 0; font-size: 11px }
kbd { background: #203337; border: 1px solid #3a5358; border-radius: 3px; padding: 1px 3px; margin-right: 2px }
footer { display: flex; flex-wrap: wrap; gap: 6px 15px; padding: 15px 0 24px; color: var(--quiet); font-size: 11px }
@media (hover: hover) {
  .tile:is(button):not(:disabled):hover { border-color: var(--cyan); background: #345751 }
  .quiet:not(:disabled):hover, .stage:not(:disabled):hover { border-color: var(--cyan) }
  .primary:hover { background: #ffdaa0 }
}
@media (max-width: 760px) {
  .top, main, footer { width: calc(100% - 24px) }
  .top { height: 50px }
  .top .quiet { min-height: 33px }
  .headline { display: grid; padding: 15px 0 11px; gap: 10px }
  .headline p { margin-top: 7px; font-size: 12px }
  .campaign { width: min(100%, 440px) }
  .stage { min-height: 36px }
  .workstation { grid-template-columns: minmax(0, 1fr); gap: 10px }
  .switchboard { padding: 10px 9px }
  .panel-head, .brief, .controls, .prompt, .completion { margin-inline: 3px }
  .lookout { display: contents }
  .observation { grid-row: 1; overflow: hidden; border: 1px solid var(--edge); border-radius: 8px; background: var(--panel) }
  .manual { border: 1px solid var(--edge); border-radius: 8px; background: var(--panel) }
  .view { height: clamp(104px, 29vw, 174px) }
  .readout { border-bottom: none }
  .readout > div { padding: 5px 9px }
  .readout strong { font-size: 14px }
  .board { max-width: 410px }
  .brief { margin-block: 6px 9px }
  .controls button { min-height: 43px }
}
@media (max-width: 360px) {
  .top, main, footer { width: calc(100% - 16px) }
  .controls { gap: 4px }
  .quiet { padding-inline: 8px }
}
