@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(fonts/barlow-400.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(fonts/barlow-500.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(fonts/barlow-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-display: swap; src: url(fonts/barlow-700.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 800; font-display: swap; src: url(fonts/barlow-condensed-800.woff2) format('woff2'); }

/* The UI is wired to the building: grid on = lit room, blackout = dark room. */
#game {
  --ground: #e4e8ef;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --line: #d6dce6;
  --ink: #141b34;
  --ink-2: #566080;
  --accent-text: #9a5700;
  --ad-bg: #141b34;
  --ad-ink: #ffffff;
  --shadow: 0 1px 2px rgba(20, 27, 52, .06), 0 10px 28px rgba(20, 27, 52, .07);

  --tungsten: #ffb23f;
  --tungsten-ink: #2b1a00;
  --lit-bg: #fff3dc;
  --live: #1f9d5b;
  --cut: #d93a40;
  --warn: #c77700;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
  color-scheme: light;
}
#game[data-grid="off"] {
  --ground: #0a0f26;
  --surface: #111836;
  --surface-2: #172045;
  --line: #243063;
  --ink: #e8ecfa;
  --ink-2: #93a0cf;
  --accent-text: #ffb23f;
  --ad-bg: #2a3674;
  --shadow: none;
  --live: #4fd88f;
  --cut: #ff6b70;
  --warn: #ffb23f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05070f; overflow: hidden; }
body { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { overscroll-behavior: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2, p, dl, dd { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--tungsten); color: var(--tungsten-ink); }
:focus-visible { outline: 2px solid var(--tungsten); outline-offset: 2px; }

.i { width: 18px; height: 18px; flex: none; }

/* 16:9 stage, scaled to fit the window */
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; box-sizing: border-box;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0); }
#game {
  position: relative; width: 1280px; height: 720px; flex: none; overflow: hidden;
  background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.4;
  transition: background-color .5s ease, color .5s ease;
}

/* ---------- HUD over the full-screen shop ---------- */
.hud-card {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-radius: 14px; box-shadow: 0 4px 18px rgba(10, 15, 38, .14);
  transition: background-color .5s ease, color .5s ease;
}
#topbar {
  position: absolute; top: 12px; left: 14px; right: 14px; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.biz { justify-self: start; padding: 10px 16px 9px; }
#bizName { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1; letter-spacing: -.01em; }
.stars { display: flex; align-items: center; gap: 4px; min-height: 18px; font-weight: 600; font-size: 13px; color: var(--accent-text); }
.stars:empty { display: none; }
.stars .i { width: 14px; height: 14px; fill: currentColor; }
.money { text-align: center; padding: 8px 22px 9px; min-width: 260px; }
#money {
  font-family: var(--display); font-weight: 800; font-size: 42px; line-height: .95; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
#ips { margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
#ips.down { color: var(--cut); }
.top-actions { justify-self: end; display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: 10px;
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap;
  box-shadow: var(--shadow);
  transition: transform .08s ease, filter .15s ease, background-color .5s ease, color .5s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--tungsten); color: var(--tungsten-ink); }
.btn.ad { background: var(--ad-bg); color: var(--ad-ink); }
.btn.ad .i { color: var(--tungsten); fill: var(--tungsten); width: 14px; height: 14px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.big { height: 48px; padding: 0 22px; font-size: 16px; font-weight: 700; }
.btn.small { height: 32px; font-size: 13px; }
.btn.icon { width: 40px; padding: 0; }
.btn.icon .i { width: 20px; height: 20px; }

/* ---------- scene ---------- */
#sky { position: absolute; inset: 0; overflow: hidden; background: #8fcfff; }
#scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }   /* drags and pinches go to the camera, not the page */
#sky.three > :not(canvas) { display: none; }
#sun, #moon { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; transition: opacity .8s ease; }
#sun { background: #ffe28a; box-shadow: 0 0 0 10px rgba(255, 226, 138, .25), 0 0 60px 10px rgba(255, 210, 90, .55); }
#moon { background: #eef0ff; box-shadow: 0 0 40px 6px rgba(200, 208, 255, .35); }
#ground { position: absolute; left: 0; right: 0; bottom: 0; height: 120px; background: #26324f; }
#pole { position: absolute; right: 360px; bottom: 120px; width: 7px; height: 210px; background: #34405f; border-radius: 2px; }
#pole::before { content: ""; position: absolute; top: 16px; left: -20px; width: 47px; height: 5px; border-radius: 2px; background: #34405f; }
#pole i { display: none; }
#building { position: absolute; left: calc(50% - 150px); bottom: 120px; width: 300px; height: 236px; background: #222b52; border-radius: 6px 6px 0 0; }
#building::before { content: ""; position: absolute; left: -8px; right: -8px; top: -10px; height: 10px; background: #1a2244; border-radius: 4px 4px 0 0; }
#sign {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 4px 14px 5px; border-radius: 6px; background: #121836;
  font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: .02em; color: #ffd27a;
  text-shadow: 0 0 12px rgba(255, 178, 63, .8);
}
#sign.dim { color: #3a4373; text-shadow: none; }
#windows { position: absolute; top: 56px; left: 18px; right: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.win { height: 52px; border-radius: 4px; display: flex; align-items: center; justify-content: center; background: #161d3d; color: #2f3970; }
.win .i { width: 24px; height: 24px; }
.win.empty .i { opacity: 0; }
.win.lit { background: #ffd27a; color: #7a4600; box-shadow: 0 0 22px rgba(255, 190, 80, .55); }
.win.dark { background: #0c1129; color: #2a3366; }
#door { position: absolute; bottom: 0; left: 50%; width: 48px; height: 52px; transform: translateX(-50%); background: #151b3a; border-radius: 4px 4px 0 0; }
#sky.flicker { animation: flick .16s steps(2) infinite; }
@keyframes flick { 50% { filter: brightness(.55); } }

.status {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 10px; border-radius: 99px;
  font-weight: 700; font-size: 13px; background: color-mix(in srgb, var(--live) 14%, transparent); color: var(--ink);
}
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--live); flex: none; }
.status.warn::before { background: #e08600; animation: blink .3s steps(2) infinite; }
.status.off { background: #d93a40; color: #fff; }
.status.off::before { background: #fff; }
.status b { font-variant-numeric: tabular-nums; }
@keyframes blink { 50% { opacity: .25; } }

#hint {
  position: absolute; top: 96px; left: 50%; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 99px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 4px 14px rgba(10, 15, 38, .14);
  font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap;
}
#hint:empty { display: none; }
#hint .i { color: var(--accent-text); }
#hint.alert { color: var(--cut); }
#hint.alert .i { color: var(--cut); }

.qchip {
  position: absolute; top: 124px; right: 14px; z-index: 4;
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 99px;
  font-weight: 700; font-size: 14px; background: rgba(255, 255, 255, .92); color: #141b34; box-shadow: 0 4px 14px rgba(10, 15, 38, .14);
}
.qchip .i { width: 16px; height: 16px; }
.qchip.closed { background: rgba(20, 27, 52, .88); color: #dfe5ff; }

/* ---------- power HUD: compact lines ---------- */
#power {
  position: absolute; left: 14px; bottom: 12px; z-index: 4; width: 272px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 9px;
}
.line-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.line-head b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.ticks { display: flex; justify-content: space-between; width: 72px; font-size: 10px; opacity: .8; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--live); transition: width .2s ease; }
#loadBar.short { background: var(--cut); }
#solarBar { background: #f0a020; }
#battBar { background: #3d8bff; }
#fuelBar { background: #8a6bff; }
.src { display: grid; grid-template-columns: 88px 1fr 96px; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.src > span { display: inline-flex; align-items: center; gap: 6px; }
.src .i { width: 14px; height: 14px; }
.src b { text-align: right; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.src.none { opacity: .45; }
.timeline { position: relative; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.timeline i { position: absolute; top: 0; bottom: 0; background: var(--live); border-radius: 2px; }
.timeline b { position: absolute; top: -1px; bottom: -1px; width: 2px; margin-left: -1px; background: var(--ink); }
.usage { display: flex; justify-content: space-between; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-2); }
.usage b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

.power-actions { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 4; display: flex; gap: 8px; align-items: center; }
.power-actions .btn { box-shadow: 0 6px 18px rgba(10, 15, 38, .25); }
.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255, 178, 63, .35); } }

/* ---------- bottom menu bar ---------- */
#menuBar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 6px; padding: 6px; border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(10, 15, 38, .2);
}
#menuBar .tab {
  position: relative; width: 104px; height: 60px; border-radius: 13px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-weight: 700; font-size: 13px; color: var(--ink-2);
  transition: background-color .15s ease, color .15s ease, transform .08s ease;
}
#menuBar .tab .i { width: 22px; height: 22px; }
#menuBar .tab:hover { color: var(--ink); background: var(--surface-2); }
#menuBar .tab:active { transform: scale(.96); }
#menuBar .tab.active { background: var(--tungsten); color: var(--tungsten-ink); }
.dot { position: absolute; top: 7px; right: 22px; width: 9px; height: 9px; border-radius: 50%; background: var(--cut); box-shadow: 0 0 0 2px var(--surface); }

/* ---------- menu panel (slides in over the shop) ---------- */
#panel {
  position: absolute; top: 12px; right: 14px; bottom: 88px; z-index: 7; width: 640px;
  display: flex; flex-direction: column; border-radius: 16px;
  background: var(--surface); box-shadow: 0 18px 50px rgba(8, 11, 28, .35);
  animation: drawer .22s cubic-bezier(.2, .8, .2, 1);
  transition: background-color .5s ease;
}
@keyframes drawer { from { opacity: 0; transform: translateX(24px); } }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 4px 18px; }
.panel-head h2 { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -.01em; }
.panel-head .buy-mode { margin-left: auto; }
#closePanel { margin-left: 4px; }
#buyMode[hidden] + #closePanel { margin-left: auto; }
.buy-mode { display: flex; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.bm { height: 30px; padding: 0 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bm.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 27, 52, .12); }
.tab-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.tab-body::-webkit-scrollbar { width: 8px; }
.tab-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.tip { max-width: 64ch; margin: 2px 4px 12px; font-size: 13px; color: var(--ink-2); }

/* machine rows: the lit/dark contrast lives here */
.row {
  --i: 0;
  display: grid; grid-template-columns: 44px 1fr 96px 92px 148px; gap: 14px; align-items: center;
  padding: 10px 12px; margin-bottom: 6px; border-radius: 12px; background: var(--surface-2);
  transition: background-color .35s ease calc(var(--i) * 70ms), color .35s ease calc(var(--i) * 70ms), box-shadow .35s ease calc(var(--i) * 70ms);
}
.row .ico {
  width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink);
  transition: inherit;
}
.row .ico .i { width: 22px; height: 22px; }
.row .name { font-weight: 600; font-size: 16px; line-height: 1.2; }
.row .cnt { margin-left: 6px; font-weight: 700; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.row .sub { margin-top: 2px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.row .ms { height: 3px; margin-top: 7px; max-width: 220px; border-radius: 9px; overflow: hidden; background: var(--line); }
.row .ms i { display: block; height: 100%; width: 0; background: var(--tungsten); }
.row.locked { opacity: .55; }
.row.locked .switch, .row.locked .state { visibility: hidden; }

/* in a blackout, powered rows are the only lit things in the room */
#game[data-grid="off"] .row.live {
  background: var(--lit-bg); color: #141b34;
  box-shadow: 0 8px 26px rgba(255, 178, 63, .22);
}
#game[data-grid="off"] .row.live .ico { background: var(--tungsten); color: var(--tungsten-ink); }
#game[data-grid="off"] .row.live .sub { color: #6a5530; }
#game[data-grid="off"] .row.live .cnt { color: #9a5700; }
#game[data-grid="off"] .row.live .switch { color: #6a5530; }
#game[data-grid="off"] .row.live .ms { background: #f0dcb8; }

.switch { display: inline-flex; align-items: center; gap: 8px; height: 32px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.switch .track { position: relative; width: 34px; height: 20px; border-radius: 99px; background: var(--line); transition: background-color .2s ease; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.switch[aria-checked="true"] .track { background: var(--live); }
.switch[aria-checked="true"] .track::after { transform: translateX(14px); }
.state { font-size: 13px; font-weight: 700; }
.state.ok { color: var(--live); }
.state.no { color: var(--cut); }
.state.warm { color: var(--warn); }
#game[data-grid="off"] .row.live .state.ok { color: #1f8a50; }
#game[data-grid="off"] .row.live .state.warm { color: #a15c00; }

.buy { flex-direction: column; gap: 0; height: 48px; line-height: 1.15; }
.buy b { font-size: 13px; font-weight: 600; }
.buy span { font-family: var(--display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }

/* upgrades */
.up {
  display: grid; grid-template-columns: 44px 1fr 168px; gap: 14px; align-items: center;
  padding: 12px; margin-bottom: 6px; border-radius: 12px; background: var(--surface-2);
}
.up .ico { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--surface); }
.up .ico .i { width: 22px; height: 22px; }
.up .name { font-weight: 600; font-size: 16px; }
.up .lvl { margin-left: 8px; font-size: 13px; font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.up .info { margin-top: 2px; font-size: 13px; color: var(--ink-2); }
.up .next { margin-top: 2px; font-size: 13px; font-weight: 600; color: var(--live); }

/* sell */
.sell-card { max-width: 480px; margin: 28px auto 0; text-align: center; }
.sell-star { color: var(--tungsten); }
.sell-star .i { width: 52px; height: 52px; fill: currentColor; }
.sell-card h2 { margin-top: 8px; font-family: var(--display); font-weight: 800; font-size: 34px; letter-spacing: -.01em; }
.sell-card > p { margin-top: 6px; color: var(--ink-2); text-wrap: balance; }
.sell-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0; }
.sell-stats div { padding: 12px; border-radius: 12px; background: var(--surface-2); }
.sell-stats dt { font-size: 13px; color: var(--ink-2); }
.sell-stats dd { margin-top: 2px; font-family: var(--display); font-weight: 800; font-size: 26px; font-variant-numeric: tabular-nums; }
.sell-card .muted { margin: 10px 0 18px; font-size: 13px; color: var(--ink-2); }

/* ---------- toasts, modal, ad ---------- */
#toasts { position: absolute; bottom: 160px; left: 50%; z-index: 20; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 99px;
  background: #141b34; color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 24px rgba(10, 15, 38, .3); animation: toast 2.8s cubic-bezier(.2, .8, .2, 1) forwards;
}
.toast .i { width: 16px; height: 16px; color: var(--tungsten); }
.toast.bad .i { color: #ff8a8e; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; } }

#modal { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(8, 11, 28, .62); }
.modal-card { width: 420px; padding: 28px; border-radius: 16px; background: var(--surface); color: var(--ink); text-align: center; box-shadow: 0 24px 60px rgba(8, 11, 28, .35); }
.modal-card h2 { font-family: var(--display); font-weight: 800; font-size: 30px; }
#modalBody { margin-top: 6px; color: var(--ink-2); }
#modalBody strong { display: block; margin: 10px 0 2px; font-family: var(--display); font-weight: 800; font-size: 44px; color: var(--ink); font-variant-numeric: tabular-nums; }
#modalBtns { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }

#adOverlay { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: #000; color: #fff; }
#adOverlay div { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 22px; font-weight: 700; }
#adOverlay small { font-size: 13px; font-weight: 400; color: #9aa3c7; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; transition-delay: 0s !important; }
}

/* ---------- store sim additions ---------- */
.meta { display: flex; align-items: center; gap: 12px; margin-top: 5px; }
.meta .stars { margin-top: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip .i { width: 15px; height: 15px; }
.chip.rating { color: var(--accent-text); }
.chip.rating .i { fill: currentColor; }
.chip.rating.low { color: var(--cut); }

.store-sum { display: flex; gap: 10px; margin: 2px 2px 12px; }
.store { flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.store > .i { width: 20px; height: 20px; color: #3d8bff; flex: none; }
.store b { display: block; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.store span { display: block; font-size: 12px; color: var(--ink-2); }
.store.warm > .i, .store.warm b { color: var(--cut); }
.store.bad > .i { color: var(--cut); }

.row .ms.fresh i { background: var(--live); }
.row .ms.fresh i.old { background: var(--cut); }
.row .ms.cold { visibility: hidden; }
.row .switch[hidden] { display: none; }
.row.stock .switch[hidden] + .state { grid-column: 3 / 5; }

#upgradeList .group { margin: 6px 4px 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
#upgradeList .group:not(:first-child) { margin-top: 16px; }

#money.owing { color: var(--cut); }

#game { contain: layout; }

#saleFx { position: absolute; top: 74px; left: 50%; z-index: 6; pointer-events: none; }
.sale { position: absolute; left: 0; transform: translateX(-50%); white-space: nowrap; font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--live); text-shadow: 0 1px 0 rgba(255,255,255,.6); animation: sale 1.1s ease-out forwards; }
@keyframes sale { from { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -26px); } }

.row.staff { grid-template-columns: 44px 1fr auto auto 148px; }
.row.bikes { grid-template-columns: 44px 1fr auto 148px; }
.row.bikes .ico .i { width: 22px; height: 22px; }
.fire[hidden], #repairBtn[hidden] { display: none; }
.orders { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.order { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.order .i { width: 16px; height: 16px; }
.order b { font-weight: 700; color: var(--ink-2); }
.order.ready b { color: var(--cut); }
.order.out b { color: var(--live); }
.books { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.book { padding: 14px 16px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.book h3 { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.book > div { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); }
.book b { font-variant-numeric: tabular-nums; color: var(--ink); }
.book b.neg { color: var(--ink-2); }
.book .net { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 700; color: var(--ink); }
.book .net b.pos { color: var(--live); }
.book .net b.neg { color: var(--cut); }
.book p { margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.sell-card { margin-top: 18px; }

#menuBar .tab.active, #menuBar .tab.active:hover { background: var(--tungsten); color: var(--tungsten-ink); }

.comfort-card { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; margin: 2px 2px 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); }
.comfort-score { display: flex; flex-direction: column; align-items: center; min-width: 74px; }
.comfort-score b { font-family: var(--display); font-weight: 800; font-size: 36px; line-height: 1; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.comfort-score span { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.comfort-card p { font-size: 13px; color: var(--ink-2); }
.furn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.furn { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.furn-top { display: flex; gap: 12px; align-items: center; }
.furn .ico { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--surface); flex: none; }
.furn .ico .i { width: 22px; height: 22px; }
.furn .name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.furn .cnt { margin-left: 4px; font-weight: 700; color: var(--accent-text); }
.furn .meta-line { margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.furn.off .meta-line { color: var(--cut); }
.furn .sub { flex: 1; font-size: 13px; color: var(--ink-2); }
.furn .buy { align-self: stretch; }
#menuBar .tab { width: 96px; }

.chip.soon { color: var(--warn); }
.usage.scarce b:last-child { color: var(--cut); }
.book-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 2px 2px 10px; }
.book-sum > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.book-sum span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.book-sum b { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.book-sum small { font-size: 11px; color: var(--ink-2); }
.pos { color: var(--live); } .neg { color: var(--cut); }
.book-chart { margin: 0 2px 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.book-chart p { font-size: 12px; color: var(--ink-2); }
.bars { display: flex; align-items: stretch; gap: 4px; height: 118px; margin-bottom: 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.bar-up, .bar-down { flex: 1; width: 100%; display: flex; justify-content: center; }
.bar-up { align-items: flex-end; border-bottom: 1px solid var(--line); }
.bar-down { align-items: flex-start; }
.bar-up i, .bar-down i { display: block; width: 70%; max-width: 26px; border-radius: 3px; }
.bar-up i { background: var(--live); } .bar-down i { background: var(--cut); }
.bar-col small { font-size: 10px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pnl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.pnl th { text-align: right; padding: 6px 8px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.pnl td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.pnl td:first-child, .pnl th:first-child { text-align: left; color: var(--ink-2); }
.pnl td.out { color: var(--ink-2); }
.pnl tr.net td { font-weight: 800; font-size: 14px; border-bottom: 2px solid var(--line); }
.pnl tr.net td:first-child { color: var(--ink); }
.pnl tr.sec td { padding-top: 14px; text-align: left; font-weight: 700; color: var(--ink); border-bottom: 0; }
.pnl tr.loss td { color: var(--ink-2); }
#tab-books .tip { margin-top: 10px; }
.day-card {
  position: absolute; top: 140px; left: 50%; z-index: 8; width: 340px; transform: translateX(-50%);
  padding: 14px 16px; border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: 0 18px 50px rgba(8, 11, 28, .35); animation: drawer .25s cubic-bezier(.2, .8, .2, 1);
}
.dc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 16px; }
.dc-head .i { color: var(--accent-text); }
.dc-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.dc-grid span { color: var(--ink-2); }
.dc-net { padding-top: 6px; margin-top: 2px; border-top: 1px solid var(--line); font-weight: 800; font-size: 15px; color: var(--ink) !important; }
.dc-net.pos { color: var(--live) !important; } .dc-net.neg { color: var(--cut) !important; }
.day-card p { margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.day-card .btn { margin-top: 10px; width: 100%; }
#menuBar .tab { width: 86px; }

.modal-card.day-modal { width: 480px; text-align: left; }
.day-modal h2 { text-align: center; }
.dm-grid { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin-top: 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.dm-grid span { color: var(--ink-2); }
.dm-grid b { color: var(--ink); text-align: right; }
.dm-grid b.pos { color: var(--live); }
.dm-net { padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--line); font-weight: 800; font-size: 18px; color: var(--ink) !important; }
.dm-net.pos { color: var(--live) !important; } .dm-net.neg { color: var(--cut) !important; }
.dm-notes { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.day-modal #modalBtns { justify-content: flex-end; }

.radio { position: absolute; top: 68px; right: 14px; z-index: 5; display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 10px 0 4px; }
.radio .btn.icon { width: 34px; height: 34px; }
.radio .btn.icon .i { width: 18px; height: 18px; }
#radioName { min-width: 118px; max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.radio.on #radioName { color: var(--ink); }
.radio.on #radioPower { color: var(--accent-text); }
#radioVol { width: 64px; accent-color: var(--tungsten); }

.top-actions { position: relative; }
.bell-count { position: absolute; top: -5px; right: 42px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--cut); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.notes { position: absolute; top: 62px; right: 14px; z-index: 9; width: 380px; max-height: 470px; display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); box-shadow: 0 18px 50px rgba(8, 11, 28, .35); animation: drawer .2s cubic-bezier(.2, .8, .2, 1); }
.notes-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 6px 16px; font-size: 15px; }
#notesList { overflow-y: auto; padding: 4px 8px 10px; }
.note { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 8px; border-radius: 10px; font-size: 13px; }
.note + .note { border-top: 1px solid var(--line); border-radius: 0; }
.note .i { width: 16px; height: 16px; margin-top: 2px; color: var(--accent-text); }
.note.bad .i { color: var(--cut); }
.note small { display: block; margin-top: 2px; font-size: 11px; color: var(--ink-2); }
#power { cursor: pointer; }
#power:hover { box-shadow: 0 0 0 2px var(--tungsten), 0 4px 18px rgba(10, 15, 38, .14); }
.energy-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 2px 2px 10px; }
.energy-sum > div, .energy-today > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.energy-sum span, .energy-today span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.energy-sum b { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.energy-sum small, .energy-today small { font-size: 11px; color: var(--ink-2); }
.energy-src { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 2px 6px; }
.esrc { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); opacity: .75; }
.esrc.live { opacity: 1; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--live) 50%, transparent); }
.esrc > .i { width: 20px; height: 20px; color: var(--accent-text); margin-top: 2px; }
.esrc b { font-size: 14px; }
.esrc .now { float: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.esrc .bar { margin: 6px 0 5px; }
.esrc small { display: block; font-size: 12px; color: var(--ink-2); }
.euse { display: grid; grid-template-columns: 20px 1.6fr .6fr .7fr .9fr .6fr; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.euse:not(.head) { background: var(--surface-2); margin-bottom: 4px; }
.euse.head { font-size: 11px; font-weight: 700; color: var(--ink-2); padding-bottom: 2px; }
.euse .i { width: 16px; height: 16px; }
.euse .bar { position: relative; height: 5px; margin-top: 5px; }
.euse .bar i { position: absolute; left: 0; top: 0; background: var(--line); }
.euse .bar i.on { background: var(--live); }
.euse.bad .bar i.on { background: var(--warn); }
.euse .st small { display: block; font-size: 11px; color: var(--ink-2); }
.euse.bad .st small { color: var(--cut); font-weight: 700; }
.energy-today { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 2px; }
.energy-today b { font-size: 14px; font-variant-numeric: tabular-nums; }
#tab-energy .group { margin: 14px 4px 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
#menuBar .tab { width: 80px; }

.comfort-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.furn .name { display: flex; flex-wrap: wrap; align-items: baseline; }
.furn-btns { display: flex; flex-direction: column; gap: 6px; }
.furn-btns .buy { height: auto; min-height: 44px; padding: 6px 10px; }
.furn-btns .b2 { background: var(--surface); }
.furn-btns .b2 span { font-family: var(--body); font-size: 12px; font-weight: 600; }
.furn-btns .b2[hidden] { display: none; }
.arrange-bar { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; font-size: 13px; font-weight: 600; }
#game.arranging #menuBar, #game.arranging .power-actions { display: none; }
#game.arranging .arrange-bar { bottom: 16px; }

.fixbtn { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 10px; border-radius: 8px; background: color-mix(in srgb, var(--cut) 14%, transparent); color: var(--cut); font-size: 12px; font-weight: 700; }
.fixbtn:hover { background: color-mix(in srgb, var(--cut) 22%, transparent); }
.fixbtn[hidden] { display: none; }
.paybar { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.paybar button { width: 22px; height: 22px; border-radius: 6px; background: var(--surface); font-weight: 800; }
.paybar button:disabled { opacity: .35; }
.paybar b { min-width: 74px; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.paybar .mood { margin-left: 6px; font-weight: 700; }
.paybar .mood.bad { color: var(--cut); } .paybar .mood.good { color: var(--live); }

.pricebar { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.pricebar button { width: 22px; height: 22px; border-radius: 6px; background: var(--surface); font-weight: 800; }
.pricebar b { min-width: 64px; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.pricebar .pr-note { margin-left: 4px; font-weight: 700; }
.pricebar .pr-note.bad { color: var(--cut); } .pricebar .pr-note.good { color: var(--live); }
.pricebar[hidden] { display: none; }
.store .btn.small { margin-left: auto; height: 30px; }
.supplies { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-2); }
.supplies span { display: inline-flex; align-items: center; gap: 4px; }
.supplies .i { width: 13px; height: 13px; }
.supplies b { color: var(--ink); font-weight: 700; }
.store-sum { flex-wrap: wrap; }
.store-sum .store { min-width: 46%; }

.row .info { min-width: 0; }
.pricebar { flex-wrap: wrap; }
.pricebar .pr-note { flex-basis: 100%; margin-left: 0; }

#tab-goals .group, #tab-staff .group { margin: 10px 4px 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.step-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 12px; background: color-mix(in srgb, var(--tungsten) 16%, var(--surface-2)); }
.step-card b { font-size: 15px; } .step-card small, .goal small, .ach small { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-2); }
.gnum { display: flex; flex-direction: column; align-items: center; min-width: 52px; font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1; color: var(--accent-text); }
.gnum span { font-family: var(--body); font-size: 11px; font-weight: 600; color: var(--ink-2); }
.gbar { height: 6px; margin-top: 7px; border-radius: 99px; background: var(--line); overflow: hidden; max-width: 320px; }
.gbar i { display: block; height: 100%; background: var(--live); }
.goal { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 6px; border-radius: 12px; background: var(--surface-2); }
.goal.claimed { opacity: .55; }
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ach { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); opacity: .6; font-size: 13px; }
.ach.got { opacity: 1; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--tungsten) 60%, transparent); }
.ach .i { width: 18px; height: 18px; color: var(--ink-2); }
.ach.got .i { color: var(--accent-text); }
#menuBar .tab { width: 74px; font-size: 12px; }

.market { display: flex; align-items: center; gap: 12px; margin: 0 2px 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 12px; color: var(--ink-2); }
.market .btn { flex: none; }
.shopname { display: flex; gap: 6px; align-items: center; }
.shopname input { width: 180px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.comfort-card { grid-template-columns: auto 1fr auto; }
.comfort-card .shopname { grid-column: 1 / -1; }
.warnbtn { background: var(--cut) !important; color: #fff !important; }

.viewbtn { position: absolute; top: 172px; right: 14px; z-index: 4; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 99px; font-weight: 700; font-size: 13px; color: var(--ink); }
.viewbtn .i { width: 16px; height: 16px; }

/* ======================================================================
   Portrait phones: a tall 480×854 stage. HUD stacks, menu wraps into two
   rows, panels open as full-width sheets, list rows go to two lines.
   ====================================================================== */
#game.portrait { font-size: 14px; }
.portrait #topbar { top: 8px; left: 8px; right: 8px; grid-template-columns: 1fr auto; row-gap: 6px; }
.portrait .biz { padding: 7px 12px; max-width: 270px; }
.portrait #bizName { font-size: 19px; }
.portrait .meta { flex-wrap: wrap; gap: 4px 10px; }
.portrait .chip { font-size: 11px; }
.portrait .chip .i { width: 13px; height: 13px; }
.portrait .money { grid-column: 1 / -1; grid-row: 2; justify-self: center; min-width: 0; padding: 5px 16px 6px; }
.portrait #money { font-size: 30px; }
.portrait #ips { font-size: 11px; }
.portrait .top-actions { grid-column: 2; grid-row: 1; gap: 6px; }
.portrait #boostBtn { height: 36px; padding: 0 10px; font-size: 12px; }
.portrait #boostBtn .lbl { max-width: 92px; white-space: normal; line-height: 1.1; text-align: left; }
.portrait .top-actions .btn.icon { width: 36px; height: 36px; }
.portrait .bell-count { right: 40px; }

.portrait #hint { top: 150px; max-width: 464px; white-space: normal; text-align: left; font-size: 12px; padding: 6px 12px; }
.portrait .radio { top: 194px; right: 8px; height: 36px; padding: 0 6px 0 2px; }
.portrait #radioPrev, .portrait #radioVol { display: none; }
.portrait #radioName { min-width: 92px; max-width: 104px; font-size: 11px; }
.portrait .qchip { top: 194px; right: auto; left: 8px; height: 30px; font-size: 11px; padding: 0 10px; }
.portrait .viewbtn { top: 232px; right: 8px; height: 30px; font-size: 12px; }
.portrait #saleFx { top: 116px; }

/* power card: compact, bottom-left above the menu */
.portrait #power { left: 8px; bottom: 128px; width: 214px; padding: 9px 10px; gap: 6px; }
.portrait #power .line:first-of-type, .portrait .usage, .portrait .supplies { display: none; }
.portrait .status { height: 26px; font-size: 11px; }
.portrait .src { grid-template-columns: 74px 1fr 66px; font-size: 11px; gap: 6px; }
.portrait .line-head { font-size: 11px; }
.portrait .power-actions { left: auto; right: 8px; bottom: 128px; transform: none; flex-direction: column; align-items: stretch; max-width: 236px; }
.portrait .power-actions .btn { height: 38px; font-size: 13px; padding: 0 12px; }
.portrait .power-actions .btn.big { height: 44px; font-size: 14px; }

/* menu: two rows of five */
.portrait #menuBar { left: 8px; right: 8px; bottom: 8px; transform: none; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 5px; border-radius: 16px; }
.portrait #menuBar .tab { width: calc((100% - 16px) / 5); height: 52px; font-size: 11px; gap: 2px; }
.portrait #menuBar .tab .i { width: 20px; height: 20px; }
.portrait .dot { right: 14px; top: 5px; }

/* panels: full-width sheet above the menu */
.portrait #panel { top: 140px; left: 6px; right: 6px; bottom: 124px; width: auto; border-radius: 16px; animation-name: sheet; }
@keyframes sheet { from { opacity: 0; transform: translateY(24px); } }
.portrait .panel-head { padding: 10px 10px 2px 14px; gap: 6px; }
.portrait .panel-head h2 { font-size: 21px; }
.portrait .bm { padding: 0 8px; height: 28px; }
.portrait .tab-body { padding: 8px; }
.portrait .tip { font-size: 12px; }

/* list rows: icon | details | buy, with the switch and status on a second line */
.portrait .row { grid-template-columns: 40px 1fr 112px; gap: 4px 10px; padding: 10px; }
.portrait .row .ico { grid-row: 1 / span 2; width: 40px; height: 40px; }
.portrait .row .info { grid-column: 2; grid-row: 1; }
.portrait .row .buy { grid-column: 3; grid-row: 1; height: 44px; }
.portrait .row .switch { grid-column: 2; grid-row: 2; justify-self: start; height: 26px; }
.portrait .row .state { grid-column: 3; grid-row: 2; text-align: right; font-size: 12px; }
.portrait .row .name { font-size: 15px; }
.portrait .row .sub { font-size: 12px; }
.portrait .row.staff .fire { grid-column: 3; grid-row: 2; height: 28px; }
.portrait .row.staff .state { grid-column: 2; grid-row: 2; text-align: left; }
.portrait .row.bikes { grid-template-columns: 40px 1fr 112px; }
.portrait .buy span { font-size: 16px; }
.portrait .up { grid-template-columns: 40px 1fr 116px; gap: 10px; padding: 10px; }
.portrait .furn-grid, .portrait .ach-grid, .portrait .energy-src { grid-template-columns: 1fr; }
.portrait .comfort-card { grid-template-columns: auto 1fr; }
.portrait .comfort-actions { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
.portrait .shopname input { width: 100%; }
.portrait .shopname { width: 100%; }
.portrait .store-sum .store { min-width: 100%; }
.portrait .market { flex-direction: column; align-items: stretch; }
.portrait .book-sum, .portrait .energy-sum, .portrait .energy-today { grid-template-columns: 1fr 1fr; }
.portrait .book-sum b, .portrait .energy-sum b { font-size: 19px; }
.portrait .pnl { font-size: 11px; }
.portrait .pnl td, .portrait .pnl th { padding: 4px 4px; }
.portrait .euse { grid-template-columns: 18px 1.5fr .9fr .9fr; gap: 6px; font-size: 11px; }
.portrait .euse > :nth-child(3), .portrait .euse > :nth-child(6) { display: none; }
.portrait .goal { grid-template-columns: 1fr; }
.portrait .sell-stats { grid-template-columns: 1fr; }
.portrait .sell-card h2 { font-size: 26px; }

/* toasts, notes, modals, arrange */
.portrait #toasts { bottom: 380px; width: 440px; }
.portrait .toast { white-space: normal; text-align: left; font-size: 12px; }
.portrait .notes { top: 54px; right: 6px; left: 6px; width: auto; max-height: 520px; }
.portrait .modal-card, .portrait .modal-card.day-modal { width: calc(100% - 20px); max-width: 440px; padding: 22px 18px; }
.portrait #modalBtns { flex-wrap: wrap; }
.portrait .arrange-bar { left: 6px; right: 6px; transform: none; flex-wrap: wrap; bottom: 128px; }
.portrait.arranging .arrange-bar { bottom: 10px; }

.prop-here { display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 14px 16px; border-radius: 12px; background: color-mix(in srgb, var(--tungsten) 14%, var(--surface-2)); }
.prop-here > .i { width: 22px; height: 22px; color: var(--accent-text); }
.prop-here small, .prop-card small, .lock small { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-2); }
.prop-here b { font-size: 16px; }
.lock { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 9px 12px; margin-bottom: 5px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.lock .i { width: 16px; height: 16px; color: var(--cut); }
.lock.ok .i { color: var(--live); }
.prop-card { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 12px 14px; margin-bottom: 6px; border-radius: 12px; background: var(--surface-2); }
.prop-card:has(> .i) { grid-template-columns: 20px 1fr; }
.prop-card > .i { width: 18px; height: 18px; color: var(--accent-text); margin-top: 2px; }
.prop-card:has(> .i) .prop-btns { grid-column: 2; }
.prop-card.slim { grid-template-columns: 1fr auto; align-items: center; }
.prop-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.prop-btns .btn { height: auto; min-height: 36px; padding: 6px 12px; white-space: normal; text-align: left; font-size: 13px; }
#tab-property .group { margin: 14px 4px 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
#menuBar .tab { width: 70px; }

.biz { max-width: 420px; }
.meta { flex-wrap: nowrap; white-space: nowrap; }
#menuBar .tab { width: 66px; }
.portrait .meta { flex-wrap: wrap; white-space: normal; }

.store.wide { flex-wrap: wrap; min-width: 100%; }
.store-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.switch.mini { height: 28px; font-size: 12px; margin-left: auto; }
.switch.mini + .btn { margin-left: 6px; }
.store-tip { flex-basis: 100%; margin: 0 2px 2px; }

/* 3D model pictures in the menus */
.ico.has-pic { background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--surface) 80%, #8fcfff 20%), var(--surface)) !important; overflow: hidden; }
.ico img.pic { width: 100%; height: 100%; object-fit: contain; display: block; }
.row { grid-template-columns: 56px 1fr 96px 92px 148px; }
.row .ico { width: 56px; height: 56px; }
.row.staff { grid-template-columns: 56px 1fr auto auto 148px; }
.up { grid-template-columns: 56px 1fr 168px; }
.up .ico { width: 56px; height: 56px; }
.furn .ico { width: 64px; height: 64px; }
.row.stock .ico { width: 44px; height: 44px; }
.row.stock { grid-template-columns: 44px 1fr 96px 92px 148px; }
.portrait .row { grid-template-columns: 52px 1fr 112px; }
.portrait .row .ico { width: 52px; height: 52px; }
.portrait .up { grid-template-columns: 52px 1fr 116px; }
.portrait .up .ico { width: 52px; height: 52px; }

/* sale pops: a solid pill beside the money card, never over the hint */
#saleFx { top: 22px; left: calc(50% + 150px); }
.sale {
  left: 0; transform: none; padding: 3px 10px; border-radius: 99px;
  background: #1f9d5b; color: #fff; font-size: 17px; text-shadow: none;
  box-shadow: 0 4px 12px rgba(10, 15, 38, .25);
  animation-name: salePill;
}
@keyframes salePill { from { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } to { opacity: 0; transform: translateY(-14px); } }
.portrait #saleFx { top: 96px; left: calc(50% + 70px); }
.portrait .sale { font-size: 14px; }

.pricebar { flex-wrap: wrap; gap: 4px; }
.pricebar b { min-width: 58px; }
.pricebar .pr-note { flex-basis: 100%; }

/* ---------- phones held upright: mobile-tycoon layout ---------- */
.more-tab, .more-sheet { display: none; }
.row.flash { animation: rowFlash 1.2s ease; }
@keyframes rowFlash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: none; } }

/* top: money + icon buttons in one row, info chips in a slim second row */
.portrait #topbar { top: 8px; left: 8px; right: 8px; grid-template-columns: 1fr auto; row-gap: 6px; }
.portrait .money { grid-column: 1; grid-row: 1; justify-self: start; text-align: left; min-width: 0; padding: 6px 14px 7px; }
.portrait #money { font-size: 30px; }
.portrait #ips { font-size: 11px; max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portrait .top-actions { grid-column: 2; grid-row: 1; gap: 6px; align-self: center; }
.portrait #boostBtn { width: 44px; height: 44px; padding: 0; font-size: 0; gap: 0; }
.portrait #boostBtn .lbl { display: none; }
.portrait #boostBtn .i { width: 20px; height: 20px; }
.portrait #boostBtn::after { content: '2×'; font-size: 12px; font-weight: 800; margin-left: 1px; }
.portrait .top-actions .btn.icon { width: 44px; height: 44px; }
.portrait .bell-count { right: 46px; }
.portrait .biz { grid-column: 1 / -1; grid-row: 2; max-width: none; padding: 0; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.portrait #bizName { display: none; }
.portrait .meta { flex-wrap: nowrap; gap: 5px; overflow: hidden; white-space: nowrap; }
.portrait .meta .chip, .portrait .stars { height: 26px; padding: 0 9px; border-radius: 99px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 2px 8px rgba(10, 15, 38, .12); font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.portrait .stars:empty { display: none; }

.portrait #hint { top: 100px; left: 8px; right: 8px; transform: none; max-width: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; font-size: 12px; padding: 6px 12px; }
.portrait #hint .i { vertical-align: -3px; margin-right: 6px; }
.portrait #saleFx { top: 20px; left: 190px; }   /* beside the money card, clear of the chips below */
.portrait .qchip { top: 134px; left: 8px; right: auto; height: 28px; font-size: 11px; padding: 0 10px; }
.portrait .viewbtn { top: 134px; right: 8px; height: 28px; font-size: 12px; }
.portrait > .radio { display: none; }

/* bottom: 4 main tabs + More */
.portrait #menuBar { left: 8px; right: 8px; bottom: 8px; transform: none; flex-wrap: nowrap; justify-content: space-between; gap: 2px; padding: 5px; border-radius: 18px; }
.portrait #menuBar .tab { flex: 1; width: auto; height: 56px; font-size: 11px; gap: 3px; }
.portrait #menuBar .tab[data-tab=energy], .portrait #menuBar .tab[data-tab=power], .portrait #menuBar .tab[data-tab=goals],
.portrait #menuBar .tab[data-tab=books], .portrait #menuBar .tab[data-tab=property], .portrait #menuBar .tab[data-tab=sell], .portrait #menuBar .tab[data-tab=stats] { display: none; }
.portrait .more-tab { display: flex; }
.portrait .more-sheet:not([hidden]) { display: block; position: absolute; left: 8px; right: 8px; bottom: 80px; z-index: 7; padding: 10px; border-radius: 18px; animation: sheet .18s ease; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.more-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 70px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); font-weight: 700; font-size: 12px; }
.more-item .i { width: 22px; height: 22px; }
.more-item .dot { top: 8px; right: 18px; }
.more-radio .radio { position: static; display: flex; margin-top: 8px; justify-content: space-between; height: 44px; box-shadow: none; background: color-mix(in srgb, var(--ink) 5%, transparent); }
.more-radio #radioPrev, .more-radio #radioVol { display: inline-flex; }
.more-radio #radioName { flex: 1; text-align: center; max-width: none; }

/* compact power strip */
.portrait #power { left: 8px; bottom: 84px; width: 190px; padding: 7px 8px; gap: 5px; }
.portrait #power .line, .portrait #power .src, .portrait .usage, .portrait .supplies { display: none; }
.portrait #power .line:nth-of-type(2) { display: block; }
.portrait .status { height: 28px; font-size: 11px; }
.portrait .power-actions { left: auto; right: 8px; bottom: 84px; transform: none; flex-direction: column; align-items: stretch; max-width: 220px; }

.portrait #panel { top: 168px; bottom: 80px; }
.portrait .arrange-bar { bottom: 84px; }
.portrait #toasts { bottom: 150px; }

.portrait #toasts { top: 170px; bottom: auto; }
.more-sheet, .more-item { transition: none; }
#menuBar .more-tab { display: none; }
.portrait #menuBar .more-tab { display: flex; }

/* ---------- stats ---------- */
.stats-hero { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-radius: 14px; background: var(--surface-2, #f3f5fa); }
.stats-hero small { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.stats-hero b { display: block; font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stats-hero > div > span { font-size: 13px; color: var(--ink-2); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px 12px; border-radius: 12px; background: var(--surface-2, #f3f5fa); }
.stat b { display: block; font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 12px; color: var(--ink-2); line-height: 1.25; }
.credits p { margin: 4px 0; font-size: 13px; }
.credits small { display: block; color: var(--ink-2); }
.portrait .stat-grid { grid-template-columns: 1fr 1fr; }
.portrait .stats-hero { flex-direction: column; align-items: stretch; }
.portrait .stats-hero b { font-size: 34px; }

/* ---------- share ---------- */
.moment-chip {
  position: absolute; top: 140px; left: 14px; z-index: 6; display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 99px; background: #ffb23f; color: #141b34; font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 18px rgba(10, 15, 38, .25); animation: momentIn .35s cubic-bezier(.2, 1.4, .4, 1);
}
.moment-chip .i { width: 17px; height: 17px; }
@keyframes momentIn { from { transform: scale(.6); opacity: 0; } }
.portrait .moment-chip { top: 168px; left: 8px; height: 32px; font-size: 13px; }
.share-modal .share-img { display: block; width: 100%; max-height: 52vh; object-fit: contain; border-radius: 12px; background: #0b1030; }
.modal-card.share-modal { width: 440px; }
.portrait .modal-card.share-modal { width: calc(100% - 20px); max-width: 440px; }

.streak { display: flex; justify-content: center; gap: 6px; margin: 10px 0 4px; }
.streak i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 14px; background: var(--surface-2); color: var(--ink-2); }
.streak i.got { background: color-mix(in srgb, var(--tungsten) 30%, var(--surface-2)); color: var(--ink); }
.streak i.now { background: var(--tungsten); color: var(--tungsten-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tungsten) 35%, transparent); }

/* loading screen: covers the page until the game has started */
#boot { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #05070f; color: #e8ecfa; font-family: var(--display), sans-serif; transition: opacity .35s ease; }
#boot svg { width: 72px; height: 72px; }
#boot b { font-size: 26px; font-weight: 700; letter-spacing: .01em; }
#boot i { width: 120px; height: 4px; border-radius: 2px; background: #172045; overflow: hidden; position: relative; }
#boot i::after { content: ''; position: absolute; inset: 0; width: 40%; background: #ffb23f; border-radius: 2px; animation: bootbar 1.1s ease-in-out infinite; }
@keyframes bootbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
#boot.done { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #boot i::after { animation: none; width: 100%; } }

/* menus that appear as you go: a new one pulses until it's opened */
#menuBar .tab.fresh, .more-tab.fresh { animation: tabFresh 1.4s ease-in-out 6; box-shadow: 0 0 0 2px var(--tungsten); }
@keyframes tabFresh { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--tungsten) 35%, transparent); transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { #menuBar .tab.fresh, .more-tab.fresh { animation: none; } }
/* early game: keep the screen to what matters */
#game.early #radio, #game.early #boostBtn, #game.early #power .src.none { display: none !important; }
/* phones held sideways (short landscape): menu bar on the right, clear of the power panel; slimmer tabs */
#game.short #menuBar { left: auto; right: 12px; transform: none; gap: 4px; padding: 5px; }
#game.short #menuBar .tab { width: 62px; font-size: 11px; }
#game.short #power { width: 250px; padding: 10px 12px; gap: 7px; }
