:root {
  --indigo: #0f0d2b;
  --ink: #2a1d2e;
  --cream: #fff3dc;
  --paper: #fbf1dd;
  --amber: #ffcf5a;
  --ember: #f0883b;
  --rose: #e8503a;
  --jade: #6fbf9a;
  --glass: rgba(20, 14, 44, 0.72);
  --glass-2: rgba(32, 22, 64, 0.82);
  --line: rgba(255, 220, 170, 0.16);
  --radius: 16px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next Rounded", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --panel-h: 224px;
  --hud-h: 118px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--indigo); color: var(--cream); font-family: var(--font); overflow: hidden; -webkit-tap-highlight-color: transparent; }
body { position: fixed; inset: 0; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }

/* ---- title ---- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; z-index: 20; }
#title { padding-bottom: 22vh; }
#title { background: radial-gradient(ellipse at 50% 60%, rgba(10, 8, 30, 0.1), rgba(10, 8, 30, 0.55) 70%); }
#logo { width: min(520px, 92vw); height: auto; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5)); }
.title-line { font-size: 1.05rem; color: #f6dcb0; margin: 4px 0 18px; opacity: 0.9; min-height: 1.4em; }
.title-actions { display: flex; flex-direction: column; align-items: center; gap: 11px; animation: rise 0.6s ease both; }
.name-row { display: flex; gap: 8px; }
.name-row input { font: inherit; font-size: 1.05rem; font-weight: 600; padding: 12px 16px; border-radius: 999px; border: 2px solid rgba(255, 220, 170, 0.35); background: rgba(255, 243, 220, 0.08); color: var(--cream); width: 240px; text-align: center; }
.name-row input::placeholder { color: rgba(255, 243, 220, 0.5); font-weight: 500; }
.fine { font-size: 0.85rem; opacity: 0.8; margin: 0; background: rgba(10, 8, 30, 0.45); padding: 4px 12px; border-radius: 999px; }
.title-error { color: #ffb4a8; max-width: 420px; }
#title.poster .title-line, #title.poster .title-actions, #title.poster .title-error { visibility: hidden; }
#title.poster #logo { width: min(640px, 92vw); margin-top: -8vh; }
#title { pointer-events: none; }
#title > * { pointer-events: auto; }
.title-idle { margin: -10px 0 14px; max-width: min(640px, 92vw); font-size: 0.82rem; line-height: 1.35; color: #ffd98a; background: rgba(10, 8, 30, 0.55); border: 1px solid rgba(255, 207, 90, 0.28); padding: 6px 14px; border-radius: 12px; }
.steps { list-style: none; margin: 2px 0 0; padding: 0; display: flex; gap: 6px; align-items: stretch; }
.steps li { display: flex; align-items: center; gap: 8px; background: rgba(10, 8, 30, 0.55); border: 1px solid var(--line); border-radius: 14px; padding: 7px 12px 7px 8px; text-align: left; position: relative; }
.steps li + li::before { content: ""; position: absolute; left: -6px; top: 50%; width: 6px; height: 2px; background: rgba(255, 207, 90, 0.5); }
.steps b { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.78rem; background: var(--amber); color: #3b1b2a; }
.steps span { display: flex; flex-direction: column; font-weight: 800; font-size: 0.86rem; line-height: 1.15; }
.steps small { font-weight: 600; font-size: 0.7rem; opacity: 0.72; }
.link-btn { background: none; border: 0; color: #ffe08a; font-weight: 800; font-size: 0.95rem; padding: 6px 10px; border-radius: 999px; text-decoration: underline; text-decoration-color: rgba(255, 224, 138, 0.4); text-underline-offset: 4px; }
.link-btn:hover { background: rgba(255, 243, 220, 0.08); text-decoration-color: #ffe08a; }

/* watching the row */
.watchbar { position: absolute; top: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; pointer-events: none; }
.watchbar > * { pointer-events: auto; }
.watch-info { flex: 0 1 auto; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; display: flex; flex-direction: column; min-width: 0; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); }
.watch-info b { color: #ffe08a; font-size: 0.95rem; }
.watch-info span { font-size: 0.78rem; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.takings { display: none; position: absolute; left: 12px; top: 74px; z-index: 9; width: 290px; max-height: calc(100vh - 140px); overflow: auto; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); font-size: 0.82rem; }
body.watching .takings:has(> div:not(:empty)) { display: block; }
.takings h3 { margin: 0 0 6px; font-size: 0.85rem; color: #ffe08a; }
.takings ol { list-style: none; margin: 0; padding: 0; }
.takings li { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: baseline; padding: 3px 0; border-top: 1px solid var(--line); }
.takings li:first-child { border-top: 0; }
.takings .rank { opacity: 0.6; font-variant-numeric: tabular-nums; }
.takings .num { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.takings small { font-weight: 400; opacity: 0.7; }
.takings li.player .who { color: #ffe08a; }
.takings p { margin: 8px 0 0; font-size: 0.74rem; opacity: 0.75; }
.takings .cup-watch:not(:empty) { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255, 207, 90, 0.45); }
.takings #takings-night:empty + .cup-watch { margin-top: 0; padding-top: 0; border-top: 0; }
.takings h3 small { font-weight: 600; color: var(--cream); opacity: 0.75; }
.takings li.me .who { color: var(--amber); font-weight: 800; }
.takings .cup-kind { font-size: 0.7rem; }
.cup-more { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted rgba(255, 224, 138, 0.6); text-underline-offset: 3px; }
.cup-more:hover { color: var(--amber); }
.watch-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.watch-actions .small.primary { padding: 12px 18px; font-size: 0.95rem; box-shadow: 0 4px 0 #a24a1e; white-space: nowrap; }
.ticker { position: absolute; left: 0; right: 0; bottom: 0; z-index: 21; height: 36px; display: flex; align-items: center; background: rgba(10, 8, 30, 0.82); border-top: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-size: 0.84rem; padding-bottom: env(safe-area-inset-bottom); }
.ticker-tag { flex: 0 0 auto; height: 100%; display: flex; align-items: center; padding: 0 12px; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: #3b1b2a; background: var(--amber); }
.ticker-track { flex: 1; overflow: hidden; height: 100%; display: flex; align-items: center; -webkit-mask: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); mask: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
.ticker-move { display: flex; white-space: nowrap; animation: tickerRun 120s linear infinite; will-change: transform; }
.ticker-move.still { animation: none; }
.tick-run { display: flex; align-items: center; }
.tick, .tick-night { padding: 0 14px; position: relative; }
.tick::before { content: ""; position: absolute; left: 0; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--amber); }
.tick.refuse::before { background: var(--rose); }
.tick.miss::before { background: #9b8bc7; }
.tick-night { font-weight: 800; color: #ffe08a; padding-left: 26px; }
@keyframes tickerRun { from { transform: translateX(0); } to { transform: translateX(-50%); } }

body.watching .toast { bottom: auto; top: 76px; }
#unsupported { background: var(--indigo); }
#unsupported h1 { font-size: 1.6rem; }
#unsupported p { max-width: 460px; line-height: 1.5; opacity: 0.85; }

/* ---- buttons ---- */
.big { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 12px 26px; min-height: 58px; border-radius: 999px; border: 0; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.01em; background: linear-gradient(180deg, #3a2f6b, #241c4a); color: var(--cream); box-shadow: 0 6px 0 #170f33, 0 10px 24px rgba(0, 0, 0, 0.35); transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.2s; }
.big:hover { filter: brightness(1.08); }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #170f33, 0 6px 14px rgba(0, 0, 0, 0.35); }
.big.primary { background: linear-gradient(180deg, #ffd96b, #f0883b); color: #3b1b2a; box-shadow: 0 6px 0 #a24a1e, 0 10px 24px rgba(240, 136, 59, 0.35); }
.big.primary:active { box-shadow: 0 2px 0 #a24a1e, 0 6px 14px rgba(240, 136, 59, 0.35); }
.big:disabled { opacity: 0.55; cursor: default; filter: saturate(0.6); }
.big .btn-sub { font-size: 0.72rem; font-weight: 600; opacity: 0.8; letter-spacing: 0; }
.ghost { background: rgba(255, 243, 220, 0.1); border: 2px solid rgba(255, 220, 170, 0.3); border-radius: 999px; min-width: 46px; font-size: 1.2rem; font-weight: 700; }
.ghost:hover { background: rgba(255, 243, 220, 0.18); }
.small { padding: 8px 14px; border-radius: 999px; border: 2px solid rgba(255, 220, 170, 0.35); background: rgba(255, 243, 220, 0.08); font-weight: 700; font-size: 0.9rem; }
.small:hover { background: rgba(255, 243, 220, 0.16); }
.small.primary { background: var(--amber); color: #3b1b2a; border-color: transparent; }
.small.danger { border-color: rgba(232, 80, 58, 0.6); color: #ffb4a8; }
.small:disabled { opacity: 0.5; cursor: default; }

/* ---- HUD ---- */
#hud { position: absolute; top: 0; left: 0; right: 0; height: var(--hud-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px; padding: 10px 12px; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-left { display: flex; justify-content: flex-start; }
.hud-right { display: flex; justify-content: flex-end; gap: 6px; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chip { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); }
.stall-chip { display: grid; grid-template-columns: auto; gap: 1px; min-width: 150px; }
.stall-sign { font-weight: 800; font-size: 0.95rem; color: #ffe08a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.money { display: flex; align-items: center; gap: 6px; font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.money b { font-variant-numeric: tabular-nums; }
.money.bump b { animation: bump 0.35s ease; }
.coin-icon { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe28a, #f3b63a 60%, #b8791c); box-shadow: 0 1px 0 #7a4b10; display: inline-block; }
.sub { font-size: 0.78rem; opacity: 0.8; }
#hud-worth { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 290px; }
#hud-worth b { color: #ffe08a; }
.cup-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 290px; }
.cup-line b { color: var(--amber); }
.goal { display: grid; gap: 3px; margin: 3px 0 1px; }
.goal-bar { display: block; height: 5px; border-radius: 3px; background: rgba(255, 220, 170, 0.16); overflow: hidden; }
.goal-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--ember), var(--amber)); box-shadow: 0 0 8px rgba(255, 207, 90, 0.6); transition: width 0.8s ease; }
.goal-text { font-size: 0.78rem; opacity: 0.9; }
.goal-text b { font-variant-numeric: tabular-nums; }
.clock { position: relative; width: 64px; height: 64px; display: grid; place-items: center; }
.ring { position: absolute; inset: 0; width: 64px; height: 64px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-bg { stroke: rgba(255, 220, 170, 0.18); }
.ring-fg { stroke: var(--amber); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 0; transition: stroke-dashoffset 0.9s linear; }
.ring-fg.walking { stroke: var(--jade); }
.clock-text { text-align: center; line-height: 1; background: var(--glass); border-radius: 50%; width: 50px; height: 50px; display: grid; place-content: center; }
.clock-text .label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; }
.clock-text b { font-size: 1.1rem; display: block; }
.event-banner { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 0.82rem; display: flex; gap: 8px; align-items: center; white-space: nowrap; max-width: 92vw; overflow: hidden; }
.event-banner b { color: var(--amber); }
.event-banner span { opacity: 0.85; overflow: hidden; text-overflow: ellipsis; }
.event-banner.festival b { color: #ff8fb1; }
.event-banner.storm b { color: #9fc5ff; }
.event-banner.bumper b { color: #8be0b0; }
.event-banner.payday b { color: #ffe08a; }
.icon-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px; min-width: 54px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; transition: background 0.15s; }
.icon-btn:hover { background: var(--glass-2); }
.icon-btn.attention { animation: pulse 1.4s ease infinite; border-color: var(--amber); }
.ico { width: 22px; height: 22px; display: block; background-color: var(--amber); -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ico-trophy { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 3h12v3h3v3a5 5 0 0 1-5 5h-.4A5 5 0 0 1 13 16.9V19h3v2H8v-2h3v-2.1A5 5 0 0 1 8.4 14H8a5 5 0 0 1-5-5V6h3V3zm0 5H5v1a3 3 0 0 0 1.2 2.4A8 8 0 0 1 6 8zm12 0a8 8 0 0 1-.2 3.4A3 3 0 0 0 19 9V8h-1z'/></svg>"); }
.ico-deed { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 2h10l4 4v16H5V2zm9 1.5V7h3.5L14 3.5zM8 10h8v2H8v-2zm0 4h8v2H8v-2zm0-8h4v2H8V6z'/></svg>"); }
.ico-sound { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 9h4l5-4v14l-5-4H4V9zm12.5 3a4.5 4.5 0 0 0-2.2-3.9v7.8a4.5 4.5 0 0 0 2.2-3.9zm3.5 0a8 8 0 0 0-4-6.9v2.3a5.8 5.8 0 0 1 0 9.2v2.3a8 8 0 0 0 4-6.9z'/></svg>"); }
.ico-sound.off { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 9h4l5-4v14l-5-4H4V9zm12 .6 1.4-1.4 1.6 1.6 1.6-1.6L22 9.6 20.4 11.2 22 12.8l-1.4 1.4-1.6-1.6-1.6 1.6-1.4-1.4 1.6-1.6L16 9.6z'/></svg>"); }
.ico-proof { --m: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2 4 6v6c0 5 3.4 8.6 8 10 4.6-1.4 8-5 8-10V6l-8-4zm-1.2 13.6-3.3-3.3 1.4-1.4 1.9 1.9 4.6-4.6 1.4 1.4-6 6z'/></svg>"); }

/* ---- hint ---- */
.hint { position: absolute; left: 12px; top: calc(var(--hud-h) + 14px); max-width: min(380px, 92vw); background: var(--paper); color: var(--ink); padding: 12px 18px 12px 46px; border-radius: 18px; font-weight: 700; font-size: 0.95rem; line-height: 1.35; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); z-index: 12; animation: dropIn 0.4s ease both; }
.hint::before { content: ""; position: absolute; left: 14px; top: 50%; width: 22px; height: 22px; transform: translateY(-50%); border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffe9a8, #ff9a3c 70%); box-shadow: 0 0 14px rgba(255, 154, 60, 0.8); }

/* ---- summary ---- */
.summary { position: absolute; top: calc(var(--hud-h) + 14px); left: 12px; width: min(440px, 92vw); max-height: calc(100vh - var(--hud-h) - var(--panel-h) - 20px); overflow: auto; background: var(--paper); color: var(--ink); border-radius: 18px; padding: 12px 16px 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); z-index: 11; border-top: 6px solid var(--amber); }
.summary-head b { animation: bump 0.4s ease; display: inline-block; }
.summary.mood-flat { border-top-color: #9b8bc7; }
.summary.mood-bad { border-top-color: var(--rose); }
.summary.mood-call { border-top-color: var(--ember); }
.summary > .close { z-index: 2; }
#summary-report { position: relative; }
.summary-outcome { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; font-size: 0.88rem; line-height: 1.35; background: rgba(0, 0, 0, 0.05); font-weight: 600; }
.summary-outcome.met { background: rgba(111, 191, 154, 0.22); padding-right: 72px; }
.summary-outcome.missed { background: rgba(232, 80, 58, 0.1); }
.stamp-call { position: absolute; right: 2px; bottom: 2px; width: 58px; height: 58px; transform: rotate(-14deg) scale(1); animation: stampDown 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; opacity: 0.9; }
.summary-call { margin-top: 10px; padding-top: 10px; border-top: 1px dashed rgba(0, 0, 0, 0.18); }
.call-head { display: flex; flex-direction: column; gap: 2px; }
.call-tag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: #a24a1e; font-weight: 800; }
.call-head b { font-size: 1.05rem; }
.summary-call p { margin: 6px 0 0; font-size: 0.9rem; line-height: 1.35; }
.call-expect { opacity: 0.7; font-size: 0.82rem; }
.call-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.call-actions .small { color: var(--ink); border-color: rgba(0, 0, 0, 0.2); background: rgba(0, 0, 0, 0.04); }
.call-actions .small.primary { background: var(--amber); border-color: transparent; }
.summary-head { display: flex; align-items: baseline; gap: 10px; padding-right: 30px; }
.summary-night { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.6; font-weight: 800; }
.summary-head b { font-size: 1.1rem; }
.summary ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 0.9rem; line-height: 1.35; }
.summary ul:empty { margin: 0; }
.summary li { display: flex; gap: 8px; align-items: flex-start; }
.summary li::before { content: ""; flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--amber); }
.summary li.frown::before { background: var(--rose); }
.summary li.moon::before { background: #9b8bc7; }
.summary li.leaf::before { background: var(--jade); }
.summary li.house::before { background: #c9a27a; }
.summary li.eye::before { background: #6fa8dc; }
.summary li.star::before { background: #ff9a3c; }
.close { position: absolute; top: 6px; right: 8px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.08); font-size: 1.2rem; line-height: 1; font-weight: 800; }
.close:hover { background: rgba(0, 0, 0, 0.16); }

/* ---- panel ---- */
.panel { position: absolute; left: 0; right: 0; bottom: 0; height: var(--panel-h); z-index: 10; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-rows: 1fr auto; gap: 8px; background: linear-gradient(180deg, rgba(15, 13, 43, 0) 0%, rgba(15, 13, 43, 0.85) 22%, rgba(15, 13, 43, 0.95) 100%); }
.goods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 980px; margin: 0 auto; width: 100%; }
.good { position: relative; background: var(--glass-2); border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px 6px; display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto; gap: 2px 8px; align-items: center; transition: border-color 0.2s, transform 0.2s; }
.good.hot { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 0 18px rgba(255, 207, 90, 0.25); }
.good.hot.storm { border-color: #9fc5ff; box-shadow: 0 0 0 1px #9fc5ff, 0 0 18px rgba(159, 197, 255, 0.25); }
.good .want { font-weight: 700; opacity: 0.9; }
.good.short .want { color: var(--amber); }
.good.slow .want { opacity: 0.55; }
.good.empty .stock b { color: #ffb4a8; }
.good.stamp { animation: stampIn 0.35s ease both; }
.good .icon { grid-row: 1 / span 2; width: 38px; height: 38px; display: grid; place-items: center; }
.good .icon svg { width: 36px; height: 36px; }
.good .gname { font-weight: 800; font-size: 0.86rem; line-height: 1; display: flex; justify-content: space-between; align-items: center; }
.good .stock { font-size: 0.72rem; opacity: 0.85; }
.good .stock b { font-size: 0.86rem; }
.good .sold { font-size: 0.68rem; color: var(--amber); font-weight: 700; }
.good .price-row { grid-column: 1 / span 2; display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 4px; margin-top: 4px; }
.good .price-row button { height: 34px; border-radius: 10px; border: 0; background: rgba(255, 243, 220, 0.12); font-size: 1.2rem; font-weight: 800; }
.good .price-row button:hover { background: rgba(255, 243, 220, 0.22); }
.good .price-row button:active { transform: scale(0.94); }
.good .price { text-align: center; font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; line-height: 1; }
.good .price small { font-size: 0.62rem; font-weight: 600; opacity: 0.7; margin-top: 2px; }
.good .price.off { color: #ffb4a8; }
.good .why { grid-column: 1 / span 2; margin: 3px 0 0; font-size: 0.68rem; line-height: 1.25; opacity: 0.82; min-height: 2.5em; }
.good .price .why-short { display: none; font-size: 0.55rem; font-weight: 600; opacity: 0.75; margin-top: 2px; }
.good.short .why { color: #ffe08a; opacity: 1; }
.good .price.pending { animation: pulse 0.9s ease infinite; }
.actions { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: center; max-width: 980px; margin: 0 auto; width: 100%; }
.actions .big { min-height: 54px; padding: 8px 22px; font-size: 1.05rem; }
.status { display: flex; align-items: center; gap: 8px; justify-self: end; font-size: 0.8rem; opacity: 0.85; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 10px var(--jade); }
.status.busy .dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: pulse 1s ease infinite; }
.status.error .dot { background: var(--rose); box-shadow: 0 0 10px var(--rose); }

/* ---- toast ---- */
.toast { position: absolute; left: 50%; bottom: calc(var(--panel-h) + 18px); transform: translateX(-50%); background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 20px; line-height: 1.35; width: max-content; max-width: min(640px, 92vw); text-align: center; font-weight: 700; font-size: 0.92rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); z-index: 15; animation: rise 0.3s ease both; border: 1px solid var(--line); }
.toast.warn { background: #5a2a2e; }
.toast.ok { background: #1d4a3a; }

/* ---- sheet ---- */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5, 3, 15, 0.55); z-index: 30; }
.sheet { position: absolute; right: 16px; top: 16px; bottom: 16px; width: min(460px, calc(100vw - 32px)); background: var(--paper); color: var(--ink); border-radius: 22px; z-index: 31; display: grid; grid-template-rows: auto 1fr; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6); animation: slideIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; position: relative; }
.sheet-head h2 { margin: 0; font-size: 1.3rem; font-weight: 800; }
.sheet-head .close { position: static; }
.sheet-body { overflow: auto; padding: 0 20px 20px; -webkit-overflow-scrolling: touch; }
.sheet-body h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.6; margin: 18px 0 8px; }
.sheet-body p { line-height: 1.45; margin: 6px 0; }
.sheet-body .muted { opacity: 0.65; font-size: 0.85rem; }
.sheet-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; background: rgba(0, 0, 0, 0.06); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.sheet-body a { color: #8a3a1e; font-weight: 700; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.row-actions input { font: inherit; font-weight: 700; padding: 8px 12px; border-radius: 999px; border: 2px solid rgba(0, 0, 0, 0.15); width: 130px; background: #fff; }
.row-actions .small { color: var(--ink); border-color: rgba(0, 0, 0, 0.2); background: rgba(0, 0, 0, 0.04); }
.row-actions .small.primary { background: var(--amber); border-color: transparent; }
.row-actions .small.danger { color: #8a2a2e; border-color: rgba(232, 80, 58, 0.5); }

/* deed */
.stamp-seal { position: absolute; bottom: 10px; right: 14px; width: 54px; height: 54px; border-radius: 50%; border: 3px double #b33a2a; color: #b33a2a; display: grid; place-content: center; font-size: 0.55rem; font-weight: 800; text-align: center; transform: rotate(-12deg); letter-spacing: 0.05em; opacity: 0.85; }
.holders { font-size: 0.8rem; opacity: 0.8; }
.listed-tag { display: inline-block; background: #7a2a2e; color: #fff; font-size: 0.7rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; letter-spacing: 0.08em; }

/* the deed card: drawn by this page; the contract's own picture sits under it */
.deed-card { position: relative; border-radius: 18px; overflow: hidden; background: linear-gradient(170deg, #fff8e8, #f1ddb2); border: 2px solid #c9a76a; box-shadow: inset 0 0 0 5px #fff8e8, inset 0 0 0 6px #d9bb82, 0 10px 26px rgba(59, 27, 42, 0.25); }
.deed-scene-wrap { position: relative; margin: 8px 8px 0; border-radius: 12px; overflow: hidden; height: 170px; background: #0f0d2b; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
.deed-scene { display: block; width: 100%; height: 100%; }
.deed-ribbon { position: absolute; top: 26px; right: -52px; transform: rotate(35deg); text-align: center; min-width: 210px; background: #7a2a2e; color: #fff; font-weight: 800; font-size: 0.7rem; letter-spacing: 0.1em; padding: 5px 44px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4); }
.deed-body { padding: 12px 18px 16px; }
.deed-kicker { font-size: 0.62rem; letter-spacing: 0.18em; font-weight: 800; color: #a8783a; text-transform: uppercase; }
.deed-card .deed-title { font-size: 1.55rem; font-weight: 800; margin: 2px 0 0; color: #3b1b2a; line-height: 1.1; padding-right: 60px; }
.deed-card .deed-sub { font-size: 0.8rem; opacity: 0.7; margin: 2px 0 10px; }
.deed-card .deed-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.deed-card .deed-stats div { background: rgba(201, 167, 106, 0.16); border-radius: 10px; padding: 6px 2px; }
.deed-card .deed-stats b { display: block; font-size: 1.05rem; color: #3b1b2a; font-variant-numeric: tabular-nums; }
.deed-card .deed-stats span { display: block; font-size: 0.62rem; opacity: 0.65; text-transform: uppercase; letter-spacing: 0.04em; }
.deed-shelf { display: flex; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.deed-good { display: inline-flex; align-items: center; gap: 2px; background: #2a1d2e; color: var(--cream); border-radius: 999px; padding: 2px 9px 2px 3px; font-size: 0.8rem; }
.deed-good svg { width: 22px; height: 22px; }
.deed-good.none { opacity: 0.4; }
.deed-royalty { font-size: 0.8rem; margin: 8px 0 0; opacity: 0.85; }
.deed-card .stamp-seal { bottom: auto; top: 192px; right: 16px; background: rgba(255, 248, 232, 0.7); }
.deed-chain { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; margin: 12px 0 4px; padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, 0.04); }
.deed-chain-img { width: 96px; height: 96px; border-radius: 8px; background: midnightblue; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); display: grid; place-content: center; color: #fff; font-size: 0.7rem; }
.deed-chain figcaption { font-size: 0.8rem; line-height: 1.4; opacity: 0.85; }
.deed-chain code, .deed-royalty code { word-break: normal; white-space: nowrap; }

/* leaderboard */
.sheet-body h3 + .board, .sheet-body h3 + .muted { margin-top: 4px; }
.board li.closed { opacity: 0.75; }
.board li.closed .who small::after { content: ""; }
.board .who em { font-style: normal; font-weight: 600; opacity: 0.7; }
.closed-stalls { margin-top: 16px; border-radius: 12px; background: rgba(0, 0, 0, 0.03); }
.closed-stalls summary { cursor: pointer; padding: 10px 12px; font-weight: 800; list-style-position: inside; }
.closed-stalls summary small { font-weight: 500; opacity: 0.65; margin-left: 4px; }
.closed-stalls .board { padding: 0 6px 8px; }
.proof-live.ok { background: rgba(111, 191, 154, 0.25); }
.proof-live.bad { background: rgba(232, 80, 58, 0.2); }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.04); }
.board li.me { background: var(--amber); font-weight: 800; }
.board li.npc .who small::after { content: " · merchant"; }
.board li.player .who small::after { content: " · player"; }
.board li.bot .who small::after { content: " · fixed rules"; }
.bot-tag { display: inline-block; vertical-align: 0.15em; background: #d9e4ec; color: #2c3e50; font-size: 0.62rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.board .rank { font-weight: 800; font-size: 1.1rem; text-align: center; }
.board .who { font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.board .who small { display: block; font-weight: 500; opacity: 0.65; font-size: 0.75rem; }
.board .worth { font-weight: 800; font-variant-numeric: tabular-nums; }

/* the Lantern Cup, at the top of the Ranks sheet */
.cup { margin: 4px 0 6px; padding: 2px 12px 10px; border-radius: 14px; background: linear-gradient(170deg, rgba(255, 207, 90, 0.2), rgba(255, 207, 90, 0.06)); border: 1px solid rgba(201, 167, 106, 0.45); }
.cup h3 { opacity: 0.85; color: #8a3a1e; margin-top: 12px; }
.cup .cup-lead { margin-top: 0; }
.cup-board { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 5px; }
.cup-board li { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.55); }
.cup-board li:first-child .rank { color: #b0701a; }
.cup-board li.me { background: var(--amber); font-weight: 800; }
.cup-board li.cup-gap { display: block; background: none; padding: 0 0 0 14px; line-height: 0.6; opacity: 0.5; }
.cup-board .rank { font-weight: 800; font-size: 1.05rem; text-align: center; }
.cup-board .who { font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cup-board .who em { font-style: normal; font-weight: 600; opacity: 0.7; }
.cup-board .who small { display: block; font-weight: 500; opacity: 0.65; font-size: 0.75rem; }
.cup-board .who .cup-kind { display: inline; font-size: 0.7rem; }
.cup-board .num { font-weight: 800; font-variant-numeric: tabular-nums; }
.cup-board .num small { font-weight: 500; opacity: 0.65; }
.cup .cup-last { font-size: 0.85rem; }
.cup .cup-how { margin-bottom: 0; }

/* proof */
.proof-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 0.85rem; }
.proof-list li { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: baseline; }
.proof-list li span:first-child { opacity: 0.6; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.tx-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 0.82rem; }
.tx-list li { display: flex; gap: 8px; align-items: baseline; }
.tx-list .kind { font-weight: 800; min-width: 96px; }
.tx-list .gas { opacity: 0.6; font-size: 0.75rem; margin-left: auto; white-space: nowrap; }

/* stall peek (tap on a stall) */
.peek { position: absolute; z-index: 12; background: var(--paper); color: var(--ink); border-radius: 14px; padding: 10px 14px; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5); font-size: 0.85rem; animation: dropIn 0.25s ease both; }
.peek b { font-size: 1rem; }
.peek table { border-collapse: collapse; margin-top: 6px; width: 100%; }
.peek td { padding: 1px 4px; font-variant-numeric: tabular-nums; }
.peek td:last-child { text-align: right; font-weight: 700; }
.peek .npc-note { opacity: 0.65; font-size: 0.75rem; }

/* ---- animations ---- */
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.title-actions { animation-name: riseCenter; }
@keyframes riseCenter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -16px) scale(0.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes stampDown { 0% { opacity: 0; transform: rotate(-14deg) scale(2.2); } 100% { opacity: 0.9; transform: rotate(-14deg) scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); color: var(--amber); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes stampIn { 0% { transform: scale(1.06); border-color: var(--jade); } 100% { transform: scale(1); } }

/* ---- fast-forward sheet ---- */
.ff-note { font-size: 0.82rem; color: #6b5a6e; margin: 0 0 10px; }
.ff-head { font-size: 1.05rem; margin-bottom: 6px; }
.ff-head span { color: #6b5a6e; }
.ff-label { margin: 10px 0 4px; font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: #6b5a6e; }
.ff-chart { width: 100%; height: auto; display: block; }
.ff-chart .ff-grid { stroke: rgba(42, 29, 46, 0.1); }
.ff-chart .ff-base { stroke: rgba(42, 29, 46, 0.35); stroke-dasharray: 3 3; }
.ff-chart .ff-flood { stroke: #d9775b; stroke-dasharray: 4 3; }
.ff-chart .ff-axis { font-size: 9px; fill: #6b5a6e; }
.ff-chart .ff-line { fill: none; stroke-width: 1.5; opacity: 0.55; }
.ff-chart .ff-tea { stroke-width: 3; opacity: 1; }
.ff-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.75rem; margin-top: 4px; }
.ff-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.ff-board { list-style: none; margin: 0; padding: 0; font-size: 0.8rem; }
.ff-board li { display: grid; grid-template-columns: 9.5em 1fr 4.5em; gap: 8px; align-items: center; padding: 2px 0; }
.ff-board .ff-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ff-board .ff-bar { height: 8px; background: rgba(42, 29, 46, 0.08); border-radius: 4px; overflow: hidden; }
.ff-board .ff-bar i { display: block; height: 100%; background: #b9a4c9; transition: width 0.18s linear; }
.ff-board li.bot .ff-bar i { background: var(--amber); }
.ff-board .ff-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.ff-stats { font-size: 0.78rem; color: #6b5a6e; margin: 10px 0; }
.ff-controls { display: flex; gap: 8px; }
.ff-controls .small { color: var(--ink); border-color: rgba(0, 0, 0, 0.2); background: rgba(0, 0, 0, 0.04); }

/* ---- phone ---- */
@media (max-width: 720px) {
  :root { --panel-h: 250px; --hud-h: 166px; }
  #hud { grid-template-columns: 1fr auto; grid-template-rows: auto auto; padding: 8px; gap: 6px; height: auto; }
  .chip { padding: 6px 10px; }
  .stall-chip .sub { font-size: 0.7rem; }
  .hud-center { grid-column: 1 / span 2; grid-row: 2; flex-direction: row; justify-content: center; }
  .hud-right { grid-column: 2; grid-row: 1; }
  .clock, .ring { width: 54px; height: 54px; }
  .clock-text { width: 42px; height: 42px; }
  .clock-text b { font-size: 0.95rem; }
  .event-banner { font-size: 0.74rem; padding: 5px 12px; max-width: calc(100vw - 80px); white-space: normal; text-align: center; line-height: 1.25; flex-wrap: wrap; justify-content: center; gap: 2px 8px; }
  .icon-btn { min-width: 44px; padding: 5px 6px; }
  .icon-label { display: none; }
  .ico { width: 20px; height: 20px; }
  .stall-chip { min-width: 0; max-width: calc(100vw - 230px); }
  .stall-sign { max-width: 100%; font-size: 0.85rem; }
  .money { font-size: 1.15rem; }
  .goods { gap: 5px; }
  .good { grid-template-columns: 1fr; padding: 6px 5px 5px; text-align: center; justify-items: center; gap: 1px; }
  .good .icon { grid-row: auto; width: 30px; height: 30px; }
  .good .icon svg { width: 30px; height: 30px; }
  .good .gname { font-size: 0.68rem; justify-content: center; }
  .good .sold { display: none; }
  .good .stock { font-size: 0.68rem; }
  .good .price-row { grid-column: 1; grid-template-columns: 1fr; grid-template-rows: auto auto auto; gap: 3px; width: 100%; }
  .good .price-row .dec { order: 3; }
  .good .price-row .inc { order: 1; }
  .good .price-row .price { order: 2; }
  .good .price-row button { height: 30px; width: 100%; }
  .good .price { font-size: 0.95rem; }
  .good .price small { font-size: 0.55rem; }
  .good .why { display: none; }
  .good .price .why-short { display: block; }
  #hud-worth { max-width: 100%; }
  #hud-worth .next { display: none; }
  .cup-line { max-width: 100%; }
  .cup-line .cup-score { display: none; }
  .goal-text { font-size: 0.7rem; }
  .steps { gap: 5px; }
  .steps li { flex-direction: column; text-align: center; gap: 3px; padding: 6px 6px; flex: 1; }
  .steps li + li::before { display: none; }
  .steps span { font-size: 0.74rem; }
  .steps small { font-size: 0.62rem; }
  .title-idle { font-size: 0.74rem; margin: -12px 0 12px; }
  .watch-info span { font-size: 0.7rem; }
  .watch-actions .small.primary { padding: 10px 12px; font-size: 0.85rem; }
  .watchbar { padding: 8px; gap: 6px; }
  .takings { top: 64px; left: 8px; width: min(250px, 66vw); font-size: 0.74rem; padding: 8px 10px; }
  #takings-night li:nth-child(n + 5), .takings p { display: none; }
  .watch-info { padding: 6px 10px; }
  .watch-info b { font-size: 0.85rem; }
  .ticker { font-size: 0.76rem; height: 32px; }
  .deed-card .deed-stats { grid-template-columns: repeat(2, 1fr); }
  .deed-chain { grid-template-columns: 72px 1fr; }
  .deed-chain-img { width: 72px; height: 72px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .big { min-height: 50px; padding: 6px 10px; font-size: 0.95rem; }
  .status { grid-column: 1 / span 2; justify-self: center; font-size: 0.72rem; }
  .hint { left: 8px; right: 8px; top: calc(var(--hud-h) + 6px); font-size: 0.84rem; padding: 9px 12px 9px 38px; max-width: none; line-height: 1.3; }
  .summary { width: calc(100vw - 16px); max-height: calc(100vh - var(--hud-h) - var(--panel-h) - 16px); overflow: auto; }
  .summary ul { font-size: 0.84rem; }
  .summary-call p { font-size: 0.84rem; }
  .summary { top: calc(var(--hud-h) + 8px); left: 8px; }
  .sheet { right: 0; left: 0; bottom: 0; top: auto; width: auto; max-height: 86vh; border-radius: 22px 22px 0 0; animation-name: slideUp; }
  @keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
}

@media (max-height: 520px) and (min-width: 721px) {
  :root { --panel-h: 176px; }
  .good .icon { display: none; }
  .good { grid-template-columns: 1fr; }
  .good .price-row { grid-column: 1; }
}

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