#dialog:is([data-kind="harbor-guide"], [data-kind="harbor-result"]) {
  width: min(93vw, 630px);
  background: #fff8e9;
  color: #244a55;
}
#dialog[data-kind="harbor-guide"] { width: min(95vw, 950px, calc(100% - var(--phone-left, 0px) - var(--phone-right, 0px))); }
#dialog[data-kind="harbor-guide"] .dialog-close { min-height: 44px; min-width: 44px; }
.harbor-brief-head { margin: 0 44px 10px 0; }
#dialog .harbor-brief-head h2 { color: #264b55; margin: 0 0 5px; }
#dialog .harbor-brief-head p, #dialog .harbor-controls { color: #3b5d62; margin: 0; font-size: 13px; }
.harbor-slips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.harbor-slip { display: flex; flex-direction: column; overflow: hidden; border-radius: 10px; border: 1px solid #9cbab0; background: #edf0dc; }
.harbor-slip[data-berth="crosswind"] { background: #e7eaf4; border-color: #a8b7cd; }
.harbor-slip[data-berth="tide-gates"] { background: #f5e8cc; border-color: #c6af81; }
.harbor-slip[data-berth="turning-bay"] { background: #e9ede0; border-color: #85a79c; }
.harbor-slip canvas { display: block; width: 100%; height: 78px; object-fit: contain; background: #1c4954; }
.harbor-slip-copy { display: grid; flex: 1; grid-template-rows: auto 1fr auto; padding: 8px 9px 9px; }
.harbor-slip h3 { margin: 0; color: #284c57; font-size: 17px; }
#dialog .harbor-slip p { min-height: 2.9em; margin: 3px 0 6px; font-size: 12px; color: #3d5a62; }
.harbor-slip-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 3px 8px; }
.harbor-slip-footer small { font-size: 11px; font-weight: 800; }
.harbor-record-route { display: block; margin-top: 2px; color: #3f675e; }
.harbor-slip-footer button { padding-inline: 12px; min-height: 44px; }
#dialog .harbor-controls { margin-top: 8px; padding-top: 7px; border-top: 1px solid #bfcbbe; }
.harbor-result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 108px), 1fr)); gap: 7px; margin: 12px 0 8px; }
.harbor-result-stats div { padding: 6px 8px; background: #e7eedc; border: 1px solid #b5c4ae; border-radius: 8px; }
.harbor-result-stats dt { font-weight: 800; font-size: 11px; }
.harbor-result-stats dd { margin: 3px 0 0; font: 850 clamp(13px, 3.6vw, 20px)/1.15 system-ui,sans-serif; font-variant-numeric: tabular-nums; }
#dialog .harbor-award { display: flex; align-items: center; gap: 5px; margin: 0; color: #735922; font-size: 13px; font-weight: 800; }
.harbor-award .glyph { width: 16px; height: 16px; }
.station-harbor-mark { display: flex; gap: 5px; margin-top: 5px; }
.station-harbor-mark .station-mark { flex: 1; min-width: 0; }
.station-map-head .station-harbor-link {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 5px 9px;
  border: 1px solid #789f99; border-radius: 8px; background: #dcefe4; color: #284d50; font-size: 12px; font-weight: 850;
}
.station-map-head .station-harbor-link .glyph { width: 16px; height: 16px; }
.station-map-head:has(.station-harbor-link) { flex-wrap: wrap; }

.harbor-hud {
  position: absolute; inset: calc(var(--top) + 62px) max(17px, var(--safe-right)) auto max(17px, var(--safe-left));
  display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none;
  color: #eaf4e9;
}
.harbor-hud[hidden] { display: none; }
.harbor-instruments { width: min(42vw, 300px); padding: 7px 9px; border: 1px solid #9edbb28a; border-radius: 10px; background: #193a46f0; box-shadow: 0 3px 0 #10293375; }
.harbor-meter-head { display: flex; flex-wrap: wrap; gap: 2px 9px; justify-content: space-between; font-size: 12px; font-weight: 850; font-variant-numeric: tabular-nums; }
.harbor-meter-head span + span { color: #afe0e0; }
.harbor-gates { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 5px; }
.harbor-gates[hidden] { display: none; }
.harbor-gates > span {
  --signal: #b8edce;
  display: flex; align-items: center; gap: 5px; min-width: 0; padding: 3px 5px;
  border: 1px solid #87b5ad70; border-radius: 5px; background: #284a52;
  color: var(--signal); font: 720 11px/1.25 system-ui, sans-serif;
}
.harbor-gates b { color: #eef3e3; flex: none; }
.harbor-gates i { position: relative; width: 10px; height: 9px; flex: none; }
.harbor-gates i::before, .harbor-gates i::after { content: ""; position: absolute; }
.harbor-gates i::before {
  width: 6px; height: 6px; top: 3px; left: 2px;
  border-top: 2px solid currentColor; border-left: 2px solid currentColor; transform: rotate(45deg);
}
.harbor-gates [data-state="closed"] { --signal: #f1a395; background: #4f4142; }
.harbor-gates [data-state="closed"] i::before {
  width: 9px; height: 2px; top: 4px; left: 0; border: 0; background: currentColor; transform: none;
}
.harbor-gates [data-state="warning"] { --signal: #ffdc95; background: #5a4b33; }
.harbor-gates [data-state="warning"] i::before {
  width: 2px; height: 5px; top: 0; left: 4px; border: 0; background: currentColor; transform: none;
}
.harbor-gates [data-state="warning"] i::after { width: 2px; height: 2px; bottom: 0; left: 4px; background: currentColor; }
.harbor-gates [data-state="held"] { --signal: #a4e6fa; }
.harbor-gates [data-state="held"] i::before { top: 1px; }
.harbor-gates [data-state="held"] i::after {
  width: 6px; height: 6px; top: 5px; left: 2px;
  border-top: 2px solid currentColor; border-left: 2px solid currentColor; transform: rotate(45deg);
}
.harbor-checks { display: flex; flex-wrap: wrap; list-style: none; padding: 0; margin: 5px 0; gap: 4px; }
.harbor-checks li { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 4px; color: #ebdfba; background: #5c554b; font-size: 11px; line-height: 1.25; font-weight: 720; }
.harbor-checks i { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.harbor-checks [data-ready] { color: #c3f8d5; background: #285642; }
.harbor-checks [data-ready] i { background: currentColor; }
.harbor-hold { height: 4px; border-radius: 4px; overflow: hidden; background: #284c57; }
.harbor-hold i { display: block; height: 100%; transform: scaleX(0); transform-origin: left; background: #ace8be; }
.harbor-live-cue { margin: 5px 0 0; color: #f5e5bc; font-size: 11px; font-weight: 720; line-height: 1.4; }
.harbor-bumps:not([hidden]) { display: block; margin-top: 3px; color: #ffd6ae; font-size: 11px; font-weight: 760; }
.harbor-chart-frame { width: clamp(97px, 17vw, 172px); flex: none; margin: 0; }
.harbor-chart { display: block; width: 100%; height: auto; border: 1px solid #88c2c5; border-radius: 8px; box-shadow: 0 2px 0 #1e3e4b99; }
.harbor-chart-frame figcaption {
  width: max-content; max-width: 100%; margin: 3px 0 0 auto; padding: 2px 5px;
  border-radius: 4px; background: #193a46f0; color: #d2efe6; font: 740 11px/1.25 system-ui,sans-serif;
}
#app[data-play="harbor"] :where(.race-only,.ability-status,.keyboard-guide:not(.harbor-keyboard),#dash,#jump,#live-camera) { display: none; }
#app[data-play="harbor"] .race-place { justify-self: start; width: max-content; min-width: 0; }
#app[data-play="harbor"] .harbor-keyboard { display: flex; }
#app[data-play="harbor"] #interact { background: #294e63; color: #fff3cc; border-color: #c6ded6; }
#app[data-play="harbor"] #interact[data-braking] { background: #e9c780; color: #29414e; }
.harbor-keyboard { display: none; }
.harbor-keyboard kbd { white-space: nowrap; }
.harbor-loop-steps, .harbor-loop-receipt ol { list-style: none; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); padding: 0; }
.harbor-loop-steps { gap: 3px; margin: 5px 0 0; }
.harbor-loop-steps[hidden] { display: none; }
.harbor-loop-steps li { border-top: 2px solid #618482; padding-top: 2px; color: #b9d1cc; font: 720 11px/1.25 system-ui,sans-serif; white-space: nowrap; }
.harbor-loop-steps li[data-state="active"] { border-color: #ffce78; color: #ffe4a8; }
.harbor-loop-steps li[data-state="done"] { border-color: #92d9b4; color: #b5edcb; }
.harbor-loop-receipt { margin: 9px 0; padding: 7px 9px; background: #254d54; color: #eff3df; border-radius: 8px; }
.harbor-loop-receipt header { display: flex; flex-wrap: wrap; gap: 3px 10px; align-items: baseline; }
.harbor-loop-receipt h3 { margin: 0; color: #ffe1a0; font-size: 16px; line-height: 1.2; }
.harbor-loop-receipt header small { color: #c2ded4; font-size: 11px; }
.harbor-loop-receipt ol { margin: 5px 0 0; gap: 6px; }
.harbor-loop-receipt li { display: grid; gap: 2px; padding-top: 4px; border-top: 1px solid #81978c; font: 700 11px/1.2 system-ui,sans-serif; }
.harbor-loop-receipt li b { font-size: 15px; font-variant-numeric: tabular-nums; }
.harbor-loop-receipt li small { font-size: 10px; color: #c4dcd1; }
.harbor-loop-receipt [data-pace="gain"] { color: #b4f4c8; }
.harbor-loop-receipt [data-pace="loss"] { color: #ffd0aa; }
@media (min-width: 476px) and (max-width: 599px) { .harbor-slips { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (any-pointer: coarse) { #app[data-play="harbor"] .harbor-keyboard { display: none; } }
#app[data-play="harbor"].touch-hud .harbor-keyboard { display: none; }
@media (orientation: landscape) and (max-height: 400px) {
  #dialog[data-kind="harbor-guide"] .dialog-content { padding: 8px 13px; }
  #dialog[data-kind="harbor-guide"] h2 { font-size: 26px; line-height: 1.1; margin-bottom: 4px; }
  .harbor-brief-head { margin-bottom: 6px; }
  #dialog .harbor-brief-head p, #dialog .harbor-controls { font-size: 11px; line-height: 1.4; }
  #dialog .harbor-controls { margin-top: 5px; padding-top: 5px; }
  .harbor-slip canvas { height: 48px; }
  .harbor-slip-copy { padding: 5px 7px 6px; }
  .harbor-slip h3 { font-size: 15px; }
  #dialog .harbor-slip p { min-height: 0; margin: 3px 0 4px; font-size: 11px; line-height: 1.35; }
  .harbor-hud { inset: calc(var(--top) + 51px) var(--phone-right) auto var(--phone-left); }
  .harbor-instruments { width: min(36vw, 255px); padding: 5px 7px; }
  .harbor-checks { gap: 3px; }
  .harbor-checks li { gap: 2px; padding-inline: 3px; font-size: 10px; white-space: nowrap; }
  .harbor-checks i { width: 5px; height: 5px; flex: none; }
  .harbor-gates > span { gap: 3px; padding: 3px 4px; }
  .harbor-slips { gap: 5px; }
  .harbor-slip-footer button { padding-inline: 8px; }
  #harbor-hud[data-harbor-loop] .harbor-instruments { width: clamp(152px,27vw,205px); }
  .harbor-loop-steps { grid-template-columns: 1fr 1.1fr 1.5fr 1fr; }
  .harbor-loop-steps li { font-size: 10px; }
}
@media (orientation: landscape) and (max-height: 360px) and (min-width: 600px) {
  #dialog[data-kind="harbor-guide"] .dialog-content { padding: 6px 9px; }
  #dialog[data-kind="harbor-guide"] .dialog-close { top: 3px; right: 4px; }
  #dialog[data-kind="harbor-guide"] .harbor-brief-head { display: flex; align-items: center; gap: 10px; margin: 0 43px 5px 0; min-height: 36px; }
  #dialog[data-kind="harbor-guide"] .harbor-brief-head h2 { flex: none; margin: 0; font-size: 23px; }
  #dialog .harbor-brief-head p { line-height: 1.3; }
  .harbor-slip canvas { height: 34px; }
  .harbor-slip-copy { padding: 4px 5px; }
  .harbor-slip-footer { display: grid; grid-template-columns: minmax(0,1fr) 44px; gap: 3px; align-items: end; }
  .harbor-slip-footer small { font-size: 10px; line-height: 1.17; }
  .harbor-slip-footer button { min-width: 44px; padding: 2px; font-size: 12px; }
  #harbor-hud[data-harbor-loop] .harbor-instruments:has([data-loop-step="dock"][data-state="active"]) {
    width: clamp(197px,32vw,230px); display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; column-gap: 6px;
  }
  .harbor-instruments:has([data-loop-step="dock"][data-state="active"]) .harbor-loop-steps { display: block; margin: 0; }
  .harbor-instruments:has([data-loop-step="dock"][data-state="active"]) .harbor-loop-steps li[data-state="done"] { display: none; }
  .harbor-instruments:has([data-loop-step="dock"][data-state="active"]) :is(.harbor-docking,.harbor-live-cue,.harbor-bumps) { grid-column: 1/-1; }
  .harbor-instruments:has([data-loop-step="dock"][data-state="active"]) .harbor-checks { display: flex; gap: 2px; }
  .harbor-instruments:has([data-loop-step="dock"][data-state="active"]) .harbor-checks li { gap: 2px; padding-inline: 2px; font-size: 10px; white-space: nowrap; }
}
@media (orientation: landscape) and (max-height: 420px) and (min-width: 480px) {
  #dialog[data-kind="harbor-result"]:has(.harbor-loop-receipt) .dialog-content {
    display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); align-items: start; padding: 9px 13px; gap: 5px 9px;
    grid-template-areas: "head head log log" "stats stats log log" "reward reward log log" "actions actions actions choice";
  }
  #dialog:has(.harbor-loop-receipt) .dialog-content > * { margin: 0; }
  #dialog .harbor-result-head:has(~ .harbor-loop-receipt) { grid-area: head; }
  #dialog .harbor-result-head:has(~ .harbor-loop-receipt) h2 { font-size: 23px; line-height: 1.15; margin: 0 0 2px; }
  .harbor-result-stats:has(+ .harbor-loop-receipt) { grid-area: stats; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; }
  .harbor-result-stats:has(+ .harbor-loop-receipt) div { padding: 5px; }
  .harbor-result-stats:has(+ .harbor-loop-receipt) dd { font-size: 15px; margin-top: 2px; }
  .harbor-loop-receipt { grid-area: log; padding: 6px 8px; }
  .harbor-loop-receipt ol { grid-template-columns: 1fr; gap: 0; margin-top: 5px; }
  .harbor-loop-receipt li { grid-template-columns: 1fr auto auto; align-items: baseline; gap: 6px; padding-block: 3px; }
  .harbor-loop-receipt ~ .harbor-award { grid-area: reward; }
  .harbor-loop-receipt ~ .dialog-actions { grid-area: actions; gap: 5px; }
  .harbor-loop-receipt ~ .result-activity-footer { grid-area: choice; padding: 0; border: 0; justify-content: flex-end; }
  .harbor-loop-receipt ~ :is(.dialog-actions,.result-activity-footer) button { min-width: 44px; min-height: 44px; padding: 3px 6px; }
}
@media (orientation: portrait) and (max-width: 475px) {
  .harbor-slips { grid-template-columns: 1fr; }
  .harbor-slip { display: grid; grid-template-columns: 88px minmax(0, 1fr); }
  .harbor-slip canvas { align-self: stretch; height: 100%; }
  #dialog .harbor-slip p { min-height: 0; }
  .harbor-hud { inset: calc(var(--top) + 53px) var(--phone-right) auto var(--phone-left); gap: 5px; }
  .harbor-instruments { width: 60%; padding: 5px 6px; }
}
