/* Ebbtide — Moonwrack. One dark room, one warm light. */

:root {
  --bg: #0a1220; --ink: #ece5d3; --ink-2: #9aa6b8; --ink-3: #5d6578; --accent: #f0b45e; --accent-2: #a9c8e8; --bad: #e0563b; --good: #7fd39a;
  --rule: rgba(236,229,211,0.2); --card: rgba(8,14,26,0.72); --card-solid: #0d1626; --card-blur: 12px;
  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-body: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --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);
  --strip-h: 64px; --palette-h: 104px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
html { background: var(--bg); }
body {
  height: 100dvh; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, .btn.is-focus, .pal-btn.is-focus, .tab.is-focus { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(240,180,94,0.35); }
body.booting .screens { opacity: 0; }
.screens { transition: opacity .4s; }

.stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body.building #field { cursor: crosshair; }

/* ---------- strip ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; color: var(--ink); }
.strip {
  position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: calc(6px + var(--sat)) calc(10px + var(--sar)) 6px calc(10px + var(--sal)); pointer-events: auto;
  background: linear-gradient(to bottom, rgba(6,10,18,0.92), rgba(6,10,18,0.55) 70%, transparent); text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
.hud-label { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); }
.stores { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 12px; max-width: 46vw; }
.stores li { display: flex; align-items: baseline; gap: 5px; font-size: 14px; white-space: nowrap; }
.stores li i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c, #888); flex: 0 0 auto; align-self: center; }
.stores li span { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.stores li b { font-weight: 500; font-variant-numeric: tabular-nums; min-width: 2.6ch; text-align: right; }
.stores li.low b { color: var(--accent); }
.stores li.out b { color: var(--bad); }
.stores li.full b { color: var(--accent-2); }
.stores li.more { display: none; }
.stores.is-open li.more { display: flex; }
.stores li.toggle { display: none; }
.stores li.toggle button { height: 22px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 11px; }
.strip-mid { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.year { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; }
.gauge { position: relative; width: min(220px, 26vw); height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: visible; }
.gauge-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 30%; background: var(--accent-2); border-radius: 3px; box-shadow: 0 0 8px var(--accent-2); transition: width .4s; }
.gauge.rising .gauge-fill { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.gauge-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.gauge-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.gauge.rising + .gauge-label { color: var(--accent); }
.strip-right { display: flex; align-items: center; gap: 12px; }
.souls { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.souls b { font-family: var(--font-display); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.souls small { font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.spirit { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.spirit i { display: block; width: 54px; height: 5px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; }
.spirit i b { display: block; height: 100%; width: 60%; background: var(--accent-2); transition: width .5s, background .5s; }
.spirit.low i b { background: var(--accent); }
.spirit.breaking i b { background: var(--bad); }
.spirit small { font-size: 10.5px; color: var(--ink-2); }
.speed { display: flex; gap: 2px; }
.speed button { width: 34px; height: 30px; border: 1px solid var(--rule); background: rgba(8,14,26,.5); color: var(--ink-2); font-size: 10px; letter-spacing: -.05em; border-radius: 3px; }
.speed button.is-on { color: var(--ink); border-color: var(--accent); background: rgba(240,180,94,.2); }
.strip-btns { display: flex; gap: 4px; }
.strip-btn { height: 30px; padding: 0 10px; border: 1px solid var(--rule); background: rgba(8,14,26,.5); border-radius: 3px; font-size: 13px; letter-spacing: .06em; }
.strip-btn.is-new { border-color: var(--accent); box-shadow: 0 0 10px rgba(240,180,94,.4); }
.strip-btn.is-on { color: var(--ink); border-color: var(--accent); background: rgba(240,180,94,.2); }

/* ---------- palette ---------- */
.palette { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 4px 8px; pointer-events: auto;
  padding: 6px calc(10px + var(--sar)) calc(8px + var(--sab)) calc(10px + var(--sal)); background: linear-gradient(to top, rgba(6,10,18,0.94), rgba(6,10,18,0.6) 70%, transparent); }
.cats { grid-column: 1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: 0 0 auto; padding: 5px 11px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; }
.cat.is-on { color: var(--ink); border-color: var(--rule); background: rgba(255,255,255,.06); }
.palette-scroll { grid-column: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px; min-width: 0; }
.palette-scroll::-webkit-scrollbar { display: none; }
.pal-btn { flex: 0 0 auto; display: grid; grid-template-columns: 44px 1fr; gap: 0 8px; align-items: center; min-width: 150px; height: 58px; padding: 4px 10px 4px 6px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(8,14,26,.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); text-align: left; color: var(--ink); }
.pal-btn .thumb { grid-row: 1 / 3; width: 44px; height: 44px; background-repeat: no-repeat; background-position: center; background-size: contain; }
.pal-btn b { font-weight: 500; font-size: 14px; line-height: 1.15; }
.pal-btn small { font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.pal-btn.cant { opacity: .8; }
.pal-btn.cant small { color: var(--accent); }
.pal-btn.locked { opacity: .45; }
.pal-btn.is-on { border-color: var(--accent); background: rgba(240,180,94,.2); }
.palette-side { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; gap: 6px; }
.palette-sel { font-size: 13.5px; color: var(--ink); max-width: 220px; text-align: right; line-height: 1.3; }
.palette-btns { display: flex; gap: 6px; }
.build-btn { height: 46px; padding: 0 22px; border: 1px solid var(--accent); border-radius: 3px; background: rgba(240,180,94,.25); color: var(--ink); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }
.build-btn:disabled { opacity: .45; }
.build-btn:active { transform: translateY(1px); }
.cancel-btn { width: 46px; height: 46px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(8,14,26,.7); font-size: 16px; }
body.lefthand .palette { grid-template-columns: auto 1fr; }
body.lefthand .palette-side { grid-column: 1; align-items: flex-start; }
body.lefthand .cats, body.lefthand .palette-scroll { grid-column: 2; }

/* ---------- inspector ---------- */
.inspector { position: absolute; right: calc(10px + var(--sar)); top: calc(var(--strip-h) + 14px + var(--sat)); width: 300px; max-height: calc(100% - var(--strip-h) - var(--palette-h) - 40px); overflow-y: auto; pointer-events: auto;
  padding: 14px 16px; background: var(--card); backdrop-filter: blur(var(--card-blur)); -webkit-backdrop-filter: blur(var(--card-blur)); border: 1px solid var(--rule); border-radius: 3px; }
.inspector .kicker { margin: 0 0 2px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.inspector h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.05; }
.inspector p { margin: 0 0 8px; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.inspector p.warn { color: var(--accent); }
.inspector .rows { list-style: none; margin: 0 0 10px; padding: 0; }
.inspector .rows li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.inspector .rows li span { color: var(--ink-2); }
.inspector .rows li b { font-weight: 500; text-align: right; }
.inspector .bar { display: block; height: 4px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; margin: 6px 0 10px; }
.inspector .bar i { display: block; height: 100%; background: var(--accent-2); }
.inspector .workers { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.inspector .workers button { width: 36px; height: 34px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(255,255,255,.05); font-size: 18px; }
.inspector .workers b { font-family: var(--font-display); font-size: 20px; min-width: 3.4ch; text-align: center; }
.inspector .ibtns { display: flex; flex-wrap: wrap; gap: 6px; }
.inspector .ibtn { flex: 1 1 auto; padding: 9px 10px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(255,255,255,.05); font-size: 14px; }
.inspector .ibtn--primary { border-color: var(--accent); background: rgba(240,180,94,.2); }
.inspector .ibtn--danger { border-color: rgba(224,86,59,.6); }
.inspector .ibtn:disabled { opacity: .45; }
.inspector .close { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-2); font-size: 16px; }
.inspector .trade { list-style: none; margin: 0 0 8px; padding: 0; }
.inspector .trade li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.inspector .tbtns { display: inline-flex; }
.inspector .tbtns button:first-child { border-radius: 3px 0 0 3px; }
.inspector .tbtns button:last-child { border-radius: 0 3px 3px 0; border-left: 0; }
.inspector .trade li span small { color: var(--ink-2); }
.inspector .trade button { padding: 5px 8px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(255,255,255,.05); font-size: 12.5px; white-space: nowrap; }
.inspector .trade button:disabled { opacity: .4; }
.inspector .folk { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.inspector .folk li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid var(--rule); }
.inspector .folk li span { color: var(--ink-2); }

/* ---------- book card, hint, toasts ---------- */
.book-card { position: absolute; left: calc(10px + var(--sal)); top: calc(var(--strip-h) + 14px + var(--sat)); width: min(360px, calc(100% - 20px)); pointer-events: auto; padding: 12px 40px 12px 16px;
  background: var(--card); backdrop-filter: blur(var(--card-blur)); -webkit-backdrop-filter: blur(var(--card-blur)); border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 3px; animation: bookin .5s ease-out both; }
@keyframes bookin { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.book-card .kicker { margin: 0 0 4px; font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.book-card .book-text { margin: 0; font-size: 15px; line-height: 1.45; font-style: italic; }
.book-card .book-close { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-2); font-size: 15px; }
.hud-hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--palette-h) + 8px + var(--sab)); margin: 0; max-width: calc(100% - 24px); text-align: center; font-size: 13px; color: var(--ink); padding: 6px 12px; background: var(--card); border: 1px solid var(--rule); border-radius: 3px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity .6s; pointer-events: none; }
.hud-hint:empty, body.has-inspector .hud-hint { display: none; }
.hud-hint.is-gone { opacity: 0; }
.toasts { position: absolute; left: 50%; bottom: calc(var(--palette-h) + 30px + var(--sab)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; max-width: calc(100% - 24px); }
.toast { margin: 0; padding: 8px 14px; background: var(--card); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--rule); border-radius: 3px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; animation: toastin .25s ease-out both; }
.toast.warn { border-color: var(--accent); }
.toast.bad { border-color: var(--bad); }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- banner ---------- */
.banner { position: absolute; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); top: max(20vh, calc(var(--strip-h) + 60px + var(--sat))); text-align: center; pointer-events: none; animation: banner 1.1s ease-out both; text-shadow: 0 2px 8px rgba(0,0,0,.8); padding: 12px 22px; background: rgba(6,10,18,.62); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 3px; }
@keyframes banner { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.banner .kicker { margin: 0 0 4px; font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--accent); }
.banner .name { margin: 0; font-family: var(--font-display); font-size: clamp(28px, 6vw, 46px); font-weight: 600; line-height: 1.05; }
.banner .line { margin: 8px 0 0; font-size: 16px; color: var(--ink-2); font-style: italic; }

/* ---------- screens ---------- */
.screens { position: absolute; inset: 0; pointer-events: none; }
.screen { position: absolute; 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)); pointer-events: auto; background: rgba(4,8,16,0.35); }
.screen--title { background: none; }
.card { width: min(100%, 560px); max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--card); backdrop-filter: blur(var(--card-blur)); -webkit-backdrop-filter: blur(var(--card-blur)); border: 1px solid var(--rule); border-radius: 3px; padding: 26px 28px; display: flex; flex-direction: column; }
.card > * { flex: 0 0 auto; }
.card > .actions { position: sticky; bottom: -26px; margin: 14px -28px -26px; padding: 12px 28px 22px; background: var(--card-solid); border-top: 1px solid var(--rule); }
.title-card > .actions { position: static; margin: 20px 0 0; padding: 0; background: none; border: 0; }
.card.wide { width: min(100%, 720px); }
.kicker { margin: 0 0 4px; font-size: 12px; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); }
.card .name { margin: 0 0 14px; font-family: var(--font-display); font-size: 36px; line-height: 1; font-weight: 600; }
.card p.line { margin: 0 0 12px; font-size: 16.5px; line-height: 1.5; }
.card p.line--small { font-size: 13.5px; color: var(--ink-2); }
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-2); }
.word { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(50px, 11vw, 92px); line-height: .95; letter-spacing: .02em; color: var(--ink); text-shadow: 0 2px 18px rgba(0,0,0,.6); }
.tag { margin: 14px 0 0; font-size: 18px; line-height: 1.35; text-shadow: 0 1px 6px rgba(0,0,0,.7); }
.tag--sub { margin-top: 6px; font-size: 15px; color: var(--ink-2); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.actions--row { flex-direction: row; justify-content: flex-end; flex-wrap: wrap; }
.actions--row .btn { width: auto; min-width: 120px; }
.actions .row { display: flex; gap: 6px; flex-wrap: wrap; }
.actions .row .btn { width: auto; flex: 1 1 auto; text-align: center; padding: 9px 10px; font-size: 14px; }
.btn { display: block; width: 100%; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(8,14,26,.55); text-align: left; font-size: 16px; transition: background .15s, border-color .15s, transform .15s; }
.btn small { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn--primary { border-color: var(--accent); background: rgba(240,180,94,.2); }
.btn--primary::after { content: "→"; float: right; margin-left: 12px; color: var(--accent); }
.btn--quiet { color: var(--ink-2); }
.foot { margin: 16px 0 0; font-size: 13px; color: var(--ink-2); text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.title-card { width: min(100%, 600px); padding: 0; }
.title-card .actions { max-width: 360px; }
.screen--title { align-items: flex-end; padding-bottom: calc(5vh + var(--sab)); }
.soundtoggle { position: absolute; right: calc(14px + var(--sar)); top: calc(12px + var(--sat)); padding: 8px 12px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(8,14,26,.55); font-size: 13px; color: var(--ink-2); }
.build { position: absolute; left: calc(16px + var(--sal)); bottom: calc(10px + var(--sab)); margin: 0; font-size: 12.5px; color: var(--ink-2); }
.build a { color: var(--ink-2); }

.story .lines p { margin: 0 0 12px; font-size: 17px; line-height: 1.5; }
.story .voice, .ending .voice { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 12.5px; color: var(--ink-2); }
.voice i { display: inline-block; width: 22px; height: 10px; background: repeating-linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 4px); opacity: .8; }
.voice.is-speaking i { animation: wave 1.2s linear infinite; }
@keyframes wave { to { background-position: 4px 0; } }
.mods { list-style: none; margin: 0 0 6px; padding: 0; }
.mods li label { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.mods li span { color: var(--ink-2); font-size: 14px; }
.mods input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }
.settings { list-style: none; margin: 0; padding: 0; }
.settings li label { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.settings li label > span:first-child { flex: 0 0 120px; }
.settings li label > span:last-child { color: var(--ink-2); font-size: 13.5px; }
.settings input[type=range] { flex: 1 1 auto; accent-color: var(--accent); }
.settings input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }
.howto { margin: 0 0 12px; }
.howto dt { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin: 10px 0 2px; }
.howto dd { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.controls h4 { margin: 0 0 4px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.controls p { margin: 0 0 3px; font-size: 13.5px; color: var(--ink-2); }
kbd { font: 11px/1 ui-monospace, Menlo, monospace; padding: 2px 5px; border: 1px solid var(--ink-3); border-bottom-width: 2px; border-radius: 3px; color: var(--ink); }
.tabs { display: flex; gap: 4px; margin: 0 0 10px; }
.tab { flex: 1 1 auto; padding: 8px 6px; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--ink-2); font-size: 14px; }
.tab.is-on { color: var(--ink); border-color: var(--accent); background: rgba(240,180,94,.15); }
.board { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.board li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--rule); font-size: 15px; }
.board li.you { color: var(--accent); }
.board li b { letter-spacing: .12em; }
.board li small { display: block; font-size: 12px; color: var(--ink-2); letter-spacing: 0; }
.board li.empty { display: block; color: var(--ink-2); font-style: italic; }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.entries li .when { display: block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.entries li .title { display: block; font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.entries li p { margin: 0 0 6px; font-size: 15px; line-height: 1.45; }
.entries li.note p { color: var(--ink-2); font-style: italic; }
.entries li.notice { padding: 6px 0; }
.entries li.notice p { font-size: 14.5px; margin: 0; }
.entries li.notice.warn p { color: var(--accent); }
.entries li.notice.bad p { color: var(--bad); }
.entries li.notice.book p { font-style: italic; }
.stats { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.stats li { display: flex; flex-direction: column; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 3px; }
.stats span { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.stats b { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.entry { margin: 10px 0 6px; }
.entry label { display: block; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; }
.entry-row { display: flex; gap: 8px; }
.entry-row input { width: 5em; min-width: 108px; padding: 10px 8px; border: 1px solid var(--rule); border-radius: 3px; background: rgba(0,0,0,.3); font-family: var(--font-display); font-size: 22px; letter-spacing: .15em; text-indent: .15em; text-transform: uppercase; text-align: center; }
.entry-row .btn { width: auto; }
.entry-note { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-2); }

/* ---------- phones ---------- */
@media (max-width: 720px), (max-height: 500px) {
  :root { --strip-h: 118px; --palette-h: 118px; }
  body { font-size: 16px; }
  .strip { grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; gap: 4px 8px; padding-top: calc(4px + var(--sat)); align-items: center; }
  .stores { grid-column: 1 / -1; grid-row: 2; max-width: none; gap: 2px 8px; align-self: center; align-items: center; }
  .stores li { font-size: 12.5px; gap: 4px; }
  .stores li span { display: inline; font-size: 9px; letter-spacing: .04em; }
  .stores li b { min-width: 0; }
  .stores li.toggle { display: flex; }
  .strip-mid { grid-column: 1; grid-row: 1; align-items: flex-start; }
  .year { font-size: 15px; }
  .gauge { width: 110px; }
  .gauge-label { font-size: 10px; }
  .strip-right { display: contents; }
  .souls { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-end; gap: 0; }
  .souls b { font-size: 22px; }
  .souls small { font-size: 10.5px; }
  .souls .hud-label { display: none; }
  .spirit { grid-column: 2; grid-row: 1; display: none; }
  .speed { grid-column: 3; grid-row: 1; }
  .speed button { width: 38px; height: 40px; font-size: 11px; }
  .strip-btns { grid-column: 3; grid-row: 1; display: none; }
  .strip-btn { height: 40px; padding: 0 10px; font-size: 12.5px; }
  .palette { grid-template-columns: 1fr; grid-template-rows: auto auto auto; padding-bottom: calc(6px + var(--sab)); }
  .cats { gap: 2px; }
  .cat { padding: 9px 8px; font-size: 11.5px; letter-spacing: .03em; }
  .palette-side { grid-column: 1; grid-row: 3; flex-direction: row; align-items: center; justify-content: space-between; }
  .palette-sel { text-align: left; max-width: none; flex: 1 1 auto; font-size: 12.5px; }
  .pal-btn { min-width: 128px; height: 54px; grid-template-columns: 40px 1fr; }
  .pal-btn .thumb { width: 40px; height: 40px; }
  .pal-btn b { font-size: 13px; }
  .pal-btn small { font-size: 10.5px; }
  .build-btn { height: 46px; padding: 0 18px; }
  .cancel-btn { width: 46px; height: 46px; }
  body.lefthand .palette-side { flex-direction: row-reverse; }
  .inspector { left: calc(8px + var(--sal)); right: calc(8px + var(--sar)); top: auto; bottom: calc(var(--palette-h) + var(--sab)); width: auto; max-height: 46vh; padding: 12px 14px; z-index: 2; }
  .inspector h3 { font-size: 21px; }
  .inspector .workers button { width: 44px; height: 44px; }
  .inspector .trade button { padding: 10px 8px; }
  .book-card { top: calc(var(--strip-h) + 8px + var(--sat)); width: calc(100% - 16px); left: 8px; }
  body.has-inspector .book-card { display: none; }
  .hud-hint { bottom: calc(var(--palette-h) + 6px + var(--sab)); font-size: 12px; }
  .toasts { bottom: auto; top: calc(var(--strip-h) + 8px + var(--sat)); }
  .toasts .toast { white-space: normal; text-align: center; }
  .banner { top: auto; bottom: calc(var(--palette-h) + 96px + var(--sab)); }
  .banner .name { font-size: clamp(24px, 6vw, 34px); }
  .banner .line { font-size: 14px; }
  .card { padding: 20px 18px; }
  .card > .actions { bottom: -20px; margin: 12px -18px -20px; padding: 10px 18px 16px; }
  .card .name { font-size: 30px; }
  .word { font-size: clamp(44px, 14vw, 72px); }
  .tag { font-size: 16px; }
  .story .lines p { font-size: 16px; }
  .actions--row .btn { min-width: 0; flex: 1 1 auto; }
  .actions .row .btn { padding: 12px 10px; }
  .settings li label > span:first-child { flex-basis: 90px; }
  .controls { grid-template-columns: 1fr; }
  .soundtoggle { padding: 12px 14px; }
}
/* on a phone the stores keep the left of the second row; Menu takes the right, and the Book is inside it */
@media (max-width: 720px), (max-height: 500px) {
  .stores { grid-column: 1 / 3; }
  .strip-btns { display: flex; grid-column: 3; grid-row: 2; justify-self: end; align-self: start; }
  .strip-btns .strip-btn { height: 34px; }
  .strip-btns [data-act="book"] { display: none; }
}
/* short screens: a phone on its side */
@media (max-height: 500px) {
  :root { --strip-h: 84px; --palette-h: 74px; }
  .strip { grid-template-rows: auto auto; }
  .stores li span { display: none; }
  .cats { display: none; }
  .palette { grid-template-rows: auto auto; }
  .palette-scroll { grid-row: 1; }
  .palette-side { grid-row: 2; }
  .pal-btn { height: 46px; min-width: 116px; grid-template-columns: 34px 1fr; }
  .pal-btn .thumb { width: 34px; height: 34px; }
  .pal-btn small { display: none; }
  .hud-hint { display: none; }
  .inspector { max-height: 58vh; }
  .book-card { top: calc(var(--strip-h) + 4px + var(--sat)); }
  .banner { bottom: calc(var(--palette-h) + 60px + var(--sab)); padding: 8px 16px; }
  .banner .name { font-size: 22px; }
  .banner .line { display: none; }
  .screen--title { align-items: center; padding-bottom: calc(12px + var(--sab)); }
  .title-card { max-height: 100%; overflow-y: auto; }
  .word { font-size: clamp(34px, 9vh, 56px); }
  .tag--sub { display: none; }
  .title-card .actions { margin-top: 10px; gap: 6px; }
  .title-card .btn { padding: 8px 14px; font-size: 15px; }
  .title-card .btn small { display: none; }
  .foot { margin-top: 8px; }
  .card { padding: 14px 16px; }
  .card > .actions { bottom: -14px; margin: 10px -16px -14px; padding: 8px 16px 12px; }
  .card .name { font-size: 24px; margin-bottom: 8px; }
  .story .lines p { font-size: 14.5px; margin-bottom: 8px; }
}
body.reduce-motion * { animation: none !important; transition: none !important; }
