/*
 * Landfall, vellum and cold water. One fixed palette, the same in light and dark OS modes.
 * This game is almost entirely words, so the type does the work: the ship's state sits in a
 * compact slab at the top, always readable, and the day's text and its choices fill the rest.
 */
:root {
  color-scheme: light;
  --bg: #e9e4d9;
  --bg-2: #ded7c8;
  --paper: #fbf8f1;
  --ink: #22262b;
  --ink-2: #3c4148;
  --muted: #6f6a60;
  --line: #ded5c2;
  --line-2: #cfc4ad;
  --sea: #2b4a5e;
  --sea-2: #3a6076;
  --sea-deep: #1c3244;
  --accent: #a85a28;
  --good: #3a6b4e;
  --warn: #9a6a1c;
  --bad: #9c382c;
  --gold: #d3a244;
  /* tutorial kit (tutorial.css) */
  --tut-accent: #d3a244;
  --tut-accent-ink: #22262b;
  --tut-bubble: #fbf8f1;
  --tut-ink: #22262b;
  --tut-muted: #6f6a60;
  --tut-dim: rgba(18, 32, 42, .58);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, #f2eee6 0%, var(--bg) 42%, var(--bg-2) 100%) fixed;
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- shell ---------- */
.app {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  max-width: 660px; margin: 0 auto;
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; padding: 12px 2px; }
.back:hover, .back:focus-visible { color: var(--ink); }
.bar-actions { display: flex; gap: 8px; }

.btn {
  min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 22px;
  border: 0; background: var(--paper); color: var(--ink);
  font-weight: 650; cursor: pointer; box-shadow: 0 1px 2px rgba(34, 38, 43, .12), 0 0 0 1px var(--line);
  transition: transform .12s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.icon { padding: 0; width: 44px; font-size: 22px; line-height: 1; letter-spacing: .04em; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.primary { background: var(--sea); color: #fbf8f1; box-shadow: none; }
.btn.wide { width: 100%; min-height: 50px; font-size: 17px; }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn:focus-visible, .seg button:focus-visible, .row:focus-visible, .link:focus-visible,
.choice:focus-visible, .fit-row:focus-visible, .step:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

.game { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }

/* ---------- the ship ---------- */
.panel {
  flex: none;
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(34, 38, 43, .1), 0 0 0 1px var(--line);
  padding: 12px 14px 10px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.leg-title { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.leg-day { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 5px; border-radius: 3px; background: var(--line); margin: 8px 0 11px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--sea-2); transition: width .45s ease-out; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 2px 6px; border-radius: 12px; background: #f3efe5;
  box-shadow: inset 0 0 0 1px var(--line);
}
.tile .ti { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile-v { font-size: 17px; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-k { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.tile.warn { background: #f8eedc; box-shadow: inset 0 0 0 1px #e6cf9e; }
.tile.warn .tile-v { color: var(--warn); }
.tile.warn .ti { stroke: var(--warn); }
.tile.bad { background: #f8e6e2; box-shadow: inset 0 0 0 1px #e7bdb4; }
.tile.bad .tile-v { color: var(--bad); }
.tile.bad .ti { stroke: var(--bad); }

/* the parallel you are trying to hold */
.lat-wrap { margin-top: 11px; }
.lat { display: block; width: 100%; height: 26px; }
.lat-track { fill: var(--line); }
.lat-target { fill: none; stroke: var(--sea-2); stroke-width: 1.2; stroke-dasharray: 2.5 2.5; opacity: .75; }
.lat-band { fill: var(--sea-2); opacity: .22; transition: x .4s, width .4s; }
.lat-mark { fill: var(--sea); transition: transform .4s; }
.lat-ends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); letter-spacing: .04em; margin-top: -2px; }
.lat-mid { color: var(--sea-2); }
.lat-note { margin: 5px 0 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
.lat-note b { color: var(--ink-2); font-weight: 650; }
.crew-line { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.crew-line .sick { color: var(--bad); }

/* ---------- the day ---------- */
/* The scene takes only the room its words need; the hold list gets the slack. */
.scene { flex: 0 0 auto; display: flex; flex-direction: column; justify-content: flex-start; padding: 2px 2px 0; }
.scene-title {
  margin: 0 0 4px; font-size: 20px; line-height: 1.25; font-weight: 750; letter-spacing: -.01em;
}
.scene-title.quiet { font-size: 15px; font-weight: 650; color: var(--muted); letter-spacing: .02em; text-transform: none; }
.scene-text { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.scene-text.wide { font-size: 16.5px; }
.scene-last { margin: 9px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); font-style: italic; }
.scene-last b { font-style: normal; color: var(--ink-2); font-weight: 650; }

.choices { flex: none; display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: block; width: 100%; text-align: left; cursor: pointer;
  min-height: 46px; padding: 9px 13px; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 1px 2px rgba(34, 38, 43, .1), 0 0 0 1px var(--line);
  font-size: 15.5px; font-weight: 600; line-height: 1.35;
  transition: transform .12s, box-shadow .15s;
}
.choice:active { transform: scale(.99); }
.choice .sub { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.choice.main { background: var(--sea); color: #f6f2e9; box-shadow: none; }
.choice.main .sub { color: #c6d6df; }
/* What the screen wants next but cannot do yet: plainly not something you can press. */
.choice.blocked, .choice:disabled {
  background: transparent; color: var(--muted); cursor: default; font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.choice.blocked .sub, .choice:disabled .sub { color: var(--muted); }
.choice:disabled:active { transform: none; }
@media (hover: hover) {
  .choice:not(:disabled):hover { box-shadow: 0 2px 6px rgba(34, 38, 43, .14), 0 0 0 1px var(--line-2); }
}

/* ---------- standing orders ---------- */
.orders { flex: none; display: flex; flex-direction: column; gap: 5px; padding-top: 2px; }
.ord-row { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 8px; }
.ord-k { font-size: 12.5px; color: var(--muted); letter-spacing: .02em; }
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 13px; background: #ded7c8; }
.seg button {
  flex: 1 1 0; min-height: 38px; border: 0; border-radius: 10px; background: transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted); transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(34, 38, 43, .16); }
.seg button.hot[aria-pressed="true"] { color: var(--bad); }

/* ---------- fitting out ---------- */
/* Stacks from the top and takes only the room it needs: a short list must not leave a band of
   empty page between itself and its footnote. */
.fitout { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
/* Stays put while you spend: you can always see what is left of the purse and the hold. */
.fit-bar {
  flex: none; position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 13px; border-radius: 14px; background: var(--paper);
  box-shadow: 0 0 0 1px var(--line), 0 2px 10px rgba(34, 38, 43, .12); font-size: 13px; color: var(--muted);
}
.fit-stat b { color: var(--ink); font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.fit-stat.tight b { color: var(--bad); }
.fit-list { flex: 0 0 auto; display: flex; flex-direction: column; gap: 7px; }
.fit-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--ink); cursor: pointer;
  box-shadow: 0 1px 2px rgba(34, 38, 43, .08), 0 0 0 1px var(--line);
}
.fit-row.on { box-shadow: 0 1px 2px rgba(34, 38, 43, .1), 0 0 0 2px var(--sea-2); background: #f4f6f6; }
.fit-row.dim { opacity: .5; }
.fit-row:disabled { cursor: default; }
.fit-name { font-size: 15px; font-weight: 650; line-height: 1.3; }
.fit-sub { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.fit-tag { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.fit-tag b { display: block; font-size: 14px; color: var(--ink); font-weight: 700; }
.fit-steps { display: flex; align-items: center; gap: 6px; }
.step {
  width: 40px; height: 40px; border: 0; border-radius: 12px; cursor: pointer;
  background: #ece7db; color: var(--ink); font-size: 20px; font-weight: 700; line-height: 1;
  box-shadow: inset 0 0 0 1px var(--line);
}
.step:disabled { opacity: .3; cursor: default; }
.fit-n { min-width: 2.4em; text-align: center; font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.fit-note { flex: none; margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(28, 50, 68, .42);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
  animation: fade .2s ease-out;
}
.overlay.soft { background: rgba(233, 228, 217, .82); align-items: center; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--paper); color: var(--ink);
  width: 100%; max-width: 480px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow: auto; overscroll-behavior: contain;
  border-radius: 22px; padding: 8px 18px 18px;
  box-shadow: 0 20px 50px rgba(28, 50, 68, .3);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 620px) { .overlay { align-items: center; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 50px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.row {
  display: block; width: 100%; text-align: left; min-height: 50px; padding: 0 4px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; font-weight: 600; cursor: pointer;
}
.group { padding: 10px 0 2px; }
.label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.note { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.menu-sheet #menu-log { margin-top: 12px; border-top: 1px solid var(--line); }
.menu-sheet .btn.wide { margin-top: 16px; }

.help-sheet { max-width: 560px; }
.help-body { padding-bottom: 6px; }
.help-body h3 { font-size: 15px; margin: 18px 0 4px; color: var(--sea); }
.help-body p, .help-body li { font-size: 14.5px; margin: 5px 0; line-height: 1.5; }
.help-body ul { padding-left: 19px; }
.help-foot { color: var(--muted); font-size: 13px; margin-top: 16px; }
.help-body code { background: #efe9dc; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

/* the ship's log */
.log-body { padding-bottom: 6px; }
.log-day { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.log-day:last-child { border-bottom: 0; }
.log-d { display: inline-block; min-width: 3.6em; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.log-day.big { font-weight: 650; }
.log-day.big .log-t { color: var(--sea); }
.log-day.bad .log-t { color: var(--bad); }

/* the end */
.over-sheet { max-width: 440px; }
.over-head { text-align: center; padding: 10px 0 4px; }
.over-title { font-size: 27px; font-weight: 800; letter-spacing: -.01em; }
.over-sub { color: var(--muted); font-size: 14.5px; margin-top: 3px; }
.over-tale { font-size: 15px; line-height: 1.55; color: var(--ink-2); margin: 12px 0 4px; text-align: center; }
.tally { margin: 10px 0 6px; }
.tally .tr {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: baseline;
  padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.tally .tr:last-child { border-bottom: 0; }
.tally .tr span i { font-style: normal; color: var(--muted); font-size: 12.5px; }
.tally .tr b { font-variant-numeric: tabular-nums; font-weight: 700; }
.tally .tr.minus b { color: var(--bad); }
.over-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 2px 2px; margin-bottom: 14px; border-top: 2px solid var(--line-2); font-size: 14px; color: var(--muted);
}
.over-total b { font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; }
.link { display: block; margin: 8px auto 0; min-height: 44px; padding: 0 16px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }

/* ---------- small phones ---------- */
@media (max-width: 380px) {
  .app { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .btn { padding: 0 13px; }
  .back { font-size: 13px; }
  .scene-title { font-size: 18.5px; }
  .tile-v { font-size: 16px; }
  .ord-row { grid-template-columns: 50px 1fr; }
}
@media (max-height: 680px) {
  .bar { min-height: 48px; }
  .game { gap: 9px; }
  .panel { padding: 10px 12px 8px; }
  .scene-text { font-size: 15.5px; }
}
/* roomier on a desktop, but never a wall of empty band */
@media (min-width: 620px) {
  .scene-title { font-size: 22px; }
  .scene-text { font-size: 17px; }
  .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .choices .choice.solo, .choices .choice.main { grid-column: 1 / -1; }
  .tiles { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
