/* ============ Design Tokens ============ */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-0: oklch(0.16 0.015 250);
  --bg-1: oklch(0.20 0.015 250);
  --bg-2: oklch(0.235 0.015 250);
  --bg-3: oklch(0.275 0.015 250);
  --bg-4: oklch(0.32 0.015 250);

  --fg-0: oklch(0.97 0.01 80);
  --fg-1: oklch(0.88 0.01 80);
  --fg-2: oklch(0.70 0.01 80);
  --fg-3: oklch(0.55 0.01 80);
  --fg-4: oklch(0.42 0.01 80);

  --line-1: oklch(0.30 0.012 250);
  --line-2: oklch(0.38 0.012 250);
  --line-3: oklch(0.48 0.012 250);

  --accent: oklch(0.78 0.14 75);
  --accent-soft: oklch(0.78 0.14 75 / 0.14);
  --accent-line: oklch(0.78 0.14 75 / 0.45);

  --good: oklch(0.74 0.13 155);
  --warn: oklch(0.78 0.14 70);
  --bad:  oklch(0.68 0.18 25);

  --mana-w: oklch(0.92 0.02 85);
  --mana-u: oklch(0.62 0.10 240);
  --mana-b: oklch(0.40 0.04 320);
  --mana-r: oklch(0.60 0.16 30);
  --mana-g: oklch(0.58 0.10 150);
  --mana-c: oklch(0.65 0.01 80);

  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --density-pad: 14px;
  --density-card-h: 96px;
  --density-card-w: 68px;
  --density-gap: 10px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --shadow-1: 0 1px 0 0 oklch(1 0 0 / 0.04) inset, 0 1px 2px oklch(0 0 0 / 0.4);
  --shadow-2: 0 8px 24px oklch(0 0 0 / 0.35);
}

[data-density="compact"] {
  --density-pad: 8px;
  --density-card-h: 76px;
  --density-card-w: 54px;
  --density-gap: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root-wrap { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--fg-1);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ============ App Shell ============ */
.app {
  display: grid;
  grid-template-columns: 56px 1fr;
  height: 100vh;
}

/* ─── Rail ─────────────────────────────────────────────────────────────────── */
.rail {
  background: var(--bg-0);
  border-right: 1px solid var(--line-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
  z-index: 50;
}
.rail-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, var(--accent) 0%, transparent 60%),
              linear-gradient(135deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--accent-line);
  margin-bottom: 12px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 18px; color: var(--fg-0); font-style: italic;
}
.rail-btn {
  width: 36px; height: 36px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--fg-3);
  transition: all 120ms;
  position: relative;
}
.rail-btn:hover { color: var(--fg-1); background: var(--bg-2); }
.rail-btn.active {
  background: var(--bg-2); color: var(--accent); border-color: var(--line-2);
}
.rail-btn.active::before {
  content: "";
  position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 2px; background: var(--accent); border-radius: 2px;
}
.rail-btn[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--bg-3); color: var(--fg-0);
  padding: 4px 8px; border-radius: 4px; font-size: 12px;
  white-space: nowrap; border: 1px solid var(--line-2);
  pointer-events: none; z-index: 100;
}
.rail-spacer { flex: 1; }

/* ─── Main ──────────────────────────────────────────────────────────────────── */
.main {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  background: var(--bg-1);
}

/* ─── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 52px;
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-1); flex-shrink: 0;
}
.topbar-title {
  font-family: var(--font-serif);
  font-size: 22px; font-style: italic;
  color: var(--fg-0); letter-spacing: 0.01em;
}
.topbar-sub {
  font-size: 12px; color: var(--fg-3);
  font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.topbar-spacer { flex: 1; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--fg-1);
  border-radius: 6px; font-size: 13px; font-weight: 500;
  transition: all 100ms; white-space: nowrap;
}
.btn:hover { background: var(--bg-3); border-color: var(--line-3); color: var(--fg-0); }
.btn-primary {
  background: var(--accent); color: oklch(0.18 0.015 250); border-color: var(--accent); font-weight: 600;
}
.btn-primary:hover { background: oklch(0.84 0.14 75); border-color: oklch(0.84 0.14 75); color: oklch(0.18 0.015 250); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--fg-0); }
.btn-danger { background: transparent; color: var(--bad); border-color: oklch(0.68 0.18 25 / 0.4); }
.btn-danger:hover { background: oklch(0.68 0.18 25 / 0.1); }
.btn-icon { padding: 6px; width: 30px; height: 30px; justify-content: center; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-xs { padding: 2px 6px; font-size: 11px; }

.kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 5px; background: var(--bg-3);
  border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 3px; color: var(--fg-2);
}

/* ─── Inputs ────────────────────────────────────────────────────────────────── */
.input {
  background: var(--bg-2); border: 1px solid var(--line-2);
  color: var(--fg-1); padding: 6px 10px; border-radius: 6px;
  font-size: 13px; width: 100%; transition: border-color 100ms;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--fg-4); }
.input-search {
  position: relative; display: flex; align-items: center;
}
.input-search svg { position: absolute; left: 8px; color: var(--fg-3); pointer-events: none; }
.input-search .input { padding-left: 28px; }

select.input option { background: var(--bg-2); }
textarea.input { resize: vertical; }

/* ─── Mana pips ─────────────────────────────────────────────────────────────── */
.pip {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  color: oklch(0.18 0.015 250);
  border: 1px solid oklch(0 0 0 / 0.25); flex-shrink: 0;
}
.pip-w { background: var(--mana-w); }
.pip-u { background: var(--mana-u); color: var(--fg-0); }
.pip-b { background: var(--mana-b); color: var(--fg-0); }
.pip-r { background: var(--mana-r); color: var(--fg-0); }
.pip-g { background: var(--mana-g); color: var(--fg-0); }
.pip-c { background: var(--mana-c); }
.pip-row { display: inline-flex; gap: 3px; align-items: center; }
.pip-sm { width: 13px; height: 13px; font-size: 8px; }

/* ─── Abstract card (battlefield) ───────────────────────────────────────────── */
.card-face {
  width: var(--density-card-w);
  height: var(--density-card-h);
  border-radius: 6px; padding: 6px;
  font-size: 10px; display: flex;
  flex-direction: column; justify-content: space-between;
  gap: 3px;
  border: 1px solid oklch(0 0 0 / 0.4);
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  position: relative; cursor: grab; user-select: none;
  transition: transform 120ms, box-shadow 120ms, border-color 120ms;
  overflow: hidden; flex-shrink: 0;
}
.card-face:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 18px oklch(0 0 0 / 0.55);
  border-color: var(--accent-line); z-index: 5;
}
.card-face:active { cursor: grabbing; }
.card-face.tapped {
  transform: rotate(90deg) translateX(8px);
  margin-right: calc(var(--density-card-h) - var(--density-card-w) + 6px);
}
.card-face.tapped:hover { transform: rotate(90deg) translateX(8px) translateY(-2px); }
.card-face.summoning-sick { filter: saturate(0.4) brightness(0.85); }
.card-face.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.card-color-bar {
  position: absolute; inset: 0 0 auto 0; height: 4px; border-radius: 6px 6px 0 0;
}
.card-img-fill {
  position: absolute; inset: 4px 0 0 0;
  width: 100%; height: calc(100% - 4px);
  object-fit: cover; display: block;
}
.card-name {
  font-size: 9px; font-weight: 600; color: var(--fg-0); margin-top: 4px;
  line-height: 1.15; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.card-art {
  flex: 1; border-radius: 3px;
  background: repeating-linear-gradient(45deg, oklch(0 0 0 / 0.18) 0 4px, transparent 4px 8px),
              var(--card-tone, var(--mana-c));
  opacity: 0.85; margin: 2px 0;
}
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: 9px; color: var(--fg-2);
}
.card-pt {
  background: oklch(0 0 0 / 0.5); padding: 1px 4px;
  border-radius: 3px; color: var(--fg-0);
}
.card-counter {
  position: absolute; bottom: 2px; right: 2px;
  background: var(--accent); color: var(--bg-0);
  border-radius: 3px; padding: 1px 4px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
}
.card-token-badge {
  position: absolute; top: -4px; right: -4px;
  font-size: 8px; font-family: var(--font-mono);
  background: var(--accent); color: var(--bg-0);
  padding: 1px 4px; border-radius: 3px; font-weight: 700; text-transform: uppercase;
}
.card-face.is-land .card-art {
  background: repeating-linear-gradient(0deg, oklch(0 0 0 / 0.15) 0 3px, transparent 3px 7px),
              var(--card-tone, var(--mana-c));
}

/* ─── Drop target ───────────────────────────────────────────────────────────── */
.drop-target {
  outline: 1px dashed var(--accent-line); outline-offset: -4px;
  background: var(--accent-soft) !important; border-radius: 8px;
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.65);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 200; animation: fadeIn 150ms ease-out;
}
.modal {
  background: var(--bg-1); border: 1px solid var(--line-2);
  border-radius: 12px; box-shadow: var(--shadow-2);
  min-width: 480px; max-width: 90vw; max-height: 85vh;
  display: flex; flex-direction: column;
  animation: slideUp 200ms cubic-bezier(0.2, 0.7, 0.3, 1);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-1);
}
.modal-title {
  font-family: var(--font-serif); font-size: 22px;
  font-style: italic; color: var(--fg-0);
}
.modal-body { padding: 20px; overflow: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--line-1);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 2000;
}
.toast {
  padding: 10px 16px; border-radius: 6px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  color: var(--fg-1); font-size: 13px; min-width: 200px;
  animation: slideUp 0.2s ease; box-shadow: var(--shadow-2);
}
.toast.success { border-color: oklch(0.74 0.13 155 / 0.6); }
.toast.error   { border-color: oklch(0.68 0.18 25 / 0.6); color: var(--bad); }

/* ─── Panel ─────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-1); border: 1px solid var(--line-1); border-radius: 8px;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line-1);
}
.panel-title {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--fg-3); font-weight: 600;
}

/* ─── Utility ───────────────────────────────────────────────────────────────── */
.eyebrow {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--fg-3); font-weight: 600;
}
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); font-style: italic; }
.muted { color: var(--fg-3); }
.dimmer { color: var(--fg-4); }
.divider { height: 1px; background: var(--line-1); margin: 8px 0; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px; font-size: 11px;
  background: var(--bg-2); border: 1px solid var(--line-1);
  color: var(--fg-2); font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tag-good { color: var(--good); border-color: oklch(0.74 0.13 155 / 0.4); }
.tag-warn { color: var(--warn); border-color: var(--accent-line); }
.tag-bad  { color: var(--bad);  border-color: oklch(0.68 0.18 25 / 0.4); }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; color: var(--fg-3); padding: 40px; gap: 10px;
}
.empty-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--line-1);
  display: grid; place-items: center; color: var(--fg-3); margin-bottom: 6px;
}
.empty-title { font-family: var(--font-serif); font-style: italic; font-size: 20px; color: var(--fg-1); }
.empty-body  { font-size: 13px; max-width: 380px; line-height: 1.5; }

/* ─── Scrollbars ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* ─── Hidden ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ============ Home Screen ============ */
.home-body { flex: 1; overflow-y: auto; padding: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-content: start; }
.home-section-title { font-family: var(--font-serif); font-style: italic; font-size: 22px; color: var(--fg-0); margin-bottom: 14px; }
.home-actions { display: flex; gap: 8px; margin-top: 6px; }

.game-card-item {
  background: var(--bg-2); border: 1px solid var(--line-1);
  border-radius: 8px; padding: 14px;
  cursor: pointer; transition: all 120ms;
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px;
}
.game-card-item:hover { border-color: var(--line-3); background: var(--bg-3); }
.game-card-title { font-weight: 600; font-size: 14px; color: var(--fg-0); }
.game-card-players { display: flex; gap: 6px; flex-wrap: wrap; }
.player-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  background: var(--bg-3); border: 1px solid var(--line-1);
  font-size: 12px; font-family: var(--font-mono);
}
.player-chip-life { color: var(--bad); font-weight: 600; }

/* ============ Deck Library ============ */
.deck-library-layout {
  flex: 1; overflow: hidden;
  display: grid; grid-template-columns: 240px 1fr 280px;
}
.deck-rail {
  border-right: 1px solid var(--line-1);
  display: flex; flex-direction: column; overflow: hidden;
}
.deck-rail-header { padding: 12px; border-bottom: 1px solid var(--line-1); display: flex; flex-direction: column; gap: 8px; }
.deck-rail-list { flex: 1; overflow-y: auto; }
.deck-item {
  padding: 11px 14px; border-bottom: 1px solid var(--line-1);
  cursor: pointer; transition: background 100ms; display: flex; flex-direction: column; gap: 4px;
}
.deck-item:hover { background: var(--bg-2); }
.deck-item.active { background: var(--accent-soft); }
.deck-item-name { font-weight: 600; font-size: 13px; color: var(--fg-0); }
.deck-item-meta { font-size: 11px; color: var(--fg-3); display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); }

.deck-detail { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.deck-detail-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--line-1); }
.deck-detail-title { font-family: var(--font-serif); font-style: italic; font-size: 26px; color: var(--fg-0); margin-bottom: 6px; }
.deck-stats-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.stat-cell { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-3); font-weight: 600; }
.stat-val { font-family: var(--font-mono); font-size: 16px; color: var(--fg-0); font-weight: 600; }

.deck-detail-body { flex: 1; padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }

.mana-curve { display: flex; align-items: flex-end; gap: 4px; height: 56px; }
.curve-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.curve-bar { width: 100%; background: var(--accent); border-radius: 2px; transition: height 200ms; }
.curve-label { font-size: 9px; color: var(--fg-3); font-family: var(--font-mono); }

.card-section-header { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-2); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.deck-card-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 4px; cursor: pointer;
  transition: background 80ms;
}
.deck-card-row:hover { background: var(--bg-2); }
.deck-card-qty { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); min-width: 18px; }
.deck-card-name { font-size: 13px; flex: 1; }
.deck-card-cost { display: flex; gap: 2px; }

.history-entry { padding: 8px 0; border-bottom: 1px solid var(--line-1); display: flex; gap: 12px; }
.history-date { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); min-width: 50px; }
.history-note { font-size: 12px; color: var(--fg-2); }

.card-search-panel {
  border-left: 1px solid var(--line-1);
  display: flex; flex-direction: column; overflow: hidden;
}
.card-search-header { padding: 12px; border-bottom: 1px solid var(--line-1); }
.card-search-results { flex: 1; overflow-y: auto; }
.card-search-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line-1);
  cursor: pointer; transition: background 80ms;
}
.card-search-item:hover { background: var(--bg-2); }
.card-search-thumb { width: 36px; height: 50px; border-radius: 3px; background: var(--bg-3); flex-shrink: 0; object-fit: cover; }
.card-search-info { flex: 1; min-width: 0; }
.card-search-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-search-type { font-size: 10px; color: var(--fg-3); margin-top: 1px; }

/* ============ Game Management ============ */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; padding: 24px; }

/* ============ Game Setup ============ */
.setup-body { flex: 1; overflow-y: auto; padding: 32px; display: grid; place-items: start center; }
.setup-inner { max-width: 640px; width: 100%; }
.setup-step { display: flex; gap: 16px; margin-bottom: 24px; }
.setup-step-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-3); border: 1px solid var(--line-2);
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 12px; color: var(--fg-2);
  margin-top: 2px;
}
.setup-step-num.done { background: var(--accent); color: var(--bg-0); border-color: var(--accent); }
.setup-step-content { flex: 1; }
.setup-step-title { font-weight: 600; font-size: 14px; margin-bottom: 10px; color: var(--fg-0); }
.player-slot { background: var(--bg-2); border: 1px solid var(--line-1); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ============ Active Gameplay ============ */
.gameplay-wrap { display: grid; grid-template-rows: auto auto 1fr auto; height: 100%; overflow: hidden; background: var(--bg-0); }

/* Player ribbon */
.player-ribbon {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-1); flex-shrink: 0;
}
.ribbon-player {
  flex: 1; display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  border-right: 1px solid var(--line-1);
  cursor: pointer; transition: background 100ms;
  border-top: 2px solid transparent;
}
.ribbon-player:hover { background: var(--bg-2); }
.ribbon-player.active {
  background: linear-gradient(180deg, var(--accent-soft) 0%, transparent 80%);
  border-top-color: var(--accent);
}
.ribbon-avatar {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-style: italic; font-size: 16px;
  color: oklch(0.18 0.015 250); border: 1px solid oklch(0 0 0 / 0.3);
  box-shadow: var(--shadow-1); flex-shrink: 0;
}
.ribbon-info { flex: 1; min-width: 0; }
.ribbon-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.ribbon-active-label { font-size: 9px; font-family: var(--font-mono); color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; }
.ribbon-deck { font-size: 11px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ribbon-vitals { display: flex; align-items: center; gap: 12px; }
.vital { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.vital-label { font-size: 9px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-3); }
.vital-val { font-family: var(--font-serif); font-style: italic; font-size: 28px; color: var(--fg-0); line-height: 1; min-width: 28px; text-align: center; }
.vital-val.compact { font-size: 14px; font-family: var(--font-mono); }
.vital-controls { display: flex; align-items: center; gap: 4px; }
.life-btn { background: transparent; border: none; color: var(--fg-3); font-size: 16px; padding: 0 3px; transition: color 100ms; }
.life-btn:hover { color: var(--fg-0); }

.ribbon-next-btn {
  background: var(--accent); color: oklch(0.18 0.015 250);
  border: none; padding: 0 24px; display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13px; flex-shrink: 0; transition: background 100ms;
}
.ribbon-next-btn:hover { background: oklch(0.84 0.14 75); }

/* Opponent summary */
.opponents-bar {
  border-bottom: 1px solid var(--line-1);
  padding: 10px 20px 12px; background: var(--bg-0); flex-shrink: 0;
}
.opponent-mini-card {
  flex: 1; min-width: 260px; background: var(--bg-1);
  border: 1px solid var(--line-1); border-radius: 8px; padding: 10px;
}
.opponent-perm {
  width: 38px; height: 54px; border-radius: 4px;
  border: 1px solid oklch(0 0 0 / 0.4);
  position: relative; flex-shrink: 0; transition: transform 200ms;
}
.opponent-perm.tapped { transform: rotate(90deg) translateX(8px); }

/* Gameplay body */
.gameplay-body { display: grid; overflow: hidden; transition: grid-template-columns 200ms; }
.gameplay-body.log-open { grid-template-columns: 1fr 300px; }
.gameplay-body.log-closed { grid-template-columns: 1fr 0px; }

.battlefield-column { display: flex; flex-direction: column; overflow: hidden; }

/* Battlefield zones */
.bf-zone {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
  padding: var(--density-pad) 20px;
  background: var(--bg-1); border: 1px solid var(--line-1); border-radius: 10px;
  transition: background 100ms;
}
.bf-zone-header { display: flex; align-items: center; gap: 10px; }
.bf-zone-cards { flex: 1; display: flex; flex-wrap: wrap; gap: var(--density-gap); align-content: flex-start; min-height: var(--density-card-h); }
.bf-zones-wrap { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }

/* Side panel */
.side-panel {
  border-left: 1px solid var(--line-1);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-1);
}
.side-panel-tabs { display: flex; align-items: center; border-bottom: 1px solid var(--line-1); }
.side-tab {
  flex: 1; padding: 12px 0; background: transparent; border: none;
  color: var(--fg-3); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em; transition: all 100ms;
}
.side-tab.active { background: var(--bg-2); color: var(--fg-0); }
.log-entry { padding: 8px 14px; border-bottom: 1px solid var(--line-1); display: flex; gap: 10px; }
.log-turn { font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); min-width: 28px; }
.log-who { font-size: 11px; color: var(--accent); font-weight: 600; }
.log-text { font-size: 12px; color: var(--fg-2); margin-left: 6px; }

/* Bottom bar */
.bottom-bar {
  display: grid; grid-template-columns: 1fr auto;
  border-top: 1px solid var(--line-1); background: var(--bg-1); flex-shrink: 0;
}
.hand-area { padding: 12px 16px; }
.hand-label-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hand-cards { display: flex; gap: var(--density-gap); overflow-x: auto; padding-bottom: 4px; min-height: var(--density-card-h); }
.zones-actions {
  border-left: 1px solid var(--line-1); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; min-width: 256px; width: 256px;
}
.zone-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.zone-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px; background: var(--bg-2); border: 1px solid var(--line-1);
  border-radius: 6px; color: var(--fg-2); transition: all 100ms;
}
.zone-tab:hover { background: var(--bg-3); border-color: var(--line-3); color: var(--fg-0); }
.zone-tab-label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.zone-tab-count { font-family: var(--font-mono); font-size: 11px; color: var(--fg-0); }
.action-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; }

/* ============ Deck Builder ============ */
.builder-layout { display: grid; grid-template-columns: 300px 1fr 260px; flex: 1; overflow: hidden; }
.builder-panel { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line-1); }
.builder-panel:last-child { border-right: none; }
.builder-panel-header { padding: 10px 14px; border-bottom: 1px solid var(--line-1); display: flex; align-items: center; gap: 8px; }
.builder-panel-body { flex: 1; overflow-y: auto; padding: 10px; }
.builder-stats { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line-1); }
.stat-badge {
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
  background: var(--bg-2); border: 1px solid var(--line-1); color: var(--fg-3);
  font-family: var(--font-mono);
}
.stat-badge.total { color: var(--fg-1); border-color: var(--accent-line); }

.deck-entry {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px; border-radius: 4px; border: 1px solid transparent;
  transition: all 80ms;
}
.deck-entry:hover { background: var(--bg-2); border-color: var(--line-1); }
.deck-entry-qty input {
  width: 32px; text-align: center; padding: 1px 3px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 3px; color: var(--fg-1); font-size: 12px; font-family: var(--font-mono);
}
.deck-entry-name { flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Scry modal ─────────────────────────────────────────────────────────────── */
.scry-cards { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; }
.scry-card-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.scry-dest-btns { display: flex; flex-direction: column; gap: 4px; width: 100px; }

/* ─── Token modal ─────────────────────────────────────────────────────────────── */
.token-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.token-form { display: grid; grid-template-columns: 1fr 80px 1fr; gap: 12px; }
.field-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-3); font-weight: 600; margin-bottom: 5px; }

/* ─── Zone drawer ────────────────────────────────────────────────────────────── */
.zone-drawer-cards { display: flex; flex-wrap: wrap; gap: 8px; }
.zone-drawer-back {
  width: 60px; height: 84px; border-radius: 4px;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line-2); display: grid; place-items: center;
  font-family: var(--font-serif); font-style: italic; font-size: 18px; color: var(--fg-3);
}

/* ─── Settings ───────────────────────────────────────────────────────────────── */
.settings-body { flex: 1; overflow-y: auto; padding: 32px; display: grid; place-items: start center; }
.settings-inner { max-width: 680px; width: 100%; display: flex; flex-direction: column; gap: 24px; }
.settings-group { }
.settings-group-title { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 22px; color: var(--fg-0); margin-bottom: 12px; }
.settings-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-1);
  background: var(--bg-1); border: 1px solid var(--line-1); border-top: none;
}
.settings-group > .settings-row:first-of-type { border-top: 1px solid var(--line-1); border-radius: 8px 8px 0 0; }
.settings-group > .settings-row:last-of-type  { border-radius: 0 0 8px 8px; }
.settings-group > .settings-row:only-of-type  { border-radius: 8px; }
.settings-row-label { flex: 1; }
.settings-row-title { font-weight: 500; color: var(--fg-1); font-size: 13px; }
.settings-row-desc  { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.shortcut-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--line-1);
  background: var(--bg-1); border: 1px solid var(--line-1); border-top: none;
}
.toggle-btn {
  width: 36px; height: 20px; border-radius: 10px; position: relative;
  transition: all 150ms; padding: 0; border: 1px solid;
}
.toggle-knob {
  position: absolute; top: 1px; width: 16px; height: 16px;
  border-radius: 50%; transition: left 150ms;
}

/* ============ Login Overlay ============ */
.login-overlay { position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; background: var(--bg-0, #14151a); z-index: 1000; }
.login-overlay.hidden { display: none; }
.login-card { text-align: center; padding: 40px; }
.login-logo { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--fg-3, #9aa0aa); margin-bottom: 20px; }
