@font-face { font-family: "Press Start 2P"; src: url(../fonts/PressStart2P-Regular.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "VT323"; src: url(../fonts/VT323-Regular.woff2) format("woff2"); font-display: swap; }

:root { --or: #ff7a18; --or-d: #a84300; --or-l: #ffb347; --bl: #2ea8ff; --dim: #8a8a9c; --line: #22222e;
  --bg: #000; --panel: #07070c; --ok: #3bff8a; --bad: #ff3b5c; --px: "Press Start 2P", ui-monospace, monospace; color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: #e8e6e3; font: 21px/1.35 "VT323", ui-monospace, monospace; }
a { color: var(--bl); }
h2, h3 { font-family: var(--px); font-weight: normal; line-height: 1.5; }
h2 { font-size: 13px; color: var(--or); margin: 0 0 12px; }
h3 { font-size: 10px; color: var(--or-l); margin: 16px 0 8px; }
p { margin: 8px 0; }
.dim { color: var(--dim); }
.ok { color: var(--ok); }
.or { color: var(--or); }
.warn { color: var(--bad); }
[hidden] { display: none !important; }

/* HUD */
.hud { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  padding: 8px 12px; background: #0a0a10; border-bottom: 4px solid var(--line); }
.title { font: 11px var(--px); color: var(--or); }
.co { color: var(--bl); }
.stat { margin-left: auto; }
.stat + .stat { margin-left: 0; }
#money { font: 13px var(--px); color: var(--or-l); }

/* buttons and inputs */
button { font: 10px var(--px); color: #000; background: var(--or); border: 0; padding: 10px 14px; min-height: 44px;
  cursor: pointer; touch-action: manipulation; box-shadow: inset -4px -4px 0 var(--or-d), inset 4px 4px 0 var(--or-l); }
button:active { box-shadow: inset 4px 4px 0 var(--or-d); }
button:disabled { background: #333; color: #777; box-shadow: none; cursor: not-allowed; }
button.alt { background: #1a1a24; color: #e8e6e3; box-shadow: inset -4px -4px 0 #0a0a10, inset 4px 4px 0 #2e2e3c; }
button.danger { background: #3a0b14; color: #ffb3c0; box-shadow: inset -4px -4px 0 #1e050a, inset 4px 4px 0 #5a1220; }
.savebtn { background: #1a1a24; color: var(--dim); box-shadow: inset -4px -4px 0 #0a0a10, inset 4px 4px 0 #2e2e3c; }
.savebtn.on { color: var(--ok); }
:focus-visible { outline: 3px solid var(--bl); outline-offset: 2px; }
input[type=text], input[type=password], textarea { font: inherit; color: inherit; background: #000; border: 2px solid #33334a;
  padding: 6px 10px; min-height: 44px; width: 100%; }
/* themed dropdown (ui.js dropdown()): looks like the text inputs, opens a pixel list under it */
.dd { position: relative; min-width: 0; }
.dd-btn, .dd-btn:active { display: block; width: 100%; font: inherit; color: inherit; text-align: left; background: #000; box-shadow: none;
  border: 2px solid #33334a; padding: 6px 38px 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn::after { content: ''; position: absolute; right: 12px; top: calc(50% - 3px); border: 6px solid transparent; border-top: 6px solid var(--or);
  border-bottom: 0; }
.dd-btn:hover, .dd-btn[aria-expanded=true] { border-color: var(--or); }
.dd-btn[aria-expanded=true]::after { border-top: 0; border-bottom: 6px solid var(--or); }
.dd-list { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% - 2px); margin: 0; padding: 0; list-style: none;
  background: #0a0a10; border: 2px solid var(--or); box-shadow: 4px 4px 0 #000; max-height: 280px; overflow-y: auto;
  scrollbar-color: var(--or) #0a0a10; }
.dd-list li { padding: 6px 10px 6px 26px; cursor: pointer; position: relative; }
.dd-list li[aria-selected=true]::before { content: '>'; position: absolute; left: 10px; color: var(--or); }
.dd-list li.active { background: var(--or); color: #000; }
.dd-list li.active::before { color: #000; }
.dd-list li[aria-disabled=true] { color: var(--dim); cursor: not-allowed; }
.dd-list li[aria-disabled=true].active { background: #22222e; color: var(--dim); }
/* pixel sliders: a square thumb on a bordered track; --v (set by main.js) is the filled part */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; min-height: 44px; margin: 0; background: transparent;
  cursor: pointer; touch-action: manipulation; }
input[type=range]::-webkit-slider-runnable-track { height: 14px; border: 2px solid #33334a;
  background: linear-gradient(90deg, var(--or-d) var(--v, 0%), #000 var(--v, 0%)); }
input[type=range]::-moz-range-track { height: 10px; border: 2px solid #33334a;
  background: linear-gradient(90deg, var(--or-d) var(--v, 0%), #000 var(--v, 0%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 30px; margin-top: -10px; border: 0; border-radius: 0;
  background: var(--or); box-shadow: inset -4px -4px 0 var(--or-d), inset 4px 4px 0 var(--or-l), 0 0 0 2px #000; }
input[type=range]::-moz-range-thumb { width: 16px; height: 30px; border: 0; border-radius: 0;
  background: var(--or); box-shadow: inset -4px -4px 0 var(--or-d), inset 4px 4px 0 var(--or-l), 0 0 0 2px #000; }
input[type=range]:focus-visible { outline: 2px dashed var(--bl); outline-offset: 2px; }
input[type=range]:disabled { cursor: default; }
input[type=range]:disabled::-webkit-slider-runnable-track { background: linear-gradient(90deg, #33334a var(--v, 0%), #000 var(--v, 0%)); }
input[type=range]:disabled::-moz-range-track { background: linear-gradient(90deg, #33334a var(--v, 0%), #000 var(--v, 0%)); }
input[type=range]:disabled::-webkit-slider-thumb { background: #55556a; box-shadow: inset -4px -4px 0 #33334a, inset 4px 4px 0 #77778a, 0 0 0 2px #000; }
input[type=range]:disabled::-moz-range-thumb { background: #55556a; box-shadow: inset -4px -4px 0 #33334a, inset 4px 4px 0 #77778a, 0 0 0 2px #000; }
label { display: block; margin-top: 8px; }
fieldset { border: 2px solid var(--line); margin: 12px 0; padding: 8px 12px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.choice { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: 0; padding: 0 10px; border: 2px solid var(--line); cursor: pointer; }
.choice:has(:checked) { border-color: var(--or); color: var(--or-l); }
.choice input { accent-color: var(--or); width: 20px; height: 20px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.form2 { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }
.form2 label { margin: 0; }

/* layout */
.app { display: grid; grid-template-columns: 150px minmax(0, 1fr); grid-template-areas: "nav quick" "nav main"; grid-template-rows: auto 1fr;
  min-height: calc(100vh - 64px); }
.app > nav { grid-area: nav; }
.app > main { grid-area: main; }
.app > .quick { grid-area: quick; }
@media (min-width: 1100px) {
  .app { grid-template-columns: 150px minmax(0, 1fr) 270px; grid-template-areas: "nav main quick"; grid-template-rows: 1fr; }
  .quick { position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 90px); overflow: auto; }
}
nav { display: flex; flex-direction: column; gap: 10px; padding: 12px 8px; border-right: 4px solid var(--line); }
/* Tab groups: a coloured frame with its name on the top edge. */
.ngroup { --gc: var(--or); position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 4px 4px;
  border: 2px solid var(--gc); box-shadow: inset 0 0 0 2px #000, 3px 3px 0 #000; }
.ngroup-label { position: absolute; top: -7px; left: 6px; padding: 0 4px; font: 7px var(--px); color: var(--gc); background: #07070c; }
.g-models { --gc: var(--bl); } .g-business { --gc: var(--ok); } .g-you { --gc: #b48cff; }
/* Tabs: a framed button with its pixel-art scene (nav.js) on the right, faded behind the name. */
nav a, nav .soon { font: 10px var(--px); display: flex; align-items: center; justify-content: space-between; min-height: 44px;
  padding: 0 8px; color: #e8e6e3; text-decoration: none; border: 2px solid #2a2a3a; image-rendering: pixelated;
  background: linear-gradient(90deg, #07070c 40%, rgba(7, 7, 12, 0.45)), var(--art, none) right 2px center / 64px 44px no-repeat, #07070c;
  box-shadow: inset -2px -2px 0 #000, inset 2px 2px 0 #1a1a26; }
nav a:hover { border-color: var(--gc); }
nav a[aria-current] { border-color: var(--gc); color: var(--gc); background: linear-gradient(90deg, #07070c 30%, rgba(7, 7, 12, 0.15)), var(--art, none) right 2px center / 64px 44px no-repeat, #101018; }
nav .soon { color: #444; }
nav small { font: 7px var(--px); }
main { padding: 16px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--panel); border: 4px solid var(--line); padding: 14px; margin: 0 0 16px; }
.grid .card { margin: 0; }
.card.hint { border-color: var(--or); }
dl.kv { display: grid; grid-template-columns: minmax(0, auto) minmax(50%, 1fr); gap: 2px 14px; margin: 0; } /* values keep half the width, so long labels wrap instead of squeezing them */
dl.kv dt { color: var(--dim); overflow-wrap: break-word; min-width: 0; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
dl.kv ul { margin: 0; padding-left: 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 2px 8px 2px 0; }
th { color: var(--dim); font-weight: normal; }
td + td, th + th { text-align: right; }
.bar { height: 16px; border: 2px solid #33334a; background: #000; }
.bar.big { height: 24px; }
.bar i { display: block; height: 100%; width: 0; background: var(--or); transition: width .25s linear; }
.bar.hot i { background: var(--bad); }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

dialog { background: #0a0a10; color: inherit; border: 4px solid var(--or); padding: 18px; width: min(560px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0, 0, 0, .75); }
dialog textarea { resize: vertical; font-size: 16px; word-break: break-all; }

/* phone: nav becomes a bottom tab bar */
@media (max-width: 700px) {
  body { font-size: 20px; }
  .app { display: block; }
  .hud { gap: 4px 12px; padding: 6px 8px; }
  .title { display: none; }
  .stat { margin-left: 0; }
  nav { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; flex-direction: row; gap: 4px; padding: 4px 4px env(safe-area-inset-bottom);
    background: #0a0a10; border: 0; border-top: 4px solid var(--line); }
  .ngroup { flex-direction: row; flex: 1 0 auto; gap: 2px; padding: 2px; border-width: 0 0 0 0; border-top: 3px solid var(--gc); box-shadow: none; }
  .ngroup-label { display: none; }
  nav a, nav .soon { flex: 1; flex-direction: column; justify-content: center; font-size: 8px; padding: 6px 2px; min-height: 52px;
    background: linear-gradient(rgba(7, 7, 12, 0.7), rgba(7, 7, 12, 0.7)), var(--art, none) center / 64px 44px no-repeat, #07070c; }
  nav a[aria-current] { background: linear-gradient(rgba(7, 7, 12, 0.4), rgba(7, 7, 12, 0.4)), var(--art, none) center / 64px 44px no-repeat, #101018; }
  nav small { font-size: 6px; margin-top: 4px; }
  main { padding: 10px 10px 80px; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .blink { animation: none; }
  .bar i { transition: none; }
}

/* ---------- small buttons, tabs, checkboxes ---------- */
button.sm { font-size: 8px; padding: 6px 10px; min-height: 36px; }
.row.tight { margin: 0; flex-wrap: nowrap; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: 0 0 8px; }
.check input { accent-color: var(--or); width: 20px; height: 20px; }

/* ---------- LAB slots and storage ---------- */
ul.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.slots li { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
ul.slots b { font-weight: normal; color: var(--or-l); }

/* ---------- SHOP ---------- */
.shop { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.cart { position: sticky; top: 80px; margin: 0; }
.items { display: grid; gap: 8px; }
.item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--panel); border: 4px solid var(--line); }
.item > div:first-child { display: grid; gap: 2px; min-width: 0; }
.item b { font-weight: normal; color: var(--or-l); }
.item.locked { opacity: .5; }
.buy { display: grid; justify-items: end; align-content: start; gap: 6px; text-align: right; }
.speeds { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--dim); }
.speeds b { color: var(--bl); font-weight: normal; }
.lines { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.lines li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { min-height: 36px; min-width: 36px; padding: 0; font-size: 12px; }
.total { font: 12px var(--px); color: var(--or-l); }

/* ---------- popup ads ---------- */
dialog.ad { width: min(380px, 92vw); padding: 0 0 16px; text-align: center; border: 6px solid; overflow: hidden; } /* no pop-in animation: a scale animation that stalled left ads stuck small */
dialog.ad::backdrop { background: rgba(0, 0, 0, .55); }
.ad-top { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 4px 10px; font: 7px var(--px); background: rgba(0, 0, 0, .35); }
.ad-x { position: relative; min-height: 32px; min-width: 32px; padding: 0; font-size: 10px; }
.ad-x.tiny { min-height: 14px; min-width: 14px; font-size: 6px; }
.ad-x.loose { position: absolute; z-index: 1; }
.ad-head { font: 15px/1.5 var(--px); margin: 18px 14px 10px; }
.ad-sub { margin: 0 14px 10px; font-size: 22px; }
.ad-price { font: 11px var(--px); margin: 0 14px 14px; animation: blink 1s steps(2) infinite; }
.ad-cta { font-size: 12px; }
.ad-1 { background: #ffe14d; color: #2a0050; border-color: #ff2fd0; }
.ad-1 .ad-cta { background: #ff2fd0; color: #fff; box-shadow: none; }
.ad-2 { background: #00e5ff; color: #001a33; border-color: #ff3b5c; }
.ad-2 .ad-cta { background: #ff3b5c; color: #fff; box-shadow: none; }
.ad-3 { background: repeating-linear-gradient(45deg, #ff7a18 0 12px, #ffb347 12px 24px); color: #000; border-color: #000; }
.ad-3 .ad-head { background: #000; color: #ffb347; padding: 8px; }
.ad-4 { background: #3bff8a; color: #003314; border-color: #2ea8ff; }
.ad-4 .ad-cta { background: #2ea8ff; color: #000; box-shadow: none; }
.ad-5 { background: #1a0033; color: #e0b0ff; border-color: #3bff8a; }
.ad-5 .ad-cta { background: #3bff8a; color: #000; box-shadow: none; }
.ad-5 .ad-head { color: #3bff8a; }
.ad-6 { background: repeating-linear-gradient(0deg, #fff 0 10px, #ffd6e8 10px 20px); color: #b0003a; border-color: #b0003a; border-style: dashed; }
.ad-6 .ad-cta { background: #b0003a; color: #fff; box-shadow: none; }

@media (max-width: 700px) {
  .shop { grid-template-columns: 1fr; }
  .cart { position: static; order: -1; }
  .cart:not(:has(.lines)) { display: none; } /* empty cart: hide on phones */
  dl.kv:has(ul.slots) { grid-template-columns: 1fr; } /* computer slots: label above, parts below */
  dl.kv:has(ul.slots) dt { margin-top: 6px; }
  .item { flex-direction: column; }
  .buy { grid-auto-flow: column; justify-content: space-between; align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  .ad-price { animation: none; }
}

/* ---------- phase 3: focus sliders, allocation, locked choices ---------- */
fieldset.focus, .alloc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 0 12px; align-items: center; }
fieldset.focus legend { grid-column: 1 / -1; }
fieldset.focus label, .alloc label { margin: 0; }
fieldset.focus b, .alloc b { font-weight: normal; color: var(--or-l); }
.choice.locked { opacity: .45; }
@media (max-width: 700px) {
  fieldset.focus, .alloc { grid-template-columns: 1fr; }
}

/* ---------- phase 4: news ticker, leaderboards ---------- */
.ticker { flex-basis: 100%; margin: 2px -12px -8px; overflow: hidden; white-space: nowrap; background: #000; border-top: 2px solid var(--line);
  color: #c8c6c3; font-size: 18px; line-height: 26px; height: 28px; }
.ticker > span { display: inline-block; padding-left: 100%; animation: ticker 60s linear infinite; }
.ticker:has(> span:empty) { display: none; }
.ticker:hover > span { animation-play-state: paused; }
@keyframes ticker { to { transform: translateX(-100%); } }
table.board td:first-child { color: var(--dim); width: 2.5em; }
table.board :is(td, th):is(:nth-child(2), :nth-child(3)) { text-align: left; }
table.board td:nth-child(2) { white-space: nowrap; }
table.board tr.you td { color: var(--or); }
table.board tr.gap td { color: var(--dim); text-align: center; }
ul.news { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 60vh; overflow: auto; }
/* Highlighted headlines (sim.js news() kinds): yours, bad news for you, rivals' moves. */
ul.news li { padding-left: 8px; border-left: 4px solid transparent; }
ul.news li:is(.n-you, .n-bad, .n-rival) { background: #0d0d14; border-left-color: currentColor; }
.n-you { color: var(--or); }
.n-bad { color: #ff8a9c; }
.n-rival { color: var(--bl); }
td.rank1 { color: var(--ok); }
@media (max-width: 700px) {
  .ticker { margin: 2px -8px -6px; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker > span { animation: none; padding-left: 8px; }
}

/* ---------- animated circuit background (js/bg.js) ---------- */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; image-rendering: pixelated; pointer-events: none; }
nav { background: rgba(0, 0, 0, .55); }

/* ---------- skill checks (js/games.js) ---------- */
dialog.game { width: min(460px, 94vw); text-align: center; }
dialog.game h2 { margin-bottom: 6px; }
.g-area { display: grid; gap: 14px; justify-items: center; margin: 16px 0; }
.g-track { position: relative; width: 100%; height: 36px; background: #000; border: 4px solid #33334a; overflow: hidden; }
.g-zone { position: absolute; top: 0; bottom: 0; background: #3bff8a55; border-left: 2px solid var(--ok); border-right: 2px solid var(--ok); }
.g-needle { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: var(--or); box-shadow: 0 0 8px var(--or); }
.g-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--bl); opacity: .8; }
.g-big { font-size: 14px; min-width: 60%; min-height: 64px; }
.g-hold { touch-action: none; user-select: none; -webkit-user-select: none; }
.g-hold.on { background: var(--bl); box-shadow: inset 4px 4px 0 #0b5c99; }
.g-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(300px, 100%); }
.g-tile { aspect-ratio: 1; font: 20px "VT323", monospace; color: var(--bl); background: #0d0d18; box-shadow: inset -4px -4px 0 #05050a, inset 4px 4px 0 #1d1d2e; }
.g-bad { color: #fff; background: repeating-linear-gradient(0deg, #ff3b5c 0 3px, #2ea8ff 3px 5px, #000 5px 8px); animation: glitch .25s steps(2) infinite; }
.g-hit { background: #3bff8a; color: #000; animation: none; }
@keyframes glitch { 50% { transform: translate(2px, -1px); filter: hue-rotate(90deg); } }
.g-show { font: 28px var(--px); color: var(--or-l); min-height: 48px; display: grid; place-items: center; letter-spacing: 6px; }
.g-show.pop { animation: pop .5s steps(3); }
@keyframes pop { from { transform: scale(1.6); color: #fff; } }
.g-pads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.g-pad { font-size: 20px; min-height: 64px; }
.g-time { height: 10px; }
.g-time i { background: var(--or-l); transition: none; }
.g-msg { font: 11px var(--px); min-height: 18px; }
.g-msg.win { color: var(--ok); }
.g-msg.fail { color: var(--bad); }
.g-msg.miss { color: var(--dim); }
@media (prefers-reduced-motion: reduce) {
  .g-bad, .g-show.pop { animation: none; }
}

/* ---------- small comparison bars next to numbers (ui.js mini) ---------- */
.withbar { white-space: nowrap; }
.mini { display: inline-block; width: 40px; height: 6px; margin-left: 6px; vertical-align: middle; background: #1a1a26; }
.mini i { display: block; height: 100%; background: var(--bl); }

/* ---------- phase 7 ---------- */
/* bars coloured by size where more is better (ui.js tone): red, yellow, green, blue */
.mini i.t0, .bar i.t0 { background: var(--bad); }
.mini i.t1, .bar i.t1 { background: #ffd23f; }
.mini i.t2, .bar i.t2 { background: var(--ok); }
.mini i.t3, .bar i.t3 { background: var(--bl); }
.bar.sm { height: 10px; border-width: 1px; margin: 2px 0 6px; }

/* quick stats panel */
.quick { padding: 12px 12px 0; }
.quick details { background: var(--panel); border: 4px solid var(--line); padding: 10px 12px; }
.quick summary { font: 10px var(--px); color: var(--or); cursor: pointer; min-height: 28px; }
.quick h3 { margin: 10px 0 4px; }
.q { font-size: 18px; }
.qh { display: flex; justify-content: space-between; gap: 8px; }
.qh span:last-child { text-align: right; overflow-wrap: anywhere; }
.qline { border-top: 2px solid var(--line); padding-top: 4px; margin-top: 4px; }
.qline p { margin: 2px 0 6px; font-size: 18px; }
@media (min-width: 1100px) { .quick { padding: 16px 16px 0 0; } }
@media (max-width: 700px) { .quick { padding: 10px 10px 0; } }

/* AUDITED star and the Singularity */
.audit, .co.audited::after { color: #ffd23f; }
.co.audited::after { content: " ★"; }
.sing { font-size: 22px; text-align: center; color: var(--or-l); animation: sing 2s steps(8) infinite; }
@keyframes sing { 50% { color: var(--bl); text-shadow: 0 0 12px var(--bl); } }
@media (prefers-reduced-motion: reduce) { .sing { animation: none; } }

/* ---------- achievements ---------- */
.ach { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.ach li { display: flex; gap: 12px; border: 2px solid var(--line); padding: 10px 12px; }
.ach li.got { border-color: var(--or-d); }
.ach p { margin: 4px 0 0; }
.ach-icon { font: 16px var(--px); color: #444; flex: none; width: 24px; text-align: center; }
.got .ach-icon { color: #ffd23f; }
.got b { color: var(--or-l); }
.ach-text { color: var(--bl); }
#toasts { position: fixed; right: 12px; bottom: 12px; z-index: 20; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: #0a0a10; border: 4px solid #ffd23f;
  color: #e8e6e3; text-decoration: none; animation: toast .3s steps(3); }
.toast b { font: 10px var(--px); color: #ffd23f; }
@keyframes toast { from { transform: translateX(110%); } }
@media (max-width: 700px) { #toasts { bottom: 72px; left: 8px; right: 8px; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- LAB scene: the room on the left, details scrolling on the right ---------- */
.lab { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); gap: 16px; align-items: start; }
.lab-scene { display: grid; gap: 12px; }
.lab-scene .card { margin: 0; }
.scene { display: block; width: 100%; height: auto; aspect-ratio: 384 / 216; image-rendering: pixelated; border: 4px solid var(--line); background: #000; }
.lab-scene > p { margin: -6px 0 0; }
.lab-side { display: grid; gap: 16px; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 4px; overscroll-behavior: contain; }
.lab-side .card { margin: 0; }
.card.flash { animation: flash .9s steps(3); }
@keyframes flash { 0%, 66% { border-color: var(--or); } }
@media (max-width: 1000px) {
  .lab { grid-template-columns: 1fr; }
  .lab-side { max-height: none; overflow: visible; }
}

/* ---------- shop shelves ---------- */
.shelf { margin: 0 0 18px; }
.shelf h3 { margin: 0 0 6px; }
.shelf-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 4px 0; align-items: end; scrollbar-width: thin; }
.plank { height: 10px; background: #6a4a2a; border-top: 3px solid #8a6a3a; box-shadow: 0 4px 0 #2a1a0a; margin-top: -2px; }
.box { position: relative; flex: none; width: 124px; min-height: 0; padding: 0; background: none; box-shadow: none; color: inherit; display: grid;
  justify-items: center; align-content: end; gap: 4px; cursor: pointer; font: inherit; }
.box:active { box-shadow: none; }
.box:hover .boxart, .box:focus-visible .boxart { transform: translateY(-4px); }
.box:focus-visible { outline: 2px dashed var(--bl); outline-offset: 2px; }
.boxart { width: 84px; height: 72px; image-rendering: pixelated; transition: transform .1s steps(2); }
.boxart.big { width: 126px; height: 108px; flex: none; }
.box.locked { opacity: .45; }
.tag { display: grid; width: 100%; padding: 4px 6px 5px; background: #ffd23f; color: #111; font-size: 16px; line-height: 1.1; text-align: left;
  clip-path: polygon(0 4px, 4px 0, 100% 0, 100% 100%, 0 100%); }
.tag b { font-weight: normal; min-height: 2.2em; }
.tag .price { font: 9px var(--px); margin-top: 3px; color: #6a2400; }
.incart { position: absolute; top: 0; right: 6px; font: 8px var(--px); color: #000; background: var(--bl); padding: 3px 4px; }
.menu-head { display: flex; gap: 14px; align-items: center; }
.menu-head h2 { margin: 0 0 4px; }
.menu-head p { margin: 2px 0; }
.price { color: var(--or-l); }
.menu-stats { display: grid; gap: 4px; margin: 10px 0; }
.qtyrow { align-items: center; }
.qn { font: 14px var(--px); width: 7em; min-height: 44px; text-align: center; color: var(--or-l); background: #000; border: 2px solid #33334a; }
@media (prefers-reduced-motion: reduce) { .boxart { transition: none; } }

/* BOARD: all models, sortable */
.wide { overflow-x: auto; }
table.models th { white-space: nowrap; }
button.sort { all: unset; cursor: pointer; color: var(--dim); }
button.sort:hover, button.sort.on { color: var(--or-l); }
button.sort:focus-visible { outline: 2px dashed var(--bl); }

/* ---------- market trends ---------- */
.trends { gap: 12px 24px; }
.trends h3 { margin-top: 4px; }
.trend-box { display: grid; grid-template-columns: auto 1fr; gap: 6px; }
.trend { width: 100%; aspect-ratio: 240 / 72; image-rendering: pixelated; background: #050508; border: 2px solid var(--line); }
.trend-y { display: flex; flex-direction: column; justify-content: space-between; font: 7px var(--px); color: var(--dim); padding: 2px 0; }
.trend-y i { font-style: normal; }
.legend { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 18px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; }
.legend b { font-weight: normal; }

/* ---------- lite mode (js/lite.js, SETTINGS) ---------- */
html.lite *, html.lite *::before, html.lite *::after { animation: none !important; transition: none !important; }
html.lite .ticker > span { padding-left: 8px; }
/* ten tabs: on phones the bar scrolls sideways when they do not all fit, and labels shrink a step on the narrowest */
@media (max-width: 700px) {
  nav { overflow-x: auto; scrollbar-width: none; }
  nav a, nav .soon { flex: 1 0 auto; padding: 6px 3px; }
}
@media (max-width: 380px) { nav a, nav .soon { font-size: 7px; padding: 6px 2px; } }

/* ---------- phase 8: company strategy ---------- */
.choices.col { grid-template-columns: 1fr; }
.deal { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 6px 0; border-bottom: 2px solid var(--line); }
.badge { font: 8px var(--px); color: #000; background: var(--or); padding: 3px 4px; margin-left: 6px; line-height: 1; }
@media (max-width: 700px) { nav a { position: relative; } .badge { position: absolute; top: 4px; right: 2px; margin: 0; font-size: 7px; } }
.toast.bad { border-color: var(--bad); }
.toast.bad b { color: #ff8a9c; }
.toast b { max-width: 34ch; line-height: 1.5; }

/* ---------- stat boxes (ui.js statBoxes / liveStats) ---------- */
.stat-boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin: 8px 0; }
.stat-box { display: grid; align-content: start; gap: 3px; min-width: 0; padding: 6px 8px; background: #050508; border: 2px solid var(--line); }
.stat-box > span { font: 7px/1.4 var(--px); color: var(--dim); text-transform: uppercase; }
.stat-box > b { font-weight: normal; font-size: 20px; line-height: 1.1; overflow-wrap: anywhere; }
.stat-box > b.warn { color: var(--bad); }
.stats-live > p { margin: 4px 0; }

/* Idle and paused (main.js): a bar across the top while away credit runs, red once it is used up */
.idlebar { position: fixed; left: 50%; top: 8px; transform: translateX(-50%); z-index: 30; max-width: min(92vw, 720px);
  padding: 8px 14px; background: #0a0a10; border: 3px solid #ffd23f; text-align: center; pointer-events: none; }
.idlebar.stop { border-color: var(--bad); color: var(--bad); }

/* ---------- DATA tab (mine.js) ---------- */
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; }
table.tiers td:nth-child(2) { text-align: right; }
.field { display: grid; grid-template-columns: repeat(var(--w), 1fr); gap: 2px; max-width: 560px; margin: 12px 0; touch-action: manipulation; }
.field .tile { aspect-ratio: 1; min-height: 0; padding: 0; font: 10px var(--px); color: #000; background: #3a2a1c;
  box-shadow: inset -3px -3px 0 #24180f, inset 3px 3px 0 #5a4430; }
.field .tile:disabled { cursor: default; }
.field .tile:not(:disabled):hover { background: #5a4430; }
.field .tile.dug { background: #0d0d14; box-shadow: none; }
.field .tile.bad { background: #3a0b14; box-shadow: none; color: var(--bad); }
.field .tile.t0, .field .tile.t1, .field .tile.t2, .field .tile.t3, .field .tile.t4 { box-shadow: inset 0 0 0 3px #0d0d14; }
.field .tile.t0 { background: #4a4a58; } .field .tile.t1 { background: #8d8b88; } .field .tile.t2 { background: #1d6aa3; }
.field .tile.t3 { background: #7b3fa0; } .field .tile.t4 { background: #b8961d; }
.field .tile[class*=" t"] { color: #000 !important; }
.mix { display: inline-flex; width: 90px; height: 10px; margin: 0 8px; vertical-align: middle; background: #000; border: 2px solid #33334a; }
.mix i { display: block; height: 100%; }
@media (max-width: 700px) { .field { gap: 1px; } .field .tile { font-size: 8px; } }

/* SETTINGS: background theme swatches (theme.js) */
.theme-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.theme-sw { display: flex; align-items: center; justify-content: center; gap: 3px; width: 40px; height: 28px; border: 2px solid; }
.theme-sw i { width: 6px; height: 6px; }
.theme-sw.on { outline: 3px solid var(--or); outline-offset: 2px; }
.theme-sw.locked { opacity: 0.25; }
.field .tile.seen-bad { color: var(--bad); }
.field .tile.seen-q { color: #ffd23f; background: #4a3a10; }

/* ---------- SKILLS (skills.js) ---------- */
.tree { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.nodes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.node { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; margin-left: calc(var(--d) * 14px);
  background: #0a0a10; border: 2px solid #33334a; position: relative; }
.node::before { content: ''; position: absolute; left: -10px; top: 50%; width: 8px; border-top: 2px solid #33334a; }
.node[style*="--d:0"]::before { display: none; }
.node div { display: flex; flex-direction: column; gap: 2px; }
.node b { font: 9px/1.5 var(--px); color: var(--or-l); }
.node.owned { border-color: var(--ok); }
.node.owned b { color: var(--ok); }
.node.locked { opacity: 0.5; }
.node .learned { font: 9px var(--px); white-space: nowrap; }
.node button { white-space: nowrap; flex-shrink: 0; }
/* SHOP: Qubit shelf */
.qshelf .item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px solid var(--line); }
.qcount { color: #ffd23f; }
.broke { font: 10px var(--px); color: #fff; background: var(--bad); padding: 4px 8px; animation: alarm 1s steps(2) infinite; }
@keyframes alarm { 50% { background: #7a1020; } }

/* ---------- tutorial coach (tutorial.js) ---------- */
.coach-ring { position: fixed; z-index: 15; pointer-events: none; border: 3px solid var(--or);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); animation: coach 1.2s steps(2) infinite; }
@keyframes coach { 50% { border-color: var(--or-l); } }
.coach { position: fixed; z-index: 16; left: 170px; bottom: 12px; /* right of the side bar */ width: min(340px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; background: #0a0a10; border: 4px solid var(--or); box-shadow: 4px 4px 0 #000; }
.coach b { font: 10px/1.5 var(--px); color: var(--or); }
.coach p { margin: 0; }
@media (max-width: 700px) { .coach { top: 104px; bottom: auto; left: 8px; width: calc(100vw - 16px); } }

/* ---------- screen frames in the open tab's group colour (main.js sets --accent from the side bar) ---------- */
:root { --accent: var(--or); --accent-d: color-mix(in srgb, var(--accent) 40%, #0a0a10); }
main :is(.card, .item, .scene), .quick details { border-color: var(--accent); }
main :is(fieldset, .stat-box, .choice, .bar, .trend, .ach li, .node, input[type=text], input[type=password], textarea, .dd-btn, .qn, .mix, .g-track),
  .quick .qline { border-color: var(--accent-d); }
main :is(.deal, .qshelf .item) { border-bottom-color: var(--accent-d); }
main .node::before { border-top-color: var(--accent-d); }
main :is(.choice:has(:checked), .dd-btn:hover, .dd-btn[aria-expanded=true], .ach li.got) { border-color: var(--accent); }
main .dd-list { border-color: var(--accent); }
main .node.owned { border-color: var(--ok); }
main input[type=range]::-webkit-slider-runnable-track { border-color: var(--accent-d); }
main input[type=range]::-moz-range-track { border-color: var(--accent-d); }
