:root {
  --bg: #0b1120;
  --panel: #0f172a;
  --row-even: #141d2e;
  --row-odd: #192438;
  --border: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #2563eb;
  --gold: #facc15;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.full-w { width: 100%; }
.gold-txt { color: var(--gold); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.top-left, .top-right { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.brand-pill {
  background: #1e293b;
  color: var(--gold);
  font-weight: 800;
  font-size: 13.5px;
  padding: 5px 11px;
  border-radius: 6px;
  letter-spacing: 0.4px;
}

/* Wildcard Badges */
.wc-group { display: flex; gap: 4px; }
.wc-badge { background: #1e293b; font-weight: 700; font-size: 12px; padding: 3px 7px; border-radius: 5px; }
.wc-c { color: #cbd5e1; }
.wc-u { color: #38bdf8; }
.wc-r { color: #facc15; }
.wc-m { color: #fb923c; }

/* Buttons & Inputs */
button {
  cursor: pointer;
  border: none;
  border-radius: 7px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 7px 12px;
  transition: 0.15s ease;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-gold { background: var(--gold); color: #0f172a; font-weight: 800; }
.btn-gold:hover:not(:disabled) { background: #eab308; }
.btn-chip { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; }
.btn-chip:hover:not(:disabled) { background: #334155; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid #334155; }
.btn-ghost:hover:not(:disabled) { color: #fff; background: #1e293b; }
.btn-tier { background: rgba(250, 204, 21, 0.14); color: var(--gold); border: 1px solid var(--gold); padding: 5px 10px; border-radius: 6px; font-weight: 700; }

input, select, textarea {
  background: #141d2e;
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 7px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
}
textarea { resize: none; flex: 1; }

/* Thinking Banner */
.thinking-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  background: #172033;
  border-bottom: 1px solid var(--gold);
  flex-wrap: wrap;
}
.thinking-left { display: flex; align-items: center; gap: 10px; }
.thinking-label { color: var(--gold); font-weight: 800; font-size: 13px; letter-spacing: 0.4px; }
.spinner {
  width: 15px; height: 15px;
  border: 2.5px solid rgba(250, 204, 21, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track { width: 90px; height: 7px; background: #0f172a; border-radius: 4px; overflow: hidden; }
.progress-fill { width: 45%; height: 100%; background: var(--gold); animation: slide 1.2s ease-in-out infinite alternate; }
@keyframes slide { from { transform: translateX(0); } to { transform: translateX(120%); } }
.nerd-fact { color: #cbd5e1; font-size: 13px; font-style: italic; }

/* Navigation */
.desktop-nav {
  display: flex;
  gap: 6px;
  padding: 8px 14px 0;
  border-bottom: 2px solid var(--accent);
}
.nav-tab {
  background: #1e293b;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  padding: 8px 15px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-tab.active { background: var(--accent); color: #fff; }
.lock-tag { font-size: 11px; color: var(--gold); font-weight: 800; }
.unread-badge { background: #ef4444; color: #fff; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 10px; }
@keyframes flashGold {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--gold); background: rgba(250, 204, 21, 0.22); color: #fff; }
  50% { box-shadow: inset 0 0 0 2px transparent; background: #1e293b; }
}
.flash-gold { animation: flashGold 1.1s infinite; }

.mobile-toolbar, .mobile-nav { display: none; }

/* Controls Drawer */
.controls-drawer {
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.ctrl-row { display: flex; gap: 10px; align-items: stretch; }
.ctrl-left { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.ctrl-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
.run-stack { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.btn-run { min-width: 155px; font-size: 14px; }
.locked-pill {
  background: rgba(250, 204, 21, 0.16);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
}
.locked-pill a { color: #fff; text-decoration: none; margin-left: 5px; }

/* Mana Color Picker */
.mana-picker { display: flex; gap: 4px; }
.mana-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  padding: 0;
  font-weight: 800;
  background: #161d2b;
  color: #64748b;
  border: 1px solid #475569;
}
.mana-btn.active[data-c="W"] { background: #f8f5e6; color: #0f172a; border: 2px solid #ffffff; }
.mana-btn.active[data-c="U"] { background: #1d4ed8; color: #ffffff; border: 2px solid #7dd3fc; }
.mana-btn.active[data-c="B"] { background: #05070a; color: #ffffff; border: 2px solid #f8fafc; }
.mana-btn.active[data-c="R"] { background: #dc2626; color: #ffffff; border: 2px solid #fca5a5; }
.mana-btn.active[data-c="G"] { background: #16a34a; color: #ffffff; border: 2px solid #86efac; }

/* Workspaces */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 2fr 1.25fr;
  gap: 10px;
  padding: 10px 14px;
  min-height: 0;
}
.lobby-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 10px;
  padding: 10px 14px;
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel-hdr {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.panel-hdr h3 { margin: 0; font-size: 14.5px; }
.panel-body { flex: 1; overflow-y: auto; padding: 8px; }
.panel-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.status-badge { font-size: 12px; font-weight: 700; color: #4ade80; }
.empty-state { color: #64748b; text-align: center; padding: 32px 14px; font-size: 14px; }

/* Deck Rows & Color-Coded Pills */
.sec-header {
  background: #0b1120;
  color: #38bdf8;
  font-weight: 700;
  font-size: 13px;
  padding: 5px 8px;
  margin-top: 4px;
  border-radius: 4px;
}
.deck-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.75);
}
.deck-row:nth-child(even) { background: var(--row-even); }
.deck-row:nth-child(odd) { background: var(--row-odd); }
.qty-col { width: 24px; font-family: Consolas, monospace; font-weight: 700; color: var(--muted); text-align: right; flex-shrink: 0; }
.card-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 1px #090d16;
}
.card-pill:hover { outline: 1.5px solid #ffffff; }
.pill-W { background: #f8f5e6; color: #0f172a; border-color: #cbd5e1; }
.pill-U { background: #1d4ed8; color: #ffffff; border-color: #60a5fa; }
.pill-B { background: #050608; color: #ffffff; border-color: #94a3b8; }
.pill-R { background: #dc2626; color: #ffffff; border-color: #f87171; }
.pill-G { background: #15803d; color: #ffffff; border-color: #4ade80; }
.pill-MULTI { background: #eab308; color: #0f172a; border-color: #fef08a; }
.pill-LAND { background: #d2b48c; color: #0f172a; border-color: #f5deb3; }
.pill-ARTIFACT { background: #9ca3af; color: #0f172a; border-color: #e5e7eb; }
.pill-COLORLESS { background: #cbd5e1; color: #0f172a; border-color: #f1f5f9; }
.nb-diamond { color: #78350f; font-size: 12px; }
.wc-star { margin-left: auto; display: inline-flex; align-items: center; flex-shrink: 0; }

/* Advisor, Notes & Chat */
.advisor-log { white-space: pre-wrap; line-height: 1.5; font-size: 14.5px; padding: 12px; }
.notes-strip {
  display: flex; gap: 6px; padding: 6px 8px;
  border-top: 1px solid var(--border); background: #0d1526;
}
.chat-bar { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--border); }
.chat-bar input { flex: 1; }

/* Stats & Bars */
.stat-box {
  background: #141d2e;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}
.stat-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 13px; }
.stat-lbl { width: 118px; flex-shrink: 0; color: #cbd5e1; }
.stat-track { flex: 1; height: 10px; background: #0b1120; border-radius: 4px; overflow: hidden; }
.stat-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.stat-val { width: 26px; text-align: right; font-weight: 700; }

/* Lobby & PMs */
.lobby-row {
  background: #141d2e; border: 1px solid #1e293b; border-radius: 7px;
  padding: 9px 10px; margin-bottom: 7px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.lobby-row:hover, .lobby-row.active { border-color: var(--accent); background: #192438; }
.pm-log { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.pm-bubble { max-width: 78%; padding: 8px 11px; border-radius: 10px; font-size: 14px; line-height: 1.4; }
.pm-mine { align-self: flex-end; background: var(--accent); color: #fff; }
.pm-theirs { align-self: flex-start; background: #1e293b; color: #f1f5f9; }

/* Tooltip, Bottom Sheet & Help Drawer */
.card-tooltip {
  position: fixed; z-index: 999; max-width: 340px;
  background: #0f172a; border: 1px solid #475569; border-radius: 8px;
  padding: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7); pointer-events: none;
}
.mana-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-left: 3px; vertical-align: middle; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: flex-end;
}
.bottom-sheet {
  width: 100%; background: #0f172a; border-top: 2px solid #334155;
  border-radius: 16px 16px 0 0; padding: 12px 18px 28px;
}
.sheet-handle { width: 42px; height: 4px; background: #475569; border-radius: 2px; margin: 0 auto 12px; }

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 950; background: rgba(5, 8, 16, 0.72);
  display: flex; justify-content: flex-end;
}
.side-drawer {
  width: 100%; max-width: 410px; height: 100%;
  background: #0f172a; border-left: 1px solid #334155;
  padding: 18px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
}
.help-body h4 { margin: 8px 0 6px; color: var(--gold); }
.help-body ol { padding-left: 18px; line-height: 1.6; }
.legend-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* Modals & Pricing */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900; background: rgba(5, 8, 16, 0.84);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.modal-card {
  background: #0f172a; border: 1px solid #334155; border-radius: 12px;
  padding: 18px; width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 10px;
}
.modal-lg { max-width: 700px; max-height: 88dvh; }
.modal-xl { max-width: 900px; max-height: 92dvh; overflow-y: auto; }
.modal-hdr { display: flex; justify-content: space-between; align-items: center; }
.modal-hdr h3 { margin: 0; }
.modal-scroll { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; max-height: 58dvh; }
.modal-footer { padding-top: 6px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.auth-tabs, .seg-group { display: flex; gap: 4px; background: #141d2e; padding: 3px; border-radius: 8px; }
.seg-btn { flex: 1; background: transparent; color: var(--muted); padding: 6px 8px; }
.seg-btn.active { background: var(--accent); color: #fff; }
.err-txt { color: #f87171; font-size: 13px; min-height: 18px; }
.legal-links { text-align: center; font-size: 12px; color: var(--muted); }
.legal-links a { color: #38bdf8; text-decoration: none; }
.token-box {
  background: #141d2e; border: 1px dashed #475569; padding: 9px 10px; border-radius: 6px;
  font-family: Consolas, monospace; font-size: 12.5px; word-break: break-all; user-select: all;
}
.sep { border: 0; border-top: 1px solid var(--border); width: 100%; }

.combo-item {
  background: #141d2e; border: 1px solid #1e293b; border-radius: 8px;
  padding: 11px; display: flex; flex-direction: column; gap: 8px;
}
.combo-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.price-card {
  background: #141d2e; border: 1px solid #334155; border-radius: 10px; padding: 15px;
  display: flex; flex-direction: column; gap: 10px; position: relative;
}
.price-card.featured { border: 2px solid var(--gold); }
.badge-pop {
  position: absolute; top: -10px; right: 12px; background: var(--gold); color: #0f172a;
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 4px;
}
.price-tag { font-size: 26px; font-weight: 800; color: #fff; }
.price-tag span { font-size: 13px; color: var(--muted); }
.price-card ul { margin: 0; padding-left: 18px; color: #cbd5e1; font-size: 13.5px; line-height: 1.6; flex: 1; }
.topup-bar {
  background: #141d2e; border: 1px solid #334155; border-radius: 8px; padding: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* Mobile Adaptive PWA (< 860px) */
@media (max-width: 860px) {
  .pc-only, .desktop-nav { display: none !important; }
  .mobile-toolbar {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 6px 10px; background: #0f172a; border-bottom: 1px solid var(--border);
  }
  .ctrl-row { flex-direction: column; }
  .run-stack { flex-direction: row; }
  .btn-run { flex: 1; min-width: 0; padding: 10px 8px; }
  .mana-btn { width: 40px; height: 40px; font-size: 15px; }
  .workspace { display: flex; flex-direction: column; padding: 8px 10px 66px; }
  .panel { flex: 1; }
  .mobile-hidden { display: none !important; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 800;
    background: #0f172a; border-top: 1px solid #334155;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 4px;
  }
  .mnav-btn { background: #1e293b; color: var(--muted); padding: 10px 2px; font-size: 12.5px; }
  .mnav-btn.active { background: var(--accent); color: #fff; }
  .pricing-grid { grid-template-columns: 1fr; }
}

/* Custom Card Art */
.plan-card-img { width: 100%; height: auto; border-radius: 8px; border: 1px solid #334155; cursor: pointer; display: block; transition: 0.15s ease; }
.plan-card-img:hover { border-color: var(--gold); transform: translateY(-2px); }
.topup-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.topup-card { background: #141d2e; border: 1px solid #334155; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.topup-card-img { width: 100%; max-width: 240px; height: auto; border-radius: 8px; border: 1px solid #334155; cursor: pointer; transition: 0.15s ease; }
.topup-card-img:hover { border-color: var(--gold); transform: translateY(-2px); }

/* Stinkbait Obsidian Overhaul */
:root {
  --bg: #0b0c10;
  --panel: #13151b;
  --panel-2: #191c24;
  --border: #2a2d3a;
  --accent: #7c3aed;
  --gold: #f59e0b;
}
body { background: radial-gradient(circle at top, #171324 0%, #0b0c10 65%) !important; }
.topbar, .tabbar, .builder-bar, .panel, .modal-card, .price-card, .topup-card {
  background: var(--panel) !important;
  border-color: var(--border) !important;
}
textarea, input, select { background: #0e1015 !important; border-color: #2e3242 !important; }
#deepBuildBtn, .btn-deep {
  background: linear-gradient(135deg, #6d28d9, #4c1d95) !important;
  color: #f8fafc !important;
  border: 1px solid #8b5cf6 !important;
}
#deepBuildBtn .lock-badge, .btn-deep .lock-badge { color: #fde047 !important; font-weight: 700; }
@keyframes helpPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.85); border-color: #f59e0b; color: #fde047; }
  50% { box-shadow: 0 0 14px 4px rgba(245, 158, 11, 0.55); border-color: #fde047; color: #ffffff; }
}
.help-flash { animation: helpPulse 1.4s infinite !important; }

.deep-lock { color: #000000 !important; filter: brightness(0) !important; margin-left: 4px; }
.deep-tier { color: #ffffff !important; opacity: 1 !important; visibility: visible !important; display: inline !important; font-weight: 700; margin-left: 2px; }



/* Stinkbait UI refinements */
html, body {
  height: 100%;
}

#deepBuildBtn {
  background: #7a1f3d !important;
  color: #ffffff !important;
  border: 1px solid #a83258 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#deepBuildBtn .deep-build-badge {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  color: #ffffff !important;
  font-weight: 700;
}
.dark-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 14, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}
.dark-modal-box {
  background: #12131c;
  color: #e8e9f2;
  border: 1px solid #3c2a6e;
  border-radius: 10px;
  padding: 20px 22px;
  max-width: 440px;
  width: 92%;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.75);
}
.dark-modal-title {
  color: #c8a2ff;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 10px;
}
.dark-modal-body {
  font-size: 0.95rem;
  line-height: 1.45;
  margin-bottom: 16px;
  white-space: pre-wrap;
}
.dark-modal-actions {
  display: flex;
  justify-content: flex-end;
}
.dark-modal-actions button {
  background: #7c3aed;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 7px 18px;
  font-weight: 600;
  cursor: pointer;
}

/* SCROLLFIX */
.workspace{flex:1;min-height:0!important;overflow:hidden;grid-template-rows:minmax(0,1fr)}
.panel{min-height:0!important;overflow:hidden}
.panel-body{flex:1;min-height:0;overflow-y:auto!important;scrollbar-width:thin;scrollbar-color:#64748b #0f172a}
.panel-body::-webkit-scrollbar{width:8px}
.panel-body::-webkit-scrollbar-thumb{background:#64748b;border-radius:4px}

.topbar,.desktop-nav,.thinking-bar,.controls-drawer{flex-shrink:0}
