:root {
  --fs: 1; --card: #f5f0e8; --ink: #17120f; --hud: #0e0b0d;
  --disp: 'Caveat Brush', 'Geist', system-ui, sans-serif; --ui: 'Geist', system-ui, sans-serif;
  --rough: 120px 10px 100px 10px / 10px 100px 10px 120px; --drop: 3px 3px 0 rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: #0e0b0d; }
body { font-family: var(--ui); line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }

/* The city stands on a wall painted in the era's colour. Set in JS per era:
   --p ground, --s text on it, --a accent, --on-a text on the accent, --hi accent that is readable on the ground, --bar stat bars.
   One rule for the player: cream paper with a dark edge can be tapped. Everything else is for reading. */
#app {
  --p: #8f1d1f; --s: #f5f0e8; --a: #f6cf1f; --on-a: #17120f; --hi: #f6cf1f; --bar: #f6cf1f; --hud-h: 0px;
  position: fixed; inset: 0; height: 100dvh; overflow: hidden; color: var(--s); background: var(--p);
  font-size: calc(clamp(14px, 2.05dvh, 16.5px) * var(--fs));
}
#app[data-contrast="high"] { --p: #000 !important; --s: #fff !important; --a: #ffd400 !important; --on-a: #000 !important; --hi: #ffd400 !important; --bar: #ffd400 !important; --card: #fff; --ink: #000; }
.map, .map canvas, .pins, .room { position: absolute; inset: 0; width: 100%; height: 100%; }
.map canvas { display: block; touch-action: none; cursor: grab; }
.map canvas.drag { cursor: grabbing; }
.pins { pointer-events: none; overflow: hidden; }
/* The inside of a place fades in over the city once the map has flown to the building. */
.room { opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility 0s .35s; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--sea, #5aa9d6) 82%, #fff), var(--sea, #5aa9d6) 70%); }
.room.on { opacity: 1; visibility: visible; transition: opacity .4s ease .5s; }
.room canvas { cursor: ew-resize; }

.paper { background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--rough); box-shadow: var(--drop); }
.pin { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; will-change: transform; }
.pin-tag { display: flex; align-items: center; gap: 6px; max-width: 176px; padding: 4px 10px 4px 7px; font-size: 12.5px; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.pin-tag span { overflow: hidden; text-overflow: ellipsis; }
.pin-tag svg { flex: none; width: 16px; height: 16px; }
.pin::after { content: ''; width: 3px; height: 16px; background: var(--ink); }
#app[data-motion="on"] .pin-tag { animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.pin:focus-visible .pin-tag, .choice:focus-visible, .place:focus-visible, .btn:focus-visible, .tab:focus-visible { outline: 3px solid var(--a); outline-offset: 2px; }

/* Top bar: where you are in the life, and the four stats by their full names. Nothing here is a button except the two tabs. */
.hud { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; flex-direction: column; gap: 6px; padding: calc(7px + env(safe-area-inset-top)) 12px 9px; background: var(--hud); color: #f5f0e8; border-bottom: 2px solid var(--bar); }
.hud-top { display: flex; align-items: center; gap: 8px; }
.hud-ch { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
.hud-ch b { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--bar); }
.hud-ch span { font-family: var(--disp); font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab { position: relative; flex: none; min-height: 34px; padding: 0 12px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--rough); box-shadow: 2px 2px 0 rgba(255, 255, 255, .28); }
.tab.new::after { content: ''; position: absolute; top: -5px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--bar); border: 2px solid var(--hud); }
.track { display: flex; gap: 3px; }
.track li { flex: 1; height: 4px; background: rgba(255, 255, 255, .18); }
.track li.done { background: var(--bar); }
.track li.now { background: linear-gradient(90deg, var(--bar) 50%, rgba(255, 255, 255, .18) 50%); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.stat { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stat-l { flex: 0 0 9.4em; font-size: 11px; font-weight: 600; white-space: nowrap; }
.stat-b { flex: 1; height: 6px; background: rgba(255, 255, 255, .16); overflow: hidden; }
.stat-b i { display: block; height: 100%; width: 0; background: var(--bar); transition: width .7s ease; }
.stat.flash .stat-l { animation: flash .9s ease-out; }
@keyframes flash { 0%, 60% { color: var(--bar); } }
.recentre { position: absolute; z-index: 5; right: 12px; top: calc(var(--hud-h) + 10px); box-shadow: var(--drop); }

/* The story card. Key information starts at the top left and runs down the left edge. */
.sheet { position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; max-height: 62dvh; display: flex; flex-direction: column; gap: 9px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--p); color: var(--s); border-top: 3px solid var(--a); box-shadow: 0 -10px 28px rgba(0, 0, 0, .35); }
.faces { flex: none; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.faces:empty { display: none; }
.face { display: flex; align-items: center; gap: 8px; min-width: 0; }
.face img { flex: none; width: 56px; height: 56px; object-fit: cover; background: var(--card); border: 3px solid var(--a); box-shadow: var(--drop); }
.face figcaption { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; font-size: 13px; font-weight: 700; line-height: 1.2; }
.face .mood, .chip { padding: 1px 7px; background: var(--a); color: var(--on-a); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.face .mood:empty { display: none; }
#app[data-motion="on"] .face.react img { animation: react .42s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes react { 0% { transform: scale(.78) rotate(-5deg); } 60% { transform: scale(1.12) rotate(2deg); } 100% { transform: none; } }

.body { flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: .4em; }
.body::-webkit-scrollbar { display: none; }
#app[data-motion="on"] .body > *, #app[data-motion="on"] .acts > * { animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.body [data-focus]:focus { outline: none; }
.body .kicker { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; font-size: .78em; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--hi); }
.kicker .where { color: color-mix(in srgb, var(--s) 75%, transparent); font-weight: 600; letter-spacing: .04em; text-transform: none; }
.body h1, .body h2 { font-family: var(--disp); font-weight: 400; line-height: .98; text-wrap: balance; }
.body h1 { font-size: clamp(2.3rem, 11vw, 3.4rem); }
.body h2 { font-size: clamp(1.6rem, 7vw, 2.2rem); }
.body p { text-wrap: pretty; }
.body .lead { font-family: var(--disp); font-size: 1.25em; line-height: 1.1; color: var(--hi); }
.body .fine { font-size: .85em; color: color-mix(in srgb, var(--s) 78%, transparent); }
.body .fine a { color: inherit; }
.body ul.lines { display: flex; flex-direction: column; gap: .45em; }
.body ul.lines li { padding-left: .8em; border-left: 3px solid var(--a); }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-row img { flex: none; width: 104px; height: auto; }
/* What a choice moved. Shown beside the outcome, then it fades. */
.delta { display: flex; flex-wrap: wrap; gap: 5px 6px; }
.delta span { padding: 1px 8px; font-size: .8em; font-weight: 700; background: var(--card); color: var(--ink); }
.delta span.down { background: var(--ink); color: var(--card); }
.delta span.rel { background: var(--a); color: var(--on-a); }
#app[data-motion="on"] .delta span:not(.rel) { animation: fade .6s ease 2.8s forwards; }
@keyframes fade { to { opacity: 0; } }

.acts { flex: none; display: flex; flex-direction: column; gap: 7px; }
/* Every answer looks the same until one is taken. */
.choice, .place { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 3.4em; padding: .45em .8em; text-align: left; cursor: pointer;
  background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--rough); box-shadow: var(--drop); font-size: .96em; font-weight: 500; line-height: 1.25;
  transition: transform .4s ease, opacity .4s ease, background-color .2s, color .2s; }
.choice kbd { flex: none; width: 1.7em; height: 1.7em; display: grid; place-items: center; font: 700 .85em var(--ui); background: var(--ink); color: var(--card); }
@media (hover: hover) { .choice:not([disabled]):hover, .place:hover, .btn:not([disabled]):hover, .tab:hover { filter: brightness(1.06); transform: translate(-1px, -1px); } }
.choice.picked { background: var(--a); color: var(--on-a); border-color: var(--on-a); transform: scale(1.015); box-shadow: none; }
.choice.picked kbd { background: var(--on-a); color: var(--a); }
.choice.gone { opacity: 0; transform: translateX(-28px); }
.choice[disabled] { cursor: default; }
.place svg { flex: none; width: 20px; height: 20px; }
.place-t { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 700; }
.place-t small { font-weight: 500; font-size: .85em; opacity: .75; }
.place[disabled] { opacity: .5; cursor: default; }
.fuse { height: 5px; background: var(--a); transform-origin: left; animation: fuse var(--t) linear both; }
@keyframes fuse { to { transform: scaleX(0); } }

.btn { display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 46px; padding: .4em 1.1em; cursor: pointer; text-decoration: none;
  font-family: var(--disp); font-size: 1.3em; line-height: 1.1; background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--rough); box-shadow: var(--drop); }
.btn small { font: 500 .58em/1.3 var(--ui); opacity: .8; }
.btn.primary { background: var(--a); color: var(--on-a); border-color: var(--on-a); }
.btn.sm { min-height: 36px; font-size: 1.08em; padding: .2em .8em; }
.btn.link { min-height: 40px; padding: 0 .3em; background: none; border: 0; box-shadow: none; color: inherit; font: 600 .9em var(--ui); text-decoration: underline; }
.btn:active, .tab:active, .choice:not([disabled]):active, .place:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .45); }
.btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acts .btn { align-self: stretch; }
.acts .row .btn { flex: 1; }

/* A record takes the middle of the screen in its gilt frame when it comes out. */
.plate { position: absolute; z-index: 4; inset: 0; display: flex; align-items: center; justify-content: center; gap: 2vmin; padding: calc(var(--hud-h) + 10px) calc(var(--ir, 0px) + 10px) calc(var(--ib, 0px) + 10px) 10px; background: color-mix(in srgb, var(--p) 76%, transparent); }
.plate figure { flex: 0 1 auto; min-width: 0; border: 20px solid transparent; border-image: url(/play/img/frame.webp) 118 / 20px round; background: var(--ink); background-clip: padding-box; box-shadow: 0 12px 0 rgba(0, 0, 0, .28); }
.plate img { display: block; width: min(68vw, 40dvh); height: auto; aspect-ratio: 1; object-fit: cover; }
.plate.two img { width: min(36vw, 30dvh); }
.plate .lettered { padding: 14px 22px; text-align: center; background: var(--p); color: var(--s); }
.plate .lettered small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; opacity: .8; }
.plate .lettered b { display: block; max-width: 9em; font: 400 clamp(1.8rem, 8vw, 2.8rem)/1 var(--disp); text-wrap: balance; }
#app[data-motion="on"] .plate figure { animation: hang .55s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes hang { from { opacity: 0; transform: translateY(-26px) rotate(-3deg); } to { opacity: 1; transform: none; } }

.wash { position: fixed; inset: 0; z-index: 30; background: var(--p); opacity: 0; pointer-events: none; }
.wash.go { animation: wash .9s ease both; }
@keyframes wash { 0% { opacity: 0; } 45%, 55% { opacity: 1; } 100% { opacity: 0; } }

/* How to play: the real screen, dimmed, with one thing lit at a time. */
.coach { position: fixed; inset: 0; z-index: 40; }
.coach-hole { position: absolute; border-radius: 6px; box-shadow: 0 0 0 200vmax rgba(10, 6, 8, .8); outline: 3px solid var(--a); outline-offset: 3px; transition: all .25s ease; }
.coach-card { position: absolute; left: 12px; right: 12px; max-width: 430px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 16px 14px; background: var(--card); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--rough); box-shadow: 4px 4px 0 rgba(0, 0, 0, .5); }
.coach-card small { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.coach-card h3 { font: 400 1.7rem/1 var(--disp); outline: none; }
.coach-card p { font-size: 15px; }
.coach-card .tag { align-self: flex-start; padding: 1px 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--ink); color: var(--card); }
.coach-card .row { justify-content: space-between; margin-top: 4px; }
.coach-card .btn.primary { background: var(--ink); color: var(--card); border-color: var(--ink); }

/* Ending: rarity, then the card. */
.end { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5dvh; text-align: center;
  padding: calc(14px + env(safe-area-inset-top)) 18px calc(14px + env(safe-area-inset-bottom)); background: var(--tb, #111); color: var(--tf, #fff); }
#app[data-motion="on"] .end > * { animation: rise .8s ease both; }
.end .stamp { font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; opacity: .6; }
.end .became { font-size: 1.15em; font-weight: 500; }
.end h1 { font-family: var(--disp); font-weight: 400; font-size: clamp(3rem, 15vw, 6rem); line-height: .9; color: var(--ta, #fff); text-wrap: balance; outline: none; }
.end hr { width: min(240px, 60%); border: 0; border-top: 2px solid currentColor; opacity: .5; margin: 0; }
.end .rarity { max-width: 30em; font-size: 1.1em; text-wrap: pretty; }
.end .second, .end .fine { max-width: 30em; font-size: .9em; opacity: .85; text-wrap: pretty; }
.end .fine a { color: inherit; }
.end .line { max-width: 30em; font-family: var(--disp); font-size: 1.2em; line-height: 1.15; text-wrap: balance; }
.end canvas { flex: 0 1 auto; min-height: 0; max-height: 52dvh; width: auto; max-width: 100%; aspect-ratio: 1; }
.end .btn { --a: var(--ta); --on-a: var(--tb); }
.end .row { justify-content: center; }

dialog { width: min(540px, calc(100% - 20px)); max-height: 86dvh; padding: 0; border: 3px solid var(--ink); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(10, 6, 8, .78); }
.dlg-h { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: var(--card); border-bottom: 3px solid var(--ink); }
.dlg-h h2 { font: 400 1.9rem/1 var(--disp); }
.dlg-b { padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: 15px; }
.dlg-b .btn, .dlg-b .place { align-self: stretch; box-shadow: 2px 2px 0 rgba(0, 0, 0, .3); }
.set { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.set input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ink); flex: none; }
.set span { display: flex; flex-direction: column; font-weight: 600; } .set small { font-weight: 400; opacity: .75; }
.set-size { border: 2px solid var(--ink); padding: 8px 12px; display: flex; gap: 6px 16px; flex-wrap: wrap; }
.set-size legend { font-weight: 700; padding: 0 6px; } .set-size label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.jr, .ppl { display: flex; flex-direction: column; gap: 8px; }
.jr li { padding: 8px 10px; border: 2px solid var(--ink); }
.jr li.album { background: var(--ink); color: var(--card); }
.jr li b { display: block; font: 400 1.35rem/1.05 var(--disp); }
.jr li small { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .65; }
.ppl li { display: flex; align-items: center; gap: 12px; padding: 6px; border: 2px solid var(--ink); }
.ppl img { flex: none; width: 54px; height: 54px; object-fit: cover; border: 2px solid var(--ink); }
.ppl b { display: block; font-size: 1rem; }
.ppl .chip { background: var(--ink); color: var(--card); }

/* An email or a name. The field is paper with a dark edge, like everything else that can be used. */
.mail { display: flex; flex-direction: column; gap: 6px; }
.mail label { font-size: .78em; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.mail .row { flex-wrap: nowrap; align-items: stretch; }
.mail input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; font-size: 16px; background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: 0; }
.mail input::placeholder { color: color-mix(in srgb, var(--ink) 55%, transparent); }
.mail input:focus-visible { outline: 3px solid var(--a); outline-offset: 2px; }
.mail .btn { flex: none; }
.mail [data-note]:empty { display: none; }
.note { padding: 5px 10px; border-left: 4px solid var(--a); font-weight: 600; }
dialog .note, dialog .mail input:focus-visible { border-color: var(--ink); outline-color: var(--ink); }
.dlg-b .fine { font-size: .85em; opacity: .8; }
.dlg-b h3 { font: 400 1.5rem/1 var(--disp); }
.dlg-b .btn.link { align-self: flex-start; box-shadow: none; }
.dlg-b .mail .btn, .dlg-b .you .btn { align-self: auto; }

/* The two boards. Rank, movement, name, score: read left to right, nothing to tap but the tabs. */
.tabs { display: flex; gap: 8px; }
.tabs .btn { flex: 1; align-items: center; text-align: center; }
.tabs .btn[aria-selected="true"] { background: var(--ink); color: var(--card); }
.board { display: flex; flex-direction: column; border-top: 2px solid var(--ink); }
.board li { display: grid; grid-template-columns: 2.4em 3.4em minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 6px; border-bottom: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); font-variant-numeric: tabular-nums; }
.board li.none { display: block; padding: 14px 6px; }
.board li.me { background: var(--ink); color: var(--card); }
.board .rk { font: 400 1.5rem/1 var(--disp); }
.board .mv { font-size: .72rem; font-weight: 700; white-space: nowrap; }
.board b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { text-align: right; font-weight: 700; line-height: 1.15; }
.board .pts small { display: block; font-size: .72em; font-weight: 500; opacity: .7; }
.you { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 2px solid var(--ink); }
.you .big { font: 400 1.7rem/1 var(--disp); }
.coll { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.coll li { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 6px 8px; border: 2px solid var(--ink); line-height: 1.2; }
.coll li.no { border-style: dashed; }
.coll li.no b { font-weight: 500; opacity: .7; }
.coll .chip { background: var(--ink); color: var(--card); }
.coll small { font-size: .75em; opacity: .75; }

/* What a finished life was worth. */
.end { overflow-y: auto; justify-content: safe center; }
.tally { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tally-n { font: 400 2.2em/1 var(--disp); color: var(--ta, #fff); }
.tally ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 6px; max-width: 30em; }
.tally li { padding: 1px 8px; font-size: .8em; font-weight: 700; border: 1px solid currentColor; }

/* Wide screens: the city fills the browser and the story card floats beside it. */
@media (min-width: 900px) {
  #app { font-size: calc(clamp(15px, 1.9dvh, 17px) * var(--fs)); }
  .hud { padding: 10px 22px 12px; gap: 8px; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 4px 26px; }
  .stat-l { font-size: 12px; }
  .sheet { left: auto; right: 24px; bottom: 24px; width: 440px; max-height: calc(100dvh - var(--hud-h) - 48px); padding: 18px 20px 20px; border: 3px solid var(--a); box-shadow: 6px 6px 0 rgba(0, 0, 0, .35); }
  .face img { width: 68px; height: 68px; }
  .plate img { width: min(40vw, 52dvh); }
  .plate.two img { width: min(24vw, 40dvh); }
  .recentre { right: 488px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
