/* Idle Supermarket Tycoon — clean corporate-retail look, blue/slate palette. */
:root {
  --bg: #070c17;
  --bg-panel: #0f172a;
  --bg-panel-2: #131e36;
  --bg-row: #16223c;
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8eefc;
  --text-dim: #93a3c0;
  --accent: #38bdf8;
  --accent-2: #60a5fa;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --star: #fcd34d;
  --insight: #c4b5fd;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  overscroll-behavior: none;
}

body {
  background-image:
    radial-gradient(1000px 600px at 15% -10%, rgba(56, 189, 248, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(96, 165, 250, 0.08), transparent 55%);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 14px 12px;
  gap: 10px;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--bg-panel-2), var(--bg-panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.brand-mark { font-size: 26px; }
.brand-text h1 { margin: 0; font-size: 16px; letter-spacing: 0.2px; }
.brand-text p { margin: 2px 0 0; font-size: 11px; color: var(--text-dim); }

.wallet {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 12px;
  min-width: 92px;
  text-align: center;
}
.stat-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.stat strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat-money strong { color: var(--good); }
.negative { color: var(--bad); }
.stars { color: var(--star); }
.insight { color: var(--insight); }
.mult { color: var(--accent); }

.topbar-actions { display: flex; gap: 8px; }

/* ---- Event banner ----------------------------------------------------- */
.event-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.18), rgba(15, 23, 42, 0.6));
  animation: slide-in 0.25s ease-out;
}
.event-banner.bad {
  border-color: rgba(248, 113, 113, 0.5);
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.2), rgba(15, 23, 42, 0.6));
}
.event-icon { font-size: 22px; }
.event-text { display: flex; flex-direction: column; min-width: 180px; }
.event-text strong { font-size: 14px; }
.event-text span { font-size: 12px; color: var(--text-dim); }
.event-timer { flex: 1; height: 6px; background: rgba(15, 23, 42, 0.8); border-radius: 99px; overflow: hidden; }
.event-timer > div { height: 100%; width: 100%; background: var(--accent); transition: width 0.1s linear; }
.event-banner.bad .event-timer > div { background: var(--bad); }

@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---- Layout ----------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.store-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 0;
}
#store { flex: 1; width: 100%; display: block; min-height: 240px; cursor: pointer; }

.store-footer {
  border-top: 1px solid var(--line);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(10, 16, 30, 0.7);
}
.gauges { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.gauge { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.gauge-label { color: var(--text-dim); white-space: nowrap; }
.gauge-track { width: 74px; height: 7px; border-radius: 99px; background: rgba(148, 163, 184, 0.18); overflow: hidden; }
.gauge-track > div { height: 100%; width: 60%; background: var(--good); transition: width 0.3s ease, background 0.3s ease; }
.warn-text { color: var(--warn); }
.good-text { color: var(--good); }

/* Speed control and day progress along the bottom of the floor */
/* A pair of turn buttons sitting on the floor itself. They go over the
   canvas rather than in the bar below it so they do not squeeze the speed
   controls, which are already tight on a phone. */
.store-panel { position: relative; }
.view-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 5px;
  z-index: 3;
}
.view-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--btn-ease), color var(--btn-ease), border-color var(--btn-ease);
}
.view-btn:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(56, 189, 248, 0.55);
  color: var(--text);
}
.view-btn:active { transform: translateY(1px); }
.view-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.speed-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-top: 1px solid var(--line);
  background: rgba(10, 16, 30, 0.7);
}
/* The trading day as a clock rather than a bare progress bar: you can see where
   09:00 is, and therefore when the delivery you just ordered actually lands. */
.day-scale { flex: 1; min-width: 0; }
.day-track { height: 5px; border-radius: 99px; background: rgba(148, 163, 184, 0.14); overflow: hidden; }
#day-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--good)); }
.day-marks { position: relative; height: 13px; margin-top: 2px; }
.day-marks i {
  position: absolute; top: 0; width: 1px; height: 3px;
  background: rgba(148, 163, 184, 0.35); transform: translateX(-50%);
}
.day-marks span {
  position: absolute; top: 3px; transform: translateX(-50%);
  font-size: 9px; color: var(--text-dim); white-space: nowrap;
}
.day-marks .truck { color: var(--accent); font-size: 10px; top: 1px; }
.day-marks i.truck-tick { background: var(--accent); height: 5px; }
/* The alert sits in the panel column, not under the floor. Two reasons: the floor
   is sized from whatever height is left beneath it, so anything down there that
   changes height makes the shop shrink and grow as the text changes; and once it
   was pinned in place to stop that, a long message simply sat on top of the
   gauges. Over here it can be as long as it likes. */
.hint {
  margin: 0 0 8px;
  padding: 7px 11px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
  background: rgba(148, 163, 184, 0.08);
  border-left: 3px solid var(--line);
  border-radius: 6px;
}
.hint.alert { color: var(--warn); border-left-color: var(--warn); background: rgba(251, 191, 36, 0.09); }
.hint.goal { color: var(--text); border-left-color: var(--good); background: rgba(74, 222, 128, 0.08); }
.store-footer { min-height: 44px; }

.panel-column {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 0;
}

.tabs { display: flex; gap: 2px; padding: 8px 8px 0; flex-wrap: wrap; }
.pip {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 99px; background: var(--good);
  box-shadow: 0 0 0 2px var(--bg-panel);
}


.window-bar { display: none; }
.tab-body { flex: 1; overflow-y: auto; padding: 10px; min-height: 0; }
.tab-pane { display: none; flex-direction: column; gap: 8px; }
.tab-pane.active { display: flex; }


/* ---- Generic cards ---------------------------------------------------- */
.card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: var(--bg-row);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 11px;
}
.card.owned { border-color: rgba(74, 222, 128, 0.38); background: rgba(22, 40, 34, 0.55); }
.card.goal-next { border-color: rgba(252, 211, 77, 0.45); background: rgba(45, 38, 18, 0.5); }
.card.locked { opacity: 0.5; }
.card.danger-card { border-color: rgba(248, 113, 113, 0.5); background: rgba(52, 22, 24, 0.6); }
.card.upgrade-card { border-color: rgba(96, 165, 250, 0.45); background: rgba(20, 32, 54, 0.6); }
.card-icon { font-size: 22px; text-align: center; }
.card-title { font-size: 13px; font-weight: 700; }
.card-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.card-tag { font-size: 10px; color: var(--warn); margin-top: 3px; }
.owned-tag { color: var(--good); font-size: 11px; font-weight: 700; }

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin: 6px 2px 0;
}
.empty { color: var(--text-dim); font-size: 12px; text-align: center; padding: 22px 10px; }

/* ---- Staff ------------------------------------------------------------ */

/* ---- Research --------------------------------------------------------- */
.branch { display: flex; flex-direction: column; gap: 6px; }
.branch-head { display: flex; align-items: center; justify-content: space-between; }
.node-line { display: flex; align-items: center; gap: 6px; }
.node-line .connector { color: var(--text-dim); font-size: 12px; }

/* ---- Awards ----------------------------------------------------------- */
.awards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 7px; }
.award {
  background: var(--bg-row);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 9px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.award.unlocked { border-color: rgba(252, 211, 77, 0.45); background: rgba(48, 39, 18, 0.5); }
.award .a-icon { font-size: 19px; filter: grayscale(1); opacity: 0.5; }
.award.unlocked .a-icon { filter: none; opacity: 1; }
.award .a-name { font-size: 12px; font-weight: 700; }
.award .a-desc { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }
.award .a-bonus { font-size: 10px; color: var(--star); margin-top: 3px; }

/* ---- Franchise -------------------------------------------------------- */
.franchise-hero {
  text-align: center;
  padding: 14px;
  border: 1px solid rgba(252, 211, 77, 0.35);
  background: linear-gradient(180deg, rgba(252, 211, 77, 0.12), rgba(15, 23, 42, 0.5));
  border-radius: var(--radius);
}
.franchise-hero .big { font-size: 30px; color: var(--star); font-weight: 800; }
.franchise-hero p { margin: 6px 0 0; font-size: 12px; color: var(--text-dim); }

.stats-list { display: flex; flex-direction: column; gap: 4px; }
.stats-list div { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 9px; background: var(--bg-row); border-radius: 8px; }
.stats-list span:last-child { font-variant-numeric: tabular-nums; color: var(--text); }
.stats-list span:first-child { color: var(--text-dim); }

/* ---- Toasts ----------------------------------------------------------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 40;
  pointer-events: none;
}
.toast {
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease-out;
  max-width: 300px;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.star { border-left-color: var(--star); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }

/* ---- Modal ------------------------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, 0.8);
  display: grid; place-items: center;
  z-index: 50;
  padding: 18px;
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow);
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 10px; font-size: 18px; }
.modal p { font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.offline-figure { font-size: 26px; color: var(--good); font-weight: 800; text-align: center; margin: 12px 0 4px; }

/* ---- Button rows -------------------------------------------------------
   Wherever buttons sit side by side they share a line: one gap, and every
   button stretched to the tallest so a row of them reads as a single band.
   Without this a two-line button (label plus price) leaves its neighbours
   short and the row goes ragged. */
.chip-row,
.staff-controls,
.order-controls,
.pay-rates,
.modal-actions,
.speed-controls {
  display: flex;
  align-items: stretch;
}

.chip-row { flex-wrap: wrap; gap: 6px; }
.staff-controls { gap: 5px; }
.order-controls { gap: 5px; }
.pay-rates { flex-wrap: wrap; gap: 6px; }
.speed-controls { gap: 3px; }
.modal-actions { flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
/* Four actions will not fit one line in a narrow modal, so they pair up two
   to a line at equal width rather than stranding one button on its own. A
   two-button modal fills one line; a single action spans it. */
.modal-actions button { flex: 1 1 calc(50% - 4px); min-width: 104px; }

/* A row of buttons under a block of text should clear it. */
.inspector .chip-row + .chip-row { margin-top: 2px; }

/* ---- Buttons -----------------------------------------------------------
   One system for every control in the game. A button's look comes from its
   intent (neutral, accent, positive, caution, danger) and its size — not from
   which panel it happens to sit in. Each class below only sets the few tokens
   and dimensions that make it different. */

:root {
  --btn-radius: 9px;
  --btn-ease: 130ms cubic-bezier(0.2, 0.7, 0.4, 1);
}

.ghost-btn, .event-action, .speed, .tab, .action-btn, .pay-rate, .mini-btn,
.big-btn, .modal-actions button, .mode-btn, .place-btn, .step-btn, .chip {
  /* Tokens a variant overrides */
  --btn-bg: rgba(15, 23, 42, 0.82);
  --btn-bg-hover: rgba(30, 41, 59, 0.95);
  --btn-border: var(--line);
  --btn-border-hover: rgba(56, 189, 248, 0.55);
  --btn-text: var(--text-dim);
  --btn-text-hover: var(--text);
  --btn-shadow: none;

  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  /* Rows stretch every button to the tallest one, so a button carrying a
     price sub-line makes its plain neighbour taller too. space-between keeps
     the main labels on one line across the row; with nothing to spread, it
     behaves exactly like centring. */
  justify-content: space-between;
  gap: 1px;

  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--btn-radius);
  color: var(--btn-text);
  box-shadow: var(--btn-shadow);

  font: inherit;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;

  padding: 7px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    background var(--btn-ease),
    border-color var(--btn-ease),
    color var(--btn-ease),
    box-shadow var(--btn-ease),
    transform var(--btn-ease),
    opacity var(--btn-ease);
}

/* Secondary line inside a button: a price, a cost, a hint. */
.ghost-btn small, .action-btn small, .pay-rate small, .big-btn small,
.place-btn small, .step-btn small, .chip small, .modal-actions button small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

/* States, shared by everything ------------------------------------------- */
.ghost-btn:hover:not(:disabled), .event-action:hover:not(:disabled),
.speed:hover:not(:disabled), .tab:hover:not(:disabled),
.action-btn:hover:not(:disabled), .pay-rate:hover:not(:disabled),
.mini-btn:hover:not(:disabled), .big-btn:hover:not(:disabled),
.modal-actions button:hover:not(:disabled), .mode-btn:hover:not(:disabled),
.place-btn:hover:not(:disabled), .step-btn:hover:not(:disabled),
.chip:hover:not(:disabled) {
  background: var(--btn-bg-hover);
  border-color: var(--btn-border-hover);
  color: var(--btn-text-hover);
  /* The lift is drawn, not moved. Nudging the button up on hover takes its
     hit box out from under a cursor resting on the bottom edge, which
     unhovers it, which drops it back under the cursor — a flicker loop you
     cannot click through. A shadow reads the same and never moves. */
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.45);
}

.ghost-btn:active:not(:disabled), .event-action:active:not(:disabled),
.speed:active:not(:disabled), .tab:active:not(:disabled),
.action-btn:active:not(:disabled), .pay-rate:active:not(:disabled),
.mini-btn:active:not(:disabled), .big-btn:active:not(:disabled),
.modal-actions button:active:not(:disabled), .mode-btn:active:not(:disabled),
.place-btn:active:not(:disabled), .step-btn:active:not(:disabled),
.chip:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(2, 6, 23, 0.45);
}

/* Keyboard users get a visible ring; mouse users do not. */
.ghost-btn:focus-visible, .event-action:focus-visible, .speed:focus-visible,
.tab:focus-visible, .action-btn:focus-visible, .pay-rate:focus-visible,
.mini-btn:focus-visible, .big-btn:focus-visible,
.modal-actions button:focus-visible, .mode-btn:focus-visible,
.place-btn:focus-visible, .step-btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  color: var(--btn-text-hover);
}

.ghost-btn:disabled, .event-action:disabled, .speed:disabled, .tab:disabled,
.action-btn:disabled, .pay-rate:disabled, .mini-btn:disabled, .big-btn:disabled,
.modal-actions button:disabled, .mode-btn:disabled, .place-btn:disabled,
.step-btn:disabled, .chip:disabled {
  opacity: 0.38;
  filter: grayscale(0.4);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Intents ---------------------------------------------------------------- */
.action-btn, .ghost-btn, .modal-actions button, .event-action {
  --btn-bg: linear-gradient(180deg, rgba(56, 189, 248, 0.22), rgba(56, 189, 248, 0.1));
  --btn-bg-hover: linear-gradient(180deg, rgba(56, 189, 248, 0.34), rgba(56, 189, 248, 0.16));
  --btn-border: rgba(56, 189, 248, 0.42);
  --btn-border-hover: rgba(56, 189, 248, 0.7);
  --btn-text: var(--text);
}

.place-btn {
  --btn-bg: linear-gradient(180deg, #4ade80, #22a55b);
  --btn-bg-hover: linear-gradient(180deg, #5cf08e, #27b866);
  --btn-border: rgba(74, 222, 128, 0.5);
  --btn-border-hover: rgba(74, 222, 128, 0.85);
  --btn-text: #052e16;
  --btn-text-hover: #052e16;
  --btn-shadow: 0 2px 10px rgba(34, 165, 91, 0.25);
}
.place-btn small { color: rgba(5, 46, 22, 0.75); }

.big-btn {
  --btn-bg: linear-gradient(180deg, var(--star), #f59e0b);
  --btn-bg-hover: linear-gradient(180deg, #fde68a, #fbbf24);
  --btn-border: rgba(252, 211, 77, 0.55);
  --btn-border-hover: rgba(252, 211, 77, 0.9);
  --btn-text: #2a1a02;
  --btn-text-hover: #2a1a02;
  --btn-shadow: 0 2px 12px rgba(245, 158, 11, 0.22);
}

.suggest-btn {
  --btn-border: rgba(252, 211, 77, 0.4);
  --btn-border-hover: var(--star);
  --btn-text: var(--star);
  --btn-text-hover: #fde68a;
}

.danger-btn, .modal-actions button.danger {
  --btn-bg: rgba(248, 113, 113, 0.16);
  --btn-bg-hover: rgba(248, 113, 113, 0.28);
  --btn-border: rgba(248, 113, 113, 0.45);
  --btn-border-hover: rgba(248, 113, 113, 0.8);
  --btn-text: var(--bad);
  --btn-text-hover: #fecaca;
}

/* Selected state for anything that toggles ------------------------------- */
.speed.active, .chip.active, .pay-rate.active, .mode-btn.active {
  --btn-bg: rgba(56, 189, 248, 0.2);
  --btn-bg-hover: rgba(56, 189, 248, 0.28);
  --btn-border: rgba(56, 189, 248, 0.6);
  --btn-text: var(--accent);
  --btn-text-hover: var(--accent);
}
.speed.active[data-speed="0"] {
  --btn-bg: rgba(251, 191, 36, 0.2);
  --btn-bg-hover: rgba(251, 191, 36, 0.28);
  --btn-border: rgba(251, 191, 36, 0.6);
  --btn-text: var(--warn);
  --btn-text-hover: var(--warn);
}

/* Shapes and sizes ------------------------------------------------------- */
.action-btn { min-width: 96px; min-height: 40px; }
.ghost-btn { min-height: 38px; font-size: 13px; }
.modal-actions button { min-height: 42px; font-size: 13px; padding: 9px 16px; }
.event-action { min-height: 40px; padding: 8px 16px; font-size: 13px; animation: pulse 0.9s infinite; }
.event-banner.bad .event-action {
  --btn-bg: linear-gradient(180deg, rgba(248, 113, 113, 0.32), rgba(248, 113, 113, 0.16));
  --btn-border: rgba(248, 113, 113, 0.55);
  --btn-text: #fecaca;
}

.place-btn { min-height: 44px; font-size: 13px; padding: 10px 18px; }
.big-btn { width: 100%; min-height: 46px; font-size: 14px; margin-top: 10px; }

.chip { border-radius: 99px; padding: 7px 14px; font-size: 11.5px; min-height: 34px; }
.step-btn { flex: 1; min-height: 40px; padding: 6px 4px; font-size: 11.5px; }
.suggest-btn { flex: 1.3; }

.mini-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 17px;
  font-weight: 700;
}
.mini-btn.wide { width: auto; min-width: 52px; padding: 0 10px; font-size: 12px; }

.speed { min-width: 42px; min-height: 32px; padding: 5px 10px; font-size: 12px; }

.pay-rate { flex: 1; min-width: 80px; min-height: 46px; padding: 7px 8px; }

.mode-btn {
  flex: 1;
  border-color: transparent;
  background: transparent;
  min-height: 38px;
  font-size: 12.5px;
}
.mode-btn:hover:not(:disabled) { border-color: transparent; }

.tab {
  min-height: 38px;
  padding: 8px 13px;
  font-size: 13px;
  border-radius: 9px 9px 0 0;
  border-bottom: none;
  border-color: transparent;
  background: transparent;
}
.tab:hover:not(:disabled) { background: rgba(30, 41, 59, 0.6); border-color: transparent; }
.tab.active {
  --btn-text: var(--text);
  background: var(--bg-panel-2);
  border-color: var(--line);
  border-bottom: none;
}

/* Fingers need more room than a mouse pointer does. */
@media (pointer: coarse) {
  .view-btn { width: 42px; height: 42px; font-size: 19px; }
  .speed { min-height: 38px; min-width: 46px; font-size: 13px; }
  .tab { min-height: 42px; padding: 10px 14px; }
  .ghost-btn, .action-btn, .step-btn, .modal-actions button { min-height: 44px; }
  .mini-btn { width: 42px; height: 42px; font-size: 19px; }
  .mini-btn.wide { width: auto; min-width: 56px; }
  .chip { min-height: 40px; padding: 9px 16px; }
  .pay-rate { min-height: 52px; }
  .place-btn, .big-btn, .event-action { min-height: 48px; }
}

/* ---- Responsive ------------------------------------------------------- */
/* Below this width the game stops being a page you scroll and becomes a
   tycoon game: the floor fills the screen, the tabs are a dock along the
   bottom, and each pane opens as a window over the shop. Stacked in a column
   the lists ran to thousands of pixels and every action began by scrolling
   past the floor and ended by scrolling back. */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    min-height: 0;
  }
  .store-panel, .panel-column { min-width: 0; }
  .store-panel { min-height: 0; }
  /* Speed and gauges move above the floor. Left in source order they end up
     at the bottom of the panel, which is exactly where the window and the
     dock now are — they were simply buried. */
  .speed-bar { order: -2; border-top: 0; border-bottom: 1px solid var(--line); }
  .store-footer { order: -1; }
  #store { order: 0; flex: 1 1 auto; min-height: 160px; }
  #app { height: 100%; min-height: 0; }
  body { overflow: hidden; }

  /* The column is only a place to hang the dock and the window from; both of
     its children are taken out of the flow, so it occupies nothing. */
  .panel-column {
    background: none;
    border: 0;
    box-shadow: none;
    overflow: visible;
    min-height: 0;
  }
  .hint { display: none; }

  /* The dock. */
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    gap: 2px;
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
    background: rgba(9, 14, 26, 0.96);
    border-top: 1px solid var(--line);
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    backdrop-filter: blur(6px);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: 1 0 auto;
    min-width: 0;
    border-radius: 9px;
    font-size: 12px;
    padding: 8px 10px;
  }

  /* The window. */
  .window-bar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + var(--win-h, 38vh));
    z-index: 32;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px 8px 13px;
    background: linear-gradient(180deg, #1c2a46, #16213a);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 26px rgba(2, 6, 23, 0.5);
  }
  .window-bar strong { font-size: 13px; letter-spacing: 0.01em; }
  .window-close {
    appearance: none;
    /* A finger's worth. It is the control a phone player reaches for most,
       and at 30px it was the smallest thing on the screen. (Setting this in
       the pointer:coarse block does not work — that block comes earlier in
       the file, so this rule wins at equal specificity.) */
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.5);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
  }
  .window-close:active { transform: translateY(1px); }

  .tab-body {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    z-index: 31;
    height: var(--win-h, 38vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.55);
  }

  .panel-column.closed .window-bar,
  .panel-column.closed .tab-body { display: none; }

  /* The turn buttons would sit under the dock otherwise. */
  /* Clear of the dock. (It cannot drop back down when the window closes:
     the controls sit in an earlier sibling, and CSS has no way to look
     backwards from the panel column's state.) */
  .view-controls { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

  /* Toasts would otherwise sit on top of the buttons in the stacked layout.
     --topbar-h is measured at runtime so they clear the header. */
  .toasts {
    left: 50%;
    right: auto;
    bottom: auto;
    top: calc(var(--topbar-h, 96px) + 16px);
    transform: translateX(-50%);
    align-items: center;
    width: min(92vw, 460px);
  }
  .toast { width: 100%; max-width: none; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
}

/* Tablet portrait: use the width for two columns of cards. */
@media (min-width: 700px) and (max-width: 960px) {
  .tab-pane { display: none; }
  .tab-pane.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .tab-pane.active > .section-title,
  .tab-pane.active > .order-bar,
  .tab-pane.active > .order-warning,
  .tab-pane.active > .stats-list,
  .tab-pane.active > .chip-row,
  .tab-pane.active > .pay-rates,
  .tab-pane.active > .awards-grid,
  .tab-pane.active > .franchise-hero,
  .tab-pane.active > .inspector,
  .tab-pane.active > .order-meter,
  .tab-pane.active > p { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  #app { padding: 8px 10px 10px; gap: 8px; }

  /* Brand and menu share a row; the stats become a scrollable strip below. */
  .topbar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand-mark { font-size: 21px; }
  .brand-text h1 { font-size: 14px; }
  .brand-text p { font-size: 10px; }
  .topbar-actions { flex: 0 0 auto; order: 2; }
  .wallet {
    order: 3;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    gap: 6px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .wallet::-webkit-scrollbar { display: none; }
  /* The strip scrolls, but the last tile was being sliced mid-word at the
     edge, which reads as a broken layout rather than as more to the right.
     Snap each tile to the edge and fade the cut so it reads as scrollable. */
  .wallet { scroll-snap-type: x proximity; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); }
  .stat { scroll-snap-align: start; }
  .stat { flex: 0 0 auto; min-width: 70px; padding: 4px 9px; }
  .stat strong { font-size: 14px; }
  .stat-label { font-size: 9px; }

  /* The floor takes whatever is left: it is the game now, not a strip above
     a list. (It used to be pinned to a share of the viewport, which made
     sense while the panel was stacked underneath it.) */
  .store-panel { min-height: 0; }

  /* The speed buttons fill the row on a phone, so the day scale next to them
     was squeezed to zero width — and because its hour labels are positioned
     absolutely and centred on themselves, all of them stacked up on the left
     edge as one unreadable smear. It gets its own row down here. */
  .speed-bar { flex-wrap: wrap; gap: 6px 10px; }
  .speed-controls { flex: 1 1 auto; }
  .day-scale { flex: 1 0 100%; min-width: 0; }

  /* One compact row that scrolls, rather than a column two lines deep. */
  .store-footer { padding: 6px 11px; }
  .gauges {
    gap: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .gauges::-webkit-scrollbar { display: none; }
  .gauge { flex: 0 0 auto; }
  .gauge-track { width: 46px; }
  .hint { font-size: 10.5px; }

  /* The dock is set up in the 960px block; here it only gets tighter so six
     tabs fit a narrow handset without scrolling sideways. */
  .tab { padding: 8px 6px; font-size: 11.5px; }
  .card { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; padding: 8px 9px; }
  .card-title { font-size: 12.5px; }
  .card-desc { font-size: 10.5px; }
  .action-btn { min-width: 84px; font-size: 11.5px; padding: 5px 9px; }
  .awards-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }

}

/* ---- Ordering screen --------------------------------------------------- */
.forecast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 10px;
  padding: 8px 11px;
}
.forecast-icon { font-size: 22px; }
.forecast strong { display: block; font-size: 12.5px; }
.forecast span { font-size: 11px; color: var(--text-dim); }

.mode-switch {
  display: flex;
  gap: 4px;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}

.order-bar {
  position: sticky;
  top: -10px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, var(--bg-panel-2), rgba(19, 30, 54, 0.97));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 11px;
  padding: 9px 12px;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.5);
}
.order-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.order-info strong { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.order-info span { font-size: 11px; color: var(--text-dim); }

.order-warning {
  font-size: 11.5px;
  color: var(--warn);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 9px;
  padding: 7px 10px;
  line-height: 1.45;
}

.order-line {
  background: var(--bg-row);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.order-line.drafting { border-color: rgba(56, 189, 248, 0.5); background: rgba(19, 35, 60, 0.75); }
.order-head { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 9px; align-items: start; }
.order-icon { font-size: 21px; line-height: 1.1; }
.order-meter {
  grid-column: 2;
  height: 5px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
  margin-top: 5px;
}
.order-meter > div { height: 100%; transition: width 0.3s ease; }


.order-qty {
  flex: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.6);
  padding: 3px 6px;
}
.order-qty.active { border-color: rgba(56, 189, 248, 0.5); background: rgba(56, 189, 248, 0.12); }
.order-qty strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.order-qty small { font-size: 9.5px; color: var(--text-dim); }


/* Expedited orders read as the pricier, secondary choice next to Place order. */
.rush-btn {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.5);
  color: var(--warn);
}
.rush-btn:disabled { opacity: 0.45; }

/* Morale above 100 is a genuine bonus band, so it reads differently. */
.over-100 { color: #c084fc; font-weight: 700; }

/* ---- Folded sections -------------------------------------------------- */
/* Things already bought — researched nodes, fitted staff upgrades — are kept
   out of the way at the bottom of their pane rather than pushing the live
   choices off the screen. */
.folded { margin: 10px 0 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.folded > summary {
  cursor: pointer; list-style: none;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim); padding: 4px 2px; user-select: none;
}
.folded > summary::-webkit-details-marker { display: none; }
.folded > summary::before { content: '▸ '; display: inline-block; width: 1em; }
.folded[open] > summary::before { content: '▾ '; }
.folded > summary:hover { color: var(--text); }
.folded[open] > summary { margin-bottom: 6px; }
.folded .card { opacity: 0.72; }

/* ---- Denser panel on a wide screen ------------------------------------ */
/* On desktop the panel has plenty of width but the cards were sized for a
   phone, so far less fitted on screen than needed to. */
@media (min-width: 1100px) {
  .tab-pane .card { padding: 8px 10px; gap: 9px; }
  .tab-pane .card-icon { font-size: 19px; }
  .tab-pane .card-title { font-size: 13px; }
  .tab-pane .card-desc { font-size: 11.5px; line-height: 1.35; }
  .tab-pane .card-tag { font-size: 10.5px; }
  .tab-pane .section-title { margin: 12px 0 6px; }
  .tab-pane .stats-list { margin-bottom: 8px; }
}

/* ---- Reports analytics ------------------------------------------------- */
.trend { display: flex; align-items: flex-end; gap: 4px; margin: 8px 0 12px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.trend-col > span { font-size: 9px; color: var(--text-dim); }
/* Each day gets the same slot height so the zero line stays put across the row. */
.trend-slot { height: 38px; width: 100%; display: flex; }
.trend-slot.up { align-items: flex-end; }
.trend-slot.down { align-items: flex-start; }
.trend-bar { width: 100%; border-radius: 3px; }
.trend-bar.up { background: var(--good); }
.trend-bar.down { background: var(--bad); }

/* Share-of-costs meter, drawn under its row rather than beside it so a long
   label never squeezes it to nothing. The row has to wrap for that, and the
   meter needs winning back from the blanket `.stats-list div` rule above. */
.stats-list .with-share { flex-wrap: wrap; }
.stats-list .with-share .share {
  display: block; flex-basis: 100%; height: 4px; padding: 0;
  border-radius: 99px; background: rgba(148, 163, 184, 0.16);
  margin-top: 5px; overflow: hidden;
}
.stats-list .with-share .share > div { display: block; height: 100%; padding: 0; border-radius: 0; background: var(--warn); }
.stats-list .negative-row { color: var(--bad); }
.tip-line { border-left: 2px solid var(--accent); padding-left: 8px; margin: 6px 0; }

/* ---- Demand tracker ---------------------------------------------------- */
.stats-list .demand-up span:last-child { color: var(--good); }
.stats-list .demand-down span:last-child { color: var(--text-dim); }
.stats-list .demand-short {
  flex-basis: 100%; display: block; padding: 4px 0 0;
  background: none; border-radius: 0;
  font-size: 11px; color: var(--warn);
}

/* Studio credit and link back to the games page, the same on every Game Golem Studios title screen */
.modal .modal-studio { margin: -6px 0 12px; font-size: 11px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; color: var(--text-dim); }
.ggs-foot { text-align: center; font-size: 11px; margin-top: 12px; }
.ggs-foot a { color: var(--text-dim); text-underline-offset: 2px; }
