:root {
  color-scheme: light;
  --paper: #e8e5d8;
  --panel: #eeebdf;
  --ink: #292c27;
  --dim: #727267;
  --line: #292c2733;
  --accent: #d84929;
  --gold: #92602b;
  --bad: #b32920;
  --ok: #3b6244;
  --sidebar: 354px;
  --header: 88px;
  --footer: 34px;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
  --display: 'Barlow Condensed', Impact, 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; touch-action: manipulation; /* no double-tap page zoom on rapid taps */ background: var(--paper); color: var(--ink); font-family: var(--mono); }
body { user-select: none; }
button { font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { display: block; }
.hidden { display: none !important; }
.eyebrow { font-size: 9px; line-height: 1.5; font-weight: 500; letter-spacing: .055em; }
.live-dot { display: inline-block; width: 5px; height: 5px; background: #4b7147; flex: none; }

#scene { position: fixed; top: var(--header); bottom: var(--footer); left: 0; right: var(--sidebar); overflow: hidden; }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#vignette { position: fixed; inset: var(--header) var(--sidebar) var(--footer) 0; pointer-events: none; border-left: 10px solid var(--paper); }

/* A single engraved instrument strip. */
#hud { position: fixed; inset: 0 0 auto; height: var(--header); display: flex; align-items: stretch; border-bottom: 2px solid var(--ink); background: var(--panel); z-index: 2; padding: 0 22px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1.4; min-width: 220px; font-family: var(--display); font-size: 29px; font-weight: 700; line-height: .9; letter-spacing: -.02em; white-space: nowrap; }
.brand-symbol { display: flex; align-items: center; justify-content: center; flex: none; width: 39px; height: 42px; background: var(--accent); color: var(--panel); font-family: var(--display); font-size: 33px; font-weight: 800; letter-spacing: -.22em; padding-right: 6px; overflow: hidden; }
.brand-symbol span { transform: translateY(6px); }
.brand small { display: block; margin-top: 8px; font-family: var(--mono); font-size: 6px; font-weight: 500; letter-spacing: .12em; }
.stat { flex: 1; min-width: 120px; padding: 15px 22px 12px; border-left: 1px solid var(--line); white-space: nowrap; }
.stat label { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; color: var(--dim); font-size: 9px; font-weight: 500; letter-spacing: .02em; margin-bottom: 5px; }
.stat b { font-family: var(--display); font-weight: 600; font-size: 33px; font-variant-numeric: tabular-nums; line-height: 1; }
.stat small { color: var(--dim); font-size: 8px; }
.stat.big { flex: 1.25; min-width: 182px; }
.stat.big b { font-size: 39px; }
.balance { display: flex; align-items: center; gap: 7px; }
.balance > small { align-self: end; padding-bottom: 3px; }
.token-symbol, .mini-coin, .hud-token { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid #8b6231; border-radius: 50%; background: #c6a566; color: #654820; font-family: var(--display); font-weight: 700; font-size: 13px; box-shadow: inset 0 0 0 2px #e6ce99; flex: none; }
#wallet-gain { color: var(--accent); font-size: 10px; opacity: 0; transition: opacity .15s; }
#wallet-gain.visible { opacity: 1; }
.hype-stat { flex: .7; min-width: 100px; }
.hype-stat b { font-size: 26px; }
.hud-controls { display: flex; align-items: center; gap: 6px; flex: none; padding-left: 12px; }
.iconbtn { align-self: center; display: grid; place-items: center; flex: none; width: 30px; height: 32px; margin-left: 0; border: 1px solid var(--ink); border-radius: 2px; background: transparent; color: var(--ink); cursor: pointer; }
.iconbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: square; stroke-linejoin: miter; }
.iconbtn[aria-pressed="false"] { color: var(--dim); border-style: dashed; }
.iconbtn:hover { background: #292c2710; }

/* Facility annotations share a flow as headings and buffs change. */
#facility-overlay { position: fixed; top: calc(var(--header) + 30px); left: 33px; width: min(440px, calc(100vw - var(--sidebar) - 120px)); max-height: calc(100dvh - var(--header) - var(--footer) - 170px); display: flex; flex-direction: column; overflow: hidden; pointer-events: none; }
#sector { position: static; flex: none; min-width: 0; }
#sector .eyebrow { display: flex; align-items: center; gap: 7px; color: var(--dim); font-size: 8px; }
#sector-index { color: var(--ink); }
.sector-separator { margin-inline: 4px; color: #a09d8f; }
#sector h1 { font-family: var(--display); font-size: clamp(30px, 2.8vw, 42px); font-weight: 700; line-height: .9; letter-spacing: -.015em; text-transform: uppercase; margin: 8px 0 6px; max-width: 100%; overflow-wrap: anywhere; }
#sector p { color: #61645a; font-size: 10px; line-height: 1.7; margin: 0; max-width: 285px; }
#buffs { display: flex; flex-wrap: wrap; gap: 5px; max-width: 300px; margin-top: 12px; }
#buffs:empty { display: none; }
.chip { border: 1px solid #42614570; background: #e8e5d8; color: #38583c; font-size: 9px; padding: 5px 7px; }
.chip.bad { color: var(--bad); border-color: #b3292066; }
#scene-tools { position: fixed; top: calc(var(--header) + 18px); right: calc(var(--sidebar) + 25px); display: flex; }
.toolbtn { display: flex; align-items: center; gap: 7px; background: var(--paper); color: var(--ink); border: 1px solid #292c2759; padding: 8px 10px; cursor: pointer; }
.toolbtn + .toolbtn { border-left: 0; }
.toolbtn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.toolbtn span { font-size: 7px; letter-spacing: .04em; }
.toolbtn:hover, .toolbtn[aria-pressed="true"] { color: var(--panel); background: var(--ink); }

/* The purchasing book uses rules and columns, rather than a stack of cards. */
#panel { position: fixed; top: var(--header); bottom: var(--footer); right: 0; width: var(--sidebar); display: flex; flex-direction: column; background: var(--panel); border-left: 2px solid var(--ink); overflow: hidden; }
.panel-heading { flex: none; padding: 24px 22px 18px; }
.panel-heading .eyebrow { display: flex; justify-content: space-between; font-size: 8px; color: var(--dim); }
.panel-version { color: var(--dim); font-size: 7px; }
.panel-heading h2 { display: flex; justify-content: space-between; align-items: center; font-family: var(--display); font-size: 42px; font-weight: 600; line-height: 1; letter-spacing: -.01em; margin: 12px 0 8px; }
.panel-heading h2 > span { color: var(--accent); font-size: 34px; }
.panel-heading p { font-size: 9px; color: var(--dim); margin: 0; }
.fleet-summary { display: flex; justify-content: space-between; align-items: center; flex: none; gap: 12px; margin: 0 22px 20px; padding: 12px 14px; color: #bdcc91; background: #30372d; border: 3px solid #777a66; outline: 1px solid var(--ink); box-shadow: inset 0 0 0 2px #191f1b; }
.fleet-summary .eyebrow { color: #a0ac80; font-size: 7px; letter-spacing: .09em; }
.fleet-output { display: flex; align-items: baseline; gap: 8px; margin-top: 5px; }
.fleet-output b { font-size: 21px; font-weight: 500; font-variant-numeric: tabular-nums; }
.fleet-output > span { color: #a0ac80; font-size: 7px; }
.monitor-caption { display: block; font-size: 5px; color: #919e75; margin-top: 5px; letter-spacing: .07em; }
#production-chart { width: 96px; height: 38px; flex: none; background-image: linear-gradient(#9cb27912 1px, transparent 1px), linear-gradient(90deg, #9cb27912 1px, transparent 1px); background-size: 12px 9px; }
#panel nav { display: flex; flex: none; margin: 0 22px; border-block: 1px solid var(--ink); }
#panel nav button { flex: 1; position: relative; white-space: nowrap; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; color: #6b6e62; padding: 12px 3px; font-size: 9px; cursor: pointer; }
#panel nav button:last-child { border-right: 0; }
#panel nav button.on { color: var(--panel); background: var(--ink); }
#panel nav button:hover:not(.on) { color: var(--ink); background: #292c2709; }
.count { display: inline-block; padding: 0 3px; margin-left: 4px; background: var(--accent); color: #fff5dc; font-size: 8px; line-height: 1.5; }
.tab { overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; padding: 15px 22px 10px; scrollbar-width: thin; scrollbar-color: #aaa998 transparent; }
.tab-intro { display: flex; justify-content: space-between; font-size: 7px; color: var(--dim); padding-bottom: 12px; border-bottom: 1px solid var(--line); letter-spacing: .04em; }
.card { --progress: 0; position: relative; display: grid; grid-template-columns: 37px 1fr 32px; width: 100%; gap: 4px 11px; align-items: center; padding: 16px 0 17px; margin: 0; border: 0; border-bottom: 1px solid #292c2742; border-radius: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; transition: background .15s; }
.card::after { content: ''; position: absolute; bottom: -1px; left: 0; height: 2px; width: calc(100% * var(--progress)); background: var(--accent); opacity: .65; transition: width .2s; }
.card:hover:not(:disabled) { background: #d8d4c44a; }
.card:active:not(:disabled) { background: #cdc7b449; }
.card:disabled { cursor: default; }
.card .ic { display: grid; place-items: center; grid-row: 1 / 4; width: 37px; min-height: 44px; color: #4b5046; }
.card .ic svg { width: 31px; height: 31px; stroke-width: 1; }
.card .nm { font-family: var(--display); font-weight: 600; font-size: 21px; letter-spacing: 0; line-height: 1; }
.card .own { grid-column: 3; grid-row: 1 / 3; align-self: start; text-align: right; font-family: var(--display); font-size: 26px; font-weight: 500; color: #6e7164; line-height: 1; }
.card .own::before { content: 'QTY'; display: block; margin-bottom: 4px; font-family: var(--mono); font-size: 6px; letter-spacing: .08em; color: #797a6e; }
.card .ds { grid-column: 2; color: #707166; font-size: 9px; line-height: 1.7; }
.card .cs { grid-column: 2; grid-row: 3; display: inline-flex; align-items: center; justify-self: start; gap: 5px; min-height: 22px; padding: 3px 7px; margin-top: 5px; background: var(--ink); color: var(--panel); font-size: 10px; }
.mini-coin { width: 12px; height: 12px; font-size: 8px; box-shadow: none; border-color: #c8b98e; background: #d4c29a; color: #594b30; }
.card:disabled .cs { background: transparent; border: 1px solid #8d8b7c66; color: #77786b; padding: 2px 6px; }
.card:disabled .mini-coin { background: #d6d0b9; color: #8b7a54; border-color: #aba187; }
.card .rate { grid-column: 3; grid-row: 3; justify-self: end; align-self: center; margin-top: 5px; color: #52634b; font-size: 8px; white-space: nowrap; }
.card.up { grid-template-columns: 1fr auto; gap: 7px 10px; }
.card.up .nm { font-size: 20px; line-height: 1.1; }
.card.up .cs { grid-column: 2; grid-row: 1; margin-top: 0; }
.card.up .ds, .card.up .fx { grid-column: 1 / 3; }
.card.up .fx { margin-top: 4px; font-size: 9px; color: #4a6042; }
.card.locked { grid-template-columns: 37px 1fr; padding-block: 16px; border-bottom-style: dashed; cursor: default; }
.card.locked .ic { font-size: 24px; color: #9a9a8b; grid-row: 1 / 3; }
.card.locked .nm { font-family: var(--mono); font-size: 9px; color: #76796b; }
.card.locked .ds { grid-column: 2; font-size: 8px; }
.card.purchased { animation: installed .5s ease-out; }
@keyframes installed { from { background: #d849292b; } }
h4 { font-size: 10px; font-weight: 500; text-transform: uppercase; margin: 15px 0 12px; }
.bought { padding: 8px 0; border-bottom: 1px dotted var(--line); font-size: 9px; line-height: 1.7; color: var(--dim); }
.panel-footer { display: flex; align-items: center; gap: 6px; flex: none; border-top: 1px solid var(--ink); padding: 12px 22px; font-size: 7px; color: var(--dim); }
#save-status { margin-left: auto; }
#tab-agi p { font-size: 10px; line-height: 1.9; color: #66695e; }
.pivot-ledger { display: grid; grid-template-columns: 1fr auto; gap: 12px; border-block: 1px solid var(--line); padding-block: 15px; margin: 20px 0; font-size: 9px; }
.pivot-ledger b { font-weight: 500; }
#hypeGain { color: var(--accent); }
.bigbtn { display: flex; justify-content: space-between; width: 100%; padding: 14px; border: 1px solid var(--ink); background: var(--accent); color: #fff0d8; font-size: 10px; font-weight: 500; cursor: pointer; }
.bigbtn:disabled { background: #d6d2c3; color: #88897c; border-color: #a29f90; cursor: default; }
.smallbtn { margin-top: 24px; border: 0; border-bottom: 1px solid var(--line); padding: 4px 0; background: none; font-size: 8px; color: var(--dim); cursor: pointer; }

/* A punched work order and a mechanical input key. */
#milestone { position: fixed; bottom: calc(var(--footer) + 27px); left: 33px; width: 224px; padding: 26px 14px 12px; border: 1px solid #8e8d7a77; background: #f2eddb; box-shadow: 3px 3px 0 #292c270a; }
.ticket-edge { position: absolute; top: 8px; left: 14px; right: 14px; display: flex; justify-content: space-between; border-bottom: 1px dashed #b0ab95; padding-bottom: 7px; }
.ticket-edge i { width: 5px; height: 5px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 1px 1px #292c2729; }
.milestone-label { display: flex; justify-content: space-between; margin-top: 7px; color: var(--dim); font-size: 7px; letter-spacing: .03em; }
#goal-percent { color: var(--accent); }
.milestone-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 9px; }
#goal-title { font-family: var(--display); font-weight: 600; font-size: 23px; line-height: 1; }
#goal-amount { font-size: 8px; color: var(--dim); white-space: nowrap; }
.progress-track { height: 4px; margin-top: 11px; background: #292c2712; overflow: hidden; }
#goal-progress { width: 0; height: 100%; background: var(--accent); transition: width .25s; }
#milestone p { margin: 8px 0 0; color: #787667; font-size: 7px; line-height: 1.8; }
#prompt-dock { position: fixed; bottom: calc(var(--footer) + 27px); left: calc((100% - var(--sidebar)) / 2); width: 268px; transform: translateX(-50%); text-align: center; }
.engine-status { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 26px; }
#flow { color: #656b5a; font-size: 8px; letter-spacing: .05em; }
#flow.active { color: var(--accent); }
#prompt { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; padding: 15px; border: 2px solid #87361e; border-radius: 3px; background: var(--accent); color: #fff0dc; box-shadow: 0 4px 0 #8a3a22, inset 0 1px 0 #f09c78; text-align: left; font-family: var(--display); font-size: 28px; font-weight: 600; line-height: .9; cursor: pointer; transition: transform .08s, box-shadow .08s; }
#prompt:hover { background: #e25230; }
#prompt:active, #prompt.firing { transform: translateY(3px); box-shadow: 0 1px 0 #8a3a22; }
.prompt-icon { padding-right: 12px; border-right: 1px solid #ffdfb845; font-family: var(--mono); font-size: 23px; line-height: 1.4; }
#prompt small { display: block; margin-top: 7px; font-family: var(--mono); font-size: 6px; font-weight: 400; letter-spacing: .025em; }
kbd { margin-left: auto; padding: 6px; border: 1px solid #fff0dc88; font-family: var(--mono); font-size: 7px; font-weight: 400; color: #ffe6ca; }
#hint { margin-top: 12px; color: #7d7b6c; font-size: 7px; transition: opacity .7s; pointer-events: none; }

#ticker { position: fixed; inset: auto 0 0; display: flex; align-items: center; gap: 18px; height: var(--footer); padding: 0 23px; border-top: 1px solid var(--ink); background: var(--ink); color: var(--paper); }
.ticker-label { display: flex; align-items: center; gap: 7px; flex: none; font-size: 7px; letter-spacing: .03em; }
.ticker-square { width: 5px; height: 5px; background: #dc6b44; }
#headline { margin: 0; font-size: 9px; color: #c1c2b4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .4s; }
.ticker-end { margin-left: auto; color: #9a9e8f; font-size: 6px; white-space: nowrap; }
#toasts { position: fixed; top: calc(var(--header) + 64px); right: calc(var(--sidebar) + 25px); width: 270px; display: flex; flex-direction: column; gap: 7px; pointer-events: none; z-index: 3; }
.toast { flex: none; }
.toast { padding: 12px; background: #f1eddc; border: 1px solid var(--ink); border-left: 4px solid #5c7150; box-shadow: 3px 3px 0 #292c2710; animation: tin .25s ease-out; }
.toast.gold { border-left-color: var(--accent); }
.toast.bad { border-left-color: var(--bad); }
.toast b { display: block; margin-bottom: 5px; font-size: 10px; font-weight: 500; }
.toast i { font-size: 8px; font-style: normal; line-height: 1.8; color: var(--dim); }
.toast.out { animation: tout .35s ease-in forwards; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
@keyframes tout { to { opacity: 0; transform: translateY(-8px); } }
#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.float { position: absolute; font-family: var(--mono); font-size: 21px; font-weight: 500; color: #8a4a25; text-shadow: 1px 1px 0 #eee9d9; transform: translate(-50%, -50%); white-space: nowrap; animation: rise .85s ease-out forwards; }
.float.small { font-size: 9px; color: #465f40; }
.hud-token { position: absolute; width: 21px; height: 21px; font-size: 13px; will-change: transform; }
.click-ripple { position: absolute; width: 24px; height: 24px; margin: -12px; border: 1px solid #b87a4280; border-radius: 50%; animation: ripple .45s ease-out forwards; }
@keyframes ripple { to { opacity: 0; transform: scale(3); } }
@keyframes fade { to { opacity: 0; } }

/* Juice: crits, flash, overclock heat, bulk buying, records. */
#flash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 40% 50%, #fff3d6, #ffb36b 60%, #ff6a2c); opacity: 0; mix-blend-mode: screen; z-index: 5; }
.float.crit { font-family: var(--display); font-size: 40px; font-weight: 800; color: var(--accent); letter-spacing: .01em; text-shadow: 2px 2px 0 #292c27, 0 0 18px #ffb36b; animation: crit .95s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes crit { 0% { transform: translate(-50%, -50%) scale(.3) rotate(-8deg); } 25% { transform: translate(-50%, -50%) scale(1.25) rotate(3deg); } 60% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -150%) scale(1) rotate(0); } }
.float { animation: rise .85s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes rise { 0% { transform: translate(-50%, -50%) scale(.6); } 20% { transform: translate(-50%, -50%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); margin-top: -70px; } }
#prompt { overflow: hidden; }
#prompt .heat { position: absolute; left: 0; bottom: 0; height: 4px; width: calc(100% * var(--heat, 0)); background: linear-gradient(90deg, #ffd27a, #fff3d6); box-shadow: 0 0 10px #ffd27a; transition: width .08s linear; }
body.overclock #prompt { background: #ff6a2c; animation: oc-throb .25s ease-in-out infinite alternate; }
body.overclock #prompt .heat { background: linear-gradient(90deg, #fff3d6, #ffe08a); }
body.overclock #vignette { box-shadow: inset 0 0 90px #ff7a2c88; }
body.overclock #flow { color: #ff6a2c; font-weight: 600; }
@keyframes oc-throb { to { box-shadow: 0 4px 0 #8a3a22, 0 0 28px #ff8a3d; } }
#wallet { transition: transform .1s; }
.buy-mode { display: flex; gap: 0; }
.buy-mode button { border: 1px solid var(--line); border-left-width: 0; background: transparent; color: var(--dim); font-size: 7px; padding: 3px 7px; cursor: pointer; }
.buy-mode button:first-child { border-left-width: 1px; }
.buy-mode button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.card .cs em { font-style: normal; opacity: .7; font-size: 8px; }
.card .ms { --ms: 0; grid-column: 2 / 4; grid-row: 4; position: relative; height: 12px; margin-top: 4px; font-size: 6px; letter-spacing: .06em; color: var(--dim); padding-left: 0; }
.card .ms::after { content: ''; position: absolute; left: 52px; right: 0; top: 4px; height: 3px; background: var(--line); }
.card .ms::before { content: ''; position: absolute; left: 52px; top: 4px; height: 3px; width: calc((100% - 52px) * var(--ms)); background: var(--gold); z-index: 1; }
.count.soft { background: transparent; color: inherit; opacity: .7; }
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-top: 12px; }
.badge { display: grid; grid-template-columns: 18px 1fr; gap: 2px 6px; padding: 8px; border: 1px dashed var(--line); color: var(--dim); }
.badge b { grid-row: 1 / 3; font-size: 15px; line-height: 1; }
.badge span { font-family: var(--display); font-size: 15px; font-weight: 600; line-height: 1; }
.badge small { font-size: 7px; line-height: 1.5; }
.badge.got { border: 1px solid var(--ink); color: var(--ink); background: #d849290d; }
.badge.got b { color: var(--accent); }
.toast.ach { border-left-color: var(--gold); background: #f6e7bf; animation: tin-pop .45s cubic-bezier(.2, 1.6, .4, 1); }
:root[data-theme="dark"] .toast.ach { background: #3a3424; }
@keyframes tin-pop { from { opacity: 0; transform: translateX(-30px) scale(.9); } }

#unit-tip { position: fixed; left: 0; top: 0; z-index: 6; display: grid; gap: 3px; padding: 8px 10px; background: var(--ink); color: var(--panel); pointer-events: none; box-shadow: 3px 3px 0 #292c2730; }
#unit-tip b { font-family: var(--display); font-size: 17px; font-weight: 600; }
#unit-tip span { font-size: 8px; }
#unit-tip small { font-size: 6px; letter-spacing: .08em; color: var(--accent); }

/* Night shift uses the same printed controls and warm accent. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #181e21;
  --panel: #22292b;
  --ink: #e6e1d4;
  --dim: #a5afa9;
  --line: #e6e1d431;
  --accent: #ec7952;
  --gold: #d2ad6d;
  --bad: #f39480;
  --ok: #aec48d;
}
:root[data-theme="dark"] .sector-separator { color: #7f8f87; }
:root[data-theme="dark"] #sector p,
:root[data-theme="dark"] :root[data-theme="dark"] :root[data-theme="dark"] .panel-heading .eyebrow,
:root[data-theme="dark"] .card .ds,
:root[data-theme="dark"] .card .own,
:root[data-theme="dark"] .card .own::before,
:root[data-theme="dark"] .card.locked .nm,
:root[data-theme="dark"] .card.locked .ic,
:root[data-theme="dark"] #tab-agi p,
:root[data-theme="dark"] #goal-amount,
:root[data-theme="dark"] #milestone p,
:root[data-theme="dark"] #hint,
:root[data-theme="dark"] #flow { color: var(--dim); }
:root[data-theme="dark"] #flow.active { color: var(--accent); }
:root[data-theme="dark"] .live-dot { background: #a1bf80; }
:root[data-theme="dark"] .chip { background: #29392e; color: #c0d5a8; border-color: #88ad7877; }
:root[data-theme="dark"] .chip.bad { color: var(--bad); background: #3c2c28; border-color: #c37e6f77; }
:root[data-theme="dark"] .card { border-bottom-color: var(--line); }
:root[data-theme="dark"] .card .ic { color: #b5c2bb; }
:root[data-theme="dark"] .card:hover:not(:disabled) { background: #e6e1d40a; }
:root[data-theme="dark"] .card:active:not(:disabled) { background: #e6e1d416; }
:root[data-theme="dark"] .card .cs { background: #d2b47a; color: #242b27; }
:root[data-theme="dark"] .card:disabled .cs { background: transparent; border-color: #a6b2a54d; color: #b4beb6; }
:root[data-theme="dark"] .card .rate,
:root[data-theme="dark"] .card.up .fx { color: #b6cc9e; }
:root[data-theme="dark"] #panel nav button { color: #bac1b9; }
:root[data-theme="dark"] #panel nav button.on { background: #d9d7c9; color: #232b28; }
:root[data-theme="dark"] .toolbtn:hover,
:root[data-theme="dark"] .toolbtn[aria-pressed="true"] { background: #ddd9ca; color: #232b28; }
:root[data-theme="dark"] #milestone { background: #292f2c; border-color: #7f87775c; }
:root[data-theme="dark"] .ticket-edge { border-color: #737e6e; }
:root[data-theme="dark"] .progress-track { background: #e6e1d41a; }
:root[data-theme="dark"] .toast { background: #2c3431; border-color: #899783; }
:root[data-theme="dark"] .toast.gold { border-left-color: var(--accent); }
:root[data-theme="dark"] .toast.bad { border-left-color: var(--bad); }
:root[data-theme="dark"] #ticker { background: #101718; color: #d8dbcd; }
:root[data-theme="dark"] .float { color: #e7c893; text-shadow: 1px 1px 0 #181e21; }
:root[data-theme="dark"] .float.small { color: #c0d6a8; }
:root[data-theme="dark"] .bigbtn:disabled { background: #343d38; color: #9aa69b; border-color: #6b786e; }

@media (min-width: 1500px) {
  :root { --sidebar: 388px; --header: 94px; }
  #hud { padding-inline: 32px; }
  .brand { min-width: 250px; font-size: 33px; }
  .stat { padding-inline: 28px; }
  #prompt-dock { width: 290px; }
  .panel-heading, .tab { padding-inline: 26px; }
  .fleet-summary, #panel nav { margin-inline: 26px; }
}
@media (max-width: 1200px) {
  .hype-stat { display: none; }
  .brand { min-width: 205px; font-size: 27px; }
  .stat { padding-inline: 18px; }
  #milestone { bottom: calc(var(--footer) + 151px); width: 204px; left: 25px; }
  .ticker-end { display: none; }
  #facility-overlay { left: 25px; }
}
@media (max-width: 950px) {
  :root { --sidebar: 315px; }
  #hud { padding-inline: 16px; }
  .brand { min-width: 190px; font-size: 25px; gap: 8px; }
  .brand-symbol { width: 33px; height: 37px; font-size: 30px; }
  .brand small { font-size: 5px; }
  .stat { min-width: 105px; padding-inline: 12px; }
  .stat.big { min-width: 157px; }
  .stat b { font-size: 29px; }
  .stat.big b { font-size: 35px; }
  .stat label { font-size: 7px; }
  #milestone { display: none; }
  #sector p { max-width: 230px; font-size: 8px; }
  .toolbtn span { display: none; }
  #scene-tools { right: calc(var(--sidebar) + 20px); }
  .toolbtn { padding: 7px; }
  #prompt-dock { width: 247px; }
  #prompt { font-size: 25px; padding: 13px; gap: 10px; }
  .panel-heading { padding: 22px 18px 17px; }
  .panel-heading h2 { font-size: 37px; }
  .panel-heading p { font-size: 8px; }
  .fleet-summary { margin-inline: 18px; padding: 11px; }
  #production-chart { width: 83px; }
  #panel nav { margin-inline: 18px; }
  .tab { padding-inline: 18px; }
  .card { grid-template-columns: 31px 1fr 29px; gap: 4px 8px; }
  .card .ic { width: 31px; }
  .card .ic svg { width: 27px; height: 27px; }
  .card .nm { font-size: 19px; }
  .card .ds { font-size: 8px; }
  .card.up { grid-template-columns: 1fr auto; }
  }
@media (max-width: 760px) and (min-width: 601px) {
  .prompt-stat { display: none; }
  .brand { min-width: 180px; }
  #facility-overlay { left: 20px; }
  #sector p { max-width: 165px; font-size: 7px; }
  #sector .eyebrow { font-size: 6px; gap: 4px; }
  #prompt-dock { width: 224px; }
  #prompt { padding: 12px; font-size: 23px; }
  #prompt small { font-size: 5px; }
  .prompt-icon { padding-right: 9px; font-size: 20px; }
}
@media (max-width: 600px) {
  :root { --sidebar: 0px; --header: 74px; --footer: 30px; }
  #hud { padding-inline: 12px; }
  .brand { min-width: 0; flex: none; gap: 6px; font-size: 21px; width: 123px; }
  .brand-symbol { width: 25px; height: 29px; font-size: 24px; padding-right: 5px; }
  .brand small { font-size: 4px; letter-spacing: .03em; margin-top: 5px; }
  .stat { min-width: 0; padding: 13px 9px; }
  .stat.big { min-width: 0; flex: 1; }
  .stat.big label { font-size: 6px; letter-spacing: 0; }
  .stat.big b { font-size: 31px; }
  .balance { gap: 4px; }
  .balance > small { font-size: 5px; }
  .token-symbol { width: 14px; height: 14px; font-size: 10px; box-shadow: none; }
  .production-stat { flex: .7; }
  .production-stat label { font-size: 6px; letter-spacing: 0; }
  .production-stat b { font-size: 28px; }
  .production-stat > small { display: block; font-size: 5px; margin-top: 2px; }
  .prompt-stat { display: none; }
  .hud-controls { gap: 4px; padding-left: 3px; }
  .iconbtn { width: 23px; height: 27px; }
  .iconbtn svg { width: 13px; height: 13px; }
  #scene, #vignette { bottom: calc(39dvh + var(--footer)); }
  #facility-overlay { top: calc(var(--header) + 19px); left: 18px; width: calc(100vw - 100px); max-height: calc(61dvh - var(--header) - var(--footer) - 115px); }
  #sector h1 { font-size: 28px; margin-top: 6px; }
  #sector .eyebrow { font-size: 6px; gap: 5px; }
  #sector p { max-width: 215px; font-size: 7px; }
  #scene-tools { top: calc(var(--header) + 16px); right: 14px; }
  .toolbtn { padding: 6px; }
  #panel { top: auto; height: 39dvh; width: 100%; border-left: 0; border-top: 2px solid var(--ink); }
  .panel-heading, .fleet-summary { display: none; }
  #panel nav { margin: 0 15px; border-top: 0; }
  #panel nav button { padding: 11px 3px; }
  .tab { padding: 12px 15px 7px; }
  .tab-intro { padding-bottom: 9px; }
  .card { grid-template-columns: 35px 1fr 35px; padding-block: 13px; gap: 3px 10px; }
  .card .ic { width: 35px; }
  .card .nm { font-size: 22px; }
  .card .ds { font-size: 8px; }
  .card .cs { margin-top: 4px; min-height: 20px; }
  .card .rate { margin-top: 4px; }
  .card.up { grid-template-columns: 1fr auto; }
  .panel-footer { padding: 9px 15px; font-size: 6px; }
  #prompt-dock { bottom: calc(39dvh + var(--footer) + 15px); width: 228px; }
  #prompt { padding: 11px 12px; font-size: 24px; gap: 10px; }
  #prompt small { font-size: 5px; margin-top: 6px; }
  .prompt-icon { font-size: 19px; padding-right: 10px; }
  kbd { padding: 5px; font-size: 6px; }
  #flow { font-size: 6px; }
  .engine-status { min-height: 21px; }
  #hint { display: none; }
  #ticker { padding-inline: 14px; gap: 12px; }
  .ticker-label { font-size: 6px; gap: 5px; }
  #headline { font-size: 8px; }
  #toasts { width: min(230px, 100%); right: 14px; top: calc(var(--header) + 56px); }
  .toast { padding: 9px 11px; }
  .toast b { font-size: 9px; }
  .toast i { font-size: 7px; }
  #buffs { max-width: 235px; margin-top: 7px; }
  .chip { font-size: 7px; padding: 4px 5px; }
}
@media (max-width: 370px) {
  .brand { width: 91px; font-size: 17px; gap: 4px; }
  .brand-symbol { width: 22px; font-size: 21px; }
  .brand small { font-size: 3.5px; }
  .stat { padding-inline: 7px; }
  .balance > small { display: none; }
  .production-stat label { font-size: 5px; }
}
@media (max-height: 760px) and (min-width: 601px) {
  .panel-heading { padding-top: 17px; }
  .fleet-summary { margin-bottom: 15px; padding-block: 9px; }
}
@media (max-height: 650px) and (min-width: 601px) {
  #milestone, .fleet-summary { display: none; }
  #facility-overlay { top: calc(var(--header) + 20px); }
  #prompt-dock { bottom: calc(var(--footer) + 17px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .float, .float.crit { animation: fade .4s ease-out forwards !important; }
}

/* ───── polish + responsive pass ───── */
/* A paper plate keeps the facility title legible over a crowded floor. */
#sector { align-self: flex-start; padding: 10px 14px 11px; background: color-mix(in srgb, var(--paper) 84%, transparent); border: 1px solid var(--line); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
:root[data-theme="dark"] #sector { background: color-mix(in srgb, #181e21 82%, transparent); }
#scene-tools .toolbtn { background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(4px); }
#scene-tools .toolbtn:hover, #scene-tools .toolbtn[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
:root[data-theme="dark"] #scene-tools .toolbtn:hover, :root[data-theme="dark"] #scene-tools .toolbtn[aria-pressed="true"] { background: #ddd9ca; color: #232b28; }
.toolbtn:active, .card:not(:disabled):active { transform: translateY(1px); }

/* Supplier sale: price tags turn green and get a stamp. */
.card.on-sale .cs { box-shadow: 0 0 0 2px var(--ok); }
.card.on-sale .cs::after { content: 'SALE'; margin-left: 6px; padding: 1px 4px; font-size: 8px; letter-spacing: .06em; color: var(--panel); background: var(--ok); }

/* Never let toasts bury the scene on small screens. */
@media (max-width: 950px), (max-height: 520px) {
  .toast:nth-child(n+2):not(.deal) { display: none; }
}

/* Phones (portrait). */
@media (max-width: 600px) {
  .brand > div { display: none; } /* the logo mark carries the brand; stats need the width */
  .brand { width: auto; }
  .brand-symbol { width: 30px; height: 34px; font-size: 28px; }
  .stat { padding: 12px 10px 10px; }
  .stat.big label, .production-stat label { font-size: 7px; }
  .stat.big b { font-size: clamp(22px, 7.4vw, 31px); }
  .production-stat b { font-size: clamp(20px, 6.4vw, 28px); }
  .balance > small, .production-stat > small { font-size: 7px; }
  .iconbtn { width: 30px; height: 30px; }
  .iconbtn svg { width: 15px; height: 15px; }
  .hud-controls { flex-direction: column; justify-content: center; gap: 3px; }
  #sector .eyebrow, #flow, .ticker-label, .panel-footer, kbd { font-size: 7px; }
  #sector p, #prompt small { font-size: 8px; }
  #headline { font-size: 9px; }
  .toolbtn { padding: 8px; }
  .toolbtn svg { width: 15px; height: 15px; }
  #panel nav button { font-size: 12px; padding-block: 12px; }
  .card .ds { font-size: 9px; }
  #toasts { left: 16px; right: 16px; width: auto; top: calc(var(--header) + 104px); }
  #prompt small { white-space: nowrap; font-size: 7px; }
  .toast b { font-size: 10px; }
  .toast i { font-size: 8px; }
}
@media (max-width: 370px) {
  .stat { padding-inline: 7px; }
  .brand-symbol { width: 26px; height: 30px; font-size: 24px; }
}

/* Phones (landscape) and other short screens: slim chrome, maximise the floor. */
@media (max-height: 520px) and (min-width: 601px) {
  :root { --header: 58px; --footer: 26px; --sidebar: min(320px, 40vw); }
  #hud { padding-inline: 14px; }
  .brand > div { display: none; }
  .brand { min-width: 0; flex: none; padding-right: 14px; }
  .brand-symbol { width: 30px; height: 34px; font-size: 28px; }
  .stat { padding: 9px 14px 7px; min-width: 0; }
  .stat label { font-size: 7px; margin-bottom: 3px; }
  .stat b { font-size: 24px; }
  .stat.big b { font-size: 28px; }
  .hype-stat { display: none; }
  .panel-heading, .fleet-summary, #milestone, #hint, .ticker-end { display: none; }
  #panel nav { margin: 0 14px; border-top: 0; }
  .tab { padding-inline: 14px; }
  .card { padding-block: 10px; }
  .card .ds { display: none; }
  .panel-footer { padding-block: 6px; }
  #facility-overlay { top: calc(var(--header) + 18px); left: 26px; }
  #sector h1 { font-size: 24px; }
  #sector p { display: none; }
  #prompt-dock { bottom: calc(var(--footer) + 10px); width: 220px; }
  #prompt { padding: 9px 12px; font-size: 22px; }
  #prompt small { display: none; }
  .engine-status { min-height: 18px; }
  #toasts { top: calc(var(--header) + 56px); right: calc(var(--sidebar) + 14px); width: min(240px, 30vw); }
  .toolbtn span { display: none; }
  #scene-tools { top: calc(var(--header) + 14px); right: calc(var(--sidebar) + 14px); }
}

/* Tablets: lift the smallest type to a readable size. */
@media (max-width: 950px) and (min-width: 601px) {
  .stat label, #sector .eyebrow, .brand small { font-size: 8px; }
  #sector p { font-size: 9px; }
  .card .ds { font-size: 9px; }
}

.save-tools { display: flex; gap: 8px; margin-top: 18px; }
.save-tools .smallbtn { flex: 1; margin: 0; }

/* juice pass */
#wallet-gain { display: inline-block; margin-left: 6px; font-weight: 600; transform: translateY(2px); transition: opacity .15s, transform .15s; }
#wallet-gain.visible { transform: none; }
#wallet-gain.spent { color: var(--bad); }
.punch { display: inline-block; animation: punch .28s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes punch { 30% { transform: scale(1.14); } }
.float.buy { font-family: var(--display); font-size: 18px; font-weight: 700; color: var(--accent); text-shadow: 1px 1px 0 var(--ink); z-index: 20; }
#floaters { z-index: 20; }
.chip.rush { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; animation: oc-throb .5s ease-in-out infinite alternate; }
#ticker.breaking .ticker-square { animation: blink .5s steps(2) 6; background: #ff5a2c; }
#ticker.breaking #headline { color: #ffd2b8; font-weight: 600; }
:root[data-theme="dark"] #ticker.breaking #headline { color: #ffc29e; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .punch, .chip.rush, #ticker.breaking .ticker-square { animation: none; } }
.golden-marker { position: fixed; left: 0; top: 0; display: grid; justify-items: center; margin: -30px 0 0 -16px; width: 32px; font-size: 32px; line-height: 1; color: #f4b63f; text-shadow: 0 0 10px #ffcf5a, 1px 1px 0 #6b4a14; opacity: 0; pointer-events: none; transition: opacity .3s; }
.golden-marker.on { opacity: 1; animation: golden-bob .6s ease-in-out infinite alternate; }
.golden-marker small { font-family: var(--mono); font-size: 8px; font-weight: 600; letter-spacing: .1em; }
@keyframes golden-bob { to { margin-top: -40px; } }
@media (prefers-reduced-motion: reduce) { .golden-marker.on { animation: none; } }
#perks { margin-top: 22px; }
#perks h4 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.perk-balance { color: var(--accent); font-family: var(--mono); font-size: 9px; letter-spacing: .04em; }
.perk-note { margin: 4px 0 10px; color: var(--dim); font-size: 8px; }
.card.perk.got { opacity: .65; }
.card.perk.got .cs { background: var(--ok); }
.toast.deal { pointer-events: auto; border-left-color: #c98a1e; }
.deal-actions { display: flex; gap: 6px; margin-top: 9px; }
.deal-actions button { flex: 1; padding: 6px 0; border: 1px solid var(--ink); background: var(--ink); color: var(--panel); font: 600 9px var(--mono); letter-spacing: .06em; cursor: pointer; }
.deal-actions button[data-a="no"] { background: transparent; color: var(--ink); }
.deal-actions button:hover { filter: brightness(1.15); }
:root[data-theme="dark"] .deal-actions button { border-color: #ddd9ca; background: #ddd9ca; color: #232b28; }
:root[data-theme="dark"] .deal-actions button[data-a="no"] { background: transparent; color: #ddd9ca; }
