:root {
 --paper: #efe5cc;
 --paper-deep: #e2d4b3;
 --ink: #2a2017;
 --ink-soft: #5d4d3c;
 --lead: #9b2c22;
 --sea: #20485a;
 --night: #0a1220;
 --brass: #b98a3c;
 --ok: #2f6b3f;
 --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
 --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink);
 font-family: var(--serif); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; -webkit-user-select: none; }
#hud > * { pointer-events: auto; }
.label { font: 600 10px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 5px; }
#orders, #instruments, #bearings, #watch, #bark, #toast {
 background: rgba(239, 229, 204, .94); border: 1px solid rgba(42, 32, 23, .35); border-radius: 6px;
 box-shadow: 0 2px 10px rgba(0, 0, 0, .28); }
#left { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 118px; max-width: 520px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none !important; }
#orders { align-self: stretch; padding: 8px 12px; }
#chapter { font: 600 10px/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--lead); }
#objective { font-size: 15px; line-height: 1.3; margin-top: 3px; text-wrap: pretty; }
#instruments { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; width: 100px; padding: 6px; text-align: center; }
#compass { width: 88px; height: 88px; display: block; margin: 0 auto; }
#speed { font: 12px var(--sans); color: var(--ink-soft); }
#speed b { font: 600 17px var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
#hull { display: flex; gap: 3px; justify-content: center; margin-top: 5px; }
#hull i { width: 14px; height: 6px; border-radius: 2px; background: var(--sea); }
#hull i.gone { background: transparent; outline: 1px solid var(--lead); outline-offset: -1px; }
#bearings, #watch { width: 200px; max-width: 100%; padding: 7px 10px; font-size: 14px; }
#bearings .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
#bearings .row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
#bearings .row.match b { color: var(--ok); }
#bearings .want { margin-top: 5px; padding-top: 5px; border-top: 1px dashed rgba(42, 32, 23, .35); font-size: 12.5px; color: var(--ink-soft); font-style: italic; }
.meter { height: 8px; border-radius: 4px; background: rgba(42, 32, 23, .16); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--brass); }
#watch.chase .meter i { background: var(--lead); }
#watchText { font-size: 13px; margin-top: 4px; }
#watch.chase { border-color: var(--lead); }
#watch.chase #watchText { color: var(--lead); font-weight: 700; }

#bark { position: absolute; left: 50%; bottom: 300px; transform: translateX(-50%); width: min(92vw, 520px); padding: 9px 13px;
 font-size: 15.5px; line-height: 1.35; text-wrap: pretty; }
#bark b { font: 600 10px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--lead); display: block; margin-bottom: 3px; }
#toast { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); padding: 10px 16px; max-width: 86vw;
 font-size: 16px; text-align: center; border-color: var(--lead); color: var(--lead); font-weight: 600; }

#tools { position: absolute; right: 10px; top: 190px; display: flex; flex-direction: column; gap: 6px; }
#tools button, #dump { background: rgba(239, 229, 204, .94); border: 1px solid rgba(42, 32, 23, .4); border-radius: 6px;
 min-width: 44px; min-height: 40px; padding: 4px 8px; font: 600 13px var(--sans); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
#tools #zoomIn, #tools #zoomOut { font-size: 20px; line-height: 1; }
#tools button:active, #sails button:active { transform: translateY(1px); }
#dump { position: absolute; left: 50%; bottom: 368px; transform: translateX(-50%); background: var(--lead); color: #fff5e4; border-color: #5c1711; padding: 10px 18px; font-size: 14px; }

#helm { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 10px max(10px, env(safe-area-inset-bottom));
 display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none !important; }
#helm > * { pointer-events: auto; }
#anchorBtn { order: 2; min-width: min(64vw, 250px); min-height: 46px; padding: 10px 20px; border-radius: 6px; border: 1px solid #1a1009;
 background: rgba(239, 229, 204, .96); color: var(--ink); font: 700 16px var(--sans); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
#anchorBtn.go { background: var(--ok); color: #f4f0df; border-color: #173a22; }
#anchorBtn:active { transform: translateY(1px); }
.glow { animation: glow 1.1s ease-in-out infinite; position: relative; z-index: 3; }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 3px rgba(255, 190, 60, .95), 0 0 18px 6px rgba(255, 190, 60, .55); } 50% { box-shadow: 0 0 0 5px rgba(255, 190, 60, .6), 0 0 26px 12px rgba(255, 190, 60, .25); } }
#tiller.glow { border-radius: 12px; }
#tip { position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%); width: min(90vw, 440px); padding: 12px 16px 14px; z-index: 4;
 background: #fffaf0; border: 2px solid var(--brass); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .45); }
#tipCount { font: 700 10px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--brass); }
#tipText { margin: 6px 0 12px; font-size: 17px; line-height: 1.4; text-wrap: pretty; }
#tipNext { background: var(--ink); color: var(--paper); border: 0; border-radius: 5px; padding: 10px 18px; font: 600 14px var(--sans); min-height: 40px; }
#tipNext.quietBtn { background: transparent; color: var(--ink-soft); box-shadow: inset 0 0 0 1px rgba(42, 32, 23, .35); }
#sails { order: 3; display: flex; gap: 0; border: 1px solid rgba(42, 32, 23, .5); border-radius: 6px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
#sails button { background: rgba(239, 229, 204, .94); border: 0; border-right: 1px solid rgba(42, 32, 23, .25); padding: 9px 11px; min-height: 40px; font: 600 12.5px var(--sans); }
#sails button:last-child { border-right: 0; }
#sails button.on { background: var(--ink); color: var(--paper); }
#sails button[disabled] { opacity: .35; }
#tiller { position: relative; width: min(64vw, 250px); touch-action: none; cursor: grab; order: 1; }
#tiller:active { cursor: grabbing; }
#tiller svg { display: block; width: 100%; overflow: visible; filter: drop-shadow(3px 6px 5px rgba(0, 0, 0, .6)); }
#tiller .arc { fill: none; stroke: rgba(42, 32, 23, .4); stroke-width: 1.2; stroke-dasharray: 2 5; }
#tiller .arcMid { stroke: rgba(42, 32, 23, .55); stroke-width: 1.6; }
#tillerArm { will-change: transform; }
#turn { position: absolute; left: 0; right: 0; top: -4px; text-align: center; font: 700 12px var(--sans); letter-spacing: .08em; text-transform: uppercase;
 color: #fff5e4; text-shadow: 0 1px 4px #000, 0 0 8px #000; height: 16px; }
#tillerHelp { position: absolute; left: 0; right: 0; bottom: 2px; text-align: center; font: 600 11px var(--sans); color: #fff5e4; text-shadow: 0 1px 4px #000; pointer-events: none; transition: opacity .4s; }

/* ---------- Boksidor ---------- */
#page, #front, #log { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; justify-content: center; align-items: flex-start;
 background: radial-gradient(120% 90% at 50% 0%, rgba(20, 30, 44, .9), rgba(6, 10, 18, .97)); padding: 5vh 16px 8vh; z-index: 5; }
#page[hidden], #front[hidden], #log[hidden], #hud[hidden] { display: none; }
article { position: relative; width: 100%; max-width: 620px; background: var(--paper); border-radius: 3px; padding: clamp(22px, 5vw, 44px) clamp(20px, 6vw, 52px);
 box-shadow: 0 0 0 1px #c9b98f, 0 0 0 7px var(--paper), 0 0 0 8px #b9a777, 0 18px 50px rgba(0, 0, 0, .6);
 background-image: radial-gradient(circle at 20% 10%, rgba(255, 255, 255, .35), transparent 50%), radial-gradient(circle at 85% 90%, rgba(120, 90, 40, .12), transparent 55%); }
#kicker, .over { font: 600 11px/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--lead); }
h1 { font-size: clamp(30px, 7vw, 44px); line-height: 1.05; font-weight: 500; margin: 8px 0 18px; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 20px; font-weight: 600; margin: 26px 0 8px; }
#text p { font-size: clamp(17px, 2.5vw, 19px); line-height: 1.58; margin: 0 0 .8em; text-wrap: pretty; hyphens: auto; }
#text p:first-child::first-letter { font-size: 3.1em; float: left; line-height: .82; padding: .06em .08em 0 0; color: var(--lead); }
#note { font: 13px/1.45 var(--sans); color: var(--ink-soft); border-left: 3px solid var(--brass); padding: 2px 0 2px 10px; margin: 18px 0 0; }
.fact { margin-top: 14px; padding: 12px 14px; background: rgba(255, 255, 255, .4); border: 1px solid rgba(42, 32, 23, .22); border-radius: 4px; }
.fact .tag { font: 600 10px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ok); }
.fact h3 { margin: 5px 0 4px; font-size: 17px; font-weight: 600; }
.fact p { margin: 0; font-size: 15px; line-height: 1.45; }
.fact .status { margin-top: 6px; font: 12.5px/1.4 var(--sans); color: var(--ink-soft); }
.fact a { color: var(--sea); }
#choices, .buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
#choices button, .buttons button { text-align: left; background: var(--ink); color: var(--paper); border: 0; border-radius: 4px; padding: 14px 18px; font-size: 17px; line-height: 1.25; }
#choices button:hover, .buttons button:hover { background: #46352a; }
#choices button + button, #continueBtn:not([hidden]) + #startBtn { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
#choices button + button:hover { background: rgba(42, 32, 23, .08); }
#front h1 { font-size: clamp(44px, 12vw, 76px); margin: 10px 0 4px; }
#front .sub { font-style: italic; font-size: 19px; color: var(--ink-soft); margin-bottom: 20px; }
#front p { font-size: 17.5px; line-height: 1.55; text-wrap: pretty; }
.small, #front p.small { font: 13px/1.5 var(--sans); color: var(--ink-soft); }
ul.small { padding-left: 18px; }
ul.small li { margin-bottom: 5px; }
#logClose { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 30px; line-height: 1; padding: 6px 10px; }
.quiet { background: none; border: 0; text-decoration: underline; color: var(--ink-soft); font: 13px var(--sans); padding: 10px 0; margin-top: 12px; }

@media (min-width: 760px) {
 #bark { bottom: 300px; }
 #tools { top: 200px; }
}
@media (max-height: 520px) {
 #tiller { width: 170px; }
 #bark { bottom: 150px; left: 30%; width: 50vw; font-size: 14px; }
 #helm { flex-direction: row; justify-content: center; align-items: flex-end; gap: 10px; }
 #anchorBtn { min-width: 120px; }
 #tip { top: 44%; }
 #dump { bottom: 150px; }
}
