/* Midnight Ride: Lantern Run's paper, ink, Delft blue and lantern gold, over a pinball cabinet. */
:root {
  --paper: #efe6d2; --paper-2: #e2d6bb; --ink: #17233a; --ink-2: #2b3a58; --delft: #2b4f86; --delft-2: #5b7fb6; --mist: #c9d7ea;
  --gold: #e9b54a; --gold-2: #ffd77a; --red: #a8352a; --night: #0b1424;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--paper); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--gold-2); }
#app-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.eyebrow { margin: 0 0 .4rem; font-size: .72rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; color: var(--delft-2); }
.micro { font-size: .64rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; color: var(--mist); opacity: .85; }
.gold { color: var(--gold); }

/* the loader, in this machine's colours */
.mr-boot { --tl-bg: #0b1424; --tl-bg-2: #1c3360; --tl-ink: #efe6d2; --tl-muted: #93a6c8; --tl-line: #2b3a58; --tl-accent: #ffd77a; --tl-accent-2: #a8352a; --tl-lamp: #ffb84a; --tl-bad: #ff6a4d; font-family: var(--serif); }
.mr-boot h1 { font-family: var(--serif); font-weight: 700; letter-spacing: -1px; font-stretch: normal; }
.mr-boot h1 em { letter-spacing: 0; }
.mr-boot .tl-field .steeple { fill: #0b1424; stroke: #93a6c8; stroke-width: 1.5; }
.mr-boot .tl-field .lantern { fill: #ffb84a; opacity: .25; animation: mr-lantern 2.4s ease-in-out infinite; }
.mr-boot .tl-field .lantern.l2 { animation-delay: 1.2s; }
.mr-boot .tl-field .ramp { fill: none; stroke: #5b7fb6; stroke-width: 3; stroke-linecap: round; opacity: .7; }
@keyframes mr-lantern { 0%, 100% { opacity: .2; } 50% { opacity: 1; filter: drop-shadow(0 0 4px #ffb84a); } }

/* buttons, as in Lantern Run: brush strokes */
.btn { position: relative; min-height: 46px; padding: 0 20px; border: 0; border-radius: 4px 14px 5px 12px / 12px 5px 14px 4px; cursor: pointer;
  background: rgba(23, 35, 58, .78); color: var(--paper); font: 650 1rem var(--sans); letter-spacing: .02em;
  box-shadow: inset 0 0 0 1.5px rgba(239, 230, 210, .35), 0 3px 0 rgba(0,0,0,.25); transition: transform .12s, background .12s; }
.btn:hover, .btn:focus-visible { background: rgba(43, 79, 134, .9); outline: none; transform: translateY(-1px) rotate(-.4deg); }
.btn.primary { background: linear-gradient(100deg, #d79a32, var(--gold) 40%, #f3c862); color: #24170a; box-shadow: inset 0 0 0 1.5px rgba(36,23,10,.35), 0 3px 0 #7a5418, 0 0 24px rgba(255, 200, 90, .25); }
.btn.primary:hover, .btn.primary:focus-visible { background: linear-gradient(100deg, #e3a83c, #ffd77a); }
.btn.ghost { background: rgba(11, 20, 36, .4); box-shadow: inset 0 0 0 1.5px rgba(239,230,210,.25); }
.chip { min-width: 40px; min-height: 40px; border: 0; border-radius: 50%; background: rgba(11, 20, 36, .66); color: var(--paper); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(239,230,210,.3); font-size: 1rem; }
.chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.chip:focus-visible { outline: 2px solid var(--gold); }

/* top bar */
.topbar { position: fixed; z-index: 20; top: calc(var(--st) + 10px); left: calc(var(--sl) + 12px); right: calc(var(--sr) + 12px); display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--paper); font: 700 .95rem var(--serif); letter-spacing: .12em; padding: 6px 12px; border-radius: 999px; background: rgba(11, 20, 36, .55); }
.brand .edition { color: var(--gold); font-weight: 600; }
.brand-lantern { width: 10px; height: 14px; border-radius: 3px 3px 4px 4px; background: radial-gradient(circle at 50% 60%, #fff3c0, #ffb84a 45%, #a8601a); box-shadow: 0 0 10px #ffb84a; }
.top-actions { display: flex; gap: 8px; }
body[data-screen="loading"] .topbar { display: none; }

/* screens */
.screen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: end start; padding: calc(var(--st) + 64px) calc(var(--sr) + 16px) calc(var(--sb) + 18px) calc(var(--sl) + 16px); overflow-y: auto; pointer-events: none; }
.screen > * { pointer-events: auto; }
.intro-card { width: min(560px, 100%); padding: 22px 22px 18px; border-radius: 6px 18px 8px 16px / 16px 8px 18px 6px; color: var(--paper);
  background: linear-gradient(160deg, rgba(23, 35, 58, .9), rgba(11, 20, 36, .82)); box-shadow: 0 0 0 1.5px rgba(233, 181, 74, .45), 6px 8px 0 rgba(0,0,0,.3), 0 30px 80px rgba(0,0,0,.45); backdrop-filter: blur(6px); }
.intro-card h1 { margin: 0 0 .5rem; font: 700 clamp(2.4rem, 7vw, 3.6rem)/0.95 var(--serif); letter-spacing: -.01em; color: var(--paper); }
.intro-card h1 em { color: var(--gold); }
.intro-copy { margin: 0 0 1rem; font: 1.02rem/1.45 var(--serif); color: var(--mist); }
.stable { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: .55rem; }
.horse { display: grid; grid-template-columns: 22px 1fr; grid-template-rows: auto auto; gap: 0 8px; align-items: center; text-align: left; padding: 7px 8px; min-height: 52px; border: 0; border-radius: 8px; cursor: pointer; background: rgba(11, 20, 36, .55); box-shadow: inset 0 0 0 1px rgba(239,230,210,.18); }
.horse i { grid-row: span 2; width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--coat) 70%, white), var(--coat)); box-shadow: inset -3px -2px 0 var(--mane); }
.horse span { font: 700 .86rem var(--serif); }
.horse small { font-size: .66rem; line-height: 1.2; color: var(--mist); opacity: .85; }
.horse.is-on { background: rgba(43, 79, 134, .75); box-shadow: inset 0 0 0 2px var(--gold); }
.horse.is-locked { opacity: .55; cursor: default; }
.horse:focus-visible { outline: 2px solid var(--gold); }
.horse-perk { margin: 0 0 .9rem; font-size: .86rem; color: var(--mist); min-height: 1.2em; }
.intro-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.intro-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: .9rem; font-size: .78rem; color: var(--mist); }
.intro-meta strong { color: var(--gold-2); font-family: var(--serif); }

/* HUD */
.hud { position: fixed; z-index: 12; left: calc(var(--sl) + 12px); top: calc(var(--st) + 62px); display: grid; gap: 8px; width: min(300px, calc(100vw - 24px)); pointer-events: none; }
.hud-score { display: grid; grid-template-columns: 1fr auto; padding: 8px 12px; border-radius: 10px; background: rgba(11, 20, 36, .62); box-shadow: inset 0 0 0 1px rgba(233,181,74,.35); }
.hud-score .micro { grid-column: 1 / -1; }
.hud-score strong { font: 700 1.7rem/1.1 var(--serif); color: var(--gold-2); font-variant-numeric: tabular-nums; }
.hud-ball { align-self: end; font-size: .8rem; color: var(--mist); }
.hud-ride { display: grid; gap: 2px; padding: 8px 12px 10px; border-radius: 10px; background: rgba(23, 35, 58, .78); box-shadow: inset 0 0 0 1.5px rgba(255, 215, 122, .6), 0 0 20px rgba(255, 190, 80, .2); }
.hud-ride strong { font: 700 1.1rem var(--serif); color: var(--paper); }
.hud-ride > span { font-size: .78rem; color: var(--mist); }
.ride-bar, .meter { height: 6px; border-radius: 3px; background: rgba(239,230,210,.15); overflow: hidden; }
.ride-bar i, .meter i { display: block; height: 100%; background: linear-gradient(90deg, #d79a32, var(--gold-2)); transform-origin: left; transform: scaleX(0); transition: transform .15s linear; }
.ride-hits { justify-self: end; font: 700 .9rem var(--serif) !important; color: var(--gold-2) !important; }
.hud-meters { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--mist); padding: 0 4px; }
#hud-tags { grid-column: 1 / -1; font: 700 .72rem var(--sans); color: var(--gold-2); letter-spacing: .08em; text-shadow: 0 1px 2px #000; }

.toasts { position: fixed; z-index: 13; right: calc(var(--sr) + 14px); top: calc(var(--st) + 64px); display: grid; gap: 6px; justify-items: end; pointer-events: none; }
.toast { padding: 6px 12px; border-radius: 4px 12px 5px 10px; background: rgba(11, 20, 36, .78); color: var(--paper); font: 650 .9rem var(--serif); box-shadow: inset 0 0 0 1px rgba(239,230,210,.25); transition: opacity .5s, transform .5s; }
.toast.big, .toast.combo, .toast.lock { color: #24170a; background: linear-gradient(100deg, #d79a32, var(--gold-2)); }
.toast.jackpot { color: #fff; background: linear-gradient(100deg, #8a1f16, #c7402a); box-shadow: 0 0 22px rgba(255, 90, 60, .45); }
.toast.ride { background: rgba(43, 79, 134, .9); }
.toast.warn { background: rgba(168, 53, 42, .92); }
.toast.is-gone { opacity: 0; transform: translateX(20px); }

.callout { position: fixed; z-index: 14; left: 50%; top: 30%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 2px; text-align: center; pointer-events: none; width: min(92vw, 640px); }
.callout span { font: 750 .78rem var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--mist); text-shadow: 0 1px 3px #000; }
.callout strong { font: 700 clamp(2rem, 7vw, 3.6rem)/1 var(--serif); color: var(--gold-2); text-shadow: 0 2px 0 #4a2e0a, 0 0 30px rgba(255, 190, 80, .55), 0 4px 18px rgba(0,0,0,.8); }
.callout em { font: italic 1.05rem var(--serif); color: var(--paper); text-shadow: 0 1px 4px #000; }
.callout.is-in { animation: mr-callout 2.2s ease-out both; }
@keyframes mr-callout { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.9) rotate(-1deg); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); } 20% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

.cannon-hint { position: fixed; z-index: 14; left: 50%; bottom: calc(var(--sb) + 112px); transform: translateX(-50%); padding: 10px 18px; border-radius: 6px 16px 8px 14px; background: rgba(168, 53, 42, .92); color: #fff; font: 700 1.1rem var(--serif); text-align: center; box-shadow: 0 0 24px rgba(255, 100, 60, .4); animation: mr-pulse .5s ease-in-out infinite alternate; pointer-events: none; }
.cannon-hint span { display: block; font: 500 .78rem var(--sans); opacity: .85; }
@keyframes mr-pulse { to { transform: translateX(-50%) scale(1.05); } }

.ride-select { position: fixed; z-index: 15; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 24px)); padding: 16px; border-radius: 6px 18px 8px 16px / 16px 8px 18px 6px; background: var(--paper); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 6px 8px 0 rgba(0,0,0,.35); }
.ride-select .eyebrow { color: var(--delft); }
#ride-options { display: grid; gap: 6px; }
.ride-opt { display: grid; padding: 8px 12px; border-radius: 8px; background: rgba(23, 35, 58, .06); }
.ride-opt b { font: 700 1.15rem var(--serif); } .ride-opt span { font: italic .9rem var(--serif); color: var(--ink-2); } .ride-opt em { font-style: normal; font-size: .82rem; color: var(--ink-2); }
.ride-opt.is-on { background: var(--ink); color: var(--paper); box-shadow: 0 0 0 2px var(--gold); } .ride-opt.is-on span, .ride-opt.is-on em { color: var(--mist); }

.bonus { position: fixed; z-index: 15; left: 50%; top: 46%; transform: translate(-50%, -50%); width: min(380px, calc(100vw - 24px)); padding: 16px 18px; border-radius: 6px 18px 8px 16px; background: rgba(11, 20, 36, .92); box-shadow: 0 0 0 1.5px var(--gold); }
#bonus-list { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: 4px; }
#bonus-list li { display: flex; justify-content: space-between; font: 1rem var(--serif); animation: mr-in .3s ease-out both; }
#bonus-list b { color: var(--gold-2); }
.bonus-total { margin: 0; text-align: right; font: 700 1.2rem var(--serif); } .bonus-total strong { color: var(--gold-2); font-size: 1.5rem; }
@keyframes mr-in { from { opacity: 0; transform: translateX(-10px); } }

/* touch pads */
.controls { position: fixed; z-index: 16; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr minmax(96px, 22vw) 1fr; gap: 8px; padding: 8px calc(var(--sr) + 8px) calc(var(--sb) + 8px) calc(var(--sl) + 8px); pointer-events: none; }
.pad { pointer-events: auto; min-height: 84px; border: 0; border-radius: 12px; background: rgba(11, 20, 36, .28); color: var(--paper); display: grid; place-items: center; align-content: center; gap: 2px; font: 700 1.4rem var(--serif); touch-action: none; box-shadow: inset 0 0 0 1px rgba(239,230,210,.14); opacity: .55; transition: opacity .2s, background .1s; }
.pad kbd { font: 600 .62rem var(--sans); letter-spacing: .12em; opacity: .75; }
.pad.is-down { background: rgba(233, 181, 74, .35); opacity: .9; }
.pad-c b { font: 700 .8rem var(--sans); letter-spacing: .14em; }
.pad .charge { width: 70%; height: 5px; border-radius: 3px; background: rgba(239,230,210,.2); overflow: hidden; }
.pad .charge i { display: block; height: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); }
@media (pointer: fine) { .controls { opacity: 0; pointer-events: none; } .controls .pad { pointer-events: none; } }

/* modal sheet: torn paper with an ink edge */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: calc(var(--st) + 16px) 16px calc(var(--sb) + 16px); background: rgba(5, 9, 18, .55); overflow-y: auto; }
.sheet { position: relative; width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 22px 24px 20px; color: var(--ink);
  background: var(--paper) linear-gradient(135deg, rgba(255,255,255,.35), rgba(120,90,40,.08));
  border-radius: 6px 18px 8px 16px / 16px 8px 18px 6px; box-shadow: 0 0 0 2px rgba(23,35,58,.85), 6px 8px 0 rgba(0,0,0,.35), 0 30px 80px rgba(0,0,0,.45); }
.sheet h2 { margin: 0 0 .7rem; font: 600 clamp(1.6rem, 4vw, 2.2rem)/1.05 var(--serif); }
.sheet h3 { font: 600 1.15rem var(--serif); margin: 1rem 0 .4rem; }
.sheet .eyebrow { color: var(--delft); }
.sheet p, .sheet li { font: 1rem/1.45 var(--serif); }
.sheet .btn { color: var(--paper); }
.sheet .btn.primary { color: #24170a; }
.close { position: absolute; top: 8px; right: 10px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); font-size: 1.6rem; cursor: pointer; }
.menu.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1rem; }
.rules { padding-left: 1.1rem; margin: 0; display: grid; gap: .5rem; }
.settings { display: grid; gap: .5rem; }
.check, .range { display: flex; align-items: center; gap: .6rem; font: 1rem var(--serif); min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--delft); }
.range input { flex: 1; accent-color: var(--delft); }
.map-list { list-style: none; padding: 0; margin: .4rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.map-list li { display: grid; padding: 7px 10px; border-radius: 8px; background: rgba(23,35,58,.06); box-shadow: inset 0 0 0 1px rgba(23,35,58,.12); font-size: .9rem; }
.map-list li b { font: 700 .95rem var(--serif); } .map-list li span { font-size: .8rem; color: var(--ink-2); } .map-list li em { font-size: .78rem; color: var(--ink-2); opacity: .8; }
.map-list li.is-done { background: rgba(233, 181, 74, .28); box-shadow: inset 0 0 0 1.5px var(--gold); }
.map-list li.is-done b::before { content: '◆ '; color: #b37a1c; }
.map-list li.is-locked { opacity: .5; }
.results-line { font-size: 1.05rem; }
.results-best { color: var(--ink-2); }

/* inspect mode */
body[data-screen="inspect"] .intro, body[data-screen="inspect"] .hud { display: none; }
#inspect-back { position: fixed; z-index: 20; left: 50%; bottom: calc(var(--sb) + 20px); transform: translateX(-50%); }

@media (max-width: 640px) {
  .screen { place-items: end center; padding-top: calc(var(--st) + 56px); }
  .intro-card { padding: 16px; }
  .stable { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud { top: calc(var(--st) + 56px); width: min(240px, 62vw); }
  .hud-score strong { font-size: 1.35rem; }
  .hud-ride > span:not(.ride-hits) { display: none; }
  .toasts { top: auto; bottom: calc(var(--sb) + 104px); }
  .brand { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) { .callout.is-in, .cannon-hint, .mr-boot .tl-field .lantern { animation: none; } }

/* the way back to TiltLab, on the title card */
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* the Feel button makes four in the top bar: on a phone the edition number gives way */
@media (max-width: 440px) { .brand .edition { display: none; } .brand { white-space: nowrap; } }
@media (max-width: 380px) { .top-actions { gap: 5px; } .top-actions .chip { min-width: 36px; min-height: 36px; font-size: .9rem; } .brand { padding: 4px 10px; } }
