:root {
  color-scheme: dark;
  --paper: #f0ebdc;
  --muted: #b0b3a9;
  --gold: #d7bd85;
  --edge: #444941;
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
  color: var(--paper);
  background: #191d1b;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; display: grid; align-content: center; background: radial-gradient(ellipse at 50% 42%, #292e28, #191d1b 80%); }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, canvas:focus-visible { outline: 2px solid #f4d395; outline-offset: 3px; }
button:disabled { cursor: wait; }
button, .touch-controls { -webkit-user-select: none; user-select: none; }
button:hover { color: #fff9e9; }
.game-shell { width: min(94vw, 1560px, max(810px, calc((100svh - 190px) * 1.77778))); margin: 0 auto; padding: 14px 0 19px; }
.masthead, .wordmark, .tools, .deck, .deck-heading, .travellers, .traveller, .bindings, .binding, .key-group, .scene-hud, .plaque, .guide-button { display: flex; align-items: center; }
.masthead { justify-content: space-between; padding: 1px 2px 15px; }
.wordmark { gap: 12px; }
.wordmark img { image-rendering: pixelated; }
.overline, .hud-label, .traveller small { display: block; font-size: 10px; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; }
.overline { color: var(--gold); }
h1, h2, .plaque strong, .traveller strong { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { margin: -1px 0 0; font-size: clamp(29px, 3vw, 39px); line-height: 1.06; letter-spacing: -.045em; }
.icon-library, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.tools { gap: 3px; }
.tools a{color:var(--gold);font-size:13px;padding:7px;text-underline-offset:3px}
.icon-button, .guide-button { border: 1px solid transparent; background: transparent; color: #c8c9bf; border-radius: 5px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; }
.guide-button { gap: 8px; min-height: 38px; padding: 0 9px; font-size: 13px; }
.icon-button:hover, .guide-button:hover, .icon-button[aria-pressed="true"] { background: #31362f; border-color: var(--edge); }
.icon-button[aria-pressed="true"] { color: var(--gold); }
#zoom-button[aria-pressed="true"] .zoom-plus { display: none; }
.tool-rule { width: 1px; height: 18px; margin: 0 6px; background: var(--edge); }
.frame { padding: 4px; background: #292e28; border: 1px solid #5b5c4d; border-radius: 5px; box-shadow: 0 12px 35px #0f110f55, inset 0 0 0 1px #34392f; }
.viewfinder { position: relative; aspect-ratio: 16 / 9; overflow: hidden; isolation: isolate; background: #242d2b; }
canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; outline-offset: -3px !important; }
.scene-hud { pointer-events: none; position: absolute; inset: clamp(9px, 1.5vw, 23px) clamp(9px, 1.5vw, 23px) auto; align-items: flex-start; justify-content: space-between; }
.plaque { gap: 11px; padding: 9px 14px 10px 11px; background: #222820ed; border: 1px solid #d1bd8aab; outline: 2px solid #263124cc; box-shadow: inset 0 0 0 2px #333b2e, 2px 3px 0 #17241559; color: #faf2da; }
.hud-label { color: #dfc58d; font-size: 8px; letter-spacing: .18em; margin-bottom: 1px; }
.plaque strong { display: block; font-size: clamp(15px, 1.4vw, 21px); line-height: 1.14; }
.chapter-number { padding: 3px 10px 3px 0; border-right: 1px solid #7d8069; font: 18px Georgia, serif; color: #ddc58c; font-variant-numeric: lining-nums; }
.weather svg { width: 25px; height: 25px; color: #e7c37a; }
.weather strong { font-size: 16px; }
#loading, .noscript { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: #252d27; color: var(--paper); padding: 2rem; }
#loading span { font: italic 21px Georgia, serif; }
[hidden] { display: none !important; }
.deck { justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; padding: 15px 3px 0; }
.deck-heading { gap: 8px; margin-bottom: 7px; }
.deck-heading .overline { font-size: 9px; }
.tiny-rule { width: 18px; height: 1px; background: #ad986c; }
.travellers { gap: 7px; }
.traveller { text-align: left; min-width: 129px; gap: 9px; background: #272c27; padding: 3px 13px 3px 4px; border: 1px solid var(--edge); border-radius: 4px; }
.traveller[aria-pressed="true"] { background: #35382e; border-color: #b59c69; }
.traveller:hover { background: #33392f; }
.cameo { display: grid; place-items: end center; width: 40px; height: 40px; border-radius: 2px; overflow: hidden; background: #414538; }
.traveller[aria-pressed="true"] .cameo { background: #565942; }
.cameo img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.traveller small { color: var(--muted); font-size: 8px; letter-spacing: .10em; }
.traveller[aria-pressed="true"] small { color: var(--gold); }
.traveller strong { display: block; font-size: 17px; line-height: 1.2; }
.practice { align-self: stretch; }
.practice-note { color: var(--muted); font: italic 11px Georgia, serif; }
.choices { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.choice { min-height: 43px; padding: 4px 11px; border: 1px solid var(--edge); border-radius: 4px; color: #dddccd; background: #272c27; font: 15px Georgia, serif; }
.choice:is(:hover, :focus-visible) { background: #33392f; }
.choice[aria-pressed="true"] { border-color: #b59c69; background: #35382e; color: #f5dfac; }
.choice.level { min-width: 34px; font-variant-numeric: tabular-nums; }
.choice.stop { min-width: 32px; font-size: 10px; color: var(--gold); }
.bindings { flex-wrap: wrap; gap: 19px; padding-top: 16px; }
.binding { gap: 7px; font-size: 12px; color: var(--muted); }
.key-group { gap: 2px; }
kbd { display: inline-block; padding: 2px 6px 3px; min-width: 21px; text-align: center; border: 1px solid #565b52; border-bottom-width: 2px; border-radius: 4px; background: #2a2f2a; font: 11px/1.25 ui-monospace, Consolas, monospace; color: #e6e5d7; }
.touch-controls { display: none; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 3px 0; }
.touch-controls button { display: grid; place-items: center; border: 1px solid #656951; background: #31372e; border-radius: 6px; touch-action: none; }
.touch-controls button:active, .touch-controls button.is-held { background: #4a503e; border-color: var(--gold); }
.dpad { display: grid; grid-template: repeat(2, 44px) / repeat(3, 44px); gap: 3px; align-items: stretch; justify-items: stretch; }
.dpad button[data-dir="up"] { grid-area: 1 / 2; }
.dpad button[data-dir="left"] { grid-area: 2 / 1; }
.dpad button[data-dir="right"] { grid-area: 2 / 3; }
.dpad button[data-dir="down"] { grid-area: 2 / 2; }
[data-dir="right"] svg { transform: rotate(90deg); }
[data-dir="down"] svg { transform: rotate(180deg); }
[data-dir="left"] svg { transform: rotate(-90deg); }
#touch-jump { width: 75px; height: 58px; gap: 1px; padding: 6px; font-size: 12px; color: var(--gold); }
dialog { padding: 32px; width: min(420px, 90vw); color: var(--paper); background: #272d28; border: 1px solid #8e8162; border-radius: 6px; box-shadow: 0 18px 70px #080c09aa; }
dialog::backdrop { background: #101511bb; }
dialog h2 { font-size: 30px; letter-spacing: -.045em; margin: 8px 0 12px; }
dialog p { color: #d2d3c7; font-size: 14px; line-height: 1.6; }
.close-guide { position: absolute; right: 8px; top: 8px; }
dialog dl { margin: 21px 0 12px; font-size: 12px; }
dialog dl div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--edge); }
dialog dd { margin: 0; color: var(--muted); text-align: right; }
dialog .guide-note { font-size: 12px; color: var(--muted); }
.return-button { border: 1px solid #ac9771; background: #444638; padding: 9px 13px; border-radius: 3px; }
.return-button span { margin-left: 8px; color: var(--gold); }
:fullscreen body { height: 100%; }
body{font-family:"Saimaa Grid",monospace;background:#18242a}
h1,h2,.traveller strong,.choice,.practice-note,.plaque strong{font-family:"Saimaa Grid",monospace}
.frame,.traveller,.choice,.touch-controls button,dialog,.return-button{border-radius:0;border:3px solid #111b22;box-shadow:inset 2px 2px #85928d,inset -2px -2px #445456;background:#29353a}
.tools a,.guide-button,.choice,.traveller strong{font-size:18px}
@media (max-width: 800px) {
  .game-shell { width: 96vw; }
  .bindings { gap: 9px; }
  .key-group { gap: 1px; }
  .deck { flex-wrap: wrap; }
}
@media (pointer: coarse), (max-width: 600px) {
  .touch-controls { display: flex; }
  .bindings { display: none; }
  .traveller { min-width: 117px; }
}
@media (pointer: coarse) and (min-width: 721px) and (min-height: 651px) {
  .game-shell { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 22px; width: min(94vw, 1560px, max(680px, calc((100svh - 215px) * 1.77778))); }
  .masthead, .frame { grid-column: 1 / -1; }
  .touch-controls { gap: 14px; }
}
@media (any-pointer: fine) and (min-width: 1100px) {
  .bindings { display: flex; }
}
@media (max-width: 720px) and (orientation: portrait) {
  .game-shell { padding: 10px 0 13px; }
  .masthead { padding-bottom: 10px; }
  .wordmark { gap: 8px; }
  .wordmark img { width: 36px; height: 36px; }
  .wordmark .overline { font-size: 8px; }
  .guide-button span { display: none; }
  .guide-button { padding: 0 8px; }
  .viewfinder { aspect-ratio: auto; height: clamp(235px, 47svh, 490px); }
  .scene-hud { inset: 8px 8px auto; }
  .plaque { padding: 5px 8px; gap: 6px; }
  .chapter-number { font-size: 14px; padding-right: 6px; }
  .hud-label { font-size: 7px; }
  .plaque strong { font-size: 13px; }
  .weather svg { width: 17px; height: 17px; }
  .deck { padding-top: 9px; }
  .practice { flex-basis: 100%; }
  .choice { min-height: 44px; }
  .choice.level { min-width: 43px; }
  .touch-controls { margin-top: 9px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 650px) {
  body { align-content: start; }
  .game-shell { width: min(99vw, calc((100svh - 60px) * 1.77778 + 156px)); display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 0 6px; padding: 3px 0; }
  .masthead { grid-column: 1 / -1; height: 43px; padding-bottom: 3px; }
  .wordmark img { width: 30px; height: 30px; }
  h1 { font-size: 23px; }
  .wordmark .overline { font-size: 7px; }
  .frame { grid-area: 2 / 1 / 4 / 2; align-self: start; }
  .deck { grid-area: 2 / 2; align-self: start; justify-content: center; padding: 2px; gap: 6px; }
  .party .deck-heading, .practice .tiny-rule, .practice-note { display: none; }
  .practice .deck-heading { justify-content: center; margin-bottom: 4px; }
  .practice .choices { justify-content: center; gap: 2px; }
  .choice { min-height: 31px; padding: 3px 4px; font-size: 12px; }
  .choice.level { min-width: 24px; }
  .travellers { flex-direction: column; gap: 3px; }
  .cameo { height: 27px; width: 27px; }
  .traveller strong { font-size: 14px; }
  .touch-controls { grid-area: 3 / 2; align-self: end; flex-direction: column-reverse; gap: 4px; margin: 0; }
  .dpad { grid-template: repeat(2, 40px) / repeat(3, 42px); }
  #touch-jump { height: 35px; width: 92px; display: flex; justify-content: center; gap: 7px; }
}
