/* Last Train Home: styles. No inline styles anywhere (CSP style-src 'self'). */
:root {
  --ink: #e9e4d8;
  --muted: #a7a9b4;
  --dim: #6f7484;
  --amber: #f2c46b;
  --amber-deep: #c99540;
  --night: #07090f;
  --card: rgba(12, 15, 24, 0.86);
  --line: rgba(233, 228, 216, 0.14);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); font-family: var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { position: fixed; inset: 0; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#scene.dragging { cursor: grabbing; }
#scene.can-use { cursor: pointer; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
kbd { font-family: var(--sans); font-size: 0.8em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--ink); }

.vignette-fx { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%); }

/* Screens and cards */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); z-index: 20; }
#loading { background: var(--night); }
#title { background: radial-gradient(ellipse at 50% 40%, rgba(7,9,15,0.35), rgba(7,9,15,0.82)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 30px; max-width: 520px; width: 100%; box-shadow: 0 30px 80px rgba(0,0,0,0.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.loading-card { text-align: center; background: transparent; border: 0; box-shadow: none; }
.brand { font-family: var(--serif); font-size: 26px; letter-spacing: 0.02em; color: var(--amber); }
.muted { color: var(--muted); }
.kicker { text-transform: uppercase; letter-spacing: 0.18em; font-size: 12px; color: var(--amber); opacity: 0.9; }
.title-card h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 7vw, 52px); margin: 8px 0 10px; line-height: 1.05; }
.tagline { color: var(--muted); line-height: 1.55; margin: 0 0 22px; font-size: 16px; }
button.primary { background: var(--amber); color: #1a1408; border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 600; cursor: pointer; }
button.primary:hover { background: #f6d084; }
button.primary.big { font-size: 18px; padding: 15px 30px; width: 100%; }
button.primary:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.title-opts { display: flex; gap: 20px; justify-content: center; margin: 16px 0 6px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink); }
.check input { accent-color: var(--amber); width: 18px; height: 18px; }
.how { list-style: none; padding: 0; margin: 14px 0 0; color: var(--dim); font-size: 13px; line-height: 1.8; text-align: center; }
.touch-only { display: none; }
html.touch .touch-only { display: inline; }
html.touch li.touch-only { display: list-item; }
html.touch .desktop-only { display: none; }

/* HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { pointer-events: auto; }
.hud-top-left { position: absolute; top: calc(14px + var(--sat)); left: calc(16px + var(--sal)); font-size: 13px; color: var(--muted); text-shadow: 0 1px 3px rgba(0,0,0,0.8); pointer-events: none; }
.service { font-family: var(--serif); color: var(--ink); font-size: 16px; margin-bottom: 3px; }
.next .lbl { text-transform: uppercase; letter-spacing: 0.14em; font-size: 10px; color: var(--amber); margin-right: 4px; }
.next .t { color: var(--dim); margin-left: 4px; }
.hud-top-right { position: absolute; top: calc(10px + var(--sat)); right: calc(12px + var(--sar)); display: flex; align-items: center; gap: 6px; }
.clock { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--amber); margin-right: 6px; text-shadow: 0 0 8px rgba(242,196,107,0.35); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(10,12,20,0.55); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; color: var(--ink); }
.icon-btn:hover { background: rgba(30,34,48,0.75); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.small { width: 32px; height: 32px; }
#btn-mute .cross { display: none; }
#btn-mute.muted .cross { display: inline; }
#btn-mute.muted .wave { display: none; }

.hud-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--sab)); display: flex; align-items: center; gap: 10px; }
.seat-btn { width: 46px; height: 46px; }
.seat-label { min-width: 170px; text-align: center; display: flex; flex-direction: column; font-size: 14px; color: var(--ink); text-shadow: 0 1px 3px rgba(0,0,0,0.9); pointer-events: none; }
.seat-label small { color: var(--dim); font-size: 11px; margin-top: 2px; }

.caption { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--sab)); width: min(640px, calc(100% - 32px)); background: rgba(6,8,14,0.78); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; font-size: 15px; line-height: 1.45; pointer-events: none; transition: opacity 0.5s; }
.caption.fade { opacity: 0; }
.caption .who { display: block; text-transform: uppercase; letter-spacing: 0.16em; font-size: 10px; color: var(--amber); margin-bottom: 3px; }
.prompt { position: absolute; left: 50%; top: 58%; transform: translate(-50%, 0); font-size: 13px; color: var(--ink); background: rgba(6,8,14,0.6); border-radius: 999px; padding: 5px 12px; pointer-events: none; white-space: nowrap; }

/* Story card */
.story { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(4,5,9,0.55); padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); }
.story-card { background: #f1ece0; color: #22201b; border-radius: 6px; max-width: 460px; width: 100%; max-height: 100%; overflow-y: auto; padding: 24px 26px 20px; box-shadow: 0 24px 70px rgba(0,0,0,0.6); font-family: var(--serif); }
.story-kicker { font-family: var(--sans); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: #8a6a2c; }
.story-card h2 { font-weight: 400; font-size: 26px; margin: 6px 0 12px; }
.story-body p { line-height: 1.6; margin: 0 0 12px; font-size: 16.5px; }
.story-body .aside { font-family: var(--sans); font-size: 13px; color: #6b6458; }
.story-card button.quiet { margin-top: 6px; background: transparent; border: 1px solid rgba(34,32,27,0.3); border-radius: 999px; padding: 9px 18px; cursor: pointer; font-family: var(--sans); color: #22201b; }
.story-card button.quiet:hover { background: rgba(34,32,27,0.06); }
/* story props */
.paper { border: 1px solid #c9c0ad; background: #e8e1cf; padding: 10px 12px; margin: 0 0 14px; }
.paper .mast { font-family: var(--serif); font-weight: 700; font-size: 20px; border-bottom: 2px solid #22201b; padding-bottom: 3px; margin-bottom: 6px; }
.paper .head { font-weight: 700; font-size: 15px; margin: 4px 0; }
.paper .clue { font-family: var(--sans); font-size: 13px; }
.paper .grid { display: inline-flex; gap: 2px; margin-left: 6px; vertical-align: middle; }
.paper .grid span { width: 18px; height: 18px; border: 1px solid #22201b; background: #fff; display: inline-block; text-align: center; font-size: 13px; line-height: 17px; font-family: var(--sans); }
.lock { background: linear-gradient(180deg, #1a2238, #0c1020); color: #eef; border-radius: 22px; padding: 18px 14px 14px; margin: 0 0 14px; font-family: var(--sans); }
.lock .time { font-size: 40px; font-weight: 300; text-align: center; letter-spacing: 0.02em; }
.lock .date { font-size: 12px; text-align: center; opacity: 0.7; margin-bottom: 12px; }
.lock .note { background: rgba(255,255,255,0.12); border-radius: 12px; padding: 8px 10px; margin-top: 6px; font-size: 13px; }
.lock .note b { display: block; font-size: 12px; opacity: 0.85; }
.napkin { background: #fffdf6; border: 1px dashed #cfc6b2; padding: 14px; margin: 0 0 14px; transform: rotate(-1.2deg); font-family: "Bradley Hand", "Segoe Print", "Comic Neue", cursive; font-size: 18px; line-height: 1.5; color: #2b3a6b; }

/* Settings panel */
.panel { position: fixed; z-index: 25; top: calc(10px + var(--sat)); right: calc(10px + var(--sar)); width: min(340px, calc(100% - 20px)); max-height: calc(100% - 20px - var(--sat) - var(--sab)); overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.panel-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--serif); font-size: 18px; margin-bottom: 8px; }
.panel .row { display: flex; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel .row small { color: var(--dim); font-size: 12px; width: 100%; padding-left: 26px; margin-top: -4px; }
.panel .slider input { flex: 1; accent-color: var(--amber); }
.panel .lbl { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 6px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--amber); color: #1a1408; }
.panel .actions button { background: transparent; border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.small-print { color: var(--dim); font-size: 12px !important; }

/* End card */
.end { background: radial-gradient(ellipse at 50% 45%, rgba(7,9,15,0.25), rgba(7,9,15,0.9)); opacity: 0; transition: opacity 2.5s ease; }
.end.show { opacity: 1; }
.end-card { text-align: center; background: rgba(9,11,18,0.72); }
.end-card h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 9vw, 64px); margin: 8px 0 6px; }
.end-line { color: var(--muted); line-height: 1.55; margin: 0 0 18px; }
.end-stories { text-align: left; font-size: 14px; color: var(--muted); margin: 0 auto 20px; max-width: 360px; line-height: 1.7; }
.end-stories .found { color: var(--ink); }
.end-stories .found::before { content: "●  "; color: var(--amber); }
.end-stories .missed::before { content: "○  "; color: var(--dim); }
.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.end-actions button:not(.primary) { background: transparent; border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 12px 20px; cursor: pointer; }
.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink); }

@media (max-width: 560px) {
  .card { padding: 22px 20px; }
  .tagline { font-size: 15px; }
  .hud-top-left { font-size: 12px; }
  .service { font-size: 14px; }
  .clock { display: none; }
  .caption { font-size: 14px; bottom: calc(80px + var(--sab)); }
  .seat-label { min-width: 140px; font-size: 13px; }
}
@media (max-height: 500px) {
  .title-card { padding: 16px 20px; }
  .title-card h1 { font-size: 30px; margin: 4px 0 6px; }
  .tagline { margin-bottom: 12px; font-size: 14px; }
  .how { display: none; }
  .caption { bottom: calc(66px + var(--sab)); }
}
@media (prefers-reduced-motion: reduce) {
  .end { transition: none; }
}
