:root {
  color-scheme: dark;
  --page: #0a1a23;
  --panel: #112831;
  --line: #29434d;
  --text: #f0f5ee;
  --muted: #adc1c7;
  --gold: #ffcc72;
  --aqua: #65e1d8;
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; background: radial-gradient(ellipse at 15% 0, #173743 0, var(--page) 55%); color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 1228px; margin-inline: auto; padding-inline: 28px; }
.site-head { border-bottom: 1px solid #ffffff14; background: #0a1b24d9; }
.masthead { display: flex; justify-content: space-between; align-items: center; min-height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .13em; font-size: .87rem; }
.brand b { color: var(--gold); font-weight: 720; }
.quiet { background: #182e38; border: 1px solid #3a5259; border-radius: 8px; padding: 7px 12px; font-size: .86rem; font-weight: 650; }
.quiet:hover { background: #24434c; }
.quiet:disabled { opacity: .45; }
.question { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 4px; border: 1px solid #859da4; border-radius: 50%; font-size: .72rem; }
.hero { margin-top: 18px; border: 1px solid #31505b; position: relative; overflow: hidden; border-radius: 14px; background: #173642; isolation: isolate; }
.hero::before { content: ''; position: absolute; inset: 0; z-index: -2; background: url('./media/lighthouse.jpg') center 34% / cover no-repeat; }
.hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, #0c212bf7, #102831d9 36%, #132c3390 58%, #1029320c 83%), linear-gradient(0deg, #10252f73, transparent 70%); }
.hero-copy { padding: 22px 29px 24px; }
.kicker { display: block; color: #93c6c6; font-size: .68rem; letter-spacing: .16em; font-weight: 800; text-transform: uppercase; }
.hero .kicker { color: #f7cc80; }
h1,h2,p { margin: 0; }
h1 { font: 500 clamp(2.25rem, 5.6vw, 4rem)/1.02 Georgia, 'Times New Roman', serif; letter-spacing: -.037em; margin: 4px 0 9px; }
.hero p { color: #dbe6e4; font-size: .94rem; max-width: 32rem; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 345px); align-items: start; gap: 15px; margin-top: 15px; }
.panel { background: linear-gradient(145deg, #17313a, var(--panel) 58%); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 12px 30px #050e1455; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 16px 11px; }
.panel h2, dialog h2 { font: 500 1.63rem/1.1 Georgia, 'Times New Roman', serif; margin-top: 3px; }
.chart-mode { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 99px; color: #bfdfdc; background: #1c4147; font: 650 .7rem/1.2 system-ui, sans-serif; white-space: nowrap; }
.chart-mode i { width: 6px; height: 6px; border-radius: 50%; background: var(--aqua); }
.chart-mode[data-phase="collision"] { color: #ffd0d1; background: #4a2e37; }
.chart-mode[data-phase="collision"] i { background: #ffa3a9; }
.chart-shell { display: grid; grid-template: 17px 1fr / 17px 1fr; padding: 0 12px 0 5px; }
.longitude, .latitude { color: #a5bdc3; display: grid; text-align: center; align-items: center; font: 650 9px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.longitude { grid-area: 1/2; grid-auto-flow: column; grid-auto-columns: 1fr; }
.latitude { grid-area: 2/1; grid-auto-rows: 1fr; }
.board { grid-area: 2/2; position: relative; isolation: isolate; width: 100%; aspect-ratio: var(--cols, 11) / var(--rows, 7); overflow: hidden; border-radius: 7px; border: 1px solid #47747e; touch-action: none; user-select: none; }
.cells, .markers, #routes { position: absolute; inset: 0; width: 100%; height: 100%; }
.cells { display: grid; grid-template-columns: repeat(var(--cols, 11), 1fr); grid-template-rows: repeat(var(--rows, 7), 1fr); background: #12404e; }
.cell { min-width: 0; min-height: 0; color: #d5eceb; background: hsl(191 53% var(--shade)); border: 0; border-right: 1px solid #9fdcd825; border-bottom: 1px solid #9fdcd825; padding: 0; position: relative; }
.cell::before { content: ''; position: absolute; width: 30%; height: 1px; top: 66%; left: 20%; border-radius: 50%; background: #b7f4e421; box-shadow: 4px -6px 0 -0.25px #b7f4e436; pointer-events: none; }
.cell:nth-child(3n)::before { left: 45%; top: 33%; width: 18%; }
.cell.rock { cursor: default; background: repeating-linear-gradient(139deg, transparent 0 5px, #100c081a 5px 6px), radial-gradient(at 68% 23%, #7d897b, #606c63 70%); border-color: #213f4875; }
.cell.rock::before { height: 37%; width: 54%; left: 23%; top: 33%; background: #858b7c; clip-path: polygon(16% 21%, 53% 0, 94% 31%, 100% 72%, 46% 100%, 0 74%); box-shadow: inset 2px 0 #9da195; }
.cell.shore-n { border-top: 2px solid #b9b29d88; }
.cell.shore-e { border-right: 2px solid #b9b29d88; }
.cell.shore-s { border-bottom: 2px solid #b9b29d88; }
.cell.shore-w { border-left: 2px solid #b9b29d88; }
.cell.eligible { box-shadow: inset 0 0 0 1px #bce7df66; }
.cell.eligible::after { content: ''; position: absolute; width: 5px; height: 5px; left: calc(50% - 2px); top: calc(50% - 2px); border-radius: 50%; background: #e4ffdcaa; }
.cell:not(.rock):hover { background: #2b6069; }
.cell:focus-visible { outline: 2px solid white; outline-offset: -3px; z-index: 1; }
#routes, .markers { pointer-events: none; }
.marker { position: absolute; width: calc(100% / var(--cols)); height: calc(100% / var(--rows)); display: grid; place-items: center; }
.dock-dot { width: 51%; height: 51%; border-radius: 50%; border: 2px solid var(--ship); color: var(--ship); display: grid; place-items: center; background: #092732cf; font: 800 clamp(.56rem, 1.15vw, .9rem)/1 ui-monospace, monospace; box-shadow: 0 0 0 3px #10283171; }
.dock-dot.done { background: var(--ship); color: #142834; }
.boat-icon { aspect-ratio: 1; width: 58%; display: grid; place-items: center; background: var(--ship); color: #0d2631; border-radius: 15% 30% 30% 15%; transform: rotate(var(--angle, 0deg)); clip-path: polygon(3% 17%, 63% 17%, 100% 50%, 63% 83%, 3% 83%, 12% 50%); }
.boat-icon b { transform: rotate(calc(-1 * var(--angle, 0deg))); font: 850 clamp(.55rem, 1.05vw, .83rem)/1 ui-monospace, monospace; }
.boat-marker.active::before { content: ''; position: absolute; width: 74%; height: 74%; border: 1px dashed var(--ship); border-radius: 25%; }
.hit-marker { z-index: 2; }
.hit { background: #ffadb0; color: #671c25; border: 2px solid white; border-radius: 50%; width: 67%; height: 67%; display: grid; place-items: center; font-size: clamp(.75rem, 2.5vw, 1.4rem); line-height: 1; font-weight: 850; box-shadow: 0 0 14px #ffaaa7ae; }
.legend { display: flex; gap: 16px; align-items: center; padding: 10px 14px 11px 22px; color: var(--muted); font-size: .73rem; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 11px; height: 11px; }
.legend-ship { background: var(--gold); clip-path: polygon(0 20%, 65% 20%, 100% 50%, 65% 80%, 0 80%); }
.legend-dock { border: 1.5px solid var(--aqua); border-radius: 50%; }
.legend-rock { background: #8f9b87; clip-path: polygon(0 38%, 56% 0, 100% 32%, 75% 100%, 15% 85%); }
.legend .key-tip { margin-left: auto; }
kbd { font: inherit; border-radius: 4px; padding: 1px 3px; background: #26434c; }
.mission-head { padding: 15px 15px 12px; border-bottom: 1px solid var(--line); }
.mission-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.count { color: var(--muted); font-size: .72rem; font-weight: 650; }
.mission-head p { color: #c0d4d8; line-height: 1.35; font-size: .85rem; margin-top: 6px; }
.levels { display: flex; gap: 6px; margin-top: 10px; }
.level { display: grid; place-items: center; width: 29px; height: 26px; border: 1px solid #37535d; border-radius: 6px; background: #0e2630; color: #bbd1d4; font-size: .77rem; font-weight: 800; }
.level[aria-current="step"] { background: #f3c77a; border-color: #f3c77a; color: #152a34; }
.level.complete:not([aria-current="step"]) { color: var(--aqua); border-color: #408984; }
.level:disabled { opacity: .5; }
.fleet { display: grid; gap: 7px; padding: 11px 12px 0; }
.ship { display: grid; grid-template-columns: 1fr auto; gap: 3px 6px; border: 1px solid #37515b; background: #102631; border-radius: 8px; padding: 7px 8px; }
.ship.selected { border-color: var(--ship); box-shadow: inset 2px 0 var(--ship); background: #1c3943; }
.ship-select { display: grid; grid-template-columns: auto 1fr; align-items: center; text-align: left; gap: 7px; background: transparent; border: 0; padding: 0; }
.ship-badge { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; background: var(--ship); color: #17252b; font: 850 .85rem/1 ui-monospace, monospace; }
.ship-name { display: block; font-weight: 750; line-height: 1.18; font-size: .87rem; }
.ship-state { display: block; font-size: .66rem; line-height: 1.3; color: #b1cace; margin-top: 2px; }
.ship-state.complete { color: #9fecde; }
.delay { display: grid; grid-template-columns: 24px minmax(23px,auto) 24px; gap: 2px; align-items: center; }
.delay-label { grid-column: 1/-1; text-align: center; font-size: .61rem; color: #b4c9cb; }
.delay-change { border: 1px solid #45616b; background: #193543; border-radius: 4px; line-height: 1; min-height: 22px; padding: 0; }
.delay-change:disabled { opacity: .32; }
.delay-change:hover:not(:disabled) { border-color: var(--ship); }
.delay-value { font: 750 .76rem/1 ui-monospace, monospace; text-align: center; color: #e7eff1; }
.controls { padding: 11px 12px 12px; }
.status { min-height: 2.8em; color: #c5d8dc; font-size: .79rem; line-height: 1.35; margin-bottom: 7px; }
.status[data-phase="collision"] { color: #ffc6c7; }
.status[data-phase="won"] { color: #96e8d4; }
.actions { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.primary { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 8px 12px; border: 1px solid #f6d08c; background: var(--gold); border-radius: 7px; color: #182630; font-weight: 820; font-size: .88rem; }
.primary:hover { background: #ffdb9a; }
.primary:disabled { opacity: .48; }
.reset { min-width: 39px; padding: 5px 8px; font-size: 1.4rem; line-height: 1; }
.hint-button { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; padding: 7px 2px 0; color: #b8d8d9; background: none; font-size: .78rem; text-align: left; }
.hint-button:hover { color: white; }
.hint-text { color: #c0d4d8; font-size: .78rem; line-height: 1.4; padding: 5px 2px 0; }
footer { display: flex; justify-content: space-between; gap: 8px; padding-block: 10px 17px; color: #a1b9bf; font-size: .7rem; }
footer span:first-child { color: #c8d8d9; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
dialog { width: min(455px, calc(100% - 24px)); max-height: calc(100% - 24px); border: 1px solid #52717a; background: #152f39; color: var(--text); border-radius: 13px; padding: 19px; }
dialog::backdrop { background: #040d15c9; }
.dialog-head { display: flex; justify-content: space-between; gap: 15px; }
.close { font-size: 1.1rem; }
dialog ol { display: grid; gap: 9px; padding-left: 21px; color: #d7e5e4; }
dialog .primary { width: 100%; }
@media (min-width: 920px) and (max-height: 810px) {
  .wrap { max-width: 1030px; }
  .hero-copy { padding-block: 14px 16px; }
  h1 { font-size: 3.2rem; }
}
@media (max-width: 860px) {
  .wrap { padding-inline: 16px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 284px; gap: 10px; }
}
@media (max-width: 680px) {
  .wrap { padding-inline: 12px; }
  .masthead { min-height: 52px; }
  .hero { margin-top: 10px; }
  .hero-copy { padding: 16px 13px; }
  .hero::before { background-position: 67% 38%; }
  .hero::after { background: linear-gradient(90deg,#0c212bf7,#102831cc 55%,#10283155); }
  .hero p { font-size: .82rem; max-width: 18rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); margin-top: 10px; }
  .panel-head { padding: 9px 10px 6px; }
  .panel h2 { font-size: 1.37rem; }
  .chart-shell { padding-right: 7px; grid-template: 14px 1fr / 13px 1fr; }
  .legend { padding: 7px 9px 8px 18px; }
  .legend .key-tip { display: none; }
  .mission-head { padding: 11px 12px 9px; }
  .level { width: 34px; height: 31px; }
  .delay { grid-template-columns: 29px minmax(23px,auto) 29px; }
  .delay-change { min-height: 27px; }
}
