@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg: #07080f;
  --c-surface: #0d1117;
  --c-border: rgba(255,255,255,0.08);
  --c-accent: #e8a030;
  --c-mint: #4dca7c;
  --c-sky: #7ec8e3;
  --c-red: #e05c5c;
  --c-purple: #a78bfa;
  --c-text: #e0e8f0;
  --c-muted: #6a7a8a;
  --font-ui: 'Chakra Petch', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html, body {
  width: 100%; height: 100%;
  background: var(--c-bg);
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
}

#canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  image-rendering: pixelated;
  touch-action: none;
}

/* ─── Build / upgrades menu - Godot-style left-aligned top tabs ───────────── */

.build-menu {
  position: fixed;
  top: 5vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(92vw, 1180px);
  height: 90vh;
  display: flex;
  flex-direction: column;
}
.build-menu.hidden { display: none; }
.build-menu { font-family: var(--font-ui); }

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 8px;
}
.menu-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
}
.menu-title span {
  color: var(--c-muted);
  font-weight: 600;
  margin-left: 8px;
  font-size: 12px;
}
.menu-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.menu-cash {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--c-mint);
  background: rgba(77,202,124,0.12);
  border: 1px solid rgba(77,202,124,0.3);
  border-radius: 6px;
  padding: 4px 10px;
}
.menu-close {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--c-text);
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.menu-close:hover { background: var(--c-red); color: #fff; }

.tab-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding-left: 6px;
}

.tab-hint {
  margin-left: auto;
  margin-right: 8px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--c-muted);
}

.tab {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 9px 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-ui);
  color: var(--c-muted);
  background: rgba(8,14,12,0.72);
  border-radius: 9px 9px 0 0;
  transform: translateY(3px);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.tab:hover { color: var(--c-text); }
.tab-discord {
  padding: 6px 10px; text-decoration: none; cursor: pointer;
  display: inline-flex; align-items: center; align-self: flex-end;
  background: rgba(8,14,12,0.72); border-radius: 9px 9px 0 0;
  transform: translateY(3px); transition: background 0.15s, transform 0.15s;
}
.tab-discord:hover { background: rgba(10,18,16,0.88); transform: translateY(0); }
.tab-discord img { width: 24px; height: 24px; display: block; opacity: 0.65; transition: opacity 0.15s; }
.tab-discord:hover img { opacity: 1; }
.tab-playtest {
  margin-left: 4px; padding: 9px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  font-family: var(--font-ui); color: var(--c-muted);
}
.tab-playtest:hover { color: var(--c-text); }
.tab.active {
  color: #fff;
  background: rgba(10,18,16,0.96);
  transform: translateY(0);
}

.panel {
  background: rgba(10,18,16,0.96);
  border: 1px solid var(--c-border);
  border-radius: 0 10px 10px 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  box-shadow: 0 14px 32px rgba(0,0,0,0.45);
}

.tab-panel { padding: 22px; }
.tab-panel.hidden { display: none; }

.panel-hint {
  font-size: 11px;
  color: var(--c-muted);
  margin-bottom: 10px;
}

.cat-nav { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.cat-nav-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--cat-color, var(--c-muted));
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.cat-nav-btn:hover { background: rgba(255,255,255,0.16); }

/* Build tab - category-grouped item grid */
.item-grid { display: flex; flex-direction: column; gap: 4px; padding-bottom: 84px; }

.cat-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cat-color, var(--c-muted));
  margin: 16px 0 8px;
}
.cat-divider:first-child { margin-top: 2px; }
.cat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cat-color, var(--c-muted));
  box-shadow: 0 0 6px var(--cat-color, transparent);
}

.cat-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.item-card {
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 14px 8px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.item-card:hover { background: rgba(255,255,255,0.09); }
.item-card.selected { border-color: var(--cat-color, var(--c-accent)); background: rgba(255,255,255,0.1); }
.item-card.disabled { opacity: 0.45; cursor: not-allowed; }
.item-card .swatch {
  display: block;
  width: 64px; height: 64px;
  border-radius: 8px;
  margin: 0 auto 10px;
  border: 1px solid rgba(255,255,255,0.15);
  image-rendering: pixelated;
}
.item-card .name { font-size: 12px; font-weight: 600; line-height: 1.2; }
.item-card .cost { font-family: var(--font-mono); font-size: 11.5px; color: var(--c-muted); margin-top: 4px; }
.item-card .cost.afford { color: var(--c-mint); }
.item-card .stat { font-family: var(--font-mono); font-size: 10px; color: var(--c-sky); margin-top: 2px; }

.corner-pip {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cat-color, var(--c-muted));
  opacity: 0;
}
.item-card.selected .corner-pip { opacity: 1; }

.slot-badge {
  position: absolute;
  top: 6px; left: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--c-muted);
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 1px 4px;
}

.lock-badge {
  position: absolute;
  bottom: 6px; left: 6px;
  font-size: 10px;
  opacity: 0;
}
.item-card.disabled .lock-badge { opacity: 0.8; }
.item-card.locked .lock-badge { opacity: 0.95; }
.item-card.locked .cost { color: var(--c-muted); font-size: 9px; }
.fish-card.disabled .swatch { filter: grayscale(1) brightness(0.6); }

/* Build tab - bottom status bar showing the currently selected item, sticky
   within the scrolling panel so it stays visible while the grid scrolls */
.action-bar {
  position: sticky;
  bottom: 0;
  margin: 16px -22px -22px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: rgba(8,14,12,0.96);
  border-top: 1px solid var(--c-border);
  backdrop-filter: blur(4px);
}
.action-preview .swatch { width: 40px; height: 40px; border-radius: 6px; }
.action-info { flex: 1; min-width: 0; }
.action-name { font-size: 13px; font-weight: 700; }
.action-desc { font-size: 11px; color: var(--c-muted); margin-top: 2px; }
.action-cost {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--c-muted);
  white-space: nowrap;
}
.action-cost.afford { color: var(--c-mint); }

/* ─── Bottom-right build HUD - live state while the big menu is closed ───── */
.build-hud {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 19;
  width: 224px;
  background: rgba(10,18,16,0.94);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.45);
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.build-hud.hidden { display: none; }
/* The build HUD and the touch action buttons both anchor to the bottom-right
   corner - on touch devices the buttons (stacked up to 160px tall) would sit
   directly on top of the HUD's button rows, including Exit. Lift the HUD
   clear of them instead. */
body.touch-active .build-hud { bottom: 170px; }

/* The full-screen build menu (92vw x 90vh, ~5vh margin) leaves only a thin
   strip clear at the bottom corners on a phone - the joystick and Interact
   button would otherwise float on top of it and steal taps meant for the
   menu's bottom-most content. Build stays visible/in place: it's the only
   way to close the menu panel while remaining in placement mode (mobile's
   equivalent of pressing B twice on desktop), same corner as the menu's
   own X so nothing new to overlap. */
body.build-menu-open .touch-joystick-base,
body.build-menu-open #touchInteractBtn { display: none; }

/* The Machines panel is bottom-left-anchored and slightly overlaps the
   joystick's top-right edge on touch devices. */
body.touch-active .machines-panel { bottom: 144px; }

.hud-row { display: flex; align-items: center; gap: 8px; }
.hud-selected .hud-preview canvas {
  display: block;
  width: 40px; height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  image-rendering: pixelated;
}
.hud-info { flex: 1; min-width: 0; }
.hud-name { font-size: 12.5px; font-weight: 700; }
.hud-sub { font-size: 9.5px; color: var(--c-muted); margin-top: 2px; }

.hud-btn {
  appearance: none;
  flex: 1;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--c-text);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.hud-btn:hover { background: rgba(255,255,255,0.16); }
.hud-btn.hud-toggle.active { background: var(--c-sky); color: #07080f; border-color: var(--c-sky); }
.hud-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.hud-arrow { display: inline-block; font-size: 13px; transition: transform 0.15s; }

.hud-bp-status { font-size: 10px; color: var(--c-muted); }

/* Controls tab - keybind cheat-sheet */
.control-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 6px;
}
.control-keys {
  flex: 0 0 auto;
  min-width: 168px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.key-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--c-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 8px;
  white-space: nowrap;
}
.key-plus, .key-or {
  font-size: 10px;
  color: var(--c-muted);
  font-weight: 600;
  margin: 0 1px;
}
.control-desc {
  flex: 1;
  font-size: 12px;
  color: var(--c-text);
  line-height: 1.4;
}

/* Upgrades tab - stat rows */
.upgrade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 10px;
}
.upgrade-row:last-child { margin-bottom: 0; }
.upgrade-info .name {
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.upgrade-info .desc { font-size: 11px; color: var(--c-muted); margin-top: 3px; }
.upgrade-info .effect {
  font-family: var(--font-mono);
  font-size: 10.5px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.effect .fx-current { color: var(--c-muted); }
.effect .fx-arrow { color: var(--c-muted); }
.effect .fx-next { color: var(--c-accent); font-weight: 700; }
.effect .maxed { color: var(--c-mint); }

.level-pair {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
}
.level-badge {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  color: var(--c-mint);
  background: rgba(77,202,124,0.15);
  border-radius: 4px;
  padding: 1px 6px;
}
.level-badge.next { color: var(--c-accent); background: rgba(232,160,48,0.15); }
.level-arrow { color: var(--c-muted); font-size: 10px; }

.upgrade-buy {
  appearance: none;
  border: none;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  background: var(--c-accent);
  color: #1a1208;
  transition: filter 0.15s;
}
.upgrade-buy:hover { filter: brightness(1.1); }
.upgrade-buy:disabled {
  background: rgba(255,255,255,0.06);
  color: var(--c-muted);
  cursor: not-allowed;
}

.lb-row .lb-score {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--c-mint);
  white-space: nowrap;
}
.lb-self { outline: 1px solid var(--c-accent); }
.lb-own-row {
  margin-top: 14px;
  background: rgba(232,160,48,0.12);
  outline: 1px solid var(--c-accent);
}

/* ─── Per-block popup - pinned at the clicked tile/player's screen pos ─────── */
.block-popup {
  position: fixed;
  z-index: 30;
  width: max-content;
  min-width: 230px;
  max-width: 280px;
  font-family: var(--font-ui);
  background: rgba(10,18,16,0.97);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.5);
  padding: 12px 14px;
  transform: translate(-50%, -100%);
  margin-top: -14px;
  transition: opacity 0.1s ease, scale 0.1s ease;
  scale: 1;
  /* The popup stays open (and thus keeps this fixed-position box on screen)
     until explicitly dismissed, but the player can walk/scroll the camera
     anywhere in the meantime - so its footprint frequently ends up sitting
     over a completely unrelated belt/Seller tile. Every real control inside
     is a <button>; the rest (padding, labels, dividers) is inert, so letting
     clicks on the inert parts fall through to the canvas beneath fixes
     "can't sell" clicks silently swallowed by a leftover popup, without
     touching the buttons themselves (re-enabled below). */
  pointer-events: none;
}
.block-popup button {
  pointer-events: auto;
}
.block-popup.hidden {
  display: none;
}
@keyframes blockPopupIn {
  from { opacity: 0; scale: 0.93; }
  to   { opacity: 1; scale: 1; }
}
.block-popup:not(.hidden) {
  animation: blockPopupIn 0.12s ease forwards;
}
.block-popup .mp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.block-popup .mp-name {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.block-popup .mp-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--c-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.block-popup .mp-close:hover { color: #fff; }
.block-popup .mp-effect {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--c-muted);
  margin-bottom: 10px;
}
.block-popup .mp-effect .fx-next { color: var(--c-accent); font-weight: 700; }
.block-popup .mp-stats {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--c-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}
.block-popup .mp-buy {
  width: 100%;
  appearance: none;
  border: none;
  border-radius: 6px;
  padding: 9px 0;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--c-accent);
  color: #1a1208;
  transition: filter 0.15s;
}
.block-popup .mp-buy:hover { filter: brightness(1.1); }
.block-popup .mp-buy:disabled {
  background: rgba(255,255,255,0.06);
  color: var(--c-muted);
  cursor: not-allowed;
}

/* Cash HUD - DOM pill so it sits above the tutorial overlay (z-index 30 > 25) */
.cash-hud {
  position: fixed;
  bottom: 6px;
  left: 6px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(8,14,8,0.88);
  border: 1px solid var(--c-border);
  border-radius: 9px;
  padding: 2px 12px 2px 2px;
  pointer-events: none;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 16px;
  color: #70cd18;
  transition: color 0.1s, transform 0.1s;
}
.cash-hud.cash-hud-pulse { color: #a0f040; transform: scale(1.08); }
.cash-hud-icon { width: 36px; height: 36px; image-rendering: pixelated; flex-shrink: 0; }
body.touch-active .cash-hud { bottom: 20px; left: 90px; }

/* Move button - appears at the bottom of every block popup */
.block-popup .mp-move {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 12px;
  background: rgba(126,200,227,0.12);
  border: 1px solid rgba(126,200,227,0.3);
  border-radius: 6px;
  color: var(--c-sky);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.block-popup .mp-move:hover { background: rgba(126,200,227,0.22); }

/* Sorter settings - size threshold pills */
.block-popup .mp-size-row {
  display: flex;
  gap: 4px;
}
.block-popup .mp-size-btn {
  flex: 1;
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--c-muted);
  border-radius: 5px;
  padding: 6px 2px;
  font-size: 9.5px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.block-popup .mp-size-btn:hover { color: var(--c-text); }
.block-popup .mp-size-btn.active {
  background: rgba(232,160,48,0.18);
  border-color: var(--c-accent);
  color: var(--c-accent);
}

/* Crate contents - grouped fish list */
.block-popup .mp-crate-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}
.block-popup .mp-crate-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.block-popup .mp-crate-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.block-popup .mp-crate-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-ui);
  font-weight: 600;
}
.block-popup .mp-crate-size { color: var(--c-muted); font-weight: 500; }
.block-popup .mp-crate-count { color: var(--c-muted); }
.block-popup .mp-crate-value { color: var(--c-mint); font-weight: 700; }

/* Teleporter settings - destination picker list */
.block-popup .mp-target-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.block-popup .mp-target-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--c-muted);
  border-radius: 5px;
  padding: 7px 8px;
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.block-popup .mp-target-btn:hover { color: var(--c-text); }
.block-popup .mp-target-btn.active {
  background: rgba(167,139,250,0.18);
  border-color: var(--c-purple);
  color: var(--c-purple);
}
.block-popup .mp-target-clear { font-style: italic; }
.block-popup .mp-target-empty {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--c-muted);
  padding: 6px 2px;
}

/* ─── Sound settings menu - fixed speaker icon, top-right ──────────────────── */
.sound-toggle-btn,
.game-menu-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}
.sound-toggle-btn img,
.game-menu-toggle-btn img {
  width: 26px; height: 26px;
  image-rendering: pixelated;
}

.sound-toggle-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 25;
  width: 38px; height: 38px;
  appearance: none;
  border: 1px solid var(--c-border);
  background: rgba(10,18,16,0.85);
  color: var(--c-text);
  border-radius: 8px;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.15s;
}
.sound-toggle-btn:hover { background: rgba(255,255,255,0.16); }

.sound-panel {
  position: fixed;
  top: 56px;
  left: 14px;
  z-index: 25;
  width: 170px;
  font-family: var(--font-ui);
  background: rgba(10,18,16,0.97);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.5);
  padding: 10px 12px;
  transition: opacity 0.13s ease, transform 0.13s ease;
  transform-origin: top left;
}
.sound-panel.hidden { opacity: 0; pointer-events: none; transform: translateY(-6px) scale(0.98); }
.sound-panel .sound-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 2px;
  cursor: pointer;
}
.sound-panel .sound-row input { cursor: pointer; }

/* ─── Game menu - save/restart, fixed gear icon next to the sound button ──── */
.game-menu-toggle-btn {
  position: fixed;
  top: 14px;
  left: 60px;
  z-index: 25;
  width: 38px; height: 38px;
  appearance: none;
  border: 1px solid var(--c-border);
  background: rgba(10,18,16,0.85);
  color: var(--c-text);
  border-radius: 8px;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.15s;
}
.game-menu-toggle-btn:hover { background: rgba(255,255,255,0.16); }

.game-menu-panel {
  position: fixed;
  top: 56px;
  left: 60px;
  z-index: 25;
  width: 170px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-ui);
  background: rgba(10,18,16,0.97);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.5);
  padding: 10px;
  transition: opacity 0.13s ease, transform 0.13s ease;
  transform-origin: top left;
}
.game-menu-panel.hidden { opacity: 0; pointer-events: none; transform: translateY(-6px) scale(0.98); }
.game-menu-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--c-text);
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.game-menu-btn:hover { background: rgba(255,255,255,0.16); }
.game-menu-btn.danger { color: var(--c-red); }
.game-menu-btn.danger:hover { background: rgba(224,92,92,0.15); }
.game-menu-divider { height: 1px; background: var(--c-border); margin: 4px 0; }
.game-menu-panel .sound-row { color: var(--c-text); }
.game-menu-label { font-size: 11px; color: var(--c-muted); padding: 2px 0 4px; text-align: center; }

.cloud-status-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.cloud-status-icon { font-size: 13px; min-width: 14px; text-align: center; }
.cloud-status-label { flex: 1; font-size: 10px; color: var(--c-muted); }
.cloud-sync-btn { flex: 0; font-size: 10px; padding: 3px 8px; min-height: unset; }
.cloud-recovery-row { display: flex; align-items: center; gap: 6px; padding: 2px 0 0; }
.cloud-recovery-label { font-size: 9px; color: var(--c-muted); white-space: nowrap; }
.cloud-recovery-code { font-family: monospace; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; color: var(--c-mint); }

.recovery-code-box {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 12px 20px;
  font-family: monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--c-mint);
  text-align: center;
  margin: 12px 0;
}

/* ─── Machines overview - icon button docked beside the cash pill HUD ──────── */
/* top/left here are just an initial fallback before the first frame's JS
   positioning (updateMachinesBtnPos in ui.js) docks it beside the cash pill. */
.machines-toggle-btn {
  position: fixed;
  top: 14px;
  left: 106px;
  z-index: 25;
  width: 38px; height: 38px;
  appearance: none;
  border: 1px solid var(--c-border);
  background: rgba(10,18,16,0.85);
  color: var(--c-text);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  padding: 0;
}
.machines-toggle-btn:hover { background: rgba(255,255,255,0.16); }
.machines-toggle-btn img {
  width: 36px; height: 36px;
  margin-top: 2px;
  image-rendering: pixelated;
}

.machines-panel {
  position: fixed;
  bottom: 60px;
  left: 106px;
  z-index: 25;
  width: 280px;
  max-height: 60vh;
  overflow-y: auto;
  font-family: var(--font-ui);
  background: rgba(10,18,16,0.97);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.5);
  padding: 10px 12px;
  transition: opacity 0.13s ease, transform 0.13s ease;
  transform-origin: bottom left;
}
.machines-panel.hidden { opacity: 0; pointer-events: none; transform: translateY(6px) scale(0.98); }
.machines-panel .machines-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 8px 0 4px;
}
.machines-panel .machines-group-title:first-child { margin-top: 0; }
.machines-panel .upgrade-row { padding: 8px 10px; margin-bottom: 6px; }
.machines-panel .upgrade-buy { padding: 6px 10px; font-size: 10.5px; }
.machines-dropdown {
  width: 100%;
  margin-bottom: 10px;
  padding: 6px 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: #e8e8e8;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
.machines-dropdown:focus { border-color: rgba(255,255,255,0.3); }
.machines-dropdown option { background: #0e1a18; color: #e8e8e8; }

/* ─── Leaderboard - fixed icon button, top-left (machines button moves away
   from this initial 106px slot every frame, so it's free for permanent use) */
.leaderboard-toggle-btn {
  position: fixed;
  top: 14px;
  left: 106px;
  z-index: 25;
  width: 38px; height: 38px;
  appearance: none;
  border: 1px solid var(--c-border);
  background: rgba(10,18,16,0.85);
  color: var(--c-text);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}
.leaderboard-toggle-btn:hover { background: rgba(255,255,255,0.16); }

.leaderboard-panel {
  position: fixed;
  top: 5vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  width: min(92vw, 640px);
  height: 90vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
}
.leaderboard-panel.hidden { display: none; }

.leaderboard-content {
  background: rgba(10,18,16,0.96);
  border: 1px solid var(--c-border);
  border-radius: 0 10px 10px 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  box-shadow: 0 14px 32px rgba(0,0,0,0.45);
  padding: 22px;
}

/* ─── First-time tutorial overlay - bottom-center, clear of other UI ───────── */
.tutorial-overlay {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  width: min(92vw, 540px);
  font-family: var(--font-ui);
  background: linear-gradient(180deg, rgba(18,30,26,0.98), rgba(9,16,14,0.98));
  border: 1px solid rgba(232,196,63,0.35);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.4), 0 0 22px rgba(232,196,63,0.10);
  padding: 16px 20px 14px;
  text-align: center;
  overflow: hidden;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.tutorial-overlay.hidden { display: none; }
/* Slides up + fades in each time the step changes (retriggered from JS). */
.tutorial-overlay.tut-enter { animation: tutEnter 0.32s cubic-bezier(.2,.9,.3,1.15); }
@keyframes tutEnter {
  from { opacity: 0; translate: 0 16px; }
  to   { opacity: 1; translate: 0 0; }
}
/* Brief green pulse when a step is completed. */
.tutorial-overlay.tut-done {
  border-color: rgba(77,202,124,0.9);
  box-shadow: 0 14px 32px rgba(0,0,0,0.55), 0 0 30px rgba(77,202,124,0.45);
}

/* Thin bar across the top of the card: how far through the whole tutorial. */
.tutorial-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(255,255,255,0.07); }
.tutorial-progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #e8a030, #f0d060);
  box-shadow: 0 0 8px rgba(240,208,96,0.7);
  transition: width 0.5s cubic-bezier(.3,.8,.3,1);
}
.tutorial-head { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 7px; }
.tutorial-badge {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-accent); color: #1a1208;
  font-size: 11px; font-weight: 800; line-height: 1;
  box-shadow: 0 0 0 3px rgba(232,160,48,0.22);
  flex: none;
}
.tutorial-badge.done { background: var(--c-mint); box-shadow: 0 0 0 3px rgba(77,202,124,0.25); }
/* The joystick (110px tall) and action buttons (60px tall, stacked) sit in
   the same bottom corners on touch devices - lift the tutorial box clear of
   both instead of letting it sit underneath them. */
body.touch-active .tutorial-overlay { bottom: 180px; }
/* Phone landscape is only ~360-400px tall. The taller tutorial card (why-line,
   live hint, buttons) plus a 180px lift would cover most of the screen, so on
   touch it goes compact at the top-centre, clear of the joystick/buttons
   (bottom corners), the icon row (top-left) and the stats box (top-right). */
body.touch-active .tutorial-overlay {
  top: 6px; bottom: auto;
  width: min(50vw, 400px);
  padding: 6px 12px 8px;
}
body.touch-active .tutorial-head       { margin-bottom: 3px; }
body.touch-active .tutorial-badge      { width: 16px; height: 16px; font-size: 9.5px; }
body.touch-active .tutorial-step-count { font-size: 9.5px; }
body.touch-active .tutorial-step-text  { font-size: 12px; margin-bottom: 4px; }
body.touch-active .tutorial-step-why   { font-size: 10.5px; line-height: 1.35; margin: -2px 0 5px; }
body.touch-active .tutorial-step-hint  { font-size: 10.5px; margin: 0 0 5px; }

.rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10,18,16,0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  font-family: var(--font-ui);
  color: var(--c-text);
}
.rotate-overlay.hidden { display: none; }
.rotate-icon { font-size: 48px; transform: rotate(90deg); }
.rotate-text { font-size: 16px; font-weight: 600; max-width: 280px; }
.tutorial-step-count {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-accent);
}
.tutorial-step-text {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  margin-bottom: 8px;
}
.tutorial-skip-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--c-muted);
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tutorial-skip-btn:hover { background: rgba(255,255,255,0.16); color: var(--c-text); }

.tutorial-step-why {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
  color: #d3ddd8; /* near-white with a slight green tint; was the dim muted grey */
  margin: -4px 0 10px;
}
.tutorial-step-why strong { color: #fff; }
.tutorial-step-hint {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-mint);
  background: rgba(77,202,124,0.10);
  border: 1px solid rgba(77,202,124,0.28);
  border-radius: 999px;
  padding: 3px 12px;
  margin: 0 0 10px;
}
.tutorial-step-why:empty, .tutorial-step-hint:empty { display: none; }
.tutorial-btn-row { display: flex; gap: 8px; justify-content: center; }
.tutorial-next-btn {
  appearance: none;
  border: none;
  background: linear-gradient(180deg, #f0b040, #d98f22);
  color: #1a1208;
  border-radius: 7px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 800;
  padding: 7px 20px;
  cursor: pointer;
  box-shadow: 0 2px 0 #8a5a10, 0 4px 10px rgba(0,0,0,0.35);
  transition: transform 0.1s, filter 0.15s;
  animation: tutNextPulse 1.6s ease-in-out infinite;
}
.tutorial-next-btn:hover { filter: brightness(1.1); }
.tutorial-next-btn:active { transform: translateY(2px); box-shadow: 0 0 0 #8a5a10, 0 2px 6px rgba(0,0,0,0.35); }
@keyframes tutNextPulse {
  0%, 100% { box-shadow: 0 2px 0 #8a5a10, 0 4px 10px rgba(0,0,0,0.35), 0 0 0 0 rgba(240,176,64,0.5); }
  50%      { box-shadow: 0 2px 0 #8a5a10, 0 4px 10px rgba(0,0,0,0.35), 0 0 0 7px rgba(240,176,64,0); }
}
.tutorial-next-btn.hidden, .tutorial-skip-choice.hidden, .tutorial-skip-btn.hidden { display: none; }
.tutorial-skip-choice { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.tutorial-skip-q { width: 100%; font-size: 12px; font-weight: 700; color: var(--c-text); }

/* Pulsing ring on the DOM element a step points at, plus a bobbing arrow
   (positioned by tutorial.js) so a first-time player can see where to click. */
.tutorial-ui-highlight {
  outline: 2px solid #e8c43f !important;
  outline-offset: 2px;
  animation: tutUiPulse 1.1s ease-in-out infinite;
}
@keyframes tutUiPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,196,63,0.6); }
  50%      { box-shadow: 0 0 0 9px rgba(232,196,63,0); }
}
.tutorial-ui-arrow {
  position: fixed;
  z-index: 60;
  transform: translateX(-50%);
  color: #e8c43f;
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0,0,0,0.7);
  pointer-events: none;
  animation: tutUiBob 0.7s ease-in-out infinite alternate;
}
.tutorial-ui-arrow.hidden { display: none; }
@keyframes tutUiBob { from { margin-top: 0; } to { margin-top: 6px; } }

/* Inline key badge - used inside tutorial step text for hotkey callouts */
.tutorial-key {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  background: linear-gradient(180deg, #f6c060, #e09a2a);
  color: #1a1208;
  border-radius: 5px;
  border-bottom: 2px solid #8a5a10; /* keycap look */
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin: 0 2px;
  font-style: normal;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ─── Build hint button ─────────────────────────────────────────────────────── */
/* Persistent "B - Build" shortcut shown in the lower-right when not in
   build mode. Pulses during the tutorial's build_open step. */
.bottom-right-group {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}
body.touch-active .bottom-right-group { right: 90px; bottom: 20px; }

.build-hint {
  position: static;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10,18,16,0.92);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  appearance: none;
  color: inherit;
}
.build-hint:hover { background: rgba(25,42,35,0.97); }
.build-hint.hidden { display: none; }
.build-hint-key {
  background: var(--c-accent);
  color: #07080f;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.build-hint-label {
  color: var(--c-text);
  font-size: 13px;
  font-weight: 600;
}
/* Pulsing glow when tutorial is asking the player to press B */
.build-hint-pulse .build-hint-key {
  animation: buildKeyPulse 1s ease-in-out infinite;
}
@keyframes buildKeyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,160,48,0.7); }
  50%       { box-shadow: 0 0 0 10px rgba(232,160,48,0); }
}

/* ─── Bulk Edit trigger button ───────────────────────────────────────────────── */
.bulk-select-trigger {
  position: static;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(10,18,16,0.92);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--c-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}
.bulk-select-trigger:hover {
  background: rgba(20,36,28,0.97);
  border-color: rgba(255,255,255,0.18);
  color: var(--c-text);
}
.bulk-select-trigger.active {
  border-color: var(--c-mint);
  background: rgba(77,202,124,0.12);
  color: var(--c-mint);
}

/* ─── Bulk Edit panel ────────────────────────────────────────────────────────── */
.bs-panel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  width: min(440px, 94vw);
  z-index: 35;
  font-family: var(--font-ui);
  background: rgba(9,15,13,0.98);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  box-shadow: 0 24px 56px rgba(0,0,0,0.7), 0 0 0 1px rgba(77,202,124,0.06);
  padding: 18px 18px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bs-panel.bs-open {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

/* Header */
.bs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bs-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bs-icon { color: var(--c-mint); opacity: 0.8; flex-shrink: 0; }
.bs-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text);
}
.bs-x {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--c-muted);
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bs-x:hover { background: rgba(224,92,92,0.18); border-color: rgba(224,92,92,0.4); color: #e05c5c; }

/* Section labels */
.bs-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: -6px;
}

/* Type pills */
.bs-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.bs-pill {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--c-muted);
  border-radius: 20px;
  padding: 6px 12px 6px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.bs-pill:hover { background: rgba(255,255,255,0.09); color: var(--c-text); }
.bs-pill.active {
  border-color: rgba(77,202,124,0.5);
  background: rgba(77,202,124,0.12);
  color: var(--c-mint);
}
.bs-pill-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
}
.bs-pill-count {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: inherit;
}

/* Separator */
.bs-sep {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0 -2px;
}

/* Config area */
.bs-cfg { display: flex; flex-direction: column; gap: 8px; }
.bs-row-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--c-muted);
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.bs-row-hint {
  font-size: 9.5px;
  font-weight: 500;
  color: rgba(106,122,138,0.7);
  letter-spacing: 0;
}
.bs-toggle-row { display: flex; gap: 5px; flex-wrap: wrap; }
.bs-toggle {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--c-muted);
  border-radius: 6px;
  padding: 7px 6px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  text-align: center;
}
.bs-toggle:hover { background: rgba(255,255,255,0.1); color: var(--c-text); }
.bs-toggle.active {
  background: rgba(77,202,124,0.16);
  border-color: rgba(77,202,124,0.55);
  color: var(--c-mint);
}

/* Select-all row */
.bs-select-all-wrap {}
.bs-add-all {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: left;
}
.bs-add-all:hover {
  background: rgba(77,202,124,0.08);
  border-color: rgba(77,202,124,0.35);
  color: var(--c-mint);
}
.bs-add-badge {
  margin-left: auto;
  background: rgba(77,202,124,0.14);
  border: 1px solid rgba(77,202,124,0.25);
  color: var(--c-mint);
  border-radius: 10px;
  padding: 1px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.bs-add-all-done {
  font-size: 10.5px;
  color: rgba(106,122,138,0.6);
  text-align: center;
  padding: 6px 0 2px;
  font-family: var(--font-mono);
}

/* Footer */
.bs-footer {
  display: flex;
  gap: 8px;
  padding-top: 2px;
}
.bs-btn-cancel {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--c-muted);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.bs-btn-cancel:hover { background: rgba(255,255,255,0.09); color: var(--c-text); }
.bs-btn-apply {
  appearance: none;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  background: var(--c-mint);
  color: #07120d;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.bs-btn-apply:hover { filter: brightness(1.1); }
.bs-btn-apply:active { transform: scale(0.98); }

/* ─── Loading screen - covers the blank canvas while images/world load ──────── */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--c-bg);
  transition: opacity 0.3s ease;
}
.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-title {
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--c-text);
}
.loading-bar-track {
  position: relative;
  width: 200px;
  height: 3px;
  border-radius: 999px;
  background: var(--c-border);
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 4%;
  border-radius: 999px;
  background: var(--c-mint);
  transition: width 0.25s ease-out;
}

/* ─── Start-screen queue - one-time screens shown before gameplay begins ──── */
.start-screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
}
.start-screen-overlay.hidden { display: none; }
.start-screen-card {
  max-height: 96vh;
  overflow-y: auto; /* phone landscape is ~360px tall - the taller cards (Sign In) must scroll instead of clipping */
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  font-family: var(--font-ui);
  background: rgba(10,18,16,0.98);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.7);
  padding: 28px 26px 26px;
}
.start-screen-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--c-text);
  text-align: center;
  letter-spacing: 0.01em;
}
.start-screen-sub {
  font-size: 12px;
  color: var(--c-muted);
  text-align: center;
  line-height: 1.5;
  margin-top: -4px;
}
.start-screen-hint {
  font-size: 11px;
  color: var(--c-muted);
  text-align: center;
  line-height: 1.5;
  margin-top: -4px;
}
.start-screen-hint strong { color: var(--c-text); font-weight: 600; }
.start-screen-error {
  font-size: 11px;
  color: var(--c-red);
  text-align: center;
  padding: 6px 10px;
  background: rgba(224,92,92,0.1);
  border: 1px solid rgba(224,92,92,0.25);
  border-radius: 6px;
}
.start-screen-input {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 7px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--c-text);
  background: rgba(255,255,255,0.07);
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}
.start-screen-input::placeholder { color: rgba(255,255,255,0.28); font-weight: 400; }
.start-screen-input:focus { outline: none; border-color: var(--c-accent); background: rgba(255,255,255,0.10); }
.ss-code-input { letter-spacing: 0.14em; text-transform: uppercase; font-family: monospace; font-size: 14px; }
.start-screen-btn {
  width: 100%;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--c-accent);
  color: #1a1208;
  transition: filter 0.15s, background 0.15s;
  letter-spacing: 0.02em;
}
.start-screen-btn:hover { filter: brightness(1.12); }

.start-screen-btn-ghost {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: rgba(255,255,255,0.07);
  color: var(--c-text);
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
}
.start-screen-btn-ghost:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.38); }

.start-screen-btn-small {
  width: 78%;
  align-self: center;
  padding: 7px 12px;
  font-size: 11.5px;
}

.start-screen-divider {
  width: 100%;
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 2px 0;
}

.start-screen-back {
  appearance: none;
  border: none;
  background: none;
  padding: 4px 0;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
  align-self: flex-start;
}
.start-screen-back:hover { color: var(--c-text); }

.touch-joystick-base {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 40;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(10,18,16,0.7);
  border: 1px solid var(--c-border);
  touch-action: none;
}
.touch-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: 1px solid var(--c-border);
  pointer-events: none;
}

.touch-action-btn {
  position: fixed;
  z-index: 40;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  appearance: none;
  border: 1px solid var(--c-border);
  background: rgba(10,18,16,0.85);
  color: var(--c-text);
  font-family: var(--font-ui);
  font-size: 11px;
  cursor: pointer;
}
.touch-action-btn:active { background: rgba(255,255,255,0.20); }
#touchInteractBtn { right: 24px; bottom: 100px; }
#touchBuildBtn    { right: 24px; bottom: 24px; }

/* ─── Pets tab ──────────────────────────────────────────────────────────────── */

.pets-gacha {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.pets-gacha-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  color: var(--c-accent);
  margin-bottom: 6px;
}
.pets-gacha-costs {
  font-size: 11px;
  color: var(--c-muted);
  margin-bottom: 10px;
}
.pets-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pets-reveal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border);
}
.pets-reveal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 60px;
}
.pet-sprite-lg {
  width: 48px; height: 48px;
  image-rendering: pixelated;
  background-size: 384px 768px; /* 8×32 … 16×32 each */
  background-position: 0 0;
  background-repeat: no-repeat;
  background-color: transparent;
}
.pet-sprite-sm {
  width: 32px; height: 32px;
  image-rendering: pixelated;
  background-size: 256px 512px;
  background-position: 0 0;
  background-repeat: no-repeat;
  flex-shrink: 0;
}
.pond-mini-sprite {
  display: inline-block;
  width: 20px; height: 20px;
  image-rendering: pixelated;
  background-size: 160px 320px;
  background-position: 0 0;
  background-repeat: no-repeat;
  vertical-align: middle;
  margin-right: 4px;
}
.pet-rarity-label {
  font-size: 9px;
  font-family: var(--font-ui);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pet-variant-name {
  font-size: 10px;
  color: var(--c-text);
}
.pets-odds {
  display: flex;
  gap: 10px;
  font-size: 10px;
  font-family: var(--font-ui);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.pets-section-title {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.pets-collection-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pet-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 6px 10px;
}
.pet-card-info { flex: 1; }
.pet-card-name { font-size: 12px; font-weight: 600; }
.pet-card-status { font-size: 10px; color: var(--c-muted); margin-top: 1px; }
.pet-card-btn { padding: 4px 10px; font-size: 10px; }

/* ─── Pond popup slots ──────────────────────────────────────────────────────── */
.pond-slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.pond-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 6px 10px;
  min-height: 36px;
}
.pond-slot-sprite {
  width: 24px; height: 24px;
  image-rendering: pixelated;
  background-size: 192px 384px;
  background-position: 0 0;
  background-repeat: no-repeat;
  flex-shrink: 0;
}
.pond-slot-name { flex: 1; font-size: 11px; font-weight: 600; }
.pond-slot-empty { color: var(--c-muted); font-size: 11px; }
.pond-slot-remove {
  background: none;
  border: none;
  color: var(--c-red);
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
  line-height: 1;
}
.pond-assign-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.pet-pond-selector {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}
.pet-card-actions { display: flex; align-items: flex-start; flex-direction: column; gap: 4px; }

/* Auto-sell toggles */
.pets-autosell {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.pets-autosell-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pets-autosell-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}
.pets-autosell-toggle input[type="checkbox"] {
  accent-color: var(--c-accent);
  width: 13px;
  height: 13px;
  cursor: pointer;
}
.pets-autosell-price { color: var(--c-muted); font-size: 10px; }

/* Sell button - muted red-toned style */
.pet-sell-btn { background: rgba(220,60,60,0.18) !important; color: #e87070 !important; }
.pet-sell-btn:hover { background: rgba(220,60,60,0.32) !important; }

/* ─── Global polish: button press feedback ──────────────────────────────────
   Every interactive button gets a subtle downward press on :active so clicking
   feels physical. The transform is fast (0.06s) so it doesn't delay feedback. */
.game-menu-btn,
.hud-btn,
.upgrade-buy,
.cat-nav-btn,
.item-card,
.tab,
.leaderboard-close-btn,
.sound-toggle-btn,
.game-menu-toggle-btn,
.machines-toggle-btn,
.leaderboard-toggle-btn,
.menu-close {
  transition-property: background, color, border-color, transform, box-shadow;
  transition-duration: 0.15s;
}

.game-menu-btn:active,
.hud-btn:active:not(.disabled),
.upgrade-buy:active,
.cat-nav-btn:active,
.item-card:active:not(.disabled):not(.locked),
.sound-toggle-btn:active,
.game-menu-toggle-btn:active,
.machines-toggle-btn:active,
.leaderboard-toggle-btn:active,
.menu-close:active,
.leaderboard-close-btn:active {
  transform: scale(0.94) translateY(1px);
  transition-duration: 0.06s;
}

/* Tab press - squish down toward the panel */
.tab:active:not(.active) {
  transform: translateY(2px);
  transition-duration: 0.06s;
}

/* ─── Block popup upgrade button - add transform to existing transition ────── */
.block-popup .upgrade-buy {
  transition-property: background, color, border-color, transform;
}

/* ─── Cash HUD pulse animation ──────────────────────────────────────────────
   The JS adds .cash-hud-pulse on every cash increase; the existing JS already
   handles adding/removing the class. This makes the pulse look softer. */
@keyframes cashPulse {
  0%   { box-shadow: 0 0 0 0 rgba(77,202,124,0.5); }
  60%  { box-shadow: 0 0 0 6px rgba(77,202,124,0); }
  100% { box-shadow: 0 0 0 0 rgba(77,202,124,0); }
}
.cash-hud-pulse {
  animation: cashPulse 0.5s ease-out forwards !important;
}
