:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22223a;
  --accent: #6c63ff;
  --accent-hover: #857df8;
  --accent-disabled: #3a3760;
  --text: #e8e8f0;
  --muted: #888899;
  --green: #4caf8a;
  --yellow: #f0c040;
  --red: #e05070;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Auth screen ── */
#auth-screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  gap: 20px;
  position: relative;
}
#auth-screen.visible { display: flex; }

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#auth-card {
  background: var(--surface);
  border: 1px solid #2a2a3e;
  border-radius: 16px;
  padding: 36px 32px;
  width: 360px;
  max-width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  position: relative;
  z-index: 1;
}

#auth-card .logo { font-size: 1.5rem; font-weight: 700; color: var(--accent-hover); margin-bottom: 6px; }
#auth-card .logo span { color: var(--text); }
#auth-card .tagline { font-size: 0.82rem; color: var(--muted); margin-bottom: 28px; }
#auth-title { font-size: 1rem; font-weight: 600; margin-bottom: 18px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid #3a3a5e;
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }

#auth-error { font-size: 0.8rem; margin-bottom: 14px; min-height: 18px; }
#auth-error.err { color: var(--red); }
#auth-error.ok  { color: var(--green); }

#auth-submit {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 11px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 14px;
}
#auth-submit:hover    { background: var(--accent-hover); }
#auth-submit:disabled { background: var(--accent-disabled); cursor: not-allowed; }

#auth-toggle { text-align: center; font-size: 0.82rem; color: var(--muted); }
#auth-toggle a { color: var(--accent-hover); cursor: pointer; text-decoration: underline; }

/* ── Game screen ── */
#game-screen { display: none; position: relative; z-index: 1; }
#game-screen.visible { display: block; }

/* ── Login stats bar ── */
#login-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 440px;
  max-width: 100%;
  position: relative;
  z-index: 1;
}
.ls-item {
  background: rgba(22,22,34,0.85); backdrop-filter: blur(8px);
  border: 1px solid #2a2a3e; border-radius: 10px;
  padding: 9px 8px; text-align: center;
}
.ls-label {
  font-size: 0.58rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 4px;
}
.ls-value {
  font-size: 0.88rem; font-weight: 700; color: var(--yellow);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ── Header ── */
#header {
  position: sticky; top: 0;
  background: var(--surface);
  border-bottom: 1px solid #2a2a3e;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  gap: 12px;
}
#header h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.03em; color: var(--accent-hover); white-space: nowrap; }
#header h1 span { color: var(--text); }

#stats { display: flex; align-items: baseline; justify-content: center; gap: 10px; flex: 1; }
#money-display  { font-size: 1.2rem; font-weight: 700; color: var(--yellow); }
#income-display { font-size: 0.78rem; color: var(--green); }

#auth-area { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#username-display { font-size: 0.8rem; color: var(--accent-hover); font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.sync-dot.syncing { background: var(--yellow); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.hdr-btn {
  background: var(--surface2); border: 1px solid #3a3a5e;
  color: var(--text); border-radius: 7px; padding: 6px 12px;
  font-size: 0.8rem; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.hdr-btn:hover        { background: #2e2e48; border-color: var(--accent); }
.hdr-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* ── Main ── */
#main { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }

#offline-toast {
  background: var(--surface2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
  animation: fadeIn 0.3s ease;
}
#offline-toast p { font-size: 0.9rem; color: var(--green); }
#offline-toast button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }
#offline-toast button:hover { color: var(--text); }

#industry-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface); border: 1px solid #2a2a3e;
  border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  transition: opacity 0.2s, border-color 0.2s;
}
.card.locked     { opacity: 0.45; }
.card.affordable { border-color: #3a3a5e; }

.card-emoji  { font-size: 2rem; width: 48px; text-align: center; flex-shrink: 0; }
.card-info   { flex: 1; min-width: 0; }
.card-name   { font-weight: 600; font-size: 1rem; margin-bottom: 3px; }
.card-income { font-size: 0.78rem; color: var(--green); margin-bottom: 2px; }
.card-cost   { font-size: 0.78rem; color: var(--muted); }

.card-right { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.owned-badge {
  background: var(--surface2); border-radius: 20px; padding: 2px 10px;
  font-size: 0.8rem; font-weight: 700; color: var(--accent-hover);
  min-width: 40px; text-align: center;
}
.buy-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, transform 0.1s; white-space: nowrap;
}
.buy-btn:hover:not(:disabled)  { background: var(--accent-hover); transform: translateY(-1px); }
.buy-btn:active:not(:disabled) { transform: translateY(0); }
.buy-btn:disabled { background: var(--accent-disabled); color: var(--muted); cursor: not-allowed; }

.section-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 8px; margin-top: 4px;
}

#footer {
  text-align: center; padding: 10px 16px; position: fixed; bottom: 0;
  width: 100%; background: var(--bg); border-top: 1px solid #1e1e2e;
}

#prestige-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.footer-btn {
  background: var(--surface2); color: var(--text); border: 1px solid #3a3a5e;
  border-radius: 9px; padding: 8px 16px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s;
}
.footer-btn:hover { border-color: var(--accent); }
#prestige-count { font-size: 0.78rem; color: var(--yellow); font-weight: 600; }
#prestige-btn {
  background: linear-gradient(135deg, #6c63ff, #c084fc);
  color: #fff; border: none; border-radius: 9px;
  padding: 8px 20px; font-size: 0.88rem; font-weight: 700; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s; white-space: nowrap;
}
#prestige-btn:hover:not(:disabled) { opacity: 0.85; transform: translateY(-1px); }
#prestige-btn:disabled { opacity: 0.35; cursor: not-allowed; background: var(--surface2); }

/* Milestone track inside card */
.milestone-track { margin-top: 5px; }
.milestone-bar {
  height: 3px; background: #2a2a3e; border-radius: 2px; overflow: hidden; margin-bottom: 2px;
}
.milestone-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), #c084fc);
  border-radius: 2px; transition: width 0.3s ease;
}
.milestone-label {
  font-size: 0.68rem; color: var(--muted);
}

/* Locked-next card (next to unlock) */
.card-locked-next {
  opacity: 0.55; border-style: dashed !important; border-color: #3a3a5e !important;
}
.card-locked-next .milestone-fill {
  background: linear-gradient(90deg, var(--green), #4caf8a);
}

/* Prestige pill in income display */
.prestige-pill {
  display: inline-block; margin-left: 6px;
  background: rgba(108,99,255,0.18); border: 1px solid #c084fc;
  color: #c084fc; border-radius: 10px; padding: 1px 7px;
  font-size: 0.68rem; font-weight: 700; vertical-align: middle;
}

/* Offline receipt cap note */
.receipt-cap-note {
  font-size: 0.78rem; color: var(--yellow); margin-top: 8px;
  text-align: center; padding: 6px 10px;
  background: rgba(240,192,64,0.1); border-radius: 7px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════════
   ADMIN SCREEN
════════════════════════════════════════════════════════════ */
#admin-screen { display: none; min-height: 100vh; position: relative; z-index: 1; }
#admin-screen.visible { display: block; }

#admin-header {
  position: sticky; top: 0; z-index: 100;
  background: #13131d;
  border-bottom: 2px solid var(--yellow);
  padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 2px 16px rgba(0,0,0,0.5);
}
.admin-brand { font-size: 1.15rem; font-weight: 700; color: var(--yellow); letter-spacing: 0.04em; }
.admin-brand .badge {
  background: var(--yellow); color: #13131d;
  font-size: 0.65rem; font-weight: 800; padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.06em; margin-left: 8px; vertical-align: middle;
}
#admin-user-area { display: flex; align-items: center; gap: 10px; }
#admin-username-display { font-size: 0.82rem; color: var(--muted); }

#admin-nav {
  background: var(--surface);
  border-bottom: 1px solid #2a2a3e;
  display: flex; gap: 0; padding: 0 24px;
}
.tab-btn {
  background: none; border: none; border-bottom: 3px solid transparent;
  color: var(--muted); padding: 12px 22px;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: color 0.15s, border-color 0.15s; white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--yellow); border-bottom-color: var(--yellow); }

#admin-body { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.panel-sub   { font-size: 0.8rem; color: var(--muted); margin-bottom: 22px; }

/* Industry editor rows */
.ind-editor-row {
  background: var(--surface); border: 1px solid #2a2a3e; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 8px;
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: 44px 1fr 68px 120px 120px 34px;
}
.ind-editor-row .ef { display: flex; flex-direction: column; gap: 4px; }
.ind-editor-row .ef label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.ind-editor-row .ef input {
  background: var(--surface2); border: 1px solid #3a3a5e; border-radius: 7px;
  color: var(--text); padding: 8px 10px; font-size: 0.88rem; outline: none;
  transition: border-color 0.15s; width: 100%;
}
.ind-editor-row .ef input:focus { border-color: var(--yellow); }
.ind-row-num {
  font-size: 0.75rem; color: var(--muted); text-align: center;
  background: var(--surface2); border-radius: 6px; padding: 4px 0;
}
.ie-del-btn {
  background: none; color: var(--muted); border: 1px solid #3a3a5e;
  border-radius: 6px; width: 34px; height: 34px; cursor: pointer;
  font-size: 0.85rem; transition: color 0.15s, border-color 0.15s;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.ie-del-btn:hover:not(:disabled) { color: var(--red); border-color: var(--red); }
.ie-del-btn:disabled { opacity: 0.25; cursor: not-allowed; }

.global-cfg {
  background: var(--surface); border: 1px solid #2a2a3e; border-radius: 10px;
  padding: 18px; margin-top: 16px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.global-cfg .ef { display: flex; flex-direction: column; gap: 4px; }
.global-cfg .ef label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.global-cfg .ef input {
  background: var(--surface2); border: 1px solid #3a3a5e; border-radius: 7px;
  color: var(--text); padding: 9px 12px; font-size: 0.9rem; outline: none;
  transition: border-color 0.15s; width: 100%;
}
.global-cfg .ef input:focus { border-color: var(--yellow); }

.action-bar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; }
.status-msg { font-size: 0.82rem; }
.status-msg.ok  { color: var(--green); }
.status-msg.err { color: var(--red); }

.btn-primary {
  background: var(--yellow); color: #13131d; border: none; border-radius: 8px;
  padding: 10px 24px; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface2); color: var(--text); border: 1px solid #3a3a5e;
  border-radius: 8px; padding: 10px 18px; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); }

/* Users table */
.tbl-wrap { overflow-x: auto; margin-top: 6px; }
table.users-tbl { width: 100%; border-collapse: collapse; }
table.users-tbl th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 8px 14px; border-bottom: 1px solid #2a2a3e;
}
table.users-tbl td { padding: 11px 14px; font-size: 0.88rem; border-bottom: 1px solid #1e1e2e; }
table.users-tbl tr:hover td { background: var(--surface); }
table.users-tbl .money-cell { color: var(--yellow); font-weight: 600; }
table.users-tbl .time-cell  { color: var(--muted); font-size: 0.8rem; }

.btn-del {
  background: none; color: var(--red); border: 1px solid var(--red);
  border-radius: 6px; padding: 4px 12px; font-size: 0.78rem; cursor: pointer;
  transition: background 0.15s;
}
.btn-del:hover { background: rgba(224,80,112,0.12); }

.tbl-toolbar {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.tbl-count { font-size: 0.82rem; color: var(--muted); }
.btn-refresh {
  background: var(--surface2); color: var(--text); border: 1px solid #3a3a5e;
  border-radius: 7px; padding: 7px 14px; font-size: 0.82rem; cursor: pointer;
  transition: border-color 0.15s;
}
.btn-refresh:hover { border-color: var(--accent); }
.empty-state { text-align: center; color: var(--muted); padding: 40px; font-size: 0.9rem; }

/* Reset password modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 200;
  display: none; justify-content: center; align-items: center;
}
.modal-overlay.visible { display: flex; }
.modal-box {
  background: var(--surface); border: 1px solid #3a3a5e; border-radius: 14px;
  padding: 28px 28px 22px; width: 380px; max-width: calc(100vw - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Rank badge in game header */
.rank-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--surface2); border: 1px solid #3a3a5e;
  border-radius: 20px; padding: 2px 9px;
  font-size: 0.73rem; font-weight: 700; color: var(--yellow);
  white-space: nowrap; flex-shrink: 0;
}

/* Rank editor rows — matches industry editor styling */
.rank-editor-row {
  background: var(--surface); border: 1px solid #2a2a3e; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 8px;
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: 44px 1fr 68px 130px 140px 34px;
}
.rank-editor-row .ef { display: flex; flex-direction: column; gap: 4px; }
.rank-editor-row .ef label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.rank-editor-row .ef input {
  background: var(--surface2); border: 1px solid #3a3a5e; border-radius: 7px;
  color: var(--text); padding: 8px 10px; font-size: 0.88rem; outline: none;
  transition: border-color 0.15s; width: 100%;
}
.rank-editor-row .ef input:focus { border-color: var(--yellow); }

/* Emoji picker button (shared between industry + rank editors) */
.emoji-btn {
  background: var(--surface2); border: 1px solid #3a3a5e; border-radius: 7px;
  color: var(--text); padding: 8px 10px; font-size: 1.05rem; cursor: pointer;
  width: 100%; transition: border-color 0.15s;
  display: flex; align-items: center; gap: 5px; line-height: 1;
}
.emoji-btn:hover, .emoji-btn.ep-active { border-color: var(--yellow); }
.emoji-btn .ep-arrow { font-size: 0.55rem; color: var(--muted); margin-left: auto; }

/* Emoji picker panel */
#emoji-picker-panel {
  position: fixed; z-index: 999;
  background: var(--surface); border: 1px solid #3a3a5e; border-radius: 12px;
  padding: 8px; width: 272px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.65);
  max-height: 270px; overflow-y: auto;
}
.ep-cat-label {
  font-size: 0.64rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.07em; padding: 5px 3px 2px; display: block;
}
.ep-cat-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin-bottom: 2px;
}
.ep-item {
  background: none; border: none; font-size: 1.2rem; cursor: pointer;
  padding: 4px 0; border-radius: 5px; transition: background 0.1s;
  line-height: 1.3; text-align: center;
}
.ep-item:hover { background: var(--surface2); }

/* MOTD / Announcement banner (in-game) */
#motd-banner {
  background: linear-gradient(135deg, rgba(108,99,255,0.13), rgba(76,175,138,0.08));
  border-bottom: 1px solid rgba(108,99,255,0.25);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 0.87rem; color: var(--text); position: relative; z-index: 1;
}
#motd-banner .motd-text { flex: 1; }
#motd-banner .motd-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#motd-banner .motd-dismiss {
  background: none; border: 1px solid rgba(108,99,255,0.3); border-radius: 5px;
  color: var(--muted); cursor: pointer; font-size: 0.72rem; padding: 3px 8px;
  transition: color 0.15s, border-color 0.15s; white-space: nowrap; font-family: inherit;
}
#motd-banner .motd-dismiss:hover { color: var(--accent-hover); border-color: var(--accent); }
#motd-banner .motd-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 0 4px; flex-shrink: 0; transition: color 0.15s;
}
#motd-banner .motd-close:hover { color: var(--text); }

/* Event editor rows */
.event-editor-row {
  background: var(--surface); border: 1px solid #2a2a3e; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px;
}
.event-editor-top {
  display: grid; gap: 10px; align-items: end; margin-bottom: 10px;
  grid-template-columns: 1fr 90px 190px 190px 34px;
}
.event-editor-row .ef { display: flex; flex-direction: column; gap: 4px; }
.event-editor-row .ef label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.event-editor-row .ef input {
  background: var(--surface2); border: 1px solid #3a3a5e; border-radius: 7px;
  color: var(--text); padding: 8px 10px; font-size: 0.88rem; outline: none;
  transition: border-color 0.15s; width: 100%;
}
.event-editor-row .ef input:focus { border-color: var(--yellow); }
.ev-status-badge {
  font-size: 0.68rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; margin-left: 6px; vertical-align: middle;
}
.ev-status-badge.active    { color: var(--green);  background: rgba(76,175,138,0.12); border: 1px solid rgba(76,175,138,0.3); }
.ev-status-badge.scheduled { color: var(--yellow); background: rgba(240,192,64,0.12); border: 1px solid rgba(240,192,64,0.3); }
.ev-status-badge.expired   { color: var(--muted);  background: rgba(100,100,120,0.10); border: 1px solid rgba(100,100,120,0.25); }

/* Admin badge in accounts table */
.admin-badge {
  font-size: 0.62rem; font-weight: 800; color: #13131d;
  background: var(--yellow); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: middle;
}

/* Event bonus pill in income display */
.event-pill {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  background: rgba(240,192,64,0.15); border: 1px solid rgba(240,192,64,0.35);
  color: var(--yellow); border-radius: 4px; padding: 1px 5px; margin-left: 6px;
  vertical-align: middle;
}

/* Version tag (clickable, opens changelog) */
.version-tag {
  background: none; border: 1px solid #3a3a5e; border-radius: 5px;
  color: var(--muted); font-size: 0.62rem; font-weight: 700; padding: 2px 7px;
  cursor: pointer; vertical-align: middle; margin-left: 7px;
  transition: border-color 0.15s, color 0.15s; font-family: inherit; letter-spacing: 0.04em;
}
.version-tag:hover { border-color: var(--accent); color: var(--accent-hover); }

/* Leaderboard table */
#leaderboard-modal .modal-box { width: 480px; }
.lb-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.lb-table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 7px 10px; border-bottom: 1px solid #2a2a3e;
}
.lb-table td { padding: 9px 10px; font-size: 0.87rem; border-bottom: 1px solid #1e1e2e; }
.lb-table tr:hover td { background: rgba(255,255,255,0.02); }
.lb-table tr.lb-you td { background: rgba(108,99,255,0.08); }
.lb-you-tag {
  font-size: 0.65rem; font-weight: 700; color: var(--accent-hover);
  background: rgba(108,99,255,0.15); border: 1px solid rgba(108,99,255,0.3);
  border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: middle;
}
.lb-not-ranked { font-size: 0.8rem; color: var(--muted); text-align: center; padding: 10px 0 2px; border-top: 1px solid #2a2a3e; margin-top: 6px; }
.lb-table .lb-pos { color: var(--muted); font-size: 0.82rem; width: 32px; text-align: center; }
.lb-table .lb-money { color: var(--yellow); font-weight: 700; text-align: right; }
.lb-empty { text-align: center; color: var(--muted); padding: 36px; font-size: 0.88rem; }

/* Offline receipt */
#offline-receipt-modal .modal-box { width: 400px; max-height: 80vh; overflow-y: auto; }
.receipt-row { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid rgba(42,42,62,.5); font-size: .85rem; }
.receipt-row:last-child { border-bottom: none; }
.receipt-icon { font-size: 1.1rem; flex-shrink: 0; width: 1.4rem; text-align: center; }
.receipt-name { flex: 1; }
.receipt-owned { font-size: .72rem; color: var(--muted); }
.receipt-earned { font-weight: 700; color: var(--yellow); font-variant-numeric: tabular-nums; }
.receipt-total-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid #2a2a3e; font-weight: 700; font-size: .95rem; }
.receipt-total-val { color: var(--green); font-size: 1.05rem; }

/* Changelog */
#changelog-modal .modal-box { width: 440px; max-height: 80vh; overflow-y: auto; }
.cl-entry { margin-bottom: 20px; }
.cl-entry:last-child { margin-bottom: 4px; }
.cl-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cl-ver-tag {
  font-size: 0.75rem; font-weight: 800; color: var(--accent-hover);
  background: rgba(108,99,255,0.12); border: 1px solid rgba(108,99,255,0.28);
  border-radius: 5px; padding: 2px 8px; flex-shrink: 0;
}
.cl-date { font-size: 0.72rem; color: var(--muted); }
.cl-items { list-style: none; padding: 0; margin: 0; }
.cl-items li {
  font-size: 0.83rem; color: var(--text); padding: 4px 0 4px 16px;
  position: relative; border-bottom: 1px solid rgba(42,42,62,0.4);
}
.cl-items li:last-child { border-bottom: none; }
.cl-items li::before { content: "▸"; position: absolute; left: 2px; color: var(--accent-hover); font-size: 0.7rem; top: 5px; }

/* Rank select in accounts table */
.rank-select {
  background: var(--surface2); border: 1px solid #3a3a5e; border-radius: 6px;
  color: var(--text); padding: 4px 8px; font-size: 0.8rem; cursor: pointer;
  outline: none; transition: border-color 0.15s; max-width: 140px;
}
.rank-select:focus { border-color: var(--yellow); }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 640px)
════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* ── Game header: stats drop to full-width second row ── */
  #header {
    flex-wrap: wrap;
    padding: 10px 14px 8px;
    gap: 4px 10px;
  }
  #header h1   { font-size: 1rem; flex: 1 1 auto; }
  #auth-area   { flex: 0 0 auto; }
  #stats       { order: 3; flex: 0 0 100%; padding: 2px 0 0; }
  #money-display  { font-size: 1.25rem; }
  #income-display { font-size: 0.76rem; }
  /* Hide username text — rank badge + buttons still visible */
  #username-display { display: none; }
  .hdr-btn { padding: 7px 11px; }

  /* ── Main content ── */
  #main { padding: 12px 10px 60px; }

  /* ── Industry cards ── */
  .card       { padding: 11px 12px; gap: 10px; }
  .card-emoji { font-size: 1.65rem; width: 38px; }
  .buy-btn    { padding: 8px 12px; font-size: 0.82rem; }

  /* ── MOTD banner ── */
  #motd-banner { flex-wrap: wrap; padding: 9px 14px; }

  /* ── Offline toast ── */
  #offline-toast { flex-wrap: wrap; gap: 8px; }

  /* ── Login stats: 3+2 grid on mobile ── */
  #login-stats   { grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 420px; }
  .ls-label      { font-size: 0.65rem; }

  /* ── Modals: full viewport width ── */
  #leaderboard-modal .modal-box { width: calc(100vw - 32px); }
  #changelog-modal .modal-box   { width: calc(100vw - 32px); max-height: 85vh; }

  /* ── Admin header + nav ── */
  #admin-header { padding: 10px 14px; }
  .admin-brand  { font-size: 0.95rem; }
  #admin-nav    { overflow-x: auto; padding: 0 10px; -webkit-overflow-scrolling: touch; }
  .tab-btn      { padding: 11px 12px; font-size: 0.82rem; }
  #admin-body   { padding: 16px 12px 60px; }

  /* ── Industry editor rows ──
     Desktop: [#] [Name] [Emoji] [Cost] [Income] [Del]  (6 col grid)
     Mobile:  Row1: [#(28px)] [Name(1fr)] [Emoji(56px)] [Del(28px)]
              Row2: [Cost(28px+1fr)] [Income(56px+28px)]
  ── */
  .ind-editor-row { grid-template-columns: 28px 1fr 56px 28px; }
  .ind-editor-row > :nth-child(1) { grid-row: 1; grid-column: 1; }
  .ind-editor-row > :nth-child(2) { grid-row: 1; grid-column: 2; }
  .ind-editor-row > :nth-child(3) { grid-row: 1; grid-column: 3; }
  .ind-editor-row > :nth-child(4) { grid-row: 2; grid-column: 1 / 3; }
  .ind-editor-row > :nth-child(5) { grid-row: 2; grid-column: 3 / 5; }
  .ind-editor-row > :nth-child(6) { grid-row: 1; grid-column: 4; }

  /* ── Rank editor rows: same reflow ── */
  .rank-editor-row { grid-template-columns: 28px 1fr 56px 28px; }
  .rank-editor-row > :nth-child(1) { grid-row: 1; grid-column: 1; }
  .rank-editor-row > :nth-child(2) { grid-row: 1; grid-column: 2; }
  .rank-editor-row > :nth-child(3) { grid-row: 1; grid-column: 3; }
  .rank-editor-row > :nth-child(4) { grid-row: 2; grid-column: 1 / 3; }
  .rank-editor-row > :nth-child(5) { grid-row: 2; grid-column: 3 / 5; }
  .rank-editor-row > :nth-child(6) { grid-row: 1; grid-column: 4; }

  /* ── Event editor top ──
     Row1: [Name(col1)]            [Del(col2)]
     Row2: [Bonus %(col1)]         [empty]
     Row3: [Start Date(col1)]      [End Date(col2)]
  ── */
  .event-editor-top { grid-template-columns: 1fr 1fr; }
  .event-editor-top > :nth-child(1) { grid-column: 1; grid-row: 1; }
  .event-editor-top > :nth-child(2) { grid-column: 1; grid-row: 2; }
  .event-editor-top > :nth-child(3) { grid-column: 1; grid-row: 3; }
  .event-editor-top > :nth-child(4) { grid-column: 2; grid-row: 3; }
  .event-editor-top > :nth-child(5) { grid-column: 2; grid-row: 1; align-self: end; }

  /* ── Global config: single column ── */
  .global-cfg { grid-template-columns: 1fr; }

  /* ── Users table: ensure horizontal scroll ── */
  .tbl-wrap { -webkit-overflow-scrolling: touch; }
}

/* ── Buy quantity selector ── */
#buy-mode-bar {
  display: flex; align-items: center; gap: 4px; margin-bottom: 10px;
}
#buy-mode-bar .bm-label {
  font-size: 0.7rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; margin-right: 4px; white-space: nowrap; flex-shrink: 0;
}
.bm-btn {
  background: var(--surface); border: 1px solid #2a2a3e;
  color: var(--muted); border-radius: 6px; padding: 5px 10px;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s; white-space: nowrap;
}
.bm-btn:hover  { border-color: var(--accent); color: var(--text); }
.bm-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Back-to-hub link (in game and admin headers) ── */
.hdr-back { color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 600; transition: color 0.15s; white-space: nowrap; }
.hdr-back:hover { color: var(--text); }

/* ── Back-to-hub banner (auth screen only) ── */
#back-banner {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  padding: .6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
}
#back-banner a { color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 600; transition: color 0.15s; }
#back-banner a:hover { color: var(--text); }
