:root {
  --midnight: #192d38;
  --midnight-2: #0f1c23;
  --night: #0b1418;
  --slate: #526778;
  --marsh: #76894b;
  --brass: #eba84f;
  --bone: #eadcb6;
  --storm: #64bcb7;
  --card: #213b46;
  --ink: #f6ecd4;
  --ink-dark: #2a2418;
  --muted: #b4c4c6;
  --dim: #86999e;
  --copper: #c8783a;
  --cream: #ffe1a3;
  --line: rgba(234, 220, 182, 0.18);
  --mint: #8ff0d0;
  --danger: #ef9373;
  --font: 'Jersey 10', 'Trebuchet MS', system-ui, sans-serif;
  --label: 'Silkscreen', 'Jersey 10', ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); }
body {
  font-family: var(--font);
  font-size: 21px;
  line-height: 1.22;
  font-synthesis: none;
  letter-spacing: 0.015em;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
button:focus-visible { outline: 3px solid var(--storm); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--font); font-weight: 400; margin: 0; letter-spacing: 0.02em; line-height: 1.05; }
.label, .eyebrow, kbd {
  font-family: var(--label);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--storm);
  display: block;
}
.label.copper, .copper { color: #f0a56b; }
.muted { color: var(--muted); }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- art skins (nine-slice) ---------- */
.skin-panel {
  border: 24px solid transparent;
  border-image: url(assets/img/ui/ui_panel.png) 27 fill / 24px stretch;
  image-rendering: pixelated;
}
.skin-paper {
  border: 18px solid transparent;
  border-image: url(assets/img/ui/ui_paper.png) 22 fill / 18px stretch;
  image-rendering: pixelated;
  color: var(--ink-dark);
}
.skin-bar {
  border-style: solid;
  border-color: transparent;
  border-width: 10px 9px;
  border-image: url(assets/img/ui/ui_bar.png) 12 10 fill / 10px 9px stretch;
  image-rendering: pixelated;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 10px; font-weight: 400; font-size: 23px; letter-spacing: .02em;
  color: var(--ink);
  border-style: solid; border-color: transparent; border-width: 12px 22px;
  border-image: url(assets/img/ui/ui_btn_iron.png) 13 26 fill / 12px 22px stretch;
  image-rendering: pixelated;
  text-shadow: 0 2px 0 rgba(0,0,0,.55);
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); filter: brightness(.92); }
.btn.primary {
  color: #3a2408; text-shadow: 0 1px 0 rgba(255,240,200,.6);
  border-width: 12px 20px;
  border-image: url(assets/img/ui/ui_btn_brass.png) 14 26 fill / 12px 20px stretch;
}
.btn.link {
  border: 0; border-image: none; min-height: 40px; color: var(--muted); font-weight: 400; font-size: 20px;
  text-decoration: underline; text-underline-offset: 4px; text-shadow: none;
}
.btn.small { min-height: 40px; font-size: 19px; border-width: 9px 16px; }
.btn[disabled] { filter: grayscale(.8) brightness(.7); cursor: default; }
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; font-size: 20px; line-height: 1;
  border: 10px solid transparent;
  border-image: url(assets/img/ui/ui_btn_square.png) 22 fill / 10px stretch;
  image-rendering: pixelated; color: var(--cream); text-shadow: 0 2px 0 rgba(0,0,0,.6);
}
.icon-btn:active { transform: translateY(2px); }
.icon-btn.off { filter: grayscale(1) brightness(.65); }
.corner-toggles { display: flex; gap: 6px; }

/* ---------- loading & tap to start ---------- */
#screen-loading { display: none; place-items: center; background: radial-gradient(circle at 50% 40%, #1c3340, var(--night)); }
#screen-loading.active { display: grid; }
.loading-box { width: min(340px, 80vw); text-align: center; }
.loading-box img { width: 100%; animation: floaty 3s ease-in-out infinite; }
.loading-bar { height: 14px; margin-top: 18px; border: 3px solid #4a3a26; background: #120d08; box-shadow: 0 0 0 2px #d29c4a; }
.loading-bar span { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, #f2b95c 0 8px, #d99a3e 8px 16px); transition: width .2s; }
#loading-text { color: var(--muted); font-size: 20px; margin-top: 12px; }

/* ---------- title ---------- */
#screen-title { background: #0b1520; overflow: hidden; }
#title-canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
.title-ui {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: space-between; padding: calc(14px + var(--safe-t)) 16px calc(22px + var(--safe-b));
  pointer-events: none;
}
.title-ui > * { pointer-events: auto; }
.title-top { display: flex; flex-direction: column; align-items: center; }
.logo-wrap { width: min(560px, 90vw); margin-top: 1vh; transform-origin: 50% 0; opacity: 0; }
.logo-img { width: 100%; display: block; filter: drop-shadow(0 6px 0 rgba(0,0,0,.45)) drop-shadow(0 0 24px rgba(255,200,110,.25)); }
.tagline {
  font-size: clamp(21px, 2.8vw, 28px); color: #ffe7b8; text-align: center; margin: 6px 0 0; max-width: 30em; opacity: 0;
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(0,0,0,.9);
}
.title-bottom { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(420px, 100%); }
.title-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.title-actions > * { opacity: 0; }
.title-actions .btn.primary { grid-column: 1 / -1; min-height: 66px; font-size: 32px; border-width: 15px 24px; }
.title-stats { display: flex; gap: 16px; justify-content: center; color: var(--muted); font-size: 19px; text-shadow: 0 2px 0 #000; opacity: 0; flex-wrap: wrap; }
.title-stats b { color: var(--cream); }
@media (min-aspect-ratio: 6/5) {
  .title-ui { align-items: flex-start; padding-left: max(24px, 5vw); padding-right: max(24px, 5vw); }
  .title-top { align-items: flex-start; }
  .logo-wrap { width: min(540px, 44vw); }
  .tagline { text-align: left; max-width: 21em; }
  .title-bottom { align-items: stretch; width: min(400px, 40vw); }
  .title-stats { justify-content: flex-start; }
  .tap-start { place-items: end start; padding-left: max(40px, 9vw); }
}
#screen-title > .corner-toggles { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; z-index: 3; }
#screen-title.ready .logo-wrap { animation: logo-drop 1s cubic-bezier(.2,1.4,.4,1) both, logo-swing 5s ease-in-out 1.2s infinite; }
#screen-title.ready .tagline { animation: fade-up .7s ease-out .55s both; }
#screen-title.ready .title-actions > * { animation: fade-up .5s ease-out both; }
#screen-title.ready .title-actions > *:nth-child(1) { animation: fade-up .5s ease-out .8s both, glow 2.4s ease-in-out 1.6s infinite; }
#screen-title.ready .title-actions > *:nth-child(2) { animation-delay: .95s; }
#screen-title.ready .title-actions > *:nth-child(3) { animation-delay: 1.05s; }
#screen-title.ready .title-stats { animation: fade-up .5s ease-out 1.2s both; }
@keyframes logo-drop { 0% { transform: translateY(-120%) rotate(-6deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes logo-swing { 0%, 100% { transform: rotate(0deg) translateY(0); } 25% { transform: rotate(1.4deg) translateY(2px); } 75% { transform: rotate(-1.4deg) translateY(-2px); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0%, 100% { filter: drop-shadow(0 0 0 rgba(255,210,120,0)); } 50% { filter: drop-shadow(0 0 14px rgba(255,210,120,.8)); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.tap-start {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: end center; padding-bottom: 24vh;
  background: radial-gradient(circle at 50% 45%, rgba(6,12,16,0), rgba(6,12,16,.55)); cursor: pointer;
}
.tap-start span {
  font-family: var(--label); font-size: 18px; color: var(--cream); letter-spacing: .08em;
  text-shadow: 0 2px 0 #000, 0 0 16px rgba(255,200,110,.6); animation: blink 1.3s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

/* ---------- map ---------- */
#screen-map { overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--night); }
.map-art { position: fixed; inset: 0; background-size: cover; background-position: center; opacity: .5; image-rendering: pixelated; }
.map-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,20,24,.45), rgba(11,20,24,.85)); }
.map-inner { position: relative; max-width: 1180px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 14px calc(28px + var(--safe-b)); }
.map-head { display: flex; align-items: center; gap: 10px; }
.map-head h2 { font-size: clamp(36px, 6vw, 54px); text-shadow: 0 3px 0 #000; }
.map-head > div:nth-child(2) { flex: 1; }
.map-sub { color: var(--muted); margin: 8px 0 16px; max-width: 40em; text-shadow: 0 2px 0 #000; }
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mission { display: flex; flex-direction: column; min-height: 100%; animation: fade-up .45s ease-out both; }
.mission:nth-child(2) { animation-delay: .08s; }
.mission:nth-child(3) { animation-delay: .16s; }
.mission:nth-child(4) { animation-delay: .24s; }
.mission.locked { filter: grayscale(.75) brightness(.7); }
.mission .thumb { height: 120px; background-size: cover; background-position: center; image-rendering: pixelated; position: relative; border: 3px solid #0d1418; box-shadow: 0 0 0 2px #b98a3e; }
.mission .thumb .num { position: absolute; left: 6px; top: 6px; font-family: var(--label); color: var(--cream); background: rgba(14,24,30,.85); padding: 2px 8px; font-size: 13px; }
.mission .body { padding: 10px 2px 2px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.mission h3 { font-size: 30px; text-shadow: 0 2px 0 #000; }
.mission .place { font-family: var(--label); font-size: 11px; color: var(--storm); }
.row { display: flex; align-items: center; gap: 10px; }
.ks-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 2px dashed rgba(234,220,182,.18); border-bottom: 2px dashed rgba(234,220,182,.18); }
.ks-line img { width: 42px; height: 42px; object-fit: contain; image-rendering: pixelated; }
.ks-line .k-name { font-weight: 400; }
.ks-line .k-sub { font-size: 18px; color: var(--muted); }
.sil { filter: brightness(0) saturate(0) opacity(.6) drop-shadow(0 0 1px rgba(234,220,182,.7)); }
.punches { display: inline-flex; gap: 5px; vertical-align: middle; }
.punches i { width: 12px; height: 12px; border: 2px solid var(--storm); display: inline-block; }
.punches i.on { background: var(--storm); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-family: var(--label); font-size: 10.5px; padding: 3px 7px; border: 2px solid rgba(234,220,182,.25); color: var(--muted); background: rgba(10,18,22,.35); }
.badge.gold { border-color: var(--brass); color: var(--brass); }
.badge.signed { border-color: var(--copper); color: #f0a56b; }
.workorder { transform: rotate(-1.2deg); font-size: 19px; position: relative; }
.workorder b { display: block; font-size: 23px; }
.workorder .wo-label { font-family: var(--label); font-size: 10px; color: #8a5a2b; }
.mission .actions-row { margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mission .actions-row .btn:not(.link) { flex: 1; }
.map-foot { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- game (full screen) ---------- */
#screen-game { background: var(--night); overflow: hidden; }
#board { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.game-ui { position: absolute; inset: 0; pointer-events: none; }
.top-stack {
  position: absolute; left: 8px; right: 8px; top: calc(6px + var(--safe-t));
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
.top-stack > * { pointer-events: auto; }
.hud { display: flex; align-items: stretch; min-height: 58px; }
.hud-cell { padding: 2px 8px; min-width: 0; flex: 1 1 0; border-right: 2px solid rgba(0,0,0,.35); box-shadow: 1px 0 0 rgba(234,190,120,.15); }
.hud-cell:last-of-type { border-right: 0; box-shadow: none; }
.hud-mission { flex: 1.6 1 0; }
.hud-cell .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; color: #f0c77e; }
.hud-cell b { display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 rgba(0,0,0,.6); }
#hud-odds { color: var(--cream); display: inline-block; }
#hud-odds.pulse { animation: pulse .9s ease-out 2; }
@keyframes pulse { 0% { transform: scale(1); } 30% { transform: scale(1.5); color: #fff3cf; text-shadow: 0 0 10px var(--brass); } 100% { transform: scale(1); } }
.prize-sil { width: 24px; height: 24px; object-fit: contain; image-rendering: pixelated; }
#hud-next .arrow { color: var(--brass); font-size: 18px; display: inline-block; width: 18px; text-align: center; }
#hud-next.flash .arrow { animation: flash .35s ease-out; }
@keyframes flash { 0% { transform: scale(1.7); color: #fff; } 100% { transform: scale(1); } }
.hud-beats { flex: .55 1 0; display: none; }
.hud-menu { align-self: center; margin-left: 6px; flex: none; }
.l-short { display: none; }
.contract-strip { display: flex; align-items: center; gap: 10px; font-size: 20px; transform: rotate(-.4deg); }
.contract-strip .label { display: inline; color: #8a4d1c; }
.contract-strip b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-family: var(--label); font-size: 10.5px; padding: 2px 6px; border: 2px solid rgba(42,36,24,.35); color: #5a4a30; white-space: nowrap; }
.pill.ok { border-color: #2c7a74; color: #1f625d; }
.pill.bad { border-color: #b2533a; color: #a2432a; }
.toast {
  position: absolute; left: 50%; top: var(--toast-top, 90px); transform: translate(-50%, -8px); opacity: 0;
  padding: 2px 8px; font-size: 21px; font-weight: 400; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100% - 24px); width: max-content; text-align: center; z-index: 4;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { color: #a2432a; }
.hint {
  position: absolute; left: 50%; bottom: var(--hint-bottom, 220px); transform: translateX(-50%); width: min(92%, 480px);
  font-size: 20px; text-align: center; pointer-events: none; z-index: 4;
}
.hint b { color: #7a3e10; }
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; pointer-events: auto;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px;
  padding: 18px 12px calc(10px + var(--safe-b));
  background: linear-gradient(to top, rgba(8, 14, 18, .92) 55%, rgba(8, 14, 18, 0));
}
.dpad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 54px); gap: 2px; }
.pad {
  border: 11px solid transparent;
  border-image: url(assets/img/ui/ui_btn_square.png) 22 fill / 11px stretch;
  image-rendering: pixelated; font-size: 20px; color: var(--cream); text-shadow: 0 2px 0 #000; touch-action: manipulation;
  display: grid; place-items: center; line-height: 1;
}
.pad:active, .pad.down-now { transform: translateY(3px); filter: brightness(1.25); }
.pad.up { grid-column: 2; grid-row: 1; }
.pad.left { grid-column: 1; grid-row: 2; }
.pad.right { grid-column: 3; grid-row: 2; }
.pad.down { grid-column: 2; grid-row: 3; }
.dpad-hub { grid-column: 2; grid-row: 2; display: grid; place-items: center; }
.dpad-hub i { width: 16px; height: 16px; background: #2a3c44; box-shadow: inset 0 0 0 3px #c99343; }
.actions { display: grid; gap: 6px; }
.act {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; font-weight: 400; font-size: 24px;
  border-style: solid; border-color: transparent; border-width: 12px 22px;
  border-image: url(assets/img/ui/ui_btn_iron.png) 13 26 fill / 12px 22px stretch; image-rendering: pixelated;
  color: var(--ink); text-shadow: 0 2px 0 #000;
}
.act:active, .act.down-now { transform: translateY(3px); filter: brightness(1.15); }
.act.ring {
  min-height: 74px; font-size: 28px; color: #3a2408; text-shadow: 0 1px 0 rgba(255,240,200,.6);
  border-width: 14px 22px; border-image: url(assets/img/ui/ui_btn_brass.png) 14 26 fill / 14px 22px stretch;
}
.act.ring.wisp { filter: drop-shadow(0 0 10px rgba(143, 240, 208, .7)); }
.act.ring img { width: 36px; height: 36px; image-rendering: pixelated; }
.act kbd { display: none; font-family: var(--font); text-transform: none; font-size: 17px; letter-spacing: .04em; padding: 0 5px; border: 2px solid rgba(0,0,0,.3); color: inherit; opacity: .75; }
.undo-glyph { font-size: 20px; line-height: 1; }
.keys-hint { display: none; grid-column: 1 / -1; color: var(--dim); font-size: 18px; margin: 0; text-align: center; font-family: var(--font); }
.tour-pulse { animation: tour-pulse 1s ease-in-out infinite; position: relative; z-index: 85; }
@keyframes tour-pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.45) drop-shadow(0 0 10px rgba(255,220,140,.9)); } }

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .top-stack { left: 14px; right: 324px; top: 12px; }
  .hud-beats { display: block; }
  .controls {
    left: auto; top: 0; width: 310px; padding: 20px 22px;
    grid-template-columns: 1fr; align-content: center; justify-items: center; gap: 16px;
    background: linear-gradient(to left, rgba(8, 14, 18, .9) 70%, rgba(8, 14, 18, 0));
  }
  .dpad { grid-template-columns: repeat(3, 68px); grid-template-rows: repeat(3, 64px); }
  .actions { width: 100%; }
  .act kbd { display: inline-block; }
  .keys-hint { display: block; }
}
@media (max-width: 560px) {
  .l-long { display: none; }
  .l-short { display: inline; }
  .hud-cell { padding: 2px 5px; }
  .hud-cell b { font-size: 20px; }
  .hud-mission { flex: 2.1 1 0; }
  .hud-mission b { font-size: 18px; white-space: normal; line-height: 1; }
  .hud-odds, .hud-next { flex: .9 1 0; }
  .skin-panel { border-width: 20px; border-image-width: 20px; }
}
@media (max-width: 380px) {
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 50px); }
}
@media (max-height: 700px) and (max-width: 899px) {
  .dpad { grid-template-rows: repeat(3, 46px); }
  .act.ring { min-height: 62px; }
  .controls { padding-top: 12px; }
}

/* ---------- modals ---------- */
#modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(6, 12, 16, .72); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(14px + var(--safe-t)) 12px calc(24px + var(--safe-b)); animation: fadein .2s ease-out;
}
@keyframes fadein { from { opacity: 0; } }
.sheet { width: 100%; max-width: 480px; margin: auto 0; display: flex; flex-direction: column; gap: 10px; animation: rise .28s cubic-bezier(.2,1.3,.4,1); }
.sheet.wide { max-width: 760px; }
@keyframes rise { from { transform: translateY(18px) scale(.97); opacity: 0; } }
.card { padding: 4px 6px; }
.card h2 { font-size: 38px; margin: 2px 0 6px; color: #fff1d2; text-shadow: 0 3px 0 rgba(0,0,0,.5); }
.card h3 { font-size: 27px; margin: 0 0 6px; }
.card p { margin: 6px 0; }
.card hr { border: 0; border-top: 2px dashed rgba(234,220,182,.2); margin: 12px 0; }
.card .stack { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.card.paper h2, .card.paper h3 { color: #2a2418; text-shadow: none; }
.card.paper .muted { color: #6a5d45; }
.card.paper .label { color: #8a4d1c; }
.card.paper hr { border-top-color: rgba(42,36,24,.25); }
.meta { font-family: var(--label); color: var(--cream); font-size: 13px; }
.odds-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.odds-table td { padding: 7px 4px; border-top: 2px dashed rgba(234,220,182,.16); vertical-align: middle; }
.odds-table td:first-child { font-weight: 400; font-size: 30px; color: var(--brass); width: 76px; text-shadow: 0 2px 0 #000; }
.odds-table tr.active td { background: rgba(235,168,79,.1); }
.odds-table tr.dim td { opacity: .45; }
.tin-preview { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; }
.tin-preview img { width: 76px; height: 76px; object-fit: contain; image-rendering: pixelated; }
.switch { display: inline-flex; border: 3px solid #0d1418; box-shadow: 0 0 0 2px #b98a3e; }
.switch button { padding: 6px 16px; min-width: 64px; font-weight: 400; color: var(--muted); background: #1a2a31; }
.switch button.on { background: var(--storm); color: #0e2427; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 4px; }
.schematic { display: block; width: 100%; max-width: 300px; margin: 8px auto 2px; border: 3px solid #0d1418; box-shadow: 0 0 0 2px #b98a3e; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 18px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px; }
.legend .lp { background: #9a4f1d; transform: rotate(45deg) scale(.8); }
.legend .lc { background: #2c6a6a; border-radius: 50%; }
.legend .lb { background: var(--brass); clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); }
.legend .lw { background: repeating-linear-gradient(135deg, #3f5560 0 3px, #2b3d45 3px 6px); }
.legend .lx { border: 2px dashed var(--copper); }

/* result */
.stamp {
  display: inline-flex; align-items: center; gap: 8px; border: 3px solid var(--brass); color: var(--brass);
  padding: 4px 10px; font-family: var(--label); font-size: 12px; transform: rotate(-3deg); background: rgba(235,168,79,.08);
}
.stamp.anim { animation: stampin .35s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes stampin { from { transform: rotate(-3deg) scale(2.2); opacity: 0; } }
.badge-inline { display: inline-block; }
.tin-stage { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: center; min-height: 104px; }
.tin-stage .tin { width: 100px; height: 100px; object-fit: contain; image-rendering: pixelated; }
.tin.empty { filter: saturate(.2) brightness(.7) contrast(.9); }
.tin.rattle { animation: rattle .12s linear 8; }
@keyframes rattle { 0% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-4px); } 100% { transform: rotate(-8deg); } }
.tin.popped { animation: popt .35s ease-out; }
@keyframes popt { 0% { transform: scale(.8); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.found-icon { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; animation: floatup .6s ease-out both; }
@keyframes floatup { from { transform: translateY(20px) scale(.6); opacity: 0; } }
.reveal { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
.reveal.in { opacity: 1; transform: none; }
.signature { display: flex; align-items: center; gap: 12px; transform: rotate(-.6deg); }
.signature svg { flex: none; }
.signature.missed { color: #a2432a; }
.story-art { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; image-rendering: pixelated; border: 3px solid #0d1418; box-shadow: 0 0 0 2px #b98a3e; }
.story-art.lineup { aspect-ratio: 2 / 1; object-fit: contain; background: #1f3743; }
.story-text { font-size: 23px; color: #ffe2b0; text-shadow: 0 2px 0 #000; }

/* shelf */
.shelf { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.shelf-slot { text-align: center; padding: 8px; background: rgba(10,18,22,.35); border: 2px dashed rgba(234,220,182,.2); }
.shelf-slot img { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; display: block; margin: 0 auto 6px; }
.shelf-slot b { display: block; }
.shelf-slot p { font-size: 18px; color: var(--muted); margin: 4px 0 0; }

/* help */
.rules-list { margin: 8px 0 0; padding-left: 18px; }
.rules-list li { margin: 4px 0; }
.controls-table { width: 100%; border-collapse: collapse; font-size: 20px; margin-top: 8px; }
.controls-table th { font-family: var(--label); font-size: 10px; color: var(--storm); text-align: left; padding: 4px; font-weight: 400; }
.controls-table td { border-top: 2px dashed rgba(234,220,182,.16); padding: 6px 4px; }
.callout { background: rgba(100, 188, 183, .14); border-left: 4px solid var(--storm); padding: 8px 10px; font-weight: 400; margin: 10px 0; }

/* ---------- guided tour ---------- */
#tour-root { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
#tour-root:empty { display: none; }
.tour-dim { position: absolute; inset: 0; background: rgba(6, 12, 16, .62); }
.tour-spot {
  position: absolute; border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(6, 12, 16, .62), 0 0 0 3px #ffd27a, 0 0 24px 6px rgba(255, 210, 122, .55);
  transition: left .25s, top .25s, width .25s, height .25s; pointer-events: none;
}
.tour-spot.round { border-radius: 50%; }
.tour-card {
  position: absolute; width: min(360px, calc(100vw - 24px)); pointer-events: auto;
  display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; animation: rise .25s ease-out;
}
.tour-card.noface { grid-template-columns: 1fr; }
.tour-card img.face { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.tour-card h3 { font-size: 26px; color: #2a2418; margin: 0 0 2px; }
.tour-card p { margin: 0; font-size: 20px; }
.tour-card .tour-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.tour-card .tour-actions .btn { min-height: 44px; font-size: 21px; }
.tour-card .tour-actions .btn.link { color: #6a5d45; }
.tour-card .tour-step { font-family: var(--label); font-size: 10px; color: #8a4d1c; }
.tour-card .tour-do { color: #7a3e10; font-weight: 400; display: block; margin-top: 4px; }
.tour-card.nudge { animation: nudge .35s ease-in-out; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- parade ---------- */
#screen-parade { background: #0d171c; overflow: hidden; }
.parade-stage { position: absolute; inset: 0; overflow: hidden; }
.parade-world { position: absolute; left: 0; top: 0; transition: transform 1.6s cubic-bezier(.45,0,.25,1); will-change: transform; }
.parade-img { width: 100%; height: 100%; display: block; image-rendering: pixelated; filter: brightness(.5) saturate(.75); transition: filter 2.6s ease; }
.parade-world.dawn .parade-img { filter: brightness(1) saturate(1.05); }
.parade-world.shake .parade-img { animation: shake .3s linear; }
@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-5px, 4px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-3px, 2px); } 80% { transform: translate(2px, -1px); } }
.parade-dawn { position: absolute; inset: 0; background: radial-gradient(circle at 66% 22%, rgba(255, 214, 140, .55), transparent 40%); opacity: 0; transition: opacity 2.6s; pointer-events: none; }
.parade-world.dawn .parade-dawn { opacity: 1; }
.parade-cards { position: absolute; inset: 0; pointer-events: none; }
.tcard {
  position: absolute; width: 96px; height: 124px; padding: 0; font-size: 10px; font-family: var(--label); text-align: center;
  border: 10px solid transparent; border-image: url(assets/img/ui/ui_paper.png) 22 fill / 10px stretch; image-rendering: pixelated; color: #2a2418;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.45));
  transition: left .9s cubic-bezier(.5,0,.3,1), top .9s cubic-bezier(.5,0,.3,1), transform .9s;
}
.tcard img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; display: block; margin: 2px auto; }
.tcard b { display: block; font-family: var(--font); font-size: 16px; line-height: 1; }
.tcard .bootprint { position: absolute; right: -4px; bottom: -6px; width: 40px; height: 46px; opacity: 0; transition: opacity .1s; transform: rotate(-14deg); }
.tcard .bootprint svg { width: 100%; height: 100%; }
.tcard.stamped .bootprint { opacity: .82; }
.parade-caption { position: absolute; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); text-align: center; width: min(92vw, 640px); }
.parade-caption h2 { font-size: clamp(36px, 6vw, 60px); text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,.8); }
.parade-caption p { font-size: clamp(21px, 2.8vw, 27px); margin: 6px 0 0; color: #ffe9c4; text-shadow: 0 2px 0 #000; }
.parade-actions { position: absolute; left: 0; right: 0; bottom: calc(22px + var(--safe-b)); display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 0 16px; }

/* debug */
.debug { position: fixed; right: 8px; bottom: 8px; z-index: 90; background: rgba(15, 25, 30, .95); border: 2px solid var(--copper); padding: 8px; font: 12px var(--label); display: flex; flex-direction: column; gap: 4px; max-width: 220px; }
.debug button { font: 11px var(--label); padding: 4px 6px; background: #22343c; border: 1px solid #3e5560; color: var(--ink); text-align: left; }
.debug .on { background: var(--copper); color: #111; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
