@font-face { font-family: 'Fraunces'; src: url('./fonts/fraunces-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url('./fonts/fraunces-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url('./fonts/fraunces-600.woff2') format('woff2'); font-weight: 600 700; font-style: normal; font-display: swap; }

:root {
  --night: #0a1020; --deep: #121b33; --panel: #1a2646; --panel-2: #131c35;
  --brass: #d6a64f; --brass-hi: #ffe7a6; --brass-lo: #8d5d18; --brass-line: rgba(214, 166, 79, .38);
  --cream: #f8eedb; --parch: #f7ecd4; --parch-2: #e9d4a8; --ink: #2a2233; --ink-soft: #6b5d63;
  --lamp: #ffcf70; --green: #3d9a63; --rose: #d9536a; --soft: #a9b5d1;
  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.2, .9, .3, 1.15);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--cream); font: 15px/1.4 var(--sans); -webkit-font-smoothing: antialiased; }
body {
  background:
    radial-gradient(120% 55% at 50% -8%, #31457a 0%, rgba(49, 69, 122, 0) 62%),
    radial-gradient(90% 40% at 50% 108%, #2a1d3d 0%, rgba(42, 29, 61, 0) 70%),
    linear-gradient(#111b34, #0a1020 60%, #070b17);
  background-attachment: fixed;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .7;
  background-image:
    radial-gradient(1px 1px at 12% 8%, #fff 50%, transparent), radial-gradient(1px 1px at 32% 18%, #fffd 50%, transparent),
    radial-gradient(1.4px 1.4px at 58% 6%, #fff 50%, transparent), radial-gradient(1px 1px at 78% 14%, #fffb 50%, transparent),
    radial-gradient(1px 1px at 90% 4%, #fff 50%, transparent), radial-gradient(1px 1px at 46% 24%, #fff9 50%, transparent),
    radial-gradient(1.2px 1.2px at 6% 30%, #fffa 50%, transparent), radial-gradient(1px 1px at 68% 28%, #fff8 50%, transparent);
}
[hidden] { display: none !important; }
svg { display: block; width: 100%; height: 100%; }
button svg, .tile svg { pointer-events: none; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
i { display: block; font-style: normal; }

button {
  font: inherit; color: inherit; cursor: pointer; min-height: 40px; padding: 8px 12px; border-radius: 12px;
  background: linear-gradient(#24335a, #19243f); border: 1px solid var(--brass-line);
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 2px 6px rgba(0, 0, 0, .35);
  transition: transform .14s var(--ease), filter .14s; -webkit-tap-highlight-color: transparent;
}
button:active:not(:disabled) { transform: translateY(1px) scale(.97); }
button:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
button.primary {
  color: #3a2408; font-weight: 700; border-color: #94631b; text-shadow: 0 1px rgba(255, 255, 255, .45);
  background: linear-gradient(#ffe9a8, #eab653 52%, #c78e2e);
  box-shadow: inset 0 1px rgba(255, 255, 255, .8), inset 0 -2px rgba(110, 68, 14, .25), 0 3px 10px rgba(0, 0, 0, .35);
}
button.primary:disabled { filter: grayscale(.7); opacity: .45; }

/* ---------------------------------------------------------------- welcome */
.welcome { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; justify-content: flex-end; background: linear-gradient(#0c1531, #0c1531 30%, rgba(12, 21, 49, 0) 60%); }
.welcome-art { flex: none; width: 100%; max-width: 640px; margin: 0 auto; aspect-ratio: 360 / 270; position: relative; }
.welcome-art svg { position: absolute; inset: 0; }
.welcome-art::after { content: ''; position: absolute; inset: auto 0 0; height: 40%; background: linear-gradient(rgba(10, 16, 32, 0), #0a1020); }
.welcome-copy { position: relative; margin-top: -60px; padding: 0 28px max(36px, env(safe-area-inset-bottom)); text-align: center; }
.eyebrow { margin: 0 0 6px; font: 600 12px/1 var(--sans); letter-spacing: .28em; text-transform: uppercase; color: var(--brass); }
.welcome h1 { margin: 0; font: 600 40px/1.02 var(--serif); letter-spacing: -.01em; color: #fff6e2; text-shadow: 0 2px 18px rgba(255, 207, 112, .25); }
.welcome h1 span { display: block; font-style: italic; font-weight: 400; font-size: 30px; color: var(--brass-hi); }
.lede { margin: 14px auto 22px; max-width: 300px; color: var(--soft); font: italic 17px/1.4 var(--serif); }
button.big { min-width: 220px; min-height: 54px; font-size: 18px; border-radius: 16px; letter-spacing: .02em; }
.error { color: #ff9d8a; min-height: 1.4em; }
.bob { animation: bob 6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 80%; }
.wave { animation: drift 9s linear infinite; }
.wave.slow { animation-duration: 15s; }
.shimmer { animation: shimmer 3.5s ease-in-out infinite; }
.twinkle:nth-child(3n) { animation: twinkle 4s ease-in-out infinite; }
.twinkle:nth-child(5n) { animation: twinkle 6s ease-in-out infinite 1s; }
@keyframes bob { 50% { transform: translateY(2.5px) rotate(-.5deg); } }
@keyframes drift { to { transform: translateX(-60px); } }
@keyframes shimmer { 50% { opacity: .55; } }
@keyframes twinkle { 50% { opacity: .15; } }

/* ---------------------------------------------------------------- game frame */
main { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom)); }

.hud { display: flex; gap: 6px; }
.hud-chip {
  flex: 1; min-width: 0; height: 42px; display: flex; align-items: center; gap: 7px; padding: 0 10px 0 6px; border-radius: 21px; position: relative;
  background: linear-gradient(#1d2a4b, #121a31); border: 1px solid var(--brass-line);
  box-shadow: inset 0 1px rgba(255, 255, 255, .07), 0 3px 8px rgba(0, 0, 0, .4); min-height: 0;
}
.hud-chip i { width: 28px; height: 28px; flex: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.hud-chip b { font: 600 18px/1 var(--serif); font-variant-numeric: tabular-nums; color: #fff6e2; }
.hud-chip small { display: block; font-size: 10px; color: var(--soft); line-height: 1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.hud-chip.level { flex: .8; }
.hud-chip .xp { position: absolute; left: 14px; right: 14px; bottom: 4px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.hud-chip .xp span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brass), var(--brass-hi)); transition: width .5s var(--ease); }
.hud-chip.icon-only { flex: 0 0 42px; padding: 0; justify-content: center; color: var(--brass-hi); }
.hud-chip.icon-only i { width: 24px; height: 24px; }
.hud-chip.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(255, 207, 112, .9); } 100% { box-shadow: 0 0 0 14px rgba(255, 207, 112, 0); } }

.chapter {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'label title' 'bar bar'; align-items: baseline; column-gap: 10px; row-gap: 5px;
  text-align: left; padding: 7px 14px 8px; min-height: 0; border-radius: 14px;
  background: linear-gradient(100deg, rgba(214, 166, 79, .16), rgba(214, 166, 79, .04) 60%), linear-gradient(#18233f, #121a31);
}
.chapter-label { grid-area: label; font: 600 10px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--brass); }
.chapter-title { grid-area: title; font: italic 400 15px/1.1 var(--serif); color: #fff3da; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { grid-area: bar; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; border-radius: 2px; background: linear-gradient(90deg, #b9832a, var(--brass-hi)); transition: width .6s var(--ease); }

/* ---------------------------------------------------------------- order tickets */
.orders { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.ticket {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 27px 6px 6px; border-radius: 14px; color: var(--ink);
  background:
    radial-gradient(circle at 0 62%, transparent 5px, rgba(0, 0, 0, 0) 5.5px),
    linear-gradient(#fdf6e6, #efdfbd);
  box-shadow: inset 0 0 0 1px rgba(141, 93, 24, .28), inset 0 -18px 24px -18px rgba(141, 93, 24, .25), 0 6px 14px rgba(0, 0, 0, .4);
}
.ticket::before { content: ''; position: absolute; left: 8px; right: 8px; top: 62%; border-top: 1.5px dashed rgba(141, 93, 24, .3); }
.ticket.fresh { animation: deal .5s var(--ease) both; }
.ticket.ready { box-shadow: inset 0 0 0 1.5px #c99630, 0 0 0 2px rgba(255, 207, 112, .35), 0 6px 18px rgba(255, 190, 80, .25); }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) rotate(-3deg) scale(.9); } }
.medal { position: absolute; top: -14px; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px #e6b85c, 0 0 0 3.5px #6e440e, 0 3px 8px rgba(0, 0, 0, .45); }
.ticket .who { font: 600 11px/1 var(--serif); letter-spacing: .04em; color: #5b4a3e; margin-top: 2px; }
.wants { display: flex; gap: 4px; margin: 2px 0; }
.want { position: relative; width: 38px; height: 38px; min-height: 0; padding: 0; border: none; border-radius: 10px; background: none; box-shadow: none; }
.want .tile { inset: 0; }
.want i { position: absolute; right: -4px; top: -4px; width: 15px; height: 15px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.reward { display: flex; align-items: center; gap: 3px; font: 600 12px/1 var(--serif); color: #5b4a3e; }
.reward i { width: 14px; height: 14px; }
.reward .gift { width: 16px; height: 16px; margin-left: 2px; }
.ticket .deliver { width: 100%; min-height: 30px; padding: 3px; font-size: 13px; border-radius: 9px; margin-top: 2px; }
.ticket .deliver:disabled { color: #8a7a68; text-shadow: none; filter: none; opacity: 1; background: linear-gradient(#efe3c8, #e1cfa8); border-color: rgba(141, 93, 24, .25); box-shadow: none; }

/* ---------------------------------------------------------------- events */
.events { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.events::-webkit-scrollbar { display: none; }
.events:empty { display: none; }
.event {
  flex: 1 0 31%; min-width: 0; display: flex; align-items: center; gap: 2px; padding: 0; text-align: left; font-size: 11px; overflow: hidden; line-height: 1.2; min-height: 44px; border-radius: 14px; scroll-snap-align: start;
  border: 1px solid rgba(255, 207, 112, .55); background: linear-gradient(120deg, #33285a, #1b2445 70%);
  box-shadow: 0 0 16px rgba(255, 190, 80, .18), inset 0 1px rgba(255, 255, 255, .1); animation: glow 3s ease-in-out infinite;
}
.event i { width: 28px; height: 28px; flex: none; }
.event b { display: block; font: 600 12.5px/1.1 var(--serif); color: var(--brass-hi); white-space: nowrap; }
.event span { min-width: 0; color: #d7dcf0; }
@keyframes glow { 50% { box-shadow: 0 0 24px rgba(255, 190, 80, .3), inset 0 1px rgba(255, 255, 255, .1); } }

/* ---------------------------------------------------------------- the pigeonholes */
.board-wrap { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.board {
  width: min(100cqw, calc(100cqh * 7 / 8)); display: grid; grid-template-columns: repeat(7, 1fr); gap: 3.5px; padding: 8px; border-radius: 16px;
  touch-action: none; user-select: none; -webkit-user-select: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .25), rgba(0, 0, 0, 0) 12%, rgba(0, 0, 0, 0) 88%, rgba(0, 0, 0, .25)),
    repeating-linear-gradient(91deg, rgba(255, 220, 170, .05) 0 2px, rgba(0, 0, 0, 0) 2px 9px, rgba(0, 0, 0, .07) 9px 11px, rgba(0, 0, 0, 0) 11px 23px),
    linear-gradient(#7a4c2b, #5b361d);
  box-shadow: inset 0 0 0 1.5px #e3b55a, inset 0 0 0 3.5px #4a2c16, inset 0 0 0 4.5px rgba(227, 181, 90, .5), 0 12px 28px rgba(0, 0, 0, .55);
}
.cell {
  position: relative; aspect-ratio: 1; min-height: 0; padding: 0; border: none; border-radius: 8px;
  background: linear-gradient(#24160d, #3a2416); box-shadow: inset 0 4px 7px rgba(0, 0, 0, .65), inset 0 -1px rgba(255, 220, 160, .12), 0 1px rgba(255, 220, 160, .1);
}
.cell:active:not(:disabled) { transform: none; }
.tile {
  position: absolute; inset: 1.5px; border-radius: 8px; padding: 1.5px; display: block;
  background: radial-gradient(circle at 32% 22%, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0) 58%), linear-gradient(var(--tint, #e8dcc4), color-mix(in srgb, var(--tint, #e8dcc4) 78%, #6b4a2a));
  box-shadow: inset 0 1px rgba(255, 255, 255, .8), inset 0 -2px rgba(0, 0, 0, .14), 0 2px 0 rgba(0, 0, 0, .35), 0 3px 6px rgba(0, 0, 0, .3);
}
img.art { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.tile.fine { background: radial-gradient(circle at 50% 40%, rgba(255, 246, 210, .95), rgba(255, 246, 210, 0) 62%), linear-gradient(var(--tint, #e8dcc4), color-mix(in srgb, var(--tint, #e8dcc4) 70%, #b07a2a));
  box-shadow: inset 0 0 0 1.5px rgba(232, 180, 80, .85), inset 0 1px rgba(255, 255, 255, .8), 0 2px 0 rgba(0, 0, 0, .35), 0 0 8px rgba(255, 200, 100, .35); }
.tile.top { overflow: hidden; background: radial-gradient(circle at 50% 42%, #fffbe6, rgba(255, 240, 190, .6) 40%, rgba(255, 240, 190, 0) 70%), linear-gradient(#ffe7a6, #e7b24c);
  box-shadow: inset 0 0 0 2px #fff1bd, inset 0 0 0 3px #c88a2a, inset 0 1px rgba(255, 255, 255, .9), 0 2px 0 rgba(0, 0, 0, .35), 0 0 14px rgba(255, 196, 80, .7); }
.tile.top::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, .7) 50%, rgba(255, 255, 255, 0) 62%); background-size: 300% 100%; animation: sweep 3.6s ease-in-out infinite; }
@keyframes sweep { 0%, 55% { background-position: 120% 0; } 100% { background-position: -20% 0; } }
.twinkle-set { animation: twinkle 2.2s ease-in-out infinite; }

/* sources: a porthole in a riveted plate; the metal says the level */
.tile.gen {
  --hi: #f3c79a; --rim: #b0703e; --lo: #5a3418; --glow: rgba(255, 170, 100, .22);
  padding: 12%;
  background:
    radial-gradient(circle at 50% 46%, #7c9bd6 0, #33497d 42%, #1b2648 59%, rgba(0, 0, 0, 0) 60%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 60%, var(--lo) 61%, var(--rim) 64%, var(--hi) 69%, var(--rim) 76%, rgba(0, 0, 0, 0) 77%),
    radial-gradient(circle at 12% 12%, var(--hi) 0 3%, var(--lo) 5.5%, rgba(0, 0, 0, 0) 6.5%),
    radial-gradient(circle at 88% 12%, var(--hi) 0 3%, var(--lo) 5.5%, rgba(0, 0, 0, 0) 6.5%),
    radial-gradient(circle at 12% 88%, var(--hi) 0 3%, var(--lo) 5.5%, rgba(0, 0, 0, 0) 6.5%),
    radial-gradient(circle at 88% 88%, var(--hi) 0 3%, var(--lo) 5.5%, rgba(0, 0, 0, 0) 6.5%),
    linear-gradient(150deg, var(--hi), var(--rim) 45%, var(--lo));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hi) 70%, #fff), inset 0 -2px rgba(0, 0, 0, .3), 0 2px 0 rgba(0, 0, 0, .45), 0 0 10px var(--glow);
}
.tile.gen.lv2 { --hi: #ffe7a6; --rim: #c99630; --lo: #6e440e; --glow: rgba(255, 200, 90, .3); }
.tile.gen.lv3 { --hi: #fbfdff; --rim: #a9b8cc; --lo: #46546a; --glow: rgba(200, 225, 255, .45); }
.tile.gen.lv4 { --hi: #fff4c2; --rim: #eab43c; --lo: #8a5a10; --glow: rgba(255, 196, 70, .65); }
.tile.gen.lv5 { --hi: #fffbe6; --rim: #f2c14e; --lo: #9a3d16; --glow: rgba(255, 150, 60, .85); overflow: hidden; }
.tile.gen.lv5::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, .65) 50%, rgba(255, 255, 255, 0) 62%); background-size: 300% 100%; animation: sweep 3.2s ease-in-out infinite; }
.tile.gen .bolt { position: absolute; z-index: 1; left: -2px; top: -2px; width: 36%; height: 36%; padding: 5%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #5a73b0, #26355f 60%, #141c36); box-shadow: 0 0 0 1px #e3b55a, 0 1px 2px rgba(0, 0, 0, .5); }
.tile.gen .bolt svg { display: block; width: 100%; height: 100%; }
[data-boost="2"] .tile.gen .bolt, .boost.x2 i { background: radial-gradient(circle at 35% 30%, #f1dcff, #a66bff 55%, #5b2aa8); }
[data-boost="4"] .tile.gen .bolt, .boost.x4 i { background: radial-gradient(circle at 35% 30%, #ffe0f0, #ff5fae 55%, #a8236a); }
[data-boost="6"] .tile.gen .bolt, .boost.x6 i { background: radial-gradient(circle at 35% 30%, #ffe2d6, #ff6a3d 55%, #a8301a); }
[data-boost="8"] .tile.gen .bolt, .boost.x8 i { background: radial-gradient(circle at 35% 30%, #e6fffb, #2fd6c0 55%, #127a6e); }
[data-boost]:not([data-boost="1"]) .tile.gen:not(.resting) .bolt { animation: zap 1.4s ease-in-out infinite; }
@keyframes zap { 50% { transform: scale(1.12); box-shadow: 0 0 0 1px #3a1a40, 0 0 8px rgba(255, 255, 255, .8); } }
.tile.gen .pips { position: absolute; z-index: 1; left: 50%; bottom: 0; transform: translate(-50%, 35%); display: flex; gap: 1.5px; padding: 1.5px 2.5px; border-radius: 6px; pointer-events: none;
  background: linear-gradient(#2a1a10, #120a06); box-shadow: 0 0 0 1px var(--rim), 0 1px 2px rgba(0, 0, 0, .5); }
.tile.gen .pips i { width: 4px; height: 4px; border-radius: 50%; background: #4a3626; }
.tile.gen .pips i.on { background: radial-gradient(circle at 35% 30%, #fffbe0, #ffc93c 60%, #c98a12); box-shadow: 0 0 3px rgba(255, 210, 90, .9); }
.cell .lvl.charges { bottom: auto; top: 1px; }
.tile.big { position: relative; inset: auto; display: block; width: 84px; height: 84px; flex: none; }
.tile.big .pips i { width: 7px; height: 7px; }

/* the boost switch, beside the energy it spends */
.hud-chip.boost { flex: none; gap: 4px; padding: 0 9px 0 5px; }
.hud-chip.boost[hidden] { display: none; }
.hud-chip.boost b { font: 700 15px/1 var(--sans); }
.boost i { width: 26px; height: 26px; padding: 4px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5a73b0, #26355f 60%, #141c36); box-shadow: 0 0 0 1px #e3b55a; }
.boost i svg { display: block; width: 100%; height: 100%; }
.hud-chip.boost:not(.x1) { border-color: #fff3c4; box-shadow: 0 0 12px rgba(255, 120, 200, .55), 0 3px 8px rgba(0, 0, 0, .5); }
button.primary.boosted { background: linear-gradient(#b06cff, #6a2fc2); }
button.primary.boosted.x4 { background: linear-gradient(#ff6fb8, #b02a72); }
button.primary.boosted.x6 { background: linear-gradient(#ff7a4a, #b0361c); }
button.primary.boosted.x8 { background: linear-gradient(#36dcc6, #128072); }

/* a source's own sheet */
.source-head { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .5); box-shadow: inset 0 0 0 1px rgba(141, 93, 24, .22); }
.source-head > div { display: flex; flex-direction: column; gap: 4px; font-family: var(--serif); }
.source-head b { font: 600 17px/1.2 var(--serif); color: #3a2408; }
.source-head small { font: 13.5px/1.35 var(--serif); color: #4a3a42; }
.source-head .boost-note { color: #7a2a8a; font-weight: 600; }
.mini-head { margin: 16px 0 0; font: 600 11px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: #8d5d18; }
.chain.odds { margin-top: 10px; }
.step .pct { position: absolute; top: -6px; left: 0; padding: 2px 7px; border-radius: 10px; font: 700 11px/1.3 var(--sans); color: #3a2408; background: linear-gradient(#fff3cc, #e2b250); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.gen-path { list-style: none; margin: 10px 0 4px; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.gen-path li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.gen-path .pic { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 12px; font: 600 20px/1 var(--serif); color: #8a6a4a; background: linear-gradient(#3a2416, #24160d); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .55); }
.gen-path .pic .tile { inset: 2px; }
.gen-path li:not(.reached) .pic .tile { filter: saturate(.35) brightness(.75); }
.gen-path li.here .pic { box-shadow: 0 0 0 2.5px #e3b55a, 0 0 14px rgba(255, 196, 80, .6); }
.gen-path small { font: 600 11px/1.2 var(--serif); color: #4a3a42; }
.gen-path .have { position: absolute; top: -6px; right: -2px; padding: 1px 6px; border-radius: 10px; font: 700 10.5px/1.3 var(--sans); color: #fff; background: linear-gradient(#4aa86a, #2e7a4a); }
.tile.resting { filter: saturate(.25) brightness(.7); }
.cell .lvl {
  position: absolute; z-index: 3; right: 1px; bottom: 1px; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 7px; pointer-events: none;
  font: 700 9.5px/14px var(--sans); text-align: center; color: #3a2408; background: linear-gradient(#fff3cc, #e2b250); box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.cell .lvl.charges { color: #fff; background: linear-gradient(#3b4f86, #1d2a4d); box-shadow: 0 0 0 1px #e3b55a, 0 1px 2px rgba(0, 0, 0, .4); }
.cell .rest-clock { position: absolute; z-index: 3; inset: 22%; pointer-events: none; animation: tick 2s ease-in-out infinite; }
@keyframes tick { 50% { transform: scale(.92); } }
.cell.sel .tile { box-shadow: 0 0 0 2px #fff3c4, 0 0 0 4px var(--lamp), 0 0 18px rgba(255, 207, 112, .8); z-index: 2; animation: lift .5s var(--ease) both; }
@keyframes lift { to { transform: translateY(-2px) scale(1.06); } }
.cell.match .tile { animation: hint 1.1s ease-in-out infinite; }
@keyframes hint { 50% { box-shadow: 0 0 0 2px #8ff0b2, 0 0 14px rgba(120, 240, 170, .75); } }
.tile.pop { animation: pop .42s var(--ease); }
.tile.drop { animation: drop .36s var(--ease) both; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes drop { from { transform: translateY(-10px) scale(.4); opacity: 0; } }
.burst { position: absolute; inset: 50%; pointer-events: none; z-index: 3; }
.burst span { position: absolute; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: radial-gradient(#fff, var(--lamp)); animation: spark .6s ease-out forwards; transform: rotate(var(--a)) translateY(0); }
.burst span:nth-child(odd) { width: 4px; height: 4px; margin: -2px; background: #fff; }
@keyframes spark { to { transform: rotate(var(--a)) translateY(-30px) scale(.2); opacity: 0; } }
.ring { position: absolute; inset: 0; border-radius: 10px; pointer-events: none; z-index: 3; box-shadow: 0 0 0 2px var(--lamp); animation: ring .5s ease-out forwards; }
@keyframes ring { to { transform: scale(1.7); opacity: 0; } }
.ghost { position: fixed; width: 58px; height: 58px; pointer-events: none; z-index: 20; transform: translate(-50%, -72%) scale(1.08); }
.ghost .tile { inset: 0; box-shadow: 0 0 0 2px var(--lamp), 0 14px 22px rgba(0, 0, 0, .55); }
.float { position: fixed; z-index: 40; pointer-events: none; font: 700 16px/1 var(--serif); color: var(--brass-hi); text-shadow: 0 2px 6px rgba(0, 0, 0, .7); animation: up 1.1s ease-out forwards; }
@keyframes up { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -34px); opacity: 0; } }

/* ---------------------------------------------------------------- the plaque and the nav */
.info {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 50px; padding: 5px 6px 5px 12px; border-radius: 14px;
  background: linear-gradient(#1c2848, #121a31); border: 1px solid var(--brass-line); box-shadow: inset 0 1px rgba(255, 255, 255, .06);
}
.info p { margin: 0; font: 13.5px/1.25 var(--serif); color: #f3e6cc; min-width: 0; display: flex; align-items: center; gap: 8px; }
.info-pic { flex: none; width: 40px; height: 40px; min-height: 0; padding: 2px; border-radius: 10px; background: radial-gradient(circle at 35% 30%, #fff8e6, #e6d2a8); border-color: #c99630; }
.info-words { min-width: 0; display: flex; flex-direction: column; }
.info-words b { font: 600 14px/1.15 var(--serif); color: #fff3da; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-words small { font: 12px/1.2 var(--sans); color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-i { flex: none; width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%; font: italic 700 15px/1 var(--serif); color: #3a2408; background: linear-gradient(#ffe9a8, #e2b250); border-color: #94631b; }
.info-hint { font: 13.5px/1.25 var(--serif); }
#info-actions { display: flex; gap: 5px; flex: none; }
#info-actions button { min-height: 36px; padding: 4px 10px; font-size: 13px; }
#info-actions button.icon-btn { width: 40px; padding: 4px; display: grid; place-items: center; }
#info-actions button.icon-btn i { width: 24px; height: 24px; }
#info-actions button.icon-btn i svg { display: block; width: 100%; height: 100%; }
.nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 4px; border-radius: 18px; background: linear-gradient(#18233f, #0f1629); border: 1px solid var(--brass-line); box-shadow: 0 -4px 18px rgba(0, 0, 0, .35); }
.nav button { --icon-cut: #141e37; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px 4px; min-height: 0; font-size: 11px; letter-spacing: .02em; color: #c9d1e6; background: none; border: none; box-shadow: none; border-radius: 14px; }
.nav button i { width: 24px; height: 24px; color: #e3cf9f; }
.nav button.due i { color: var(--lamp); filter: drop-shadow(0 0 6px rgba(255, 207, 112, .7)); }
.nav button.due::after { content: ''; position: absolute; top: 4px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 2px #121a31; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); width: max-content; max-width: 88vw; margin: 0; z-index: 30;
  padding: 10px 16px; border-radius: 14px; color: var(--ink); font: 15px/1.3 var(--serif); text-align: center;
  background: linear-gradient(#fdf6e6, #eddcb7); box-shadow: 0 0 0 1px #c99630, 0 10px 28px rgba(0, 0, 0, .55); animation: toast .35s var(--ease);
}
.toast:empty { display: none; }
@keyframes toast { from { transform: translate(-50%, 12px); opacity: 0; } }

/* ---------------------------------------------------------------- sheets */
dialog {
  width: min(430px, 94vw); max-height: 88dvh; padding: 20px 16px 16px; border: none; border-radius: 22px; color: var(--ink);
  background: radial-gradient(120% 60% at 50% 0, #fffaf0, rgba(255, 250, 240, 0) 70%), linear-gradient(#fbf2df, #ead7ae);
  box-shadow: 0 0 0 1px #d9a84a, 0 0 0 5px #2b2033, 0 0 0 6px #b98a3c, 0 30px 70px rgba(0, 0, 0, .7);
}
dialog[open] { animation: rise .34s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.96); } }
dialog::backdrop { background: radial-gradient(circle at 50% 40%, rgba(10, 16, 32, .6), rgba(4, 7, 14, .9)); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 4px; font: 600 23px/1.15 var(--serif); text-align: center; color: #2b2033; }
dialog h2 + .sub { margin: 0 0 12px; text-align: center; font: italic 14px/1.3 var(--serif); color: var(--ink-soft); }
dialog p { margin: 8px 0; }
dialog button { color: var(--ink); background: linear-gradient(#fffbf2, #f1e3c4); border-color: rgba(141, 93, 24, .35); box-shadow: inset 0 1px #fff, 0 2px 4px rgba(90, 60, 20, .18); }
dialog button.primary { color: #3a2408; background: linear-gradient(#ffe9a8, #eab653 52%, #c78e2e); border-color: #94631b; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.muted { color: var(--ink-soft); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.slot { position: relative; aspect-ratio: 1; min-height: 0; padding: 0; border-radius: 11px; background: linear-gradient(#3a2416, #24160d) !important; box-shadow: inset 0 3px 6px rgba(0, 0, 0, .55) !important; border: none !important; color: #e9d4a8 !important; font: 600 18px var(--serif); }
.slot .tile { inset: 2px; }
.slot:disabled { opacity: 1; }
.chain-row .mini.slot { display: grid; place-items: center; border-radius: 11px; }

.option { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; text-align: left; padding: 8px 12px 8px 8px; min-height: 60px; border-radius: 14px; }
.option i { width: 44px; height: 44px; border-radius: 12px; padding: 6px; background: linear-gradient(#2a3a63, #18233f); box-shadow: inset 0 0 0 1px rgba(227, 181, 90, .6); }
.option b { display: block; font: 600 15px/1.2 var(--serif); }
.option small { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.option .val { font: 700 15px/1 var(--serif); color: #8d5d18; white-space: nowrap; }
.option:disabled { opacity: .55; }

.chain-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; text-align: left; padding: 6px 12px 6px 6px; min-height: 56px; }
.chain-row .mini { position: relative; width: 44px; height: 44px; }
.chain-row .mini .tile { inset: 0; }
.chain-row b { font: 600 15px/1.2 var(--serif); }
.bar { display: block; height: 5px; border-radius: 3px; background: rgba(141, 93, 24, .18); margin-top: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #c78e2e, #f0c35e); }
.chain-row .count { font: 600 13px var(--serif); color: #8d5d18; }

label.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 46px; padding: 0 4px; border-bottom: 1px solid rgba(141, 93, 24, .18); font: 15px var(--serif); }
label.switch input { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: #cdbb98; position: relative; cursor: pointer; transition: background .2s; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .2); flex: none; }
label.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(#fff, #f1e6d0); box-shadow: 0 2px 4px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
label.switch input:checked { background: linear-gradient(#e9b552, #c78e2e); }
label.switch input:checked::after { transform: translateX(18px); }

.envelope { position: relative; margin: 6px auto; max-width: 300px; padding: 30px 20px 26px; text-align: center; border-radius: 6px; color: #2b2033; font: 600 26px/1.1 var(--serif);
  background: linear-gradient(160deg, #fffaf0, #f2e2bf); box-shadow: 0 10px 24px rgba(60, 40, 10, .3), inset 0 0 0 1px rgba(141, 93, 24, .25); animation: deal .4s var(--ease); }
.envelope::before { content: 'Deliver to'; display: block; margin-bottom: 6px; font: 600 10px/1 var(--sans); letter-spacing: .24em; text-transform: uppercase; color: #8d5d18; }
.envelope::after { content: ''; position: absolute; top: 10px; right: 12px; width: 26px; height: 30px; border: 2px dashed #c0473d; border-radius: 3px; opacity: .6; }
.pigeon { font: 600 16px var(--serif); min-height: 50px; }

.cast { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.cast > div { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 14px; background: rgba(255, 255, 255, .45); box-shadow: inset 0 0 0 1px rgba(141, 93, 24, .2); }
.cast .face { width: 46px; height: 46px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px #e6b85c; }
.cast b { display: block; font: 600 13px/1.15 var(--serif); }
.hearts { display: flex; gap: 1px; margin-top: 3px; }
.hearts i { width: 14px; height: 14px; }
.chapter-list p { font: 14.5px/1.45 var(--serif); }
.chapter-list b { color: #8d5d18; }

/* story scenes */
dialog.scene { padding: 0; overflow: hidden auto; }
dialog.ship .scene-art { aspect-ratio: 320 / 200; }
.scene-art { position: relative; aspect-ratio: 320 / 190; background: #2a1a10; }
.scene-art::after { content: ''; position: absolute; inset: auto 0 0; height: 22px; background: linear-gradient(rgba(251, 242, 223, 0), #fbf2df); }
.plate {
  position: relative; z-index: 1; width: max-content; max-width: 88%; margin: -22px auto 0; padding: 6px 18px 7px; border-radius: 10px;
  font: 600 14px/1.1 var(--serif); color: #3a2408; text-align: center; background: linear-gradient(#ffeab0, #dba84e); box-shadow: inset 0 1px #fff7d6, 0 0 0 1px #8d5d18, 0 4px 10px rgba(0, 0, 0, .35);
}
.plate small { display: block; font: 600 9.5px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: #7a4f12; margin-bottom: 3px; }
.scene-body { padding: 10px 20px 18px; }
.scene-text { margin: 6px 0 4px; font: 17px/1.5 var(--serif); color: #2b2033; text-wrap: pretty; }
.scene-text.quote { font-style: italic; }
.choice { display: grid; grid-template-columns: 50px 1fr; align-items: center; gap: 12px; text-align: left; padding: 8px 14px 8px 8px; min-height: 66px; font: 15px/1.3 var(--serif); }
.choice .face { width: 50px; height: 50px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px #e6b85c, 0 0 0 3.5px #6e440e; }
.gain { display: flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px var(--serif); color: #8d5d18; }
.gain i { width: 20px; height: 20px; }

/* a whole chain */
.chain-source { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, .5); box-shadow: inset 0 0 0 1px rgba(141, 93, 24, .22); font: 14px/1.35 var(--serif); }
.src-art { flex: none; width: 46px; height: 46px; padding: 3px; border-radius: 12px; background: radial-gradient(circle at 50% 30%, #6c8bc7, #2f4374 70%); box-shadow: inset 0 0 0 1.5px #e3b55a; }
.chain { list-style: none; margin: 14px 0 4px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 20px; }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.step:not(:last-child)::after { content: '›'; position: absolute; right: -15px; top: 22px; font: 400 24px/1 var(--serif); color: #b98a3c; }
.step:nth-child(3n)::after { content: none; }
.step .pic { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; max-width: 84px; border-radius: 14px; background: linear-gradient(#3a2416, #24160d); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .55); }
.step .pic .tile { inset: 3px; }
.step small { font: 600 12px/1.2 var(--serif); color: #4a3a42; min-height: 2.4em; }
.step.here .pic { box-shadow: 0 0 0 2.5px #e3b55a, 0 0 14px rgba(255, 196, 80, .6); }
.step.crown small::before { content: '♛ '; color: #c99630; }
.step.hidden .pic { font: 600 26px/1 var(--serif); color: #8a6a4a; }
.step.hidden.next .pic { color: #e9d4a8; box-shadow: inset 0 3px 6px rgba(0, 0, 0, .55), 0 0 0 2px rgba(201, 150, 48, .7); }
.step.hidden small { color: #8a7a68; font-weight: 400; font-style: italic; }
.step .have { position: absolute; top: -6px; right: 0; padding: 2px 7px; border-radius: 10px; font: 700 11px/1.3 var(--sans); color: #fff; background: linear-gradient(#4aa86a, #2e7a4a); box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }

/* locked squares */
.tile.locked { padding: 0; background: none; box-shadow: 0 2px 0 rgba(0, 0, 0, .35), 0 3px 6px rgba(0, 0, 0, .3); overflow: hidden; }
.cell .need { position: absolute; z-index: 2; left: 16%; top: 12%; width: 62%; height: 62%; padding: 3px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fffaf0, color-mix(in srgb, var(--tint) 70%, #fff)); box-shadow: 0 0 0 1.5px #c99630, 0 2px 4px rgba(0, 0, 0, .45); opacity: .95; }
.cell .need img { opacity: .92; }
.cell.match .need { box-shadow: 0 0 0 2px #8ff0b2, 0 0 12px rgba(120, 240, 170, .9); animation: hint 1.1s ease-in-out infinite; }

/* blend modes used inside the ship rooms */
.screen { mix-blend-mode: screen; }
.multiply { mix-blend-mode: multiply; }
.soft { mix-blend-mode: soft-light; }
.motes .mote { animation: drift-up 9s ease-in-out infinite; }
.motes .m1 { animation-duration: 12s; animation-delay: -3s; }
.motes .m2 { animation-duration: 15s; animation-delay: -6s; }
.motes .m3 { animation-duration: 11s; animation-delay: -8s; }
@keyframes drift-up { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: .9; } 100% { transform: translate(14px, -40px); opacity: 0; } }
.swing { transform-box: view-box; transform-origin: 242px 87px; animation: swing 2s ease-in-out infinite; }
@keyframes swing { 0%, 100% { transform: rotate(5deg); } 50% { transform: rotate(-5deg); } }
.reveal { transform-box: fill-box; transform-origin: 50% 100%; animation: reveal 1s var(--ease) both; }
@keyframes reveal { 0% { opacity: 0; transform: translateY(10px) scale(.86); filter: brightness(2.4) saturate(.2); } 60% { opacity: 1; filter: brightness(1.5); } 100% { transform: none; filter: none; } }

/* unclaimed parcels */
.tile.sealed img { opacity: .9; }
.cell .wrap { position: absolute; z-index: 3; inset: 7%; pointer-events: none; opacity: .58; animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-6deg); } 90% { transform: rotate(5deg); } 95% { transform: rotate(-3deg); } }
.cell .lvl.timer { color: #fff; background: linear-gradient(#e2574c, #a8241e); box-shadow: 0 0 0 1px #fff3dc, 0 1px 2px rgba(0, 0, 0, .4); font-variant-numeric: tabular-nums; }

/* someone speaks */
.toast.speech { display: flex; align-items: center; gap: 10px; text-align: left; max-width: min(360px, 92vw); padding: 8px 14px 8px 8px; }
.toast.speech .face { width: 46px; height: 46px; flex: none; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px #e6b85c, 0 0 0 3.5px #6e440e; }
.toast.speech b { display: block; font: 600 11px/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #8d5d18; margin-bottom: 2px; }
.toast.speech span:last-child { font-style: italic; }

/* tips for new sorters */
.coach {
  position: fixed; z-index: 35; padding: 10px 12px; border-radius: 14px; pointer-events: none; color: var(--ink); font: 15px/1.35 var(--serif);
  background: linear-gradient(#fffaf0, #f1e1bd); box-shadow: 0 0 0 1.5px #d9a84a, 0 12px 30px rgba(0, 0, 0, .55); animation: toast .35s var(--ease);
}
.coach::after { content: ''; position: absolute; left: var(--arrow, 50%); bottom: -7px; width: 14px; height: 14px; margin-left: -7px; transform: rotate(45deg); background: #f1e1bd; box-shadow: 1.5px 1.5px 0 #d9a84a; }
.coach.below::after { bottom: auto; top: -7px; background: #fffaf0; box-shadow: -1.5px -1.5px 0 #d9a84a; }
.coach p { margin: 0 0 6px; }
.coach button { pointer-events: auto; min-height: 30px; padding: 2px 10px; font: 600 12px var(--sans); color: #6b5d63; background: rgba(255, 255, 255, .6); border-color: rgba(141, 93, 24, .3); box-shadow: none; }
.coach-target { position: relative; z-index: 2; animation: beckon 1.3s ease-in-out infinite !important; }
@keyframes beckon { 0%, 100% { box-shadow: 0 0 0 2px var(--lamp), 0 0 0 0 rgba(255, 207, 112, .7); } 50% { box-shadow: 0 0 0 2px var(--lamp), 0 0 0 9px rgba(255, 207, 112, 0); } }

/* letters */
dialog.letter-sheet { background: radial-gradient(120% 60% at 50% 0, #fffdf6, rgba(255, 253, 246, 0) 70%), linear-gradient(#fbf4e3, #efdfbd); }
.letter-head { display: flex; align-items: center; gap: 12px; }
.letter-head .face { width: 58px; height: 58px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px #e6b85c, 0 0 0 3.5px #6e440e; }
.letter-head small { font: 600 10px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: #8d5d18; }
.letter-head h2 { text-align: left; margin: 3px 0 0; font-size: 19px; }
.letter { position: relative; margin: 14px 0 4px; padding: 18px 18px 18px 22px; border-radius: 4px; font: italic 17px/1.6 var(--serif); color: #3a2c3a; text-wrap: pretty;
  background: repeating-linear-gradient(transparent 0 26.4px, rgba(80, 110, 170, .18) 26.4px 27.2px), linear-gradient(#fffdf5, #f7ecd2); box-shadow: 0 8px 20px rgba(60, 40, 10, .25), inset 0 0 0 1px rgba(141, 93, 24, .2); transform: rotate(-.6deg); animation: deal .45s var(--ease); }
.letter::before { content: ''; position: absolute; left: 12px; top: 0; bottom: 0; border-left: 1.5px solid rgba(214, 80, 70, .35); }
.letter-row { display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; text-align: left; padding: 6px 10px 6px 6px; }
.letter-row .face { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 1.5px #e6b85c; }
.letter-row b { display: block; font: 600 14px/1.2 var(--serif); }
.letter-row small { color: var(--ink-soft); font-size: 12px; }
dialog h3 { margin: 16px 0 6px; font: 600 11px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: #8d5d18; }
.chapter-list .ending { font-style: italic; color: #5b3a6a; }
.center { text-align: center; }

/* the ship */
.ship-view {
  position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overscroll-behavior: contain;
  padding: max(10px, env(safe-area-inset-top)) 0 max(14px, env(safe-area-inset-bottom));
  background: radial-gradient(120% 50% at 50% 0, #2b3c6b, rgba(43, 60, 107, 0) 60%), linear-gradient(#111b34, #0a1020 70%); animation: rise .35s var(--ease);
}
.ship-view > * { width: min(100%, 520px); margin: 0 auto; }
.ship-top { display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.ship-top .icon-only { flex: 0 0 42px; font: 400 28px/1 var(--serif); color: var(--brass-hi); padding-bottom: 4px; }
.ship-title { flex: 1; min-width: 0; text-align: center; }
.ship-title small { display: block; font: 600 10px/1 var(--sans); letter-spacing: .24em; text-transform: uppercase; color: var(--brass); }
.ship-title h2 { margin: 3px 0 0; font: 600 24px/1.1 var(--serif); color: #fff3da; text-shadow: 0 2px 12px rgba(255, 207, 112, .25); }
.ship-purse { flex: 0 0 auto; padding-right: 14px; }
.ship-stage {
  position: relative; aspect-ratio: 4 / 3; border-radius: 0 0 22px 22px; overflow: hidden; background: #1a1008;
  box-shadow: 0 0 0 1.5px #e3b55a, 0 0 0 4px #2b2033, 0 0 0 5px rgba(227, 181, 90, .5), 0 18px 40px rgba(0, 0, 0, .6);
}
@media (min-width: 521px) { .ship-stage { border-radius: 22px; } }
.ship-scene, .ship-pins, .ship-fx, .ship-overlay { position: absolute; inset: 0; }
.ship-fx, .ship-overlay { pointer-events: none; }
.ship-stage.locked .ship-scene { filter: grayscale(.7) brightness(.55) blur(1px); }
.pin {
  position: absolute; width: 36px; height: 36px; min-height: 0; margin: -18px 0 0 -18px; padding: 6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3b4f86, #1d2a4d); border: 2px solid #e3b55a; box-shadow: 0 4px 10px rgba(0, 0, 0, .5);
  animation: bob-pin 2.4s ease-in-out infinite;
}
.pin i { width: 100%; height: 100%; }
.pin.afford { border-color: #fff1bd; box-shadow: 0 0 0 4px rgba(255, 207, 112, .35), 0 0 18px rgba(255, 207, 112, .8), 0 4px 10px rgba(0, 0, 0, .5); }
.pin.sel { transform: scale(1.2); background: radial-gradient(circle at 35% 30%, #ffe9a8, #c78e2e); animation: none; }
@keyframes bob-pin { 50% { transform: translateY(-4px); } }
.ship-arrow { position: absolute; top: 50%; width: 38px; height: 54px; min-height: 0; margin-top: -27px; padding: 0; font: 400 30px/1 var(--serif); color: var(--brass-hi); background: rgba(10, 16, 32, .55); border: 1px solid rgba(227, 181, 90, .5); backdrop-filter: blur(4px); }
.ship-arrow.prev { left: 8px; border-radius: 12px; }
.ship-arrow.next { right: 8px; border-radius: 12px; }
.ship-arrow:disabled { opacity: 0; pointer-events: none; }
.ship-lock { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 80%; padding: 14px 22px; border-radius: 16px; text-align: center; color: var(--ink);
  background: linear-gradient(#fbf2df, #e6d2a8); box-shadow: 0 0 0 1.5px #c99630, 0 14px 30px rgba(0, 0, 0, .6); font: 15px/1.35 var(--serif); }
.ship-lock i { width: 30px; height: 30px; margin: 0 auto 4px; color: #8d5d18; }
.ship-lock b { display: block; font: 600 11px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: #8d5d18; margin-bottom: 4px; }
.ship-meter { display: flex; align-items: center; gap: 10px; padding: 2px 16px 0; }
.ship-meter .progress { flex: 1; height: 6px; border-radius: 3px; }
.ship-meter small { font: 600 12px var(--serif); color: var(--brass-hi); white-space: nowrap; }
.ship-jobs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 12px 6px; }
.job-card {
  position: relative; display: grid; grid-template-columns: 58px 1fr; grid-template-rows: auto auto; column-gap: 10px; row-gap: 6px; align-items: center; padding: 8px; border-radius: 16px; color: var(--ink);
  background: linear-gradient(#fdf6e6, #eddcb7); box-shadow: inset 0 0 0 1px rgba(141, 93, 24, .28), 0 6px 14px rgba(0, 0, 0, .4); transition: transform .2s var(--ease);
}
.job-card.sel { box-shadow: inset 0 0 0 2px #c99630, 0 0 0 3px rgba(255, 207, 112, .45), 0 8px 20px rgba(255, 190, 80, .3); transform: translateY(-2px); }
.job-card.done { background: linear-gradient(#f3ecdc, #e4d6b8); }
.job-card.done .job-pic { filter: none; }
.job-card.locked { opacity: .6; }
.job-pic { grid-row: span 2; width: 58px; height: 58px; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1.5px #e3b55a, 0 0 0 3px #3b2530, 0 3px 6px rgba(0, 0, 0, .3); background: #2a1a10; }
.job-card:not(.done) .job-pic { filter: saturate(.85); }
.job-name { font: 600 14px/1.15 var(--serif); }
.job-go { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 32px; padding: 3px 10px; font: 700 14px var(--serif); border-radius: 10px; }
.job-go i { width: 16px; height: 16px; }
.job-go.short:disabled { opacity: .55; filter: grayscale(.6); }
.job-done { display: flex; align-items: center; gap: 5px; font: 600 13px var(--serif); color: #3d7a50; }
.job-done i { width: 18px; height: 18px; }
.ship-thanks { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; color: var(--ink); background: linear-gradient(#fdf6e6, #eddcb7); box-shadow: 0 6px 14px rgba(0, 0, 0, .4); }
.ship-thanks .face { width: 56px; height: 56px; flex: none; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px #e6b85c, 0 0 0 3.5px #6e440e; }
.ship-thanks p { margin: 0; font: italic 15px/1.4 var(--serif); }
.ship-thanks b { display: block; font: 600 11px/1.2 var(--sans); font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: #8d5d18; margin-bottom: 3px; }
.ship-h { margin: 8px auto 0; padding: 0 16px; font: 600 11px/1 var(--sans); letter-spacing: .24em; text-transform: uppercase; color: var(--brass); }
.ship-rooms { display: flex; gap: 10px; overflow-x: auto; padding: 4px 12px 8px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.ship-rooms::-webkit-scrollbar { display: none; }
.room-tab { position: relative; flex: 0 0 132px; display: flex; flex-direction: column; gap: 5px; padding: 0 0 7px; min-height: 0; border-radius: 14px; overflow: hidden; scroll-snap-align: center; text-align: left; background: linear-gradient(#1d2a4b, #121a31); }
.room-tab.here { box-shadow: 0 0 0 2px #e3b55a, 0 0 16px rgba(255, 207, 112, .35); }
.room-pic { display: block; aspect-ratio: 4 / 3; }
.room-tab.locked .room-pic { filter: grayscale(.8) brightness(.5); }
.room-tab small { padding: 0 9px; font: 600 12.5px/1.1 var(--serif); color: #f3e6cc; }
.room-badge { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; }
.room-badge.lock { padding: 3px; border-radius: 50%; color: #e3cf9f; background: rgba(10, 16, 32, .75); }
.room-badge.count { width: auto; height: auto; padding: 3px 7px; border-radius: 10px; font: 700 11px/1 var(--sans); color: #3a2408; background: linear-gradient(#ffe9a8, #e2b250); }
.burst.big { position: absolute; inset: auto; width: 0; height: 0; }
.burst.big span { width: 9px; height: 9px; margin: -4.5px; animation-duration: .85s; }
.burst.big span:nth-child(odd) { width: 6px; height: 6px; margin: -3px; }
.stamp { position: absolute; left: 50%; top: 46%; padding: 10px 26px 12px; border-radius: 12px; text-align: center; transform: translate(-50%, -50%) rotate(-6deg);
  font: 600 34px/1 var(--serif); letter-spacing: .04em; color: #7a1f17; border: 3px solid #a8241e; background: rgba(255, 246, 225, .92); box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: stamp .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.stamp small { display: block; font: 600 10px/1 var(--sans); letter-spacing: .26em; text-transform: uppercase; color: #a8241e; margin-bottom: 6px; }
@keyframes stamp { from { opacity: 0; transform: translate(-50%, -50%) rotate(-6deg) scale(2.6); } }
.confetti i { position: absolute; top: -10px; left: var(--x); width: 7px; height: 11px; border-radius: 2px; background: var(--c); animation: fall 2.6s cubic-bezier(.3, .6, .5, 1) var(--d) both; }
@keyframes fall { from { transform: translateY(0) rotate(0); } to { transform: translateY(330px) rotate(540deg); opacity: .2; } }

@media (max-height: 700px) {
  .ticket { padding-top: 20px; }
  .want { width: 34px; height: 34px; }
  .chapter { padding: 5px 12px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* tasks */
.chapter-row { display: flex; gap: 6px; }
.chapter-row .chapter { flex: 1; min-width: 0; }
.tasks-btn { position: relative; flex: none; width: 52px; min-height: 0; padding: 0; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(#18233f, #121a31); border: 1px solid var(--brass-line); }
.tasks-btn i { width: 28px; height: 28px; }
.tasks-btn i svg { display: block; width: 100%; height: 100%; }
.tasks-btn b { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font: 700 11px/18px var(--sans); color: #fff; background: var(--rose); box-shadow: 0 0 0 2px #121a31; }
.tasks-btn b:empty { display: none; }
.tasks-btn.due { box-shadow: 0 0 12px rgba(255, 207, 112, .45); }
.task-head { display: flex; justify-content: space-between; align-items: baseline; }
.task-head small { font: 500 11px/1 var(--sans); letter-spacing: 0; text-transform: none; color: #8a7a68; }
.task { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .55); box-shadow: inset 0 0 0 1px rgba(141, 93, 24, .2); }
.task.ready { box-shadow: inset 0 0 0 1.5px #e3b55a, 0 0 12px rgba(255, 196, 80, .35); }
.task.claimed { opacity: .6; }
.task.bonus { background: linear-gradient(100deg, rgba(255, 228, 160, .7), rgba(255, 255, 255, .5)); }
.task-words { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.task-words b { font: 600 14.5px/1.2 var(--serif); color: #2b2033; }
.task-words small { font: 12px/1.25 var(--sans); color: #6a5a52; }
.task-words .bar { display: block; height: 5px; border-radius: 3px; background: rgba(60, 40, 20, .15); overflow: hidden; }
.task-words .bar span { display: block; height: 100%; background: linear-gradient(90deg, #c99630, #ffd77a); }
.task button { flex: none; min-height: 34px; padding: 4px 12px; font-size: 13px; }
.task-done { width: 26px; height: 26px; flex: none; }
.task-done svg { display: block; width: 100%; height: 100%; }
.gate { margin: 0 0 6px; font: italic 15px/1.4 var(--serif); color: #5a4030; text-align: center; }

/* the stamp album */
.album-entry i { width: 40px; height: 40px; }
.album-entry.due { box-shadow: inset 0 0 0 1.5px #e3b55a, 0 0 12px rgba(255, 196, 80, .4); }
.album-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; text-align: center; }
.album-nav button { min-height: 40px; padding: 0; font: 400 26px/1 var(--serif); }
.album-nav b { display: block; font: 600 18px/1.2 var(--serif); color: #2b2033; }
.album-nav small { font: 12px/1.3 var(--sans); color: #8a7a68; }
.album-page { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 14px 4px 16px; padding: 16px; border-radius: 10px;
  background: repeating-linear-gradient(0deg, rgba(120, 90, 50, .07) 0 1px, transparent 1px 26px), linear-gradient(#f6ecd6, #ecdcbc); box-shadow: inset 0 0 0 1px rgba(141, 93, 24, .25), inset 0 2px 10px rgba(80, 50, 20, .15); }
.pstamp { position: relative; aspect-ratio: 4 / 5; padding: 9%; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: radial-gradient(circle, transparent 0 2.4px, #fffaf0 2.9px) -5px -5px / 9px 9px; filter: drop-shadow(0 2px 2px rgba(60, 40, 20, .35)); transform: rotate(var(--tilt, 0deg)); }
.pstamp:nth-child(3n + 1) { --tilt: -2deg; } .pstamp:nth-child(4n) { --tilt: 1.5deg; } .pstamp:nth-child(5n + 2) { --tilt: -1deg; }
.pstamp::before { content: ''; position: absolute; inset: 5px; background: #fffaf0; z-index: 0; }
.pstamp > * { position: relative; z-index: 1; }
.pstamp .face { flex: 1; width: 100%; padding: 6%; border-radius: 2px; background: radial-gradient(circle at 50% 35%, #fff, color-mix(in srgb, var(--tint) 75%, #fff)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tint) 60%, #5a3a20); }
.pstamp.s2 .face { box-shadow: inset 0 0 0 2px #c99630; }
.pstamp.s3 .face { background: radial-gradient(circle at 50% 35%, #fffbe6, #f2c14e); box-shadow: inset 0 0 0 2px #9a3d16, 0 0 10px rgba(255, 196, 80, .6); }
.pstamp small { font: 9px/1 var(--sans); letter-spacing: 1px; color: #c0473d; }
.pstamp .dup { position: absolute; top: -4px; right: -4px; padding: 1px 5px; border-radius: 9px; font: 700 10px/1.3 var(--sans); color: #fff; background: #6a5a52; }
.pstamp.fresh { animation: stick .7s var(--ease) both; }
.pstamp.fresh::after { content: 'New'; position: absolute; z-index: 2; bottom: -6px; left: 50%; transform: translateX(-50%); padding: 1px 6px; border-radius: 8px; font: 700 9.5px/1.4 var(--sans); color: #fff; background: #3d9a63; }
@keyframes stick { from { transform: scale(1.3) rotate(8deg); opacity: 0; } }
.pstamp.empty { background: none; filter: none; border: 1.5px dashed rgba(120, 90, 50, .45); border-radius: 4px; justify-content: center; }
.pstamp.empty::before { content: none; }
.pstamp.empty .q { font: 600 24px/1 var(--serif); color: rgba(120, 90, 50, .5); }
.pstamp.empty small { color: rgba(120, 90, 50, .5); }

.event > button { min-height: 44px; border: none; background: none; box-shadow: none; color: inherit; padding: 4px; }
.event-take { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; text-align: left; font-size: 11px; }
.event-take span { min-width: 0; }
.event-track { flex: none; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 6px 4px 0 !important; }
.event-track .ring { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#ffd77a var(--p, 0%), rgba(255, 255, 255, .15) 0); }
.event-track .ring span { width: 14px; height: 14px; border-radius: 50%; background: #1b2445; }
.event-track small { font: 700 9.5px/1 var(--sans); color: #ffe7a6; }
.track-chest { position: relative; flex: none; width: 44px; height: 44px; }
.track-chest .tile { inset: 0; }

/* chests */
.tile.chest { padding: 4%; background: radial-gradient(circle at 50% 38%, #fff6dc, #ecd29a 72%, #c99a52); box-shadow: inset 0 0 0 1.5px #b98a3c, inset 0 1px rgba(255, 255, 255, .8), 0 2px 0 rgba(0, 0, 0, .35), 0 3px 6px rgba(0, 0, 0, .3); }
.tile.chest.c2 { box-shadow: inset 0 0 0 2px #d9a84a, 0 2px 0 rgba(0, 0, 0, .35), 0 0 8px rgba(255, 196, 80, .45); }
.tile.chest.c3 { background: radial-gradient(circle at 50% 38%, #fffbe6, #ffe39a 60%, #e7b24c); box-shadow: inset 0 0 0 2px #fff1bd, inset 0 0 0 3px #c88a2a, 0 2px 0 rgba(0, 0, 0, .35), 0 0 14px rgba(255, 196, 80, .75); overflow: hidden; }
.tile.chest.c3::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, .6) 50%, rgba(255, 255, 255, 0) 62%); background-size: 300% 100%; animation: sweep 3.4s ease-in-out infinite; }
.chest-path { grid-template-columns: repeat(3, 1fr); max-width: 300px; margin-inline: auto; }

/* pearls and timed chests */
.hud-chip.pearls { flex: .62; }
.hud-chip.pearls i { width: 24px; height: 24px; }
.pearl-btn { display: inline-flex; align-items: center; gap: 4px; }
.pearl-btn i { width: 18px; height: 18px; flex: none; }
.pearl-btn i svg { display: block; width: 100%; height: 100%; }
.cell .chest-lock { position: absolute; z-index: 3; right: 2px; top: 2px; width: 40%; height: 40%; pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.cell .chest-lock svg { display: block; width: 100%; height: 100%; }

/* ---------------------------------------------------------------- room for the rack
   The rack takes whatever height is left, so everything around it stays lean, leaner on short screens. */
main { gap: 6px; padding-inline: 6px; }
.orders { margin-top: 8px; }
.board { padding: 5px; gap: 2.5px; border-radius: 13px; }
.cell .tile:not(.locked):not(.gen) > img.art, .ghost .tile:not(.gen) > img.art { transform: scale(1.13); }
.tile.gen { padding: 9%; }
.info { min-height: 46px; }
@media (max-height: 820px) {
  main { gap: 5px; }
  .hud-chip { height: 36px; }
  .hud-chip i { width: 22px; height: 22px; }
  .hud-chip b { font-size: 16px; }
  .chapter { padding: 5px 12px 6px; row-gap: 4px; }
  .tasks-btn { width: 44px; }
  .tasks-btn i { width: 24px; height: 24px; }
  .ticket { padding: 19px 5px 5px; gap: 2px; }
  .medal { width: 30px; height: 30px; top: -11px; }
  .ticket .who { font-size: 10px; margin-top: 0; }
  .want { width: 34px; height: 34px; }
  .ticket .deliver { min-height: 26px; font-size: 12px; margin-top: 1px; }
  .event, .event > button { min-height: 36px; }
  .event i { width: 24px; height: 24px; }
  .info { min-height: 42px; padding-block: 3px; }
  .nav { padding: 2px; }
  .nav button { padding: 2px 2px 1px; font-size: 10px; gap: 1px; }
  .nav button i { width: 19px; height: 19px; }
  .reward { position: absolute; top: 4px; right: 6px; font-size: 11px; }
  .reward i { width: 12px; height: 12px; }
  .reward .gift { display: none; }
  .ticket .who { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ticket { padding-top: 22px; }
  .chapter { padding: 4px 11px 5px; }
}
@media (max-height: 700px) {
  .orders { margin-top: 6px; }
  .want { width: 30px; height: 30px; }
  .nav button span { display: none; }
  .nav button { padding: 5px 2px; }
  .nav button i { width: 22px; height: 22px; }
  .event-take span { display: none; }
  .event { flex: 0 0 auto; }
  .chapter-label { display: none; }
}

/* source parts and timed sources */
.tile.part { background: radial-gradient(circle at 50% 38%, #f4f8ff, #cfdcef 72%, #9fb3d0); box-shadow: inset 0 0 0 1.5px #7d93b8, inset 0 1px rgba(255, 255, 255, .8), 0 2px 0 rgba(0, 0, 0, .35); }
.tile.part::before { content: ''; position: absolute; inset: 2px; border-radius: 6px; border: 1.5px dashed rgba(201, 150, 48, .8); pointer-events: none; }
.tile.part.p3 { box-shadow: inset 0 0 0 2px #d9a84a, 0 2px 0 rgba(0, 0, 0, .35), 0 0 8px rgba(255, 196, 80, .45); }
.tile.gen.timed .bolt { background: radial-gradient(circle at 35% 30%, #fff3c4, #f2c25a 60%, #b97f22); }
.job-name { display: flex; flex-direction: column; gap: 3px; }
.job-need { display: flex; align-items: center; gap: 5px; font: 11px/1.2 var(--sans); color: #a8241e; }
.job-need.got { color: #2e7a4a; }
.job-need .tile { position: relative; inset: auto; width: 24px; height: 24px; flex: none; }
