html, body { margin: 0; height: 100%; overflow: hidden; background: #0F2742; }
canvas { display: block; }
#banner {
  position: fixed; top: 0; left: 0; right: 0; pointer-events: none;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
}
#headline {
  margin: 0;
  font-family: Helvetica, Roboto, Arial, sans-serif;
  font-size: clamp(15px, min(2.8vw, 3.4vh), 30px);
  letter-spacing: 0.5px;
  font-weight: bold;
  text-align: center;
  text-shadow: 0 0 2px #C8C8C8;
  color: #0F0104;
  transition: color 2s, opacity 1.5s;
}
#headline.gone { opacity: 0; }
#headline.inside { text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
/* What went wrong, under the headline: a dark pill so it reads against sea or sky. */
#subline {
  width: fit-content; max-width: min(560px, 100%); box-sizing: border-box; margin: 8px auto 0; padding: 7px 14px; border-radius: 12px;
  font: bold clamp(12px, min(1.8vw, 2.2vh), 15px)/1.4 Helvetica, Roboto, Arial, sans-serif; color: #fff; text-align: center;
  background: rgba(14, 20, 24, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 0 0 1.5px rgba(255, 77, 61, 0.7);
}
#subline[hidden] { display: none; }
#subline > span { display: block; }
/* Someone on the radio: a card of its own, in place of the headline. A top line says who's talking, with a green light
   and signal bars that dance while they talk; under it their words come out one at a time (the rest held in place,
   unseen, so the card doesn't grow as they do). */
#banner.on-air #headline { display: none; }
#subline.radio {
  width: min(440px, 100%); margin-top: 0; padding: 11px 16px 13px; border-radius: 16px; text-align: left; font-weight: normal;
  background: rgba(14, 20, 24, 0.72); color: #eef1f2;
  box-shadow: inset 0 0 0 1px rgba(95, 224, 138, 0.3), 0 4px 18px rgba(0, 0, 0, 0.25);
  animation: tune-in 0.35s ease-out; transition: opacity 0.8s;
}
#subline.radio.gone { opacity: 0; pointer-events: none; }
/* A click says the rest at once, and the next puts it away (hud.js). */
#subline.radio { pointer-events: auto; cursor: pointer; }
#subline .caller {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
  font: bold 10.5px/1.2 Helvetica, Roboto, Arial, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: #5fe08a;
}
#subline .caller .led { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #5fe08a; box-shadow: 0 0 7px #5fe08a; opacity: 0.5; transition: opacity 0.4s; }
#subline.talking .caller .led { opacity: 1; }
#subline .caller .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#subline .signal { display: flex; align-items: flex-end; gap: 2px; height: 11px; flex: none; }
#subline .signal span { width: 3px; height: 3px; border-radius: 1px; background: currentColor; opacity: 0.6; }
#subline.talking .signal span { animation: signal 0.9s ease-in-out infinite alternate; }
#subline.talking .signal span:nth-child(2) { animation-delay: -0.3s; }
#subline.talking .signal span:nth-child(3) { animation-delay: -0.6s; }
#subline.talking .signal span:nth-child(4) { animation-delay: -0.45s; animation-duration: 0.7s; }
#subline .line { margin: 0; font: clamp(14px, min(2vw, 2.4vh), 16px)/1.45 Georgia, 'Times New Roman', serif; }
#subline .line + .line { margin-top: 5px; }
#subline .unsaid { visibility: hidden; }
@keyframes tune-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes signal { from { height: 3px; } to { height: 11px; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #subline.radio, #subline.talking .signal span { animation: none; } }
/* Whoever's talking, if they have a portrait (faces.js): a round face at the card's side; two at once overlap. */
#subline.radio.with-face { position: relative; min-height: 84px; padding-left: 86px; }
#subline > .face { position: absolute; left: 14px; top: 13px; width: 58px; height: 58px; }
#subline > .face svg { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 0 0 2px rgba(95, 224, 138, 0.35); }
#subline > .face.pair svg { position: absolute; width: 44px; height: 44px; }
#subline > .face.pair svg:first-child { left: -4px; top: -2px; }
#subline > .face.pair svg:last-child { left: 18px; top: 22px; }
/* Toasts: quieter news, stacked at the top right (below the New version pill when it's up), sliding in and away. */
#corner {
  position: fixed; z-index: 4; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none;
}
#toasts { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#update:not([hidden]) ~ #corner { top: calc(max(12px, env(safe-area-inset-top)) + 52px); }
/* The gauge (hud.js tracker()): a toast that stays, at the top right, with the toasts stacking below it. */
#tracker { width: min(240px, calc(100vw - 32px)); animation: toast-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
#tracker[hidden] { display: none; }
#tracker .words { flex: 1; }
#tracker .bar { display: block; height: 8px; margin: 5px 0 3px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; opacity: 1; }
#tracker .bar i { display: block; height: 100%; width: var(--fill, 0%); border-radius: 4px; background: linear-gradient(90deg, #ff4fa3, #ffe03a 40%, #3dff8a 70%, #2fd8ff); transition: width 0.4s; }
#tracker .reading { font-size: 12px; font-variant-numeric: tabular-nums; }
/* Its warning (paint drones coming): a red line blinking under the reading, and a red edge round the card. */
#tracker.alert { box-shadow: inset 0 0 0 1.5px rgba(255, 77, 61, 0.85), 0 4px 18px rgba(0, 0, 0, 0.25); }
#tracker .words .alert { font-size: 12px; font-weight: bold; color: #ff6a5a; opacity: 1; animation: blink 0.8s steps(1) infinite; }
#tracker .alert[hidden], #tracker .sub[hidden] { display: none; }
/* A race's (races.js): its clock on a line of its own, and a plain blue bar, amber when the time's nearly up. */
#tracker .sub { font-size: 15px; font-weight: bold; font-variant-numeric: tabular-nums; opacity: 1; }
#tracker[data-kind=race] .bar i { background: #3d8bff; }
#tracker[data-kind=race].late .bar i { background: #ffb03a; }
@media (prefers-reduced-motion: reduce) { #tracker .words .alert { animation: none; } }
/* A distance to keep (the strange signal's tail, mystery.js): a band to stay in on a red scale, a mark for where she
   is (red outside it), the band's ends in metres under it, and the badge's arrow pointing the way. */
#tracker .bar[hidden], #tracker .range[hidden], #tracker .ends[hidden] { display: none; }
#tracker .range { position: relative; display: block; height: 8px; margin: 7px 0 2px; border-radius: 4px; background: rgba(255, 77, 61, 0.35); opacity: 1; }
#tracker .range .band { position: absolute; top: 0; bottom: 0; background: rgba(61, 255, 138, 0.5); opacity: 1; }
#tracker .range .you { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; border-radius: 2px; background: #fff; box-shadow: 0 0 4px rgba(0, 0, 0, 0.7); opacity: 1; transition: left 0.3s; }
#tracker .range .you.out { background: #ff6a5a; }
#tracker .ends { position: relative; display: block; height: 13px; font-size: 10px; font-variant-numeric: tabular-nums; }
#tracker .ends span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; opacity: 0.7; }
#tracker .badge .aim { width: 18px; height: 18px; fill: #f2c200; }
.toast {
  display: flex; align-items: center; gap: 12px; box-sizing: border-box; min-width: min(200px, calc(100vw - 32px)); max-width: min(320px, calc(100vw - 32px)); padding: 12px 18px 12px 12px; border-radius: 14px;
  font: 14px/1.3 Helvetica, Roboto, Arial, sans-serif; color: #eef1f2;
  background: rgba(14, 20, 24, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px rgba(242, 194, 0, 0.3), 0 4px 18px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2); transition: opacity 0.5s, transform 0.5s;
}
.toast.gone { opacity: 0; transform: translateX(24px); }
.toast .badge { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; color: #f2c200; background: rgba(242, 194, 0, 0.14); }
.toast .badge .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toast .words { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast strong { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: #f2c200; }
.toast .words span { opacity: 0.85; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; transition: opacity 0.5s; } .toast.gone { transform: none; } }
/* Paused: the world holds still behind a dim veil. */
/* The HUD and the mini map sit above it (z-index 6), so the menus can be opened while paused. */
#paused { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(8, 12, 16, 0.45); cursor: pointer; z-index: 5; }
#paused[hidden] { display: none; }
#paused .card { padding: 22px 36px; border-radius: 20px; text-align: center; color: #eef1f2; font: 13px/1.4 Helvetica, Roboto, Arial, sans-serif; background: rgba(14, 20, 24, 0.85); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3); }
#paused h2 { margin: 0 0 6px; font-size: 30px; letter-spacing: 4px; text-transform: uppercase; }
#paused p { margin: 0; opacity: 0.7; }
/* ---- HUD: the speedo in the bottom-left corner and a control panel in the bottom-right ---- */
/* It runs right across the bottom, letting clicks through between them. */
#hud {
  position: fixed; z-index: 6; left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; pointer-events: none;
  font: 12px/1.3 Helvetica, Roboto, Arial, sans-serif; color: #eef1f2; white-space: nowrap;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#hud > * { pointer-events: auto; }
/* Shared glass for the panel, the speedo and the sheets. */
#panel, #speedo, .sheet {
  background: rgba(14, 20, 24, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}
#hud.hit #panel, #hud.hit #speedo { box-shadow: 0 0 0 2px #ff6b5e, 0 4px 18px rgba(0, 0, 0, 0.25); }

#panel { width: 296px; box-sizing: border-box; padding: 12px; border-radius: 18px; display: flex; flex-direction: column; gap: 10px; }
#panel .readout { display: flex; flex-direction: column; gap: 3px; padding: 0 2px; }
#panel .topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#money { font-weight: bold; font-size: 18px; color: #f2c200; font-variant-numeric: tabular-nums; transition: color 0.3s; }
#clock { display: flex; align-items: center; gap: 4px; font-weight: bold; font-variant-numeric: tabular-nums; opacity: 0.85; }
#clock svg { width: 13px; height: 13px; fill: currentColor; }
/* With a fortune in the bank on a narrow screen, the day gives way rather than the minimise key. */
#clock { min-width: 0; }
#clock svg, #money, #hud .topline button { flex: none; }
#clock-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#clock #clock-moon, #clock.night #clock-sun { display: none; }
#clock.night #clock-moon { display: inline; }
#money.earning { color: #53f06f; }
#engine { font-weight: bold; letter-spacing: 1px; text-transform: uppercase; font-variant-numeric: tabular-nums; }
/* Hull condition: a short bar that empties and reddens as the damage mounts. */
#hull { display: flex; align-items: center; gap: 6px; font-weight: bold; font-variant-numeric: tabular-nums; }
#hull[hidden] { display: none; }
#hull .name { text-transform: uppercase; letter-spacing: 1px; }
#hull .meter { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
#hull-bar { display: block; height: 100%; border-radius: 3px; background: currentColor; transition: width 0.4s; }
#hull[data-state="fair"] { color: #f2c200; }
#hull[data-state="poor"] { color: #ff9a3d; }
#hull[data-state="wrecked"] { color: #ff6b5e; }
#berth { display: flex; align-items: center; gap: 5px; min-height: 16px; min-width: 0; }
/* A long place name ends in an ellipsis rather than spilling out of the panel; the distance after it always shows. */
#berth-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#berth-distance { flex: none; white-space: nowrap; }
#berth-distance:empty { display: none; }
#berth.done { color: #f2c200; font-weight: bold; }
#pointer { display: none; width: 11px; height: 11px; flex: none; fill: #f2c200; }
#berth.nav #pointer { display: block; }
#panel .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

#speedo { order: -1; width: 150px; height: 150px; flex: none; border-radius: 50%; }
#speedo .face { fill: rgba(0, 0, 0, 0.35); stroke: rgba(255, 255, 255, 0.25); stroke-width: 1.5; }
#speedo .tick { stroke: rgba(255, 255, 255, 0.7); stroke-width: 1.5; }
#speedo .major { stroke: #fff; stroke-width: 3; }
#speedo .astern { stroke: #ff6b5e; }
#speedo .zone { fill: none; stroke: #ff6b5e; stroke-width: 3; opacity: 0.6; }
#speedo text { fill: #fff; text-anchor: middle; font: bold 15px Helvetica, Roboto, Arial, sans-serif; }
#speedo #knots { font-size: 34px; font-variant-numeric: tabular-nums; }
#speedo .unit { font-size: 11px; letter-spacing: 2px; opacity: 0.7; }
#needle { fill: #ff6a13; }
#order { fill: #5fa9d9; }
/* Rudder and rate of turn, on the arc along the bottom of the speedo. */
#steering .track { fill: none; stroke: rgba(255, 255, 255, 0.15); stroke-width: 6; stroke-linecap: round; }
#steering .turn { fill: none; stroke-width: 6; stroke-dasharray: 0 1; }
#turn-port { stroke: #ff6b5e; }
#turn-starboard { stroke: #53f06f; }
#steering .centre { stroke: rgba(255, 255, 255, 0.6); stroke-width: 1.5; }
#rudder-mark { fill: #fff; }

/* ---- Buttons: every button in the game is a raised console key ---- */
#hud button, .sheet button {
  position: relative; box-sizing: border-box; cursor: pointer; color: #eef1f2;
  font: bold 11px/1.2 Helvetica, Roboto, Arial, sans-serif; letter-spacing: 1px;
  background: linear-gradient(#2c353b, #1a2125); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 0 rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s, color 0.2s;
}
#hud button:hover:not(:disabled), .sheet button:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.35); }
#hud button:active:not(:disabled), .sheet button:active:not(:disabled) {
  transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 0 rgba(0, 0, 0, 0.5);
}
#hud button:focus-visible, .sheet button:focus-visible { outline: 2px solid #5fa9d9; outline-offset: 2px; }
/* With a controller (body.pad, input.js) the focus is where it presses, so it always shows, and clear of the edges. */
body.pad dialog :is(button, input, select, textarea, a, [tabindex]):focus { outline: 3px solid #f2c200; outline-offset: 2px; scroll-margin: 40px; }
/* HUD keys: the icon on the left, the control's name over its current setting beside it, and a status light top right. */
#hud .key { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 8px; padding: 8px 10px; text-align: left; }
.key svg { grid-row: span 2; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.key .name { text-transform: uppercase; }
.key .value { font-weight: normal; letter-spacing: 0.3px; opacity: 0.7; }
.key .name, .key .value { overflow: hidden; text-overflow: ellipsis; }
.key .name { padding-right: 8px; }
/* With nothing to say, the name sits level with the icon. */
.key:has(.value:empty) svg { grid-row: auto; }
.key .value:empty { display: none; }
/* The radio says the most, so it has the whole row, its name and what it's saying on one line. */
#hud #radio { grid-column: 1 / -1; grid-template-columns: auto auto minmax(0, 1fr); padding-right: 18px; }
#radio .name { padding-right: 0; }
#radio svg { grid-row: auto; }
#radio .led { top: 50%; margin-top: -3.5px; }
/* A controller's button for the key (labelKeys() in hud.js), only while the controller's in use: in a column of its own
   on the right, level with the setting, under the status light; the radio's at the end of its one line. The panel's
   wider then, so the settings still fit beside them. */
.key .pad-key { display: none; }
body.pad #hud:not(.compact) #panel { width: 372px; }
@media (pointer: coarse) { body.pad #hud:not(.compact) #panel { width: auto; max-width: 360px; } }
body.pad #hud:not(.compact) .key { grid-template-columns: auto minmax(0, 1fr) auto; }
body.pad #hud:not(.compact) .key .name { grid-column: 2 / -1; }
body.pad #hud:not(.compact) .key .value { grid-column: 2; }
body.pad #hud:not(.compact) #radio { grid-template-columns: auto auto minmax(0, 1fr) auto; }
body.pad #hud:not(.compact) #radio .name { grid-column: 2; }
body.pad #hud:not(.compact) #radio .value { grid-column: 3; }
body.pad #hud:not(.compact) .key .pad-key:not([hidden]) {
  display: block; grid-column: 3; grid-row: 2; justify-self: end; align-self: end; margin-left: 8px; min-width: 14px; padding: 2px 5px; border-radius: 6px;
  font: bold 10px/1.1 Helvetica, Roboto, Arial, sans-serif; letter-spacing: 0; text-transform: none; text-align: center; white-space: nowrap;
  color: #eef1f2; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.3); pointer-events: none;
}
body.pad #hud:not(.compact) #radio .pad-key:not([hidden]) { grid-column: 4; grid-row: 1; align-self: center; }
body.pad #hud:not(.compact) .key:has(.value:empty) .pad-key:not([hidden]) { grid-row: 1; align-self: center; margin-right: 12px; }
body.pad .key .pad-key svg { display: block; width: 13px; height: 13px; margin: -1px 0; fill: currentColor; stroke: none; opacity: 1; }
body.pad .key .pad-key svg .lit { fill: #f2c200; }
.key .led {
  position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; border-radius: 50%;
  background: #3d464c; transition: background 0.2s, box-shadow 0.2s;
}
#power[aria-checked="true"] .led { background: #53f06f; box-shadow: 0 0 7px #53f06f; }
#power[aria-checked="false"] .led { background: #ff4d3d; box-shadow: 0 0 7px #ff4d3d; }
#anchor[aria-pressed="true"] .led, #map-open[aria-pressed="true"] .led { background: #5fa9d9; box-shadow: 0 0 7px #5fa9d9; }
#shop-open.ready .led { background: #f2c200; box-shadow: 0 0 7px #f2c200; }
#shop-open.ready { border-color: rgba(242, 194, 0, 0.6); }
#shop-open.repairs .led { background: #ff9a3d; box-shadow: 0 0 7px #ff9a3d; }
#shop-open.repairs { border-color: rgba(255, 154, 61, 0.6); }
/* A distress call blinks the radio red until it's answered; answered, it stays lit. */
#radio.calling .led { background: #ff4d3d; box-shadow: 0 0 7px #ff4d3d; animation: blink 0.8s steps(1) infinite; }
#radio.calling { border-color: rgba(255, 77, 61, 0.7); }
#radio.responding .led { background: #ff9a3d; box-shadow: 0 0 7px #ff9a3d; }
/* Trying to drop the anchor too fast flashes its light red. */
#anchor.refused .led { background: #ff4d3d; box-shadow: 0 0 7px #ff4d3d; animation: blink 0.3s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { #radio.calling .led, #anchor.refused .led { animation: none; } }

/* ---- Sheets: the upgrades shop and the help ---- */
.sheet {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-sizing: border-box; padding: 18px 20px 20px; border: none; border-radius: 20px;
  font: 13px/1.4 Helvetica, Roboto, Arial, sans-serif; color: #eef1f2; background-color: rgba(14, 20, 24, 0.9); overflow: auto;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.25); }
.sheet header { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.sheet h2 { margin: 0; font-size: 18px; letter-spacing: 1px; text-transform: uppercase; }
#shop-money { margin-left: auto; font-weight: bold; font-size: 16px; color: #f2c200; font-variant-numeric: tabular-nums; }
.sheet .close { width: 32px; height: 32px; padding: 0; font-size: 18px; line-height: 1; margin-left: auto; flex: none; }
#shop-money + .close { margin-left: 0; }
.sheet section { padding: 12px 0; border-top: 1px solid rgba(255, 255, 255, 0.15); }
.sheet h3 { margin: 0 0 4px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.7; }
.sheet p { margin: 0 0 8px; }
.sheet small { display: block; margin-top: 6px; opacity: 0.65; }
.sheet button:disabled { cursor: default; opacity: 0.45; }
.sheet .quiet { padding: 8px 12px; letter-spacing: 0.3px; }

.tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 12px 0 10px; }
.sheet .tabs button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 0 8px; font-size: 10px; text-transform: uppercase; }
.sheet .tabs button[aria-selected="true"] { border-color: #fff; background: linear-gradient(#3a454c, #262f34); }
.tabs .icon { width: 22px; height: 22px; }
.sheet .tabs button.ready::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: #f2c200; box-shadow: 0 0 7px #f2c200; }
/* Line icons, stroked in the text colour. */
.sheet .icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#shop { width: min(620px, calc(100vw - 32px)); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#shop input { user-select: text; -webkit-user-select: text; }
/* One height for every tab, so the sheet doesn't jump about: the header and tabs stay put and only the page scrolls,
   its scrollbar out in the sheet's padding. Asking to buy shrinks it back to fit the question. */
#shop[open] { display: flex; flex-direction: column; overflow: hidden; }
#shop:not(.confirming) { height: min(640px, calc(100dvh - 32px)); }
#shop header, #shop .tabs { flex: none; }
/* Styling her (shop.js): the Style tab on its own, a narrower sheet in the top right with nothing dimmed, so she can be
   seen while she's painted. On a tall screen it takes the top half and she's framed below it. */
#shop.styling { width: min(400px, calc(100vw - 32px)); margin: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) auto auto; }
#shop.styling:not(.confirming) { height: min(600px, calc(100dvh - 32px)); }
#shop.styling::backdrop { background: transparent; }
#shop.styling .tabs { display: none; }
@media (orientation: portrait) { #shop.styling:not(.confirming) { height: min(600px, 50dvh); } }
#shop-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -14px 0 -6px; padding: 4px 8px 6px 6px; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.25) transparent; }
/* ---- Shop cards: a big icon badge, a title and what you have, then what's on offer ---- */
#shop .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
#shop .card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
#shop .card.wide { grid-column: 1 / -1; }
#shop .card-head { display: flex; align-items: center; gap: 12px; }
#shop .badge { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 14px; color: #5fa9d9; background: rgba(95, 169, 217, 0.14); box-shadow: inset 0 0 0 1px rgba(95, 169, 217, 0.3); }
#shop .badge .icon { width: 28px; height: 28px; }
#shop .card-title { flex: 1; min-width: 0; }
#shop .card h3 { margin: 0 0 2px; font-size: 14px; letter-spacing: 0.3px; text-transform: none; opacity: 1; }
#shop .card-title p { margin: 0; opacity: 0.75; }
#shop .card small { margin: 0; }
#shop .card > .buy, #shop .card > .maxed, #shop .card > .locked-line { margin-top: auto; }
#shop .card.damaged .badge { color: #ff9a3d; background: rgba(255, 154, 61, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 154, 61, 0.4); }
#shop .card.damaged .card-title p { color: #ff9a3d; opacity: 1; }
#shop .card.aboard .badge { color: #53f06f; background: rgba(83, 240, 111, 0.12); box-shadow: inset 0 0 0 1px rgba(83, 240, 111, 0.35); }
#shop .pips { display: flex; gap: 4px; align-self: flex-start; margin-top: 4px; }
#shop .pips i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.15); }
#shop .pips i.on { background: #5fa9d9; box-shadow: 0 0 6px rgba(95, 169, 217, 0.7); }
#shop .maxed, #shop .locked-line { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: bold; color: #53f06f; }
#shop .locked-line { color: #ff9a8f; font-weight: normal; }
#shop .maxed .icon, #shop .locked-line .icon, #shop .price .icon { width: 15px; height: 15px; }
#shop .price { display: inline-flex; align-items: center; gap: 4px; }
#shop .meter { display: block; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#shop .meter span { display: block; height: 100%; border-radius: 4px; background: #ff9a3d; }
#shop .tab-note { margin-top: 12px; }
/* Style tab: each group headed by its icon. */
#shop .group { padding: 12px 0; }
#shop .group:first-child { border-top: none; padding-top: 4px; }
#shop .group h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; opacity: 0.85; }
#shop .group h3 .icon { width: 20px; height: 20px; color: #5fa9d9; }
/* Fleet: a card per ship, with her silhouette. */
#shop .ship-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
#shop .ship-card { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 10px 12px 12px; text-align: left; letter-spacing: 0.3px; border-radius: 16px; }
#shop .ship-card .silhouette { width: 100%; height: auto; margin-bottom: 4px; border-radius: 10px; background: linear-gradient(#253a4a, #1a2a36); }
#shop .ship-card .name { font-size: 14px; }
#shop .ship-card .stats { font-weight: normal; opacity: 0.85; }
#shop .ship-card .note { font-weight: normal; opacity: 0.6; }
#shop .ship-card .price { margin-top: auto; padding-top: 4px; }
#shop .ship-card[aria-pressed="true"] { border-color: #fff; }
#shop .ship-card[aria-pressed="true"] .price { color: #53f06f; }
#shop .ship-card:not(:disabled):not([aria-pressed="true"]) .price { color: #f2c200; }
#shop .ship-card.locked .price { color: #ff9a8f; font-weight: normal; }
#shop .ship-card:is(.locked, .short) .silhouette { filter: grayscale(0.8) brightness(0.7); }
/* What's stopping a swap (cargo aboard, the cranes working), under the price. */
#shop .ship-card .why { display: block; font-weight: normal; font-size: 12px; color: #ff9a8f; opacity: 1; }
/* The hold, at the top of the Jobs tab: how full she is, and what each job's boxes are for. */
#shop .cards + .hold-panel { margin: 16px 0 0; }
#shop .hold-panel { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
#shop .hold-head { display: flex; align-items: center; gap: 12px; }
#shop .hold-title h3 { margin: 0 0 2px; font-size: 14px; letter-spacing: 0.3px; text-transform: none; opacity: 1; }
#shop .hold-title p { margin: 0; font-size: 13px; opacity: 0.8; }
#shop .hold-title p b { color: #53f06f; }
#shop .hold-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
#shop .hold-bar i { min-width: 3px; }
#shop .hold-bar i.waiting { background: repeating-linear-gradient(135deg, var(--lot) 0 4px, transparent 4px 8px); opacity: 0.7; }
#shop .hold-bar i.free { background: rgba(255, 255, 255, 0.1); }
#shop .hold-lots { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 0; padding: 0; list-style: none; }
#shop .hold-lots li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
#shop .hold-lots .dot { width: 10px; height: 10px; flex: none; border-radius: 3px; }
#shop .hold-lots .what, #shop .hold-lots .count { display: flex; flex-direction: column; min-width: 0; }
#shop .hold-lots .what { flex: 1; }
#shop .hold-lots .count { align-items: flex-end; text-align: right; }
#shop .hold-lots span span { font-size: 12px; opacity: 0.7; }
/* Captain: the face, the name, the level and experience. */
#shop .captain { display: flex; gap: 16px; align-items: center; padding: 6px 0 16px; border-top: none; }
#shop .portrait .avatar { width: 92px; height: 92px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(0, 0, 0, 0.4); }
#shop .who { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
#shop .captain-name { display: flex; align-items: center; gap: 10px; font-weight: bold; letter-spacing: 1px; text-transform: uppercase; font-size: 11px; }
#shop .captain-name input { flex: 1; min-width: 0; padding: 7px 12px; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 10px; font: bold 16px Helvetica, Roboto, Arial, sans-serif; color: inherit; background: rgba(0, 0, 0, 0.3); text-transform: none; letter-spacing: 0; }
#shop .captain-name input:focus { outline: none; border-color: #fff; }
#shop .level { display: flex; justify-content: space-between; align-items: baseline; }
#shop .level b { font-size: 18px; color: #f2c200; }
#shop .level span { font-variant-numeric: tabular-nums; opacity: 0.75; }
#shop .meter.xp span { background: linear-gradient(90deg, #f2c200, #ffdf5e); }
#shop .points { margin: 0; opacity: 0.7; }
#shop .points.has { opacity: 1; color: #f2c200; font-weight: bold; }
#shop .train:not(:disabled) { border-color: rgba(242, 194, 0, 0.6); }
@media (max-width: 520px) { .sheet .tabs button { font-size: 0; gap: 0; } #shop .captain { align-items: flex-start; } #shop .portrait .avatar { width: 64px; height: 64px; } }
#shop .tally { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0; }
#shop .tally div { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); }
#shop .tally dt { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.7; }
#shop .tally dd { margin: 4px 0 0; font-size: 16px; font-weight: bold; font-variant-numeric: tabular-nums; }
#shop .buy, #shop .swatch { letter-spacing: 0.3px; }
#shop .buy { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 14px; text-align: left; }
#shop .buy:not(:disabled) { border-color: rgba(242, 194, 0, 0.6); }
#shop .buy:not(:disabled) .price { color: #f2c200; font-weight: bold; }
#shop .buy .price { flex: none; }
/* Anything that can't be picked is only a little faded, with what's stopping it in red: the price when it's money, the
   lock when it's a level or licence, the reason when it's something else. */
#shop button:disabled { opacity: 0.8; }
#shop .short .price, #shop .locked .price, #shop .blocked > span:first-child { color: #ff9a8f; }
#shop .swatch.short .price { opacity: 1; }
#shop .part { margin: 4px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; }
#shop .part ~ .part { margin-top: 14px; }
#shop .swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#shop .swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; }
#shop .swatch::before { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
#shop .flag::before { border-radius: 3px; width: 34px; height: 22px; }
#shop .flag-name { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
#shop .flag-name input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 10px; font: inherit; color: inherit; background: rgba(0, 0, 0, 0.3); }
#shop .flag-name input:focus { outline: none; border-color: #fff; }
#shop .sticker::before { width: 44px; height: 30px; border-radius: 0; box-shadow: none; }
#shop .sticker[aria-pressed="true"] .price { color: #53f06f; }
#shop .swatch[aria-pressed="true"] { border-color: #fff; }
#shop .swatch .price { font-weight: normal; opacity: 0.8; }
#shop .toggle, #help .toggle { display: flex; justify-content: space-between; width: 100%; padding: 11px 14px 9px; letter-spacing: 0.3px; }
#shop .toggle[aria-pressed="true"] .price, #help .toggle[aria-pressed="true"] .price { color: #53f06f; }
#sound-on[aria-pressed="false"] .price { color: #ff9a8f; }
#sound, #weather-set, #graphics-set, #backup-set { display: grid; gap: 10px; }
#restore-bad { margin: 8px 0 0; }
/* A setting with a few fixed choices: its name, then a button each, the one in use lit. */
#help .choice { display: flex; align-items: center; gap: 12px; font-weight: bold; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
#help .choice > span { flex: 1; }
#help .choice > div { display: flex; gap: 6px; }
#help .choice button { min-width: 64px; padding: 9px 10px 7px; letter-spacing: 0.3px; text-transform: none; }
#help .choice button[aria-pressed="true"] { border-color: #53f06f; color: #53f06f; }
#sound .volume, #dev-time { display: grid; grid-template-columns: 104px 1fr 44px; align-items: center; gap: 12px; font-weight: bold; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
#sound output, #dev-time output { text-align: right; font-weight: normal; font-variant-numeric: tabular-nums; opacity: 0.8; text-transform: none; }
#sound [type="range"], #dev-time [type="range"] { width: 100%; margin: 0; accent-color: #5fa9d9; cursor: pointer; }
#sound [type="range"]:focus-visible, #dev-time [type="range"]:focus-visible { outline: 2px solid #5fa9d9; outline-offset: 4px; }
/* Buying asks first: the tabs and list give way to the question. */
#shop.confirming .tabs, #shop.confirming #shop-body { display: none; }
#confirm { padding: 18px 0 4px; border-top: 1px solid rgba(255, 255, 255, 0.15); }
#confirm h3 { font-size: 16px; letter-spacing: 0.5px; text-transform: none; opacity: 1; margin-bottom: 6px; }
#confirm-cost { opacity: 0.75; }
#confirm .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
#confirm .actions button { padding: 11px 14px; justify-content: center; }

/* The map fills its sheet, short of the screen's height. */
#map { width: min(640px, calc(100vw - 32px)); }
#chart { display: block; width: 100%; max-width: calc(100dvh - 110px); margin: 8px auto 0; border-radius: 12px; }

#help .howto { margin: 0; padding: 0 0 0 18px; display: grid; gap: 8px; }
#help .hint { opacity: 0.7; }
#bindings { margin-bottom: 12px; }
#bind-device { margin-bottom: 12px; }
#rumble { margin-bottom: 12px; }
#bind-device > div { flex: 1; }
#bind-device button { flex: 1; }
#bindings .bind-group + .bind-group { margin-top: 14px; }
#bindings h3 { margin-bottom: 8px; }
/* A row per action, its name on one line and its key a fixed width on the right, a faint rule between them. */
#bindings .bind-row { display: flex; align-items: center; gap: 12px; padding: 5px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
#bindings .bind-row:first-child { border-top: none; }
#bindings .bind-row > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bindings .bind { flex: none; width: 136px; padding: 7px 10px; justify-content: center; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
#bindings .bind.listening { border-color: #f2c200; color: #f2c200; }
#help .warning { color: #ff9a8f; }
#help .confirm-row p { margin: 0 0 8px; }
#help .confirm-row .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#help .confirm-row button { padding: 10px 14px; }
#help .hint + .toggle { margin-top: 8px; }
#help .confirm-row .buy { border-color: rgba(242, 194, 0, 0.6); color: #f2c200; }
#help .toggle:disabled { opacity: 0.5; }
#help .toggle[hidden] { display: none; }
.sheet .danger { border-color: rgba(255, 77, 61, 0.8); color: #ff9a8f; }
/* Phones: a narrower panel and a smaller speedo, so both fit side by side. */
@media (max-width: 640px) {
  #hud { gap: 8px; }
  #panel { width: 204px; padding: 10px; gap: 8px; }
  #panel .controls { gap: 6px; }
  /* Too narrow for the words beside the icon, so the icon goes back on top (the radio keeps its one line). */
  #hud .key { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 7px 8px 8px; }
  #hud .key svg { margin-bottom: 2px; }
  #hud #radio { flex-direction: row; align-items: center; gap: 6px; padding-right: 18px; }
  #hud #radio svg { margin-bottom: 0; }
  #speedo { width: 104px; height: 104px; }
}
/* ---- A key to shrink the HUD to its icons; on touch screens, see-through steering keys and a throttle lever ---- */
/* Round keys in the top line: settings, and the one that shrinks the HUD. */
#hud button.round { display: flex; width: 28px; height: 28px; padding: 0; border-radius: 50%; align-items: center; justify-content: center; }
#hud button#help-open { margin-left: auto; }
#hud .topline button + button { margin-left: -2px; }
#hud .round svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#help-open svg { width: 16px; height: 16px; stroke-width: 2; }
#hud.compact #hud-size svg { transform: rotate(180deg); }
/* Collapsed, the panel stretches to fill the room beside the speedo, and the keys are one row swiped sideways: a key
   cut off at the edge shows there's more. */
#hud.compact #panel .controls {
  grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 64px; gap: 6px;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain;
}
#hud.compact #panel .controls::-webkit-scrollbar { display: none; }
#hud.compact .key { scroll-snap-align: start; }
#hud.compact .key .name, #hud.compact .key .value { display: none; }
#hud.compact .key { display: flex; align-items: center; justify-content: center; padding: 9px 12px; }
#hud.compact #radio { grid-column: auto; padding-right: 12px; }
#hud.compact #radio .led { top: 9px; margin-top: 0; }
#hud.compact .key svg { margin-bottom: 0; }
/* With a mouse there's no swiping, so collapsed the keys sit in two rows of three instead. */
@media (pointer: fine) {
  #hud.compact #panel .controls { grid-template-columns: repeat(3, 1fr); grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; }
  #hud.compact .key { justify-content: center; }
  #hud.compact #radio { grid-column: span 2; }
}
/* Steering keys at the left edge and the throttle lever at the right, both halfway up and see-through. */
#steer, #throttle { display: none; position: fixed; top: 37%; transform: translateY(-50%); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#steer { left: max(12px, env(safe-area-inset-left)); gap: 10px; }
#steer button {
  display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; padding: 0; color: #fff; font: inherit;
  background: rgba(14, 20, 24, 0.25); border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 50%; touch-action: none;
}
#steer button:active { background: rgba(255, 255, 255, 0.3); }
#steer svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#throttle { right: max(12px, env(safe-area-inset-right)); width: 46px; height: min(32vh, 260px); }
#throttle .track {
  position: absolute; right: 0; top: 0; bottom: 0; width: 46px; border-radius: 23px;
  background: rgba(14, 20, 24, 0.25); border: 1px solid rgba(255, 255, 255, 0.35); box-sizing: border-box;
}
/* Below stop is astern, tinted red. */
#throttle .zone { position: absolute; left: 0; right: 0; bottom: 0; top: calc(15px + (100% - 30px) * 0.769); border-radius: 0 0 23px 23px; background: rgba(255, 107, 94, 0.22); }
/* The handle stays inside the track: --at runs 0 (full ahead, at the top) to 1 (full astern, at the bottom). */
/* Near either end it swells into a dome that follows the curve of the track's end there (4px in from it all round). */
#throttle .handle {
  --top: clamp(0, calc((0.12 - var(--at, 0.769)) / 0.12), 1);
  --bottom: clamp(0, calc((var(--at, 0.769) - 0.88) / 0.12), 1);
  position: absolute; left: 4px; right: 4px;
  height: calc(22px + 8px * var(--top) + 8px * var(--bottom));
  top: calc(4px + (100% - 30px) * var(--at, 0.769) - 8px * var(--bottom));
  border-radius: calc(11px + 7px * var(--top)) calc(11px + 7px * var(--top)) calc(11px + 7px * var(--bottom)) calc(11px + 7px * var(--bottom)) / calc(11px + 7px * var(--top)) calc(11px + 7px * var(--top)) calc(11px + 7px * var(--bottom)) calc(11px + 7px * var(--bottom));
  background: rgba(242, 194, 0, 0.75); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); transition: top 0.08s linear;
}
#throttle.astern .handle { background: rgba(255, 107, 94, 0.8); }
#throttle.held .handle { background: #f2c200; transition: none; }
#throttle.held.astern .handle { background: #ff6b5e; }
/* On touch screens the HUD sits at the bottom left, and the steering keys and throttle come out. */
@media (pointer: coarse) {
  #hud { flex-flow: row wrap-reverse; align-items: flex-start; justify-content: flex-start; }
  #speedo { order: 1; }
  /* The panel takes the room beside the speedo, so the next-port line fits. */
  #panel, #hud.compact #panel { order: 2; width: auto; flex: 1 1 0; min-width: 0; max-width: 320px; }
  #steer { display: flex; }
  #throttle { display: block; }
}

/* ---- The opening: the captain's musing, then Mom's letter on the desk ---- */
#intro { width: min(520px, calc(100vw - 32px)); padding: 22px 24px 24px; }
#intro-opening { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "title avatar" "musing avatar" "read read"; gap: 6px 18px; align-items: start; }
#intro-opening[hidden], #intro-letter[hidden] { display: none; }
#intro .avatar { grid-area: avatar; width: 96px; height: 96px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(0, 0, 0, 0.4); }
#intro h2 { grid-area: title; margin-top: 10px; }
#intro .musing { grid-area: musing; margin: 0; font: italic 20px/1.4 Georgia, 'Times New Roman', serif; opacity: 0.92; }
#intro #intro-read { grid-area: read; margin-top: 18px; }
#intro .buy { display: flex; width: 100%; justify-content: center; padding: 13px 16px; font-size: 13px; letter-spacing: 0.5px; border-color: rgba(242, 194, 0, 0.6); color: #f2c200; }
#intro.reading { width: min(600px, calc(100vw - 32px)); }
#intro .paper, #story .paper {
  max-height: calc(100dvh - 170px); overflow: auto; margin-bottom: 16px; padding: 26px 30px; border-radius: 4px; transform: rotate(-0.6deg);
  color: #2b2118; font: 17px/1.55 'Bradley Hand', 'Segoe Print', 'Comic Sans MS', cursive;
  background: linear-gradient(transparent 0 calc(100% - 1px), rgba(90, 120, 170, 0.18) 0) 0 14px / 100% 26.35px, linear-gradient(135deg, #fbf5e6, #efe3c6);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45), inset 0 0 40px rgba(160, 120, 60, 0.18);
}
#intro .paper p, #story .paper p { margin: 0 0 12px; }
#intro .paper p:last-child, #story .paper p:last-child { margin: 0; text-align: right; font-size: 20px; }
#intro .paper p:nth-last-child(2), #story .paper p:nth-last-child(2) { margin: 18px 0 2px; text-align: right; }
#intro #intro-done { width: 100%; }
#shop .card.unavailable { opacity: 0.5; }
#shop .card.unavailable .badge { color: #9aa3a8; background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }

/* The dock's tabs (at Fishy Isle one more, the tackle shop; away from a dock only Captain), and the menu's three. */
#shop .tabs { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
#shop[data-docked="false"] .tabs, #shop.learning .tabs { display: none; }
.sheet .tabs button[hidden] { display: none; }
#help .tabs { grid-template-columns: repeat(3, 1fr); }
#help .tabs button { padding: 10px 0 7px; }
#help.dev .tabs { grid-template-columns: repeat(4, 1fr); }
#help .tabs button { padding: 10px 0; font-size: 11px; }
#help .pane > section:first-child { border-top: none; }
/* The game's version, small at the foot of the Game tab. */
#version { margin: 18px 0 2px; text-align: center; font-size: 11px; letter-spacing: 1px; opacity: 0.5; }

/* The jobs board. */
#shop .welcome { padding: 12px 14px; border-radius: 14px; background: rgba(242, 194, 0, 0.12); box-shadow: inset 0 0 0 1px rgba(242, 194, 0, 0.35); }
#shop .board { margin: 12px 0 8px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.7; }
#shop .card.job .story-text { margin: 0; opacity: 0.85; }
#shop .card.job .tag { font-style: normal; margin-left: 6px; display: inline-block; padding: 4px 7px; line-height: 1; text-box: trim-both cap alphabetic; border-radius: 6px; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: #1a1300; background: #f2c200; vertical-align: 2px; }
#shop .card.job.story { box-shadow: inset 0 0 0 1px rgba(242, 194, 0, 0.35); }
/* Island errands (errands.js): wanted back from the sea. */
#shop .card.job.wanted .tag { background: #5fe0c4; color: #062a22; }
/* Escort runs (convoys.js). */
#shop .card.job.escort .tag { background: #ff8a3a; color: #2a1200; }
#shop .card.job.mine .badge { color: #53f06f; background: rgba(83, 240, 111, 0.12); box-shadow: inset 0 0 0 1px rgba(83, 240, 111, 0.35); }
#shop .card.job .job-state { margin: 0; color: #53f06f; }
/* Odd jobs: a smaller card, the button beside the title and the blurb quieter. */
#shop .card.job.odd { gap: 6px; padding: 10px 12px; }
#shop .card.job.odd .badge { width: 36px; height: 36px; border-radius: 10px; }
#shop .card.job.odd .badge .icon { width: 22px; height: 22px; }
#shop .card.job.odd .card-title p { font-size: 12px; }
#shop .card.job.odd .story-text { font-size: 12px; opacity: 0.6; }
#shop .card.job.odd .buy { flex: none; width: auto; max-width: 180px; flex-direction: column; align-items: flex-end; gap: 1px; padding: 7px 12px; text-align: right; }
@media (max-width: 480px) {
  #shop .card.job.odd .card-head { flex-wrap: wrap; }
  #shop .card.job.odd .buy { order: 1; width: 100%; max-width: none; flex-direction: row; align-items: center; text-align: left; }
}
#shop .empty { opacity: 0.7; }
#shop[data-tab="contracts"] .cards { grid-template-columns: 1fr; }
#help { width: min(560px, calc(100vw - 32px)); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* Style's own row of tabs: paint, flag or stickers. */
#shop .subtabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
#shop .subtabs.two { grid-template-columns: repeat(2, 1fr); }
#shop .subtabs.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 480px) { #shop .subtabs.four .icon { display: none; } }
#shop .subtabs button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 0; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#shop .subtabs button[aria-selected="true"] { border-color: #fff; background: linear-gradient(#3a454c, #262f34); }
#shop .subtabs .icon { width: 18px; height: 18px; color: #5fa9d9; }

/* ---- The strange signal's story: the radio's eerie blue light, Corvid's sheet and the binoculars ---- */
#radio.strange.calling .led, #radio.strange.responding .led { background: #8fe8ff; box-shadow: 0 0 8px #8fe8ff; }
#radio.strange.calling { border-color: rgba(143, 232, 255, 0.7); }
/* A friend calling (calls.js). */
#radio.friendly.calling .led { background: #5fe08a; box-shadow: 0 0 8px #5fe08a; }
#radio.friendly.calling { border-color: rgba(95, 224, 138, 0.7); }
/* Johan's within reach (johan.js): a steady gold light. */
#radio.trader .led { background: #f2c94c; box-shadow: 0 0 8px #f2c94c; }
#radio.trader { border-color: rgba(242, 201, 76, 0.7); }
#story { width: min(520px, calc(100vw - 32px)); padding: 22px 24px 24px; background-color: rgba(8, 11, 18, 0.94); }
#story .story-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
#story .avatar { width: 84px; height: 84px; flex: none; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(0, 0, 0, 0.4); }
#story .avatar.corvid { box-shadow: 0 0 0 3px rgba(143, 232, 255, 0.7), 0 0 18px rgba(143, 232, 255, 0.35); }
#story .avatar[hidden] { display: none; }
#story-lines p { margin: 0 0 10px; font: 16px/1.5 Georgia, 'Times New Roman', serif; }
#story:not(.musing):not(.note) #story-lines p::before { content: "\201C"; }
#story:not(.musing):not(.note) #story-lines p::after { content: "\201D"; }
#story-lines .unsaid { visibility: hidden; }
#story:not(.musing) #story-lines p.waiting::before, #story:not(.musing) #story-lines p:not(.done)::after { visibility: hidden; }
#story.musing #story-lines p { font-style: italic; font-size: 19px; opacity: 0.92; }
/* The burst, fanned out across the sheet: each print a little further along, tipped this way or that, dealt in one by one. */
#story-photos { position: relative; height: 150px; margin: 6px 0 14px; }
#story-photos[hidden] { display: none; }
#story-photos figure {
  --w: min(150px, 40%);
  position: absolute; top: calc(10px + 14px * (var(--i) % 2)); left: calc((100% - var(--w)) * var(--i) / max(1, var(--n) - 1)); width: var(--w); margin: 0;
  padding: 5px 5px 16px; box-sizing: border-box; background: #f4f1e8; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transform: rotate(var(--tilt)); animation: deal 0.35s ease-out backwards; animation-delay: calc(0.12s * var(--i));
}
#story-photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) rotate(0deg); } }
@media (prefers-reduced-motion: reduce) { #story-photos figure { animation: none; } }
#story-choices { display: grid; gap: 8px; margin-top: 16px; }
#story-choices button { padding: 13px 16px; font-size: 13px; letter-spacing: 0.5px; }
#story-choices .buy { border-color: rgba(143, 232, 255, 0.6); color: #8fe8ff; }
/* A note out of a bottle: the paper's been at sea a while, and there's no portrait. */
#story.note .story-head { margin-bottom: 10px; }
#story.note .paper { margin-bottom: 0; transform: rotate(0.8deg); background: radial-gradient(ellipse at 85% 15%, rgba(120, 90, 40, 0.22), transparent 40%), radial-gradient(ellipse at 10% 90%, rgba(110, 140, 120, 0.2), transparent 45%), linear-gradient(135deg, #f1e6c8, #dccaa0); }
#story.note #story-lines p { font: 17px/1.5 'Bradley Hand', 'Segoe Print', 'Comic Sans MS', cursive; }
#story.note #story-lines p:last-child { font-size: 20px; }
#story.note #story-choices .buy { border-color: rgba(242, 194, 0, 0.6); color: #f2c200; }

body.binoculars #hud, body.binoculars #banner, body.binoculars #corner, body.binoculars #steer, body.binoculars #throttle { display: none; }
#binoculars { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#binoculars.dragging { cursor: grabbing; }
#binoculars::backdrop { background: transparent; }
/* Black but for two overlapping eyepieces (RADIUS and OFFSET in binoculars.js), soft at the rim. */
#binoculars .lenses {
  position: absolute; inset: 0; background: #000; --r: 36vmin; --off: 25vmin;
  -webkit-mask: radial-gradient(circle var(--r) at calc(50% - var(--off)) 50%, transparent 94%, #000 100%), radial-gradient(circle var(--r) at calc(50% + var(--off)) 50%, transparent 94%, #000 100%);
  -webkit-mask-composite: source-in;
  mask: radial-gradient(circle var(--r) at calc(50% - var(--off)) 50%, transparent 94%, #000 100%), radial-gradient(circle var(--r) at calc(50% + var(--off)) 50%, transparent 94%, #000 100%);
  mask-composite: intersect;
}
#binoculars .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#binoculars .flash.go { animation: shutter 0.35s ease-out; }
@keyframes shutter { 0% { opacity: 0.6; } 100% { opacity: 0; } }
#binoculars button { font: 13px/1.4 Helvetica, Roboto, Arial, sans-serif; color: #eef1f2; background: rgba(14, 20, 24, 0.75); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 12px; cursor: pointer; }
#binoculars .close { position: absolute; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); width: 40px; height: 40px; font-size: 20px; }
#snap { position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 12px 20px; font-size: 14px; letter-spacing: 0.5px; border-color: rgba(143, 232, 255, 0.7) !important; color: #8fe8ff !important; box-shadow: 0 0 18px rgba(143, 232, 255, 0.3); }
#snap[hidden] { display: none; }
/* A nudge when they're stuck (binoculars.js), where the Snap button will be. */
#binoculars .hint { position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 32px); margin: 0; padding: 10px 18px; box-sizing: border-box; font: 14px/1.3 Helvetica, Roboto, Arial, sans-serif; color: #eef1f2; text-align: center; background: rgba(14, 20, 24, 0.75); border-radius: 12px; pointer-events: none; opacity: 0; transition: opacity 0.6s; }
#binoculars .hint.on { opacity: 1; }
#snap svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

/* The developer menu (?dev=true). */
#help .dev-row { display: flex; gap: 8px; }
#help .dev-row input { user-select: text; -webkit-user-select: text; flex: 1; min-width: 0; padding: 8px 10px; font: inherit; color: #eef1f2; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 10px; }
#help .dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
#help .dev-grid button, #help .dev-row button { padding: 10px 12px; }

/* The captain's log: the next story job in yellow, Corvid's case in his pale blue. */
#shop .card .story-text { margin: 0; opacity: 0.85; }
#shop .card.next { border-color: rgba(242, 194, 0, 0.55); }
#shop .card.next .badge { color: #f2c200; }
/* The log's Under way list: one thin row each. */
#shop .rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
#shop .row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
#shop .row .badge { width: 36px; height: 36px; border-radius: 10px; }
#shop .row .badge .icon { width: 22px; height: 22px; }
#shop .row-text { flex: 1; min-width: 0; }
#shop .row h3 { margin: 0 0 1px; font-size: 13px; letter-spacing: 0.3px; text-transform: none; }
#shop .row-text p { margin: 0; font-size: 12px; opacity: 0.75; }
#shop .row-text .row-state { color: #53f06f; opacity: 1; }
#shop .row-go { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#shop .row-go .buy { width: auto; padding: 7px 12px; }
#shop .row .heading, #shop .card .heading { font-size: 12px; font-weight: bold; color: #f2c200; }
#shop .row.here { border-color: rgba(242, 194, 0, 0.55); }
#shop .row.story { box-shadow: inset 0 0 0 1px rgba(242, 194, 0, 0.35); }
#shop .row.job .badge { color: #53f06f; background: rgba(83, 240, 111, 0.12); box-shadow: inset 0 0 0 1px rgba(83, 240, 111, 0.35); }
#shop .row.mayday .badge { color: #ff4d3d; background: rgba(255, 77, 61, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 77, 61, 0.4); }

/* ---- The old hand: the Boost key (across the whole row, so seven keys still sit neatly) and the mini map ---- */
#hud .key[hidden] { display: none; }
#boost { grid-column: 1 / -1; }
#hud.compact #boost { grid-column: auto; }
@media (pointer: fine) { #hud.compact #boost { grid-column: 1 / -1; } }
#boost.ready .led { background: #f2c200; box-shadow: 0 0 7px #f2c200; }
#boost.running .led { background: #ff9a3d; box-shadow: 0 0 9px #ff9a3d; animation: blink 0.4s steps(1) infinite; }
#boost.running { border-color: rgba(255, 154, 61, 0.7); }
@media (prefers-reduced-motion: reduce) { #boost.running .led { animation: none; } }
/* Round and see-through, top left; the headline keeps clear of it on both sides so it stays centred. */
#minimap {
  --size: 160px;
  position: fixed; top: max(16px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); z-index: 6;
  width: var(--size); height: var(--size); border-radius: 50%; opacity: 0.82; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), 0 4px 16px rgba(0, 0, 0, 0.3);
}
#minimap[hidden] { display: none; }
body.minimap #banner { padding-left: calc(var(--mini, 160px) + 28px); padding-right: calc(var(--mini, 160px) + 28px); }
@media (max-width: 640px) {
  #minimap { --size: 96px; }
  body.minimap #banner { --mini: 96px; }
}
body.binoculars #minimap { display: none; }

/* With the autopilot too, the last row is Autopilot and Boost side by side. */
#hud .controls:has(#autopilot:not([hidden])) #boost { grid-column: auto; }
#autopilot[aria-checked="true"] .led { background: #53f06f; box-shadow: 0 0 7px #53f06f; }

/* Towed home after sinking (salvage.js). */
#salvage { width: min(480px, calc(100vw - 32px)); padding: 22px 24px 24px; }
#salvage .salvage-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
#salvage .avatar { width: 88px; height: 88px; flex: none; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(0, 0, 0, 0.4); }
#salvage-lines p { margin: 0 0 10px; font: italic 18px/1.45 Georgia, 'Times New Roman', serif; opacity: 0.92; }
#salvage .bill { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.15); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
#salvage .bill strong { font-size: 22px; letter-spacing: 0; color: #ff8a7a; }
#salvage .bill.left strong { font-size: 16px; color: inherit; }
#salvage .bill.left strong.owing { color: #ff8a7a; }
#salvage #salvage-done { display: flex; width: 100%; justify-content: center; margin-top: 14px; padding: 13px 16px; font-size: 13px; letter-spacing: 0.5px; border-color: rgba(242, 194, 0, 0.6); color: #f2c200; }

/* A new version's out (update.js): a small pill, top right. */
#update { position: fixed; z-index: 6; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 999px; font: 600 13px system-ui, -apple-system, sans-serif; color: #fff; background: rgba(16, 24, 28, 0.82); border: 1px solid rgba(242, 194, 0, 0.6); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
#update[hidden] { display: none; }
#update button { padding: 6px 12px; border: 0; border-radius: 999px; font: inherit; color: #1a1300; background: #f2c200; cursor: pointer; }
#update button:disabled { opacity: 0.6; cursor: default; }

/* The developer's flying camera: the HUD steps aside, and a line of keys sits at the bottom. */
body.flying #hud { display: none; }
#flycam { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 8px 14px; font: 13px/1.3 system-ui, sans-serif; color: #eef1f2; background: rgba(10, 20, 28, 0.7); border-radius: 10px; pointer-events: none; z-index: 20; }

/* ---- Fishing (fishing.js, reel.js): the Fish key, the reel game and the captain's fish log ---- */
#fish { grid-column: 1 / -1; }
#hud.compact #fish { grid-column: auto; }
@media (pointer: fine) { #hud.compact #fish { grid-column: 1 / -1; } }
#fish { touch-action: none; user-select: none; -webkit-user-select: none; }
#fish.on .led { background: #8fe8ff; box-shadow: 0 0 7px #8fe8ff; }
#fish.bite { border-color: rgba(255, 77, 61, 0.85); }
#fish.bite .led { background: #ff4d3d; box-shadow: 0 0 9px #ff4d3d; animation: blink 0.25s steps(1) infinite; }
#fish.holding { border-color: rgba(83, 240, 111, 0.8); }
@media (prefers-reduced-motion: reduce) { #fish.bite .led { animation: none; } }
/* The reel, in the HUD's glass: the catch zone (green, like a lit key light) between its two arrows, the fish, and
   the meter beside it. It stands left of the HUD, middle of the screen. */
#reel {
  position: fixed; z-index: 6; top: 46%; right: calc(max(16px, env(safe-area-inset-right)) + 440px); transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
  font: 14px/1.3 Helvetica, Roboto, Arial, sans-serif; color: #eef1f2;
}
#reel[hidden] { display: none; }
@media (max-width: 900px) { #reel { top: 36%; right: auto; left: 50%; transform: translate(-50%, -50%); } #reel .track { height: min(40vh, 300px); } }
#reel .strike[hidden], #reel .frame[hidden], #reel .hint[hidden] { display: none; }
/* A bite: a red light and a bold !, blinking like the Mayday key. */
#reel .strike {
  display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; margin: 0; border-radius: 50%;
  font: bold 38px/1 Helvetica, Roboto, Arial, sans-serif; color: #ff4d3d; text-shadow: 0 0 12px rgba(255, 77, 61, 0.8);
  background: rgba(14, 20, 24, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 2px rgba(255, 77, 61, 0.75), 0 0 18px rgba(255, 77, 61, 0.45), 0 4px 18px rgba(0, 0, 0, 0.25);
  animation: strike 0.5s steps(1) infinite;
}
@keyframes strike { 50% { box-shadow: inset 0 0 0 2px rgba(255, 77, 61, 0.35), 0 4px 18px rgba(0, 0, 0, 0.25); color: rgba(255, 77, 61, 0.6); } }
@media (prefers-reduced-motion: reduce) { #reel .strike { animation: none; } }
#reel .frame {
  display: flex; gap: 8px; padding: 10px; border-radius: 18px;
  background: rgba(14, 20, 24, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}
#reel .track {
  position: relative; width: 44px; height: min(52vh, 360px); border-radius: 12px; overflow: hidden;
  background: linear-gradient(rgba(95, 169, 217, 0.22), rgba(95, 169, 217, 0.05)), linear-gradient(#2c353b, #1a2125);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), inset 0 2px 6px rgba(0, 0, 0, 0.4);
}
#reel .zone {
  position: absolute; left: 4px; right: 4px; border-radius: 8px;
  background: rgba(83, 240, 111, 0.12); box-shadow: inset 0 0 0 1px rgba(83, 240, 111, 0.55); transition: background 0.15s, box-shadow 0.15s;
}
#reel .zone.on { background: rgba(83, 240, 111, 0.24); box-shadow: inset 0 0 0 1px #53f06f, 0 0 10px rgba(83, 240, 111, 0.45); }
/* The two arrows, pointing in at the top and bottom of the zone. */
#reel .arrow { position: absolute; left: 50%; width: 0; height: 0; transform: translateX(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; }
#reel .arrow.top { top: 3px; border-top: 7px solid #eef1f2; }
#reel .arrow.bottom { bottom: 3px; border-bottom: 7px solid #eef1f2; }
#reel .zone.on .arrow.top { border-top-color: #53f06f; }
#reel .zone.on .arrow.bottom { border-bottom-color: #53f06f; }
/* The fish: the shop's line-drawn fish icon. */
#reel .fish { position: absolute; left: 50%; width: 30px; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; color: #eef1f2; filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6)); }
#reel .fish svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#reel .meter { position: relative; width: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
#reel .meter i { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px; transition: background 0.2s; }
/* Lines of help, in the toasts' glass. */
#reel .hint, #reel .lesson {
  border-radius: 14px; background: rgba(14, 20, 24, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px rgba(242, 194, 0, 0.3), 0 4px 18px rgba(0, 0, 0, 0.25);
}
#reel .hint { max-width: 200px; margin: 0; padding: 8px 12px; text-align: center; font-weight: bold; font-size: 13px; }
body.binoculars #reel { display: none; }
/* The tackle shop and the fish log. */
#shop .fish-log { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
#shop .fish-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); text-align: center; }
#shop .fish-card.unknown { opacity: 0.55; }
#shop .fish-card h3 { margin: 0; font-size: 14px; }
#shop .fish-card p { margin: 0; font-size: 12px; opacity: 0.75; }
#shop .fish-art { width: 96px; height: 48px; }
#shop .catch { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
#shop .catch .fish-art { width: 56px; height: 28px; }
#shop .catch span { flex: 1; font-size: 14px; }
#shop .catch b { font-size: 13px; }
#tracker[data-kind="fishing"].late .bar i { background: #ff9a3d; }
/* The first time: what's what, beside the reel, with a practice before the real thing. */
#reel .lesson { position: absolute; right: calc(100% + 16px); top: 50%; transform: translateY(-50%); width: 250px; box-sizing: border-box; padding: 14px 16px; cursor: default; }
#reel .lesson[hidden], #reel .lesson [hidden] { display: none; }
#reel .lesson h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: #f2c200; }
#reel .lesson .lines p { margin: 0 0 8px; }
#reel .lesson .state { margin: 4px 0 10px; font-weight: bold; font-size: 13px; color: #53f06f; }
#reel .lesson .buy {
  position: relative; box-sizing: border-box; display: flex; justify-content: center; width: 100%; padding: 10px 14px; cursor: pointer;
  font: bold 11px/1.2 Helvetica, Roboto, Arial, sans-serif; letter-spacing: 1px; text-transform: uppercase; color: #f2c200;
  background: linear-gradient(#2c353b, #1a2125); border: 1px solid rgba(242, 194, 0, 0.6); border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 0 rgba(0, 0, 0, 0.5);
}
#reel .lesson .buy:hover { border-color: #f2c200; }
#reel .lesson .buy:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 0 rgba(0, 0, 0, 0.5); }
#reel .frame.paused { opacity: 0.7; }
@media (max-width: 900px) { #reel .lesson { right: auto; left: 50%; top: auto; bottom: calc(100% + 12px); transform: translateX(-50%); } }
#reel .lesson .buy[hidden] { display: none; }
/* Just a bite: the ! goes up out of the way of the float. */
#reel.biting { top: 22%; }
@media (max-width: 900px) { #reel.biting { top: 22%; } }
/* After a catch, Cast again and Pack up side by side. */
#hud .controls:has(#pack:not([hidden])) #fish { grid-column: auto; }
#pack { grid-column: auto; }
/* ---- The first voyage (firstvoyage.js): a prompt under the ship, and a glow on what it's about ---- */
#coach {
  position: fixed; z-index: 5; left: 50%; top: 62%; transform: translate(-50%, 8px); max-width: calc(100% - 32px); box-sizing: border-box; margin: 0;
  display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 14px;
  font: bold 15px/1.3 Helvetica, Roboto, Arial, sans-serif; color: #eef1f2; background: rgba(14, 20, 24, 0.78);
  box-shadow: 0 0 0 2px rgba(242, 194, 0, 0.7), 0 4px 18px rgba(0, 0, 0, 0.3);
  pointer-events: none; opacity: 0; transition: opacity 0.5s, transform 0.5s;
}
#coach.on { opacity: 1; transform: translate(-50%, 0); }
#coach kbd {
  min-width: 26px; padding: 3px 7px; box-sizing: border-box; border-radius: 7px; text-align: center;
  font: bold 16px/1.2 Helvetica, Roboto, Arial, sans-serif; color: #14181c; background: #f2c200; box-shadow: 0 3px 0 #9c7d00;
}
#coach.on kbd { animation: press 1.4s ease-in-out infinite; }
#coach kbd + span { margin-left: 4px; }
@keyframes press { 0%, 60%, 100% { transform: none; box-shadow: 0 3px 0 #9c7d00; } 30% { transform: translateY(2px); box-shadow: 0 1px 0 #9c7d00; } }
.coached { animation: coached 1.4s ease-in-out infinite; border-radius: 12px; }
#berth.coached { border-radius: 6px; outline: 2px solid transparent; outline-offset: 3px; }
@keyframes coached { 50% { box-shadow: 0 0 0 3px rgba(242, 194, 0, 0.9), 0 0 22px rgba(242, 194, 0, 0.6); } }
/* The board on the first voyage: a note at the top, the first job's buttons glowing, and no way out until it's taken. */
#shop .coach-card { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: rgba(242, 194, 0, 0.14); box-shadow: inset 0 0 0 1px rgba(242, 194, 0, 0.5); }
#shop .coach-card h3 { margin: 0 0 4px; font-size: 16px; color: #f2c200; }
#shop .coach-card p { margin: 0; opacity: 0.85; }
#shop.learning .close { display: none; }
#shop .buy.glow, #shop.learning #confirm-yes { animation: coached 1.4s ease-in-out infinite; }
/* On a touch screen the middle's taken by the HUD, so the prompt sits at the bottom, beside the throttle lever. */
@media (pointer: coarse) and (orientation: landscape) {
  #coach { top: auto; left: auto; bottom: max(14px, env(safe-area-inset-bottom)); right: calc(max(12px, env(safe-area-inset-right)) + 58px); max-width: 240px; transform: translateY(8px); }
  #coach.on { transform: none; }
}
@media (pointer: coarse) and (orientation: portrait) { #coach { top: 46%; } }
/* A character's portrait (faces.js) in place of a card's icon. */
#shop .badge.face { padding: 0; overflow: hidden; border-radius: 50%; background: none; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18); }
#shop .badge.face svg { width: 100%; height: 100%; display: block; }
/* Portraits (faces.js) are round wherever they're shown, whatever their own clipping does. */
svg.face { clip-path: circle(50%); }
/* The People page of the captain's log: everyone to meet, like the fish log. */
#shop .people { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
#shop .person-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); text-align: center; }
#shop .person-card.unknown { opacity: 0.55; }
#shop .person-card svg { width: 76px; height: 76px; margin-bottom: 4px; }
#shop .person-card h3 { margin: 0; font-size: 14px; }
#shop .person-card p { margin: 0; font-size: 12px; line-height: 1.35; opacity: 0.8; }
#shop .person-card .place { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.6; }

/* Johan's trade boat (johan.js): his sheet has no tabs, and his line at the top beside his portrait. */
#shop.trading .tabs { display: none; }
#shop .trader-hello { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
#shop .trader-hello .badge { width: 64px; height: 64px; flex: none; }
#shop .trader-hello p { margin: 0; font: italic 16px/1.4 Georgia, 'Times New Roman', serif; }
/* Kevin's priority shipments (kevin.js): his face on the card, and a tag of their own. */
#shop .card.job.priority { box-shadow: inset 0 0 0 1px rgba(143, 184, 255, 0.35); }
#shop .card.job.priority .tag { background: #8fb8ff; color: #0b1a33; }

/* ---- The yacht's helicopter (helicopter.js): its key, the flight panel in place of the HUD's, and the fade ---- */
#heli { grid-column: 1 / -1; }
#hud.compact #heli { grid-column: auto; }
@media (pointer: fine) { #hud.compact #heli { grid-column: 1 / -1; } }
#heli:not(:disabled) .led { background: #f2c200; box-shadow: 0 0 7px #f2c200; }
#heli:disabled { opacity: 0.55; cursor: default; }
#heli-panel { display: none; width: 280px; box-sizing: border-box; padding: 12px; border-radius: 18px; flex-direction: column; gap: 10px;
  background: rgba(14, 20, 24, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25); }
body.heli #panel, body.heli #speedo, body.heli #throttle { display: none; }
body.heli #heli-panel { display: flex; }
#heli-panel .gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#heli-panel .gauge { display: flex; flex-direction: column; gap: 1px; }
#heli-panel .gauge strong { font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
#heli-panel .gauge span { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.7; }
#heli-pad { display: flex; align-items: center; gap: 5px; min-width: 0; }
#heli-pad svg { width: 11px; height: 11px; flex: none; fill: #f2c200; }
#heli-pad .where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#heli-pad .far { flex: none; white-space: nowrap; }
#heli-pad.here { color: #f2c200; font-weight: bold; }
#heli-pad.here svg, #heli-pad.here .far { display: none; }
#hud #heli-home { display: grid; grid-template-columns: auto minmax(0, 1fr); padding: 10px; }
#heli-home .name { grid-row: span 2; }
#heli-home .led { background: #f2c200; box-shadow: 0 0 7px #f2c200; }
/* Touch screens: forward and back, climb and sink at the right edge, where the throttle lever was. */
#heli-stick { display: none; position: fixed; top: 37%; transform: translateY(-50%); right: max(12px, env(safe-area-inset-right)); grid-template-columns: 60px 60px; gap: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#heli-stick button {
  display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; padding: 0; color: #fff; font: inherit;
  background: rgba(14, 20, 24, 0.25); border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 50%; touch-action: none;
}
#heli-stick button:active { background: rgba(255, 255, 255, 0.3); }
#heli-stick svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
@media (pointer: coarse) {
  body.heli #heli-stick { display: grid; }
  body.heli #heli-panel { order: 2; flex: 1 1 0; max-width: 320px; }
}
@media (max-width: 640px) {
  #heli-panel { width: 190px; padding: 10px; gap: 8px; }
  #heli-panel .gauge strong { font-size: 21px; }
}
/* Black over everything for a moment while the helicopter's put back aboard. */
#curtain { position: fixed; inset: 0; z-index: 40; background: #000; opacity: 0; pointer-events: none; display: none; }
#curtain.on { display: block; pointer-events: auto; }
