/* Layout: the pixel sea fills the screen at port; at sea a game panel sits under a 44%-height scene. */
:root {
  --night: #0c1230;
  --panel: #10183d;
  --panel-2: #172255;
  --edge: #050818;
  --ink: #f4ecd8;
  --ink-dim: #a9b1d6;
  --ink-faint: #3a4580;
  --straw: #f1c04a;
  --straw-deep: #a8761c;
  --red: #e0533d;
  --red-deep: #8e2a1c;
  --cyan: #6fe3ff;
  --paper: #ead9b0;
  --paper-dark: #b99c62;
  --paper-ink: #2a1a10;

  --t-rookie: #a9b1d6;
  --t-supernova: #6fe3ff;
  --t-warlord: #9be35a;
  --t-emperor: #ff9a3c;
  --t-king: #ffd84a;
  --t-wreck: #e0533d;
  --t-becalmed: #7c86a8;

  --pixel: "Press Start 2P", "Courier New", monospace;
  --body: "VT323", "Courier New", monospace;

  --sea-h: 100dvh;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 400 22px/1.2 var(--body);
  -webkit-font-smoothing: none;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
img, canvas { image-rendering: pixelated; }

.app { min-height: 100dvh; position: relative; }
.app[data-screen="play"] { --sea-h: 56dvh; }
.sea { position: fixed; inset: 0 0 auto 0; width: 100%; height: var(--sea-h); display: block; }   /* no animated height: every step would wipe and redraw the canvas (flicker) */
.scanlines {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.screen { position: relative; z-index: 2; }

/* ---------- pixel buttons ---------- */
.btn {
  font: 400 12px/1 var(--pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--panel-2);
  border: 3px solid var(--ink);
  border-radius: 0;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--edge), inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.05s;
}
.btn:hover { background: #22306e; }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--edge), inset -3px -3px 0 rgba(0, 0, 0, 0.35); }
.btn:focus-visible, input:focus-visible, summary:focus-visible, .mode:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.btn-straw { background: var(--straw); color: #241500; border-color: #fff1c2; box-shadow: 0 4px 0 var(--straw-deep), inset -3px -3px 0 rgba(120, 70, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.4); }
.btn-straw:hover { background: #ffd060; }
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--ink-faint); }
.btn-wide { width: 100%; padding: 16px; font-size: 14px; }

/* ---------- sound toggles ---------- */
.sys {
  position: fixed; z-index: 15;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: max(12px, env(safe-area-inset-right, 0px));
  display: flex; gap: 6px;
}
.icon-btn {
  width: 38px; height: 38px; padding: 7px; cursor: pointer;
  background: rgba(12, 18, 48, 0.85); border: 3px solid var(--ink); border-radius: 0;
  box-shadow: 0 3px 0 var(--edge);
}
.icon-btn svg { width: 100%; height: 100%; display: block; fill: var(--ink); shape-rendering: crispEdges; }
.icon-btn[aria-pressed="false"] { border-color: var(--ink-faint); }
.icon-btn[aria-pressed="false"] svg { fill: var(--ink-faint); }
.icon-btn[aria-pressed="false"]::after { content: ""; position: absolute; }
.app[data-screen="play"] .sys { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); }
/* volume panel: opens under the buttons (above them when they sit at the bottom) */
.volpop { position: absolute; right: 0; top: calc(100% + 8px); width: 250px; padding: 10px 12px; display: grid; gap: 10px;
  background: var(--panel); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--edge); }
.app[data-screen="play"] .volpop, .app[data-screen="wanted"] .volpop { top: auto; bottom: calc(100% + 8px); }
.vol-row { display: grid; grid-template-columns: 74px 1fr 30px; align-items: center; gap: 8px; cursor: pointer; }
.vol-name { font: 400 8px/1.2 var(--pixel); text-transform: uppercase; color: var(--ink-dim); letter-spacing: 0.06em; }
.vol-row b { font: 400 9px/1 var(--pixel); color: var(--straw); text-align: right; font-weight: 400; }
.vol-row input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; --fill: 70%; }
.vol-row input[type=range]::-webkit-slider-runnable-track { height: 10px; border: 2px solid var(--ink-faint);
  background: linear-gradient(90deg, var(--straw) var(--fill), var(--edge) var(--fill)); }
.vol-row input[type=range]::-moz-range-track { height: 6px; border: 2px solid var(--ink-faint); background: var(--edge); }
.vol-row input[type=range]::-moz-range-progress { height: 6px; background: var(--straw); }
.vol-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 20px; margin-top: -7px;
  background: var(--ink); border: 2px solid var(--night); box-shadow: 0 2px 0 var(--edge); }
.vol-row input[type=range]::-moz-range-thumb { width: 10px; height: 18px; border-radius: 0; background: var(--ink); border: 2px solid var(--night); }
.vol-row input[type=range]:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---------- route list (desktop) ---------- */
.route {
  position: fixed; z-index: 4;
  right: max(12px, env(safe-area-inset-right, 0px));
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  display: flex; flex-direction: column; gap: 0;
  font: 400 8px/1 var(--pixel);
  pointer-events: none;
  border-right: 2px dashed rgba(244, 236, 216, 0.35);
  padding-right: 10px;
}
.route li { list-style: none; position: relative; padding: 5px 0; text-align: right; color: rgba(244, 236, 216, 0.55); text-shadow: 2px 2px 0 var(--edge); }
.route li::after { content: ""; position: absolute; right: -15px; top: 4px; width: 8px; height: 8px; background: var(--night); border: 2px solid rgba(244, 236, 216, 0.55); }
.route li.passed { color: var(--straw); }
.route li.passed::after { background: var(--straw); border-color: var(--straw); }
.route li.here { color: var(--ink); }
.route li.here::before { content: "YOU"; position: absolute; right: calc(100% + 8px); top: 3px; background: var(--straw); color: #241500; padding: 2px 4px; text-shadow: none; }
.route ul { margin: 0; padding: 0; }
.app[data-screen="play"] .route { top: calc(env(safe-area-inset-top, 0px) + 72px); }
.app[data-screen="debug"] .route, .app[data-screen="result"] .route { display: none; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; z-index: 5; left: 0; right: 0;
  top: env(safe-area-inset-top, 0px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.hud-stat { display: flex; flex-direction: column; gap: 6px; background: rgba(8, 12, 36, 0.82); border: 3px solid var(--ink); padding: 8px 10px; justify-self: start; box-shadow: 0 3px 0 var(--edge); }
.hud-right { justify-self: end; text-align: right; }
.hud-label { font: 400 8px/1 var(--pixel); color: var(--ink-dim); letter-spacing: 0.1em; text-transform: uppercase; }
.hud-value { font: 400 clamp(11px, 1.6vw, 16px)/1 var(--pixel); font-variant-numeric: tabular-nums; }
.straw { color: var(--straw); }
.pips { display: flex; gap: 6px; padding-top: 8px; flex-wrap: wrap; justify-content: center; max-width: 40vw; }
.pip { width: 18px; height: 18px; border: 3px solid var(--ink-dim); background: rgba(8, 12, 36, 0.8); }
.pip.now { border-color: var(--straw); animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { border-color: var(--ink); } }
.pip[data-tier] { border-color: var(--edge); }
.pip[data-tier="rookie"] { background: var(--t-rookie); }
.pip[data-tier="supernova"] { background: var(--t-supernova); }
.pip[data-tier="warlord"] { background: var(--t-warlord); }
.pip[data-tier="emperor"] { background: var(--t-emperor); }
.pip[data-tier="king"] { background: var(--t-king); box-shadow: 0 0 0 2px #fff6c0; }
.pip[data-tier="wreck"] { background: var(--t-wreck); }
.pip[data-tier="becalmed"] { background: var(--t-becalmed); }

.landfall {
  position: fixed; z-index: 6; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 78px);
  transform: translateX(-50%);
  font: 400 clamp(12px, 2vw, 18px)/1.2 var(--pixel); color: var(--straw);
  background: rgba(8, 12, 36, 0.9); border: 3px solid var(--straw); box-shadow: 0 4px 0 var(--edge);
  padding: 10px 16px; white-space: nowrap; text-align: center;
  animation: landfall 2.4s steps(12) forwards;
}
.landfall small { display: block; font-size: 8px; color: var(--ink-dim); margin-bottom: 6px; letter-spacing: 0.2em; }
@keyframes landfall { 0% { opacity: 0; transform: translate(-50%, 10px); } 12%, 78% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* ---------- PORT ---------- */
.screen-title {
  min-height: 100dvh;
  display: flex; align-items: flex-start; justify-content: center;
  padding-block: calc(env(safe-area-inset-top, 0px) + 40px) max(40px, 24dvh);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.title-wrap { width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.logo {
  margin: 0;
  font: 400 clamp(34px, 8.4vw, 76px)/1 var(--pixel);
  color: var(--straw);
  letter-spacing: 0.02em;
  text-shadow: 4px 4px 0 var(--red-deep), 8px 8px 0 var(--edge);
  animation: logo 3s steps(3) infinite;
}
@keyframes logo { 50% { transform: translateY(-3px); } }
.tagline { margin: 0; font: 400 clamp(10px, 1.6vw, 14px)/1 var(--pixel); color: var(--cyan); letter-spacing: 0.24em; text-transform: uppercase; text-shadow: 3px 3px 0 var(--edge); }
.pitch { margin: 0; font-size: 24px; line-height: 1.1; max-width: 32ch; text-shadow: 2px 2px 0 var(--edge); }
.voyage-meta { margin: 0; font: 400 9px/1.6 var(--pixel); color: var(--ink-dim); letter-spacing: 0.12em; text-transform: uppercase; text-shadow: 2px 2px 0 var(--edge); }
.voyage-meta b { color: var(--ink); font-weight: 400; }

.modes { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mode {
  text-align: center; font: inherit; color: var(--ink); cursor: pointer; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(12, 18, 48, 0.9); border: 3px solid var(--ink-faint); border-radius: 0;
  padding: 12px 8px; box-shadow: 0 4px 0 var(--edge);
}
.mode:hover:not([disabled]) { border-color: var(--ink); }
.mode:active:not([disabled]) { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.mode-icon { width: 28px; height: 28px; fill: var(--cyan); shape-rendering: crispEdges; }
.mode-name { font: 400 9px/1.3 var(--pixel); text-transform: uppercase; }
.mode-blurb { display: none; }
.mode-tag { font: 400 7px/1 var(--pixel); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-dim); margin-top: auto; }
.mode[disabled] { cursor: default; opacity: 0.55; border-style: dashed; }
.mode-main {
  grid-column: 1 / -1; padding: 0; border: none; background: none; box-shadow: none; gap: 6px;
}
.mode-main .play-btn {
  width: min(460px, 100%); padding: 18px 16px 14px;
  font: 400 clamp(15px, 2.4vw, 20px)/1 var(--pixel);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.mode-main .play-btn small { font: 400 9px/1 var(--pixel); letter-spacing: 0.1em; opacity: 0.8; }
.mode-done { font-size: 20px; color: var(--straw); text-shadow: 2px 2px 0 var(--edge); }
.more-ways { grid-column: 1 / -1; margin: 8px 0 0; font: 400 8px/1 var(--pixel); letter-spacing: 0.2em; color: var(--ink-dim); text-shadow: 2px 2px 0 var(--edge); }

.howto { width: 100%; max-width: 560px; text-align: left; background: rgba(12, 18, 48, 0.92); border: 3px solid var(--ink-faint); }
.howto summary { cursor: pointer; padding: 12px 14px; font: 400 9px/1.2 var(--pixel); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.howto-body { padding: 0 14px 14px; font-size: 20px; color: var(--ink-dim); }
.howto-body p { margin: 0 0 12px; }
.tier-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tier-legend li { display: grid; grid-template-columns: 22px 120px 46px minmax(0, 1fr); gap: 10px; align-items: center; }
.tier-legend .sw { width: 16px; height: 16px; border: 2px solid var(--edge); }
.tier-legend .t-name { font: 400 9px/1.3 var(--pixel); }
.tier-legend .t-pts { font: 400 9px/1 var(--pixel); color: var(--ink); }
.data-warn { margin: 0; color: var(--t-wreck); font-size: 20px; max-width: 60ch; text-shadow: 2px 2px 0 var(--edge); }

/* tier colors */
.tc[data-tier="rookie"], [data-tier="rookie"] .tc, [data-tier="rookie"] .sw { color: var(--t-rookie); background-color: transparent; }
[data-tier="rookie"] .sw { background: var(--t-rookie); }
.tc[data-tier="supernova"], [data-tier="supernova"] .tc { color: var(--t-supernova); }
[data-tier="supernova"] .sw { background: var(--t-supernova); }
.tc[data-tier="warlord"], [data-tier="warlord"] .tc { color: var(--t-warlord); }
[data-tier="warlord"] .sw { background: var(--t-warlord); }
.tc[data-tier="emperor"], [data-tier="emperor"] .tc { color: var(--t-emperor); }
[data-tier="emperor"] .sw { background: var(--t-emperor); }
.tc[data-tier="king"], [data-tier="king"] .tc { color: var(--t-king); text-shadow: 0 0 10px rgba(255, 216, 74, 0.6); }
[data-tier="king"] .sw { background: var(--t-king); }
.tc[data-tier="wreck"], [data-tier="wreck"] .tc { color: var(--t-wreck); }
[data-tier="wreck"] .sw { background: var(--t-wreck); }
.tc[data-tier="becalmed"], [data-tier="becalmed"] .tc { color: var(--t-becalmed); }

/* ---------- AT SEA ---------- */
.screen-play { padding-top: 56dvh; min-height: 100dvh; }
.panel {
  position: relative;
  min-height: 44dvh;
  background: var(--panel);
  border-top: 4px solid var(--ink);
  box-shadow: 0 -4px 0 var(--edge);
  padding-block: 22px calc(70px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 4px, transparent 4px 8px);
}
.panel > * { width: 100%; max-width: 680px; }
.prompt-head { display: flex; justify-content: space-between; font: 400 9px/1 var(--pixel); letter-spacing: 0.1em; color: var(--ink-dim); }
.lives { color: var(--red); letter-spacing: 0.2em; font-size: 12px; }
.prompt { margin: 0; text-align: center; font: 400 clamp(15px, 2.6vw, 22px)/1.5 var(--pixel); text-wrap: balance; text-shadow: 3px 3px 0 var(--edge); }
.guess { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.guess input {
  min-width: 0; width: 100%;
  font: 400 26px/1 var(--body); color: var(--ink);
  background: var(--edge); border: 3px solid var(--ink); border-radius: 0;
  padding: 10px 12px; box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.5);
  caret-color: var(--straw);
}
.guess input::placeholder { color: #59609a; }
.guess.shake { animation: shake 0.3s steps(4); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-4px); } }

.logpose { position: relative; width: 50px; height: 50px; flex: none; }
.logpose canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.lp-ring { fill: var(--edge); stroke: var(--ink-faint); stroke-width: 5; }
.lp-time { fill: none; stroke: var(--straw); stroke-width: 5; stroke-dasharray: 100; stroke-dashoffset: 0; transform: rotate(-90deg); transform-origin: 32px 32px; }
.logpose.low .lp-time { stroke: var(--red); }
.logpose.low { animation: shake 0.5s steps(4) infinite; }
.lp-glass { fill: rgba(111, 227, 255, 0.12); stroke: var(--ink-dim); stroke-width: 2; }
.lp-needle { fill: var(--ink-dim); }
.lp-north { fill: var(--red); }
.lp-pin { fill: var(--ink); }
#lpNeedle { transform-origin: 32px 32px; }
#lpSecs { position: absolute; right: -8px; bottom: -8px; font: 400 9px/1 var(--pixel); background: var(--panel); border: 2px solid var(--ink-faint); padding: 3px; }

.hint { min-height: 24px; text-align: center; font-size: 22px; color: var(--ink-dim); }
.hint button { font: 400 9px/1 var(--pixel); color: var(--straw); background: var(--edge); border: 2px solid var(--straw); padding: 7px 8px; margin: 6px 4px 0; cursor: pointer; }

.reveal { display: flex; flex-direction: column; gap: 14px; animation: rise 0.35s steps(5); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.stamp {
  align-self: center;
  font: 400 clamp(20px, 4vw, 32px)/1 var(--pixel);
  padding: 10px 14px; border: 4px solid currentColor;
  text-shadow: 3px 3px 0 var(--edge); box-shadow: 4px 4px 0 var(--edge);
  transform: rotate(-3deg);
  animation: stamp 0.3s steps(4);
}
@keyframes stamp { from { transform: rotate(-3deg) scale(1.8); opacity: 0; } to { transform: rotate(-3deg) scale(1); opacity: 1; } }
.reveal[data-tier="king"] .stamp { animation: stamp 0.3s steps(4), kingflash 0.4s steps(2) 0.3s 4; }
@keyframes kingflash { 50% { color: #ffffff; } }
.reveal-row { display: flex; gap: 16px; align-items: center; justify-content: center; }
.portrait {
  width: 84px; height: 84px; flex: none; overflow: hidden;
  border: 3px solid var(--ink); background: var(--panel-2); box-shadow: 4px 4px 0 var(--edge);
  display: grid; place-items: center;
  font: 400 20px/1 var(--pixel); color: var(--ink-dim);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reveal-text { min-width: 0; }
.answer-name { font: 400 clamp(12px, 2vw, 16px)/1.4 var(--pixel); }
.answer-line { color: var(--ink-dim); font-size: 22px; line-height: 1.05; margin-top: 4px; }
.answer-pts { font: 400 11px/1.6 var(--pixel); margin-top: 6px; }
.others { font-size: 21px; line-height: 1.15; color: var(--ink-dim); text-align: center; border-top: 3px dashed var(--ink-faint); padding-top: 12px; }
.others b { color: var(--ink); font-weight: 400; }

/* ---------- RESULT ---------- */
.screen-result {
  min-height: 100dvh;
  padding-block: calc(env(safe-area-inset-top, 0px) + 60px) calc(28px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgba(6, 10, 30, 0.55);
}
.result-wrap { max-width: 960px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 28px; align-items: start; }
.poster {
  color: var(--paper-ink);
  background:
    repeating-linear-gradient(0deg, rgba(120, 80, 30, 0.07) 0 2px, transparent 2px 6px),
    var(--paper);
  border: 4px solid var(--paper-dark);
  box-shadow: 0 0 0 4px var(--paper-ink), 8px 8px 0 4px var(--edge);
  padding: 18px 18px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transform: rotate(-1.5deg);
  animation: pin 0.5s steps(6);
  container-type: inline-size;
}
@keyframes pin { from { transform: rotate(5deg) translateY(-40px); opacity: 0; } to { transform: rotate(-1.5deg); opacity: 1; } }
.poster-wanted { font: 400 16cqi/1 var(--pixel); letter-spacing: 0.02em; text-shadow: 3px 3px 0 var(--paper-dark); }
.poster-photo {
  width: 100%; aspect-ratio: 4 / 3.3; max-width: 100%;
  border: 4px solid var(--paper-ink); background: #cdb88a;
  display: grid; place-items: center; overflow: hidden;
  font: 400 40px/1 var(--pixel); color: rgba(42, 26, 16, 0.5);
}
.poster-photo img { width: 100%; height: 100%; object-fit: cover; filter: sepia(0.35) contrast(1.05); }
.poster-photo svg { width: 60%; height: auto; shape-rendering: crispEdges; }
.poster-doa { font: 400 6.5cqi/1 var(--pixel); letter-spacing: 0.06em; }
.poster-name {
  width: 100%; text-align: center; text-transform: uppercase;
  font: 400 5.6cqi/1.2 var(--pixel); color: var(--paper-ink);
  background: transparent; border: none; border-bottom: 3px dashed rgba(42, 26, 16, 0.35); padding: 4px 0 6px;
}
.poster-name:focus { outline: none; border-bottom-color: var(--paper-ink); }
.poster-bounty { font: 400 min(22px, 7.4cqi)/1.2 var(--pixel); font-variant-numeric: tabular-nums; }
.berry { margin-right: 4px; }
.poster-foot { width: 100%; display: flex; justify-content: space-between; font: 400 8px/1 var(--pixel); padding-top: 8px; border-top: 3px solid rgba(42, 26, 16, 0.3); }

.logbook { background: rgba(12, 18, 48, 0.94); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--edge); padding: 18px; min-width: 0; }
.logbook-title { margin: 0; font: 400 16px/1.2 var(--pixel); color: var(--straw); text-shadow: 3px 3px 0 var(--edge); }
.logbook-sub { margin: 8px 0 10px; font-size: 22px; color: var(--ink-dim); }
.log { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; }
.log li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 2px 12px; padding: 9px 0; border-bottom: 3px dashed var(--ink-faint); }
.log .n { font: 400 9px/1.8 var(--pixel); color: var(--ink-dim); }
.log .q { font-size: 19px; line-height: 1.05; color: var(--ink-dim); }
.log .a { font-size: 22px; grid-column: 2; }
.log .s { grid-row: 1 / span 2; grid-column: 3; text-align: right; font: 400 9px/1.6 var(--pixel); }
.log .s b { display: block; font-weight: 400; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.copy-fallback { width: 100%; margin-top: 12px; min-height: 110px; font: 20px/1.1 var(--body); color: var(--ink); background: var(--edge); border: 3px solid var(--ink-faint); padding: 10px; }

/* ---------- DATA CHECK ---------- */
.screen-debug { background: var(--night); min-height: 100dvh; padding-block: 28px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.dbg { max-width: 1100px; margin: 0 auto; }
.dbg h1 { font: 400 20px/1.3 var(--pixel); color: var(--straw); margin: 0 0 10px; }
.dbg h2 { font: 400 10px/1.4 var(--pixel); color: var(--cyan); margin: 28px 0 10px; }
.dbg p { color: var(--ink-dim); margin: 0 0 8px; max-width: 80ch; }
.dbg a { color: var(--straw); }
.dbg-q { border-top: 3px solid var(--ink-faint); padding: 10px 0; }
.dbg-q h3 { margin: 0 0 6px; font-size: 24px; font-weight: 400; }
.dbg-q h3 small { color: var(--ink-dim); font-size: 18px; }
.dbg-a { display: flex; flex-wrap: wrap; gap: 6px; }
.dbg-a span { font-size: 18px; border: 2px solid var(--ink-faint); padding: 2px 6px; }
.dbg-small { columns: 2 280px; font-size: 18px; color: var(--ink-dim); }

/* ---------- WANTED ---------- */
:root { --w-same: #3c9a46; --w-near: #c9971c; --w-diff: #a63a2c; --w-unknown: #2a3366; }
.app[data-screen="wanted"] { --sea-h: 44dvh; }
.app[data-screen="wanted"] .sys { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); }
.app[data-screen="wanted"] .route { display: none; }
.screen-wanted { padding-top: 44dvh; min-height: 100dvh; }
.panel-wanted > * { max-width: 1060px; }
.panel-wanted > .prompt-head, .panel-wanted > .prompt, .panel-wanted > .wsearch, .panel-wanted > .hint, .panel-wanted > .wcaught, .panel-wanted > .wtools { max-width: 680px; }
.panel-wanted .hint { min-height: 0; }

.wsearch { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.wsearch input {
  min-width: 0; width: 100%;
  font: 400 26px/1 var(--body); color: var(--ink);
  background: var(--edge); border: 3px solid var(--ink); border-radius: 0;
  padding: 10px 12px; box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.5); caret-color: var(--straw);
}
.wsearch input::placeholder { color: #59609a; }
.wsearch.shake { animation: shake 0.3s steps(4); }
.wlist {
  position: absolute; z-index: 8; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 0; list-style: none; max-height: min(330px, 46dvh); overflow-y: auto;
  background: var(--panel); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--edge);
}
.wlist li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; cursor: pointer; border-bottom: 2px solid var(--ink-faint); }
.wlist li:last-child { border-bottom: none; }
.wlist li[aria-selected="true"] { background: var(--panel-2); box-shadow: inset 4px 0 0 var(--straw); }
.wlist li:hover:not(.used) { background: var(--panel-2); }
.wlist li.used { cursor: default; opacity: 0.45; }
.wlist li.wgroup { position: sticky; top: 0; z-index: 1; cursor: default; justify-content: space-between; padding: 7px 10px 6px;
  background: var(--ink); color: var(--night); font: 400 8px/1.2 var(--pixel); letter-spacing: 0.08em; text-transform: uppercase; }
.wlist li.wgroup:hover { background: var(--ink); }
.wlist li.wgroup b { font-weight: 400; }
.portrait.wmini { width: 36px; height: 36px; border-width: 2px; box-shadow: 2px 2px 0 var(--edge); font-size: 10px; }
.wopt-name { flex: 1; min-width: 0; font-size: 24px; line-height: 1; }
.wopt-name small { display: block; font-size: 17px; color: var(--ink-dim); }
.wopt-tag { font: 400 7px/1 var(--pixel); color: var(--ink-dim); letter-spacing: 0.1em; }

.wtools { display: flex; justify-content: center; gap: 10px; }
.wtools .btn { padding: 9px 12px; font-size: 9px; }
.wcaught { display: flex; flex-direction: column; gap: 14px; animation: rise 0.35s steps(5); }
.wcaught[data-tier="king"] .stamp { animation: stamp 0.3s steps(4), kingflash 0.4s steps(2) 0.3s 4; }

.wboard { display: flex; flex-direction: column; gap: 10px; }
.wrow { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px; align-items: stretch; }
.wwho { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 0; text-align: center; }
.portrait.wport { width: 46px; height: 46px; border-width: 2px; box-shadow: 3px 3px 0 var(--edge); font-size: 12px; }
.wname { font: 400 8px/1.4 var(--pixel); overflow-wrap: anywhere; }
.wrow.win .wname { color: var(--t-king); }
.wtiles { display: grid; grid-template-columns: repeat(var(--cols, 11), minmax(0, 1fr)); gap: 5px; }
.wtile {
  position: relative; min-width: 0; min-height: 70px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 16px 3px 6px; text-align: center;
  background: var(--w-diff); border: 3px solid var(--edge);
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.3), inset 3px 3px 0 rgba(255, 255, 255, 0.14);
  animation: flip 0.36s steps(4) both; animation-delay: calc(var(--i) * 90ms);
}
.wtile.still { animation: none; }
@keyframes flip { 0% { transform: scaleY(0); filter: brightness(2); } 60% { transform: scaleY(1.08); } 100% { transform: none; filter: none; } }
.wtile[data-state="same"] { background: var(--w-same); }
.wtile[data-state="near"] { background: var(--w-near); }
.wtile[data-state="unknown"] { background: var(--w-unknown); }
.wlab { position: absolute; top: 4px; left: 0; right: 0; font: 400 6px/1 var(--pixel); letter-spacing: 0.06em; text-transform: uppercase; color: rgba(255, 255, 255, 0.75); }
.wval { font-size: 19px; line-height: 0.95; overflow-wrap: break-word; hyphens: auto; max-width: 100%; text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45); }
.warr { width: 21px; height: 12px; fill: var(--ink); shape-rendering: crispEdges; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.5)); }
.wkey { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; font-size: 19px; color: var(--ink-dim); }
.wkey span[data-state]::before { content: ""; display: inline-block; width: 13px; height: 13px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--edge); background: var(--w-diff); }
.wkey span[data-state="same"]::before { background: var(--w-same); }
.wkey span[data-state="near"]::before { background: var(--w-near); }
.wkey span[data-state="unknown"]::before { background: var(--w-unknown); }

/* title card with two buttons */
.mode-split { cursor: default; }
.mode-split:active { transform: none !important; box-shadow: 0 4px 0 var(--edge) !important; }
.mode-btns { display: flex; gap: 6px; width: 100%; justify-content: center; flex-wrap: wrap; }
.btn-mini { padding: 7px 7px; font-size: 7px; box-shadow: 0 3px 0 var(--edge), inset -2px -2px 0 rgba(0, 0, 0, 0.3); border-width: 2px; }
.btn-mini.btn-straw { box-shadow: 0 3px 0 var(--straw-deep), inset -2px -2px 0 rgba(120, 70, 0, 0.35); }

/* result: wanted poster + mini board */
.poster[data-nobounty="1"] .berry { display: none; }
.wboard-mini { display: flex; flex-direction: column; margin: 0 0 18px; }
.wmrow { display: grid; grid-template-columns: 26px auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 7px 0; border-bottom: 3px dashed var(--ink-faint); }
.wmrow .n { font: 400 9px/1 var(--pixel); color: var(--ink-dim); }
.wmrow .a { font-size: 22px; min-width: 0; overflow-wrap: anywhere; }
.wsq { display: flex; gap: 3px; }
.wsq i { width: 14px; height: 14px; border: 2px solid var(--edge); background: var(--w-diff); }
.wsq i[data-state="same"] { background: var(--w-same); }
.wsq i[data-state="near"] { background: var(--w-near); }
.wsq i[data-state="unknown"] { background: var(--w-unknown); }
@media (max-width: 1000px) {
  .wrow { grid-template-columns: 1fr; gap: 6px; }
  .wwho { flex-direction: row; justify-content: flex-start; gap: 10px; }
  .portrait.wport { width: 32px; height: 32px; font-size: 9px; }
  .wname { font-size: 9px; text-align: left; }
  .wtiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .wboard { gap: 16px; }
}
@media (max-width: 560px) {
  .wtiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .wtile { min-height: 62px; }
  .wval { font-size: 18px; }
  .wsq i { width: 11px; height: 11px; }
  .wsq { gap: 2px; }
}
@media (max-width: 460px) {
  .app[data-screen="wanted"] { --sea-h: 30dvh; }
  .app[data-screen="wanted"] .pips { max-width: 48vw; gap: 3px; }
  .app[data-screen="wanted"] .pip { width: 12px; height: 12px; }
  .screen-wanted { padding-top: 30dvh; }
}

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) { .route { display: none; } }
@media (max-width: 720px) {
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-wrap { grid-template-columns: 1fr; }
  .poster { max-width: 360px; margin: 0 auto; width: 100%; }
  .tier-legend li { grid-template-columns: 22px 100px 40px minmax(0, 1fr); }
}
@media (max-width: 460px) {
  .screen-title { padding-top: calc(env(safe-area-inset-top, 0px) + 64px); }
  .app[data-screen="play"] { --sea-h: 44dvh; }
  .screen-play { padding-top: 44dvh; }
  .guess { grid-template-columns: minmax(0, 1fr) auto; }
  .guess .btn { grid-column: 1 / -1; grid-row: 2; }
  .logpose { grid-column: 2; grid-row: 1; }
  .pips { max-width: 40vw; gap: 4px; }
  .pip { width: 13px; height: 13px; border-width: 2px; }
  .hud-stat { padding: 6px 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- settings: difficulty + spoiler filter ---------- */
.settings { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 8px; background: rgba(12, 18, 48, 0.92); border: 3px solid var(--ink-faint); padding: 12px 14px; text-align: left; }
.set-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.set-label { font: 400 9px/1 var(--pixel); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); min-width: 92px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-btn { font: 400 10px/1 var(--pixel); text-transform: uppercase; color: var(--ink); background: var(--panel-2); border: 3px solid var(--ink-faint); padding: 9px 12px; cursor: pointer; box-shadow: 0 3px 0 var(--edge); }
.seg-btn[aria-pressed="true"] { background: var(--straw); color: #241500; border-color: #fff1c2; }
.seg-btn:focus-visible, .set-select:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.set-select { flex: 1; min-width: 0; font: 400 20px/1 var(--body); color: var(--ink); background: var(--edge); border: 3px solid var(--ink-faint); padding: 6px 8px; }
.set-note { margin: 0; font-size: 18px; line-height: 1.05; color: var(--ink-dim); }

.set-ep { flex: 0 1 120px; }

/* prompt help: "?" button, bracket note, explanation */
.prompt-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.prompt-row .prompt { min-width: 0; }
.hint-btn { flex: none; width: 30px; height: 30px; font: 400 12px/1 var(--pixel); color: var(--edge); background: var(--cyan); border: 3px solid #d8f8ff; box-shadow: 0 3px 0 var(--edge); cursor: pointer; }
.hint-btn[aria-expanded="true"] { background: var(--straw); border-color: #fff1c2; }
.hint-btn:focus-visible { outline: 3px solid var(--straw); outline-offset: 2px; }
.prompt-note { margin: -6px 0 0; text-align: center; font-size: 20px; line-height: 1; color: var(--ink-dim); }
.hint-pop { margin: 0; padding: 10px 12px; background: var(--edge); border: 3px solid var(--cyan); font-size: 20px; line-height: 1.1; color: var(--ink); }

/* Pirate King cutscene: full screen, above everything, blocks clicks while it plays */
.cutscene { position: fixed; inset: 0; z-index: 50; background: #000; display: grid; place-items: center; transition: opacity 0.1s; }
.cutscene canvas { width: 100vw; height: 56.25vw; max-height: 100vh; max-width: 177.78vh; image-rendering: pixelated; display: block; }

.dev-king { flex: none; font-size: 8px; padding: 8px; background: #3a1a4a; border-color: #ff7ad8; }

/* developer bar (?dev) */
.dev-bar { position: fixed; z-index: 30; left: max(10px, env(safe-area-inset-left, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 8px; background: rgba(40, 10, 50, 0.92); border: 3px solid #ff7ad8; font: 400 8px/1 var(--pixel); color: #ff7ad8; }
.dev-bar .btn { font-size: 8px; padding: 7px 8px; }
.dev-bar .btn[aria-pressed="true"] { background: #ff7ad8; color: #1a0a20; }

/* loading screen: covers the half-built page until the game is ready (shown on every load/reload) */
.boot { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--night); color: var(--straw); font: 400 14px/1 var(--pixel); letter-spacing: 0.1em; transition: opacity 0.15s; }
/* the words only show if loading is slow, so a quick settings reload doesn't flash them */
.boot span, .boot i { opacity: 0; animation: bootshow 0s 0.45s forwards; }
.boot i { animation: bootshow 0s 0.45s forwards, bootdot 0.9s steps(2) 0.45s infinite; }
@keyframes bootshow { to { opacity: 1; } }
.boot i { width: 8px; height: 8px; background: var(--straw); }
.boot i:nth-of-type(2) { animation-delay: 0.45s, 0.75s; } .boot i:nth-of-type(3) { animation-delay: 0.45s, 1.05s; }
.boot.gone { opacity: 0; pointer-events: none; }
@keyframes bootdot { 50% { opacity: 0.15; } }

/* results: where your score sits among typical voyages */
.curve { margin: 4px 0 14px; padding: 10px; background: var(--edge); border: 3px solid var(--ink-faint); }
.curve canvas { width: 100%; height: auto; display: block; image-rendering: pixelated; }
.curve-note { margin: 6px 0 0; font: 400 8px/1.6 var(--pixel); color: var(--cyan); letter-spacing: 0.06em; }

.credits { margin: 6px auto 0; max-width: 60ch; font-size: 16px; line-height: 1.15; color: var(--ink-dim); text-align: center; text-shadow: 2px 2px 0 var(--edge); }
.credits a { color: var(--ink); }
