/* Styling modeled on company.wizards.com: light pages, deep-purple ink (#290D4A),
   purple-blue accent (#6E64DA), bright blue highlight (#0291FF), soft blue-violet
   gradients, system font stack, sentence-case headings. */
:root {
  --bg: #f6f4ef;
  --bg-soft: #efece4;
  --bg-panel: #ffffff;
  --bg-input: #ffffff;
  --border: #e7e2d6;
  --border-hi: #d4cdbd;
  --ink: #2a2438;
  --ink-deep: #0f051c;
  --text: #2c2b33;
  --text-dim: #7d7690;
  --accent: #6e64da;
  --accent-active: #a49fda;
  --blue: #0291ff;
  --blue-bright: #02bdff;
  --good: #15803d;
  --warn: #b45309;
  --bad: #dc2626;
  --grad: linear-gradient(120deg, #02bdff, #6e64da 60%, #9a8ce8);
  --btn: #472b8f;
  --btn-hover: #56379f;
  --link: #472b8f;
  --code-bg: #ecebf5;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

/* Dark html background so nothing white ever shows below/past the footer */
html { background: var(--ink-deep); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1.6rem 1.75rem 1.1rem;
  background:
    radial-gradient(ellipse 65% 110% at 12% -30%, rgba(2, 189, 255, 0.14), transparent),
    radial-gradient(ellipse 55% 100% at 88% -25%, rgba(110, 100, 218, 0.14), transparent);
}
.brand h1.site-title {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.health { font-size: 0.78rem; color: var(--text-dim); padding-bottom: 0.3rem; }
.health.ready { color: var(--good); }
.health.error { color: var(--warn); }

.tabs { padding: 0 1.75rem; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--text-dim);
  font-family: var(--sans); font-size: 0.95rem; font-weight: 600;
  padding: 0.7rem 1.1rem; cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); }

main { padding: 1.5rem 1.75rem 3rem; max-width: 1200px; margin: 0 auto; width: 100%; flex: 1; }
.panel.hidden { display: none; }

h2 { font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }

.controls {
  display: flex; gap: 1rem; align-items: end; margin-bottom: 1.2rem; flex-wrap: wrap;
}
.controls label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--text-dim); font-weight: 600; }
select, textarea {
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 8px;
  font: inherit; padding: 0.55rem 0.65rem;
}
select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110, 100, 218, 0.15); }
select { min-width: 220px; }
.preset-select { width: 100%; margin-bottom: 0.5rem; color: var(--text-dim); }

button.primary {
  background: var(--btn);
  color: #fff;
  font-weight: 700;
  border: none; border-radius: 999px;
  padding: 0.65rem 1.7rem; cursor: pointer;
  transition: background 120ms ease;
}
button.primary:hover:not(:disabled) { background: var(--btn-hover); }
/* Disabled is the same fully solid purple — only the cursor changes */
button.primary:disabled { background: var(--btn); cursor: not-allowed; }
button.secondary {
  background: var(--bg-panel); color: var(--accent);
  border: 2px solid var(--accent); border-radius: 999px;
  padding: 0.45rem 1.2rem; cursor: pointer; font-weight: 700;
}
button.secondary:hover { background: rgba(110, 100, 218, 0.08); }

.deck-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 800px) { .deck-grid { grid-template-columns: 1fr; } }
.deck-col h2 { font-size: 1rem; margin: 0 0 0.45rem; }
textarea {
  width: 100%; min-height: 260px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem;
}
textarea.goal { min-height: 120px; font-family: var(--sans); font-size: 0.95rem; }
.hint { color: var(--text-dim); font-size: 0.8rem; }

.deck-feedback { margin-top: 0.5rem; font-size: 0.82rem; }
.deck-feedback .issue-error { color: var(--bad); }
.deck-feedback .issue-warning { color: var(--warn); }
.deck-feedback .ok { color: var(--good); }

.curve-bars { display: flex; align-items: flex-end; gap: 4px; height: 60px; margin: 0.5rem 0 0.25rem; }
.curve-bar { flex: 1; background: var(--grad); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; opacity: 0.9; }
.curve-bar span {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  font-size: 0.65rem; color: var(--text-dim);
}
.curve-labels { display: flex; gap: 4px; font-size: 0.65rem; color: var(--text-dim); }
.curve-labels div { flex: 1; text-align: center; }

.status { color: var(--accent); font-size: 0.88rem; min-height: 1.4rem; margin: 0.75rem 0; font-weight: 600; }
.status.error { color: var(--bad); }

table.sim-table {
  width: 100%; border-collapse: collapse; margin: 1rem 0;
  font-size: 0.85rem; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(41, 13, 74, 0.06);
}
.sim-table th, .sim-table td { padding: 0.5rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
.sim-table tr:first-child th { font-weight: 700; color: var(--ink); background: var(--bg-soft); }
.sim-table th { color: var(--text-dim); font-weight: 500; }
.sim-table td.num { font-variant-numeric: tabular-nums; }
.metric-label { cursor: help; border-bottom: 1px dotted var(--text-dim); }
.metric-label sup { font-size: 0.65em; color: var(--accent); margin-left: 2px; }

.prose {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem 1.3rem; margin: 1rem 0;
}
.prose:empty { display: none; }
.prose h1, .prose h2, .prose h3 { font-size: 1rem; margin: 1rem 0 0.4rem; color: var(--ink); }
.prose ul { padding-left: 1.3rem; }
.prose code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.85em; }

.verdict-card {
  background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 14px;
  border-top: 4px solid transparent;
  border-image: var(--grad) 1;
  border-image-slice: 1 0 0 0;
  padding: 1.3rem 1.5rem; margin: 1.5rem 0;
  box-shadow: 0 4px 18px rgba(41, 13, 74, 0.1);
}
.verdict-card h2 { margin-top: 0; }
.verdict-card h3 { font-weight: 700; color: var(--ink); font-size: 0.9rem; }
.prob-bar-wrap { margin: 1rem 0; }
.prob-bar {
  display: flex; height: 36px; border-radius: 8px; overflow: hidden;
  font-weight: 700; font-size: 0.9rem;
}
.prob-a { background: var(--accent); color: #fff; display: flex; align-items: center; padding-left: 0.8rem; }
.prob-b { background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: flex-end; padding-right: 0.8rem; flex: 1; }
.ci-note { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.35rem; }

.badge {
  display: inline-block; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.12rem 0.75rem; font-size: 0.78rem; margin-right: 0.4rem; font-weight: 600;
  color: var(--text);
}
.badge.beatdown { border-color: var(--accent); color: var(--accent); }

.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
@media (max-width: 800px) { .kv-grid { grid-template-columns: 1fr; } }
.kv-grid h3 { margin: 0 0 0.3rem; font-size: 0.9rem; color: var(--text-dim); }

.interaction-list { margin: 0.75rem 0; padding-left: 1.2rem; font-size: 0.88rem; }
.caveats { font-size: 0.8rem; color: var(--text-dim); border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.6rem; }

.suggestion-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 1rem 0; }
.suggestion-table th, .suggestion-table td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.suggestion-table th { color: var(--ink); font-weight: 700; }
.verified-yes { color: var(--good); }
.verified-no { color: var(--bad); }
.alt-list { color: var(--text-dim); font-size: 0.8rem; margin: 0.25rem 0 0; padding-left: 1rem; }

.card-name { color: var(--accent); cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.card-name:hover { color: var(--accent-active); }
.card-tooltip { position: fixed; z-index: 50; pointer-events: none; }
.card-tooltip img { width: 320px; border-radius: 14px; box-shadow: 0 10px 34px rgba(15, 5, 28, 0.45); }
.card-tooltip.hidden { display: none; }

.resim-compare td.better { color: var(--good); }
.resim-compare td.worse { color: var(--bad); }

.steps {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.9rem 1.3rem; margin-bottom: 1.2rem; font-size: 0.9rem;
}
.steps h2 { margin: 0.2rem 0 0.5rem; font-size: 1.05rem; }
.steps ol { margin: 0.3rem 0; padding-left: 1.3rem; }
.steps li { margin: 0.35rem 0; }
.steps a { color: var(--link); font-weight: 700; }
.steps code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.85em; }

.log-paths { margin: 0.4rem 0; font-size: 0.78rem; color: var(--text-dim); }
.log-paths code { user-select: all; }
.file-btn {
  display: inline-block; background: var(--btn); color: #fff; font-weight: 700;
  border-radius: 999px; padding: 0.45rem 1.2rem; cursor: pointer; margin: 0.4rem 0.6rem 0.2rem 0;
}
.file-btn:hover { background: var(--btn-hover); }
.log-status { margin-top: 0.4rem; font-size: 0.88rem; font-weight: 600; min-height: 1.2rem; }
.log-status.info { color: var(--link); }
.log-status.ok { color: var(--good); }
.log-status.error { color: var(--bad); }

.decklist-pre {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.8rem 1rem; font-size: 0.8rem; line-height: 1.45;
  max-height: 300px; overflow-y: auto; white-space: pre-wrap; margin: 0.6rem 0;
}
.deck-issues { margin: 0.5rem 0; font-size: 0.82rem; }
.copy-deck.copied { border-color: var(--good); color: var(--good); }

.share-bar {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.6rem 0.9rem; margin: 0.8rem 0; font-size: 0.88rem; font-weight: 600;
}
.share-bar input.share-name {
  border: 1px solid var(--border-hi); border-radius: 6px; padding: 0.35rem 0.5rem;
  font: inherit; width: 190px;
}
.share-bar button.primary { padding: 0.4rem 1.1rem; }
.share-bar button.secondary { padding: 0.35rem 0.9rem; }
.share-bar a { color: var(--link); word-break: break-all; }

.history-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 0.9rem; margin: 0.4rem 0;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
}
.history-summary { cursor: pointer; flex: 1; font-weight: 600; color: var(--ink); }
.history-summary:hover { color: var(--link); }
.history-when { color: var(--text-dim); font-weight: 400; font-size: 0.78rem; margin-left: 0.6rem; }
.history-del { font-size: 0.75rem; padding: 0.25rem 0.8rem; }

footer {
  /* Dark purple gradient band */
  background: linear-gradient(135deg, #472b8f, #290d4a 60%, #0f051c);
  color: rgba(255, 255, 255, 0.92);
  margin-top: 2.5rem;
  padding: 0.5rem 1.75rem;
  font-size: 0.72rem;
}
footer a { color: #fff; }
footer p { max-width: 1200px; margin: 0.25rem auto; }
footer { position: relative; }
.admin-link {
  position: absolute; right: 0.9rem; bottom: 0.45rem;
  font-size: 0.68rem; opacity: 0.45; text-decoration: none;
}
.admin-link:hover { opacity: 0.9; text-decoration: underline; }

.admin-stats { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0.5rem 0 1rem; }
.admin-stat {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.6rem 1rem; font-size: 0.85rem;
}
.admin-stat strong { display: block; font-size: 1.2rem; color: var(--ink); }

/* ---------------- Dark mode ---------------- */
:root[data-theme="dark"] {
  --bg: #14121b;
  --bg-soft: #1b1826;
  --bg-panel: #1b1826;
  --bg-input: #241f31;
  --border: #363048;
  --border-hi: #4d4468;
  --ink: #e9e5f7;
  --text: #d9d6e4;
  --text-dim: #9d97b0;
  --accent: #8b7fd9;
  --accent-active: #a49fda;
  --blue: #3ea6ff;
  --blue-bright: #02bdff;
  --good: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --btn: #5a3fb0;
  --btn-hover: #6a4cc4;
  --link: #a49fda;
  --code-bg: #2a2438;
}

.header-side { display: flex; align-items: flex-end; gap: 0.8rem; }
.theme-toggle {
  background: var(--bg-input); border: 1px solid var(--border-hi); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---------------- Sample hand / mulligan practice ---------------- */
.hand-tools { margin-top: 0.6rem; }
.hand-btn { font-size: 0.78rem; padding: 0.3rem 0.9rem; }
.hand-area { margin-top: 0.6rem; }
.hand-cards { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.5rem 0; }
.hand-card {
  width: 118px; border-radius: 6px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 5, 28, 0.25);
  transition: transform 0.12s ease, outline-color 0.12s ease;
}
.hand-card:hover { transform: translateY(-4px); }
.hand-card.selected { outline: 3px solid var(--bad); transform: translateY(-6px); }
.hand-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hand-actions button { font-size: 0.78rem; padding: 0.3rem 0.9rem; }

/* ---------------- Price / rarity chips ---------------- */
.badge.price-badge { color: var(--good); border-color: var(--good); }
.badge.rarity-mythic { color: #d3202a; border-color: #d3202a; }
.badge.rarity-rare { color: #a58e4a; border-color: #a58e4a; }
.badge.rarity-uncommon { color: #707883; border-color: #707883; }
.badge.rarity-common { color: var(--text-dim); }

/* ---------------- Mana-base advice ---------------- */
.mana-advice { margin-top: 0.3rem; }

/* ---------------- Sideboard plan ---------------- */
.sb-plan { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 0.75rem 0; }
@media (max-width: 800px) { .sb-plan { grid-template-columns: 1fr; } }
.sb-plan h4 { margin: 0 0 0.35rem; font-size: 0.85rem; color: var(--text-dim); }
.sb-plan ul { margin: 0; padding-left: 1.1rem; font-size: 0.85rem; }
.sb-in li::marker { color: var(--good); }
.sb-out li::marker { color: var(--bad); }

/* ---------------- Meta gauntlet ---------------- */
.gauntlet-table td .secondary { font-size: 0.72rem; padding: 0.2rem 0.7rem; }
.gauntlet-bar {
  display: inline-block; height: 10px; border-radius: 5px;
  background: var(--grad); vertical-align: middle; margin-right: 0.4rem;
}
.gauntlet-note { font-size: 0.78rem; color: var(--text-dim); }

/* ---------------- Deck Viewer ---------------- */
.viewer-top textarea { min-height: 200px; }
.viewer-actions { margin-top: 0.5rem; }
.viewer-actions button { font-size: 0.85rem; }
.viewer-controls { margin: 0.8rem 0 0; }
.viewer-controls select { min-width: 150px; }
.viewer-summary { display: flex; flex-wrap: wrap; gap: 0.3rem 0; margin: 1rem 0 0.25rem; align-items: center; }
.viewer-pips { display: inline-flex; gap: 2px; align-items: center; }
.viewer-section-title { font-size: 1.15rem; margin: 1.4rem 0 0.4rem; }
.viewer-group-title { font-size: 0.85rem; color: var(--text-dim); font-weight: 700; margin: 0.9rem 0 0.4rem; text-transform: uppercase; letter-spacing: 0.04em; }
.viewer-count { font-weight: 500; color: var(--text-dim); font-size: 0.8em; margin-left: 0.2rem; }

.viewer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.viewer-grid:has(.vc-small) { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.vc {
  position: relative; padding: 0; border: none; background: none; cursor: pointer;
  border-radius: 4.75% / 3.5%; text-align: left; font: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 2px 8px rgba(15, 5, 28, 0.22);
}
.vc img { display: block; width: 100%; aspect-ratio: 488 / 680; border-radius: 4.75% / 3.5%; background: var(--bg-soft); }
.vc:hover, .vc:focus-visible { transform: translateY(-4px) scale(1.02); box-shadow: 0 10px 24px rgba(15, 5, 28, 0.35); outline: none; z-index: 1; }
.vc:focus-visible img { outline: 3px solid var(--accent); }
.vc-count {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(15, 5, 28, 0.85); color: #fff; font-weight: 800; font-size: 0.8rem;
  padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35);
}
.vc-dfc {
  position: absolute; left: 6px; top: 6px;
  background: rgba(15, 5, 28, 0.85); color: #fff; font-size: 0.8rem;
  width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

.viewer-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.vrow {
  display: grid; grid-template-columns: 2.2rem 1fr auto 1fr; gap: 0.7rem; align-items: center;
  padding: 0.45rem 0.8rem; background: var(--bg-panel); border: none; border-bottom: 1px solid var(--border);
  font: inherit; font-size: 0.86rem; color: var(--text); text-align: left; cursor: pointer;
}
.vrow:last-child { border-bottom: none; }
.vrow:hover { background: var(--bg-soft); }
.vrow-count { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.vrow-name { font-weight: 600; color: var(--ink); }
.vrow-type { color: var(--text-dim); font-size: 0.8rem; text-align: right; }
@media (max-width: 700px) { .vrow { grid-template-columns: 2rem 1fr auto; } .vrow-type { display: none; } }

/* Mana pips */
.mana {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.15em; height: 1.15em; border-radius: 50%; font-size: 0.78em; font-weight: 800;
  margin: 0 1px; vertical-align: -0.15em; color: #111; line-height: 1;
  box-shadow: inset -1px -1px 0 rgba(0, 0, 0, 0.25);
}
.mana-w { background: #fffbd5; }
.mana-u { background: #aae0fa; }
.mana-b { background: #cbc2bf; }
.mana-r { background: #f9aa8f; }
.mana-g { background: #9bd3ae; }
.mana-c, .mana-generic { background: #cac5c0; }
.mana-hybrid { background: linear-gradient(135deg, #e8e0d0, #c9c2b8); font-size: 0.6em; }
.mana-other { background: #e0d8c0; font-size: 0.6em; }

/* Card detail modal */
body.modal-open { overflow: hidden; }
.card-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.card-modal.hidden { display: none; }
.card-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 5, 28, 0.72); backdrop-filter: blur(3px); }
.card-modal-box {
  position: relative; display: grid; grid-template-columns: 330px 1fr; gap: 1.4rem;
  width: min(940px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto;
  background: var(--bg-panel); color: var(--text); border-radius: 16px; padding: 1.4rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); border: 1px solid var(--border);
}
@media (max-width: 760px) {
  .card-modal-box { grid-template-columns: 1fr; padding: 1rem; }
  .card-modal-img { max-width: 300px; margin: 0 auto; }
}
.card-modal-img { display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.card-modal-img img { width: 100%; aspect-ratio: 488 / 680; border-radius: 4.75% / 3.5%; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35); background: var(--bg-soft); }
.card-modal-flip { font-size: 0.8rem; padding: 0.3rem 0.9rem; }
.card-modal-flip.hidden { display: none; }
.card-modal-close {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-hi);
  background: var(--bg-input); color: var(--text); cursor: pointer; font-size: 0.9rem;
}
.card-modal-close:hover { border-color: var(--accent); color: var(--accent); }
.card-modal-nav {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, 0.15); color: #fff; font-size: 1.8rem; line-height: 1; cursor: pointer;
}
.card-modal-nav:hover { background: rgba(255, 255, 255, 0.3); }
.card-modal-prev { left: max(0.5rem, calc(50vw - 470px - 56px)); }
.card-modal-next { right: max(0.5rem, calc(50vw - 470px - 56px)); }
@media (max-width: 1100px) { .card-modal-nav { display: none; } }

.card-modal-info { min-width: 0; padding-right: 1.6rem; }
.card-modal-title { display: flex; align-items: baseline; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.card-modal-title h2 { margin: 0; font-size: 1.35rem; }
.card-modal-cost .mana { font-size: 1rem; }
.card-modal-badges { margin: 0.5rem 0 0.8rem; }
.face { margin: 0.5rem 0; }
.face-name { font-weight: 700; color: var(--ink); font-size: 1rem; }
.face-type { color: var(--text-dim); font-size: 0.88rem; font-weight: 600; margin-bottom: 0.35rem; display: flex; justify-content: space-between; gap: 1rem; }
.face-pt { color: var(--ink); font-weight: 800; }
.face-oracle { font-size: 0.92rem; line-height: 1.5; }
.face-oracle p { margin: 0.35rem 0; }
.face-sep { border: none; border-top: 1px dashed var(--border-hi); margin: 0.8rem 0; }
.legal-grid { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 1rem 0 0.6rem; }
.legal { font-size: 0.72rem; padding: 0.15rem 0.55rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-dim); }
.legal b { color: var(--text); font-weight: 700; margin-right: 0.15rem; }
.legal-yes { border-color: var(--good); color: var(--good); }
.legal-no { opacity: 0.6; }
.legal-warn { border-color: var(--bad); color: var(--bad); }
.card-modal-links { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: 0.6rem; font-size: 0.85rem; }
.card-modal-links a { color: var(--link); font-weight: 700; }

/* Deck Viewer: TCGplayer export bar */
.viewer-export {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.5rem 0.9rem; margin: 0.6rem 0 0.2rem; font-size: 0.85rem;
}
.viewer-export-label { font-weight: 700; color: var(--ink); }
.viewer-export button { font-size: 0.8rem; padding: 0.3rem 0.9rem; }
.viewer-export button.copied { border-color: var(--good); color: var(--good); }
.viewer-check { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--text-dim); font-weight: 600; cursor: pointer; }
.viewer-check input { accent-color: var(--accent); }

/* ---------------- Goldfish table ---------------- */
#goldfish-setup textarea { min-height: 200px; }
.gf-topbar {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.6rem 1rem; margin-bottom: 0.8rem;
}
.gf-topbar > div { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.gf-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.gf-life { font-size: 1.7rem; font-weight: 800; color: var(--ink); min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.gf-life.dead { color: var(--bad); }
.gf-turn-num { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.gf-dmg { display: flex; gap: 3px; align-items: center; }
.gf-dmg button, .gf-poison button, .gf-you button, .gf-libtools button {
  background: var(--bg-input); border: 1px solid var(--border-hi); color: var(--text); border-radius: 6px;
  padding: 0.25rem 0.5rem; font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.gf-dmg button:hover, .gf-poison button:hover, .gf-you button:hover, .gf-libtools button:hover { border-color: var(--accent); color: var(--accent); }
.gf-dmg input { width: 52px; border: 1px solid var(--border-hi); border-radius: 6px; padding: 0.25rem 0.4rem; font: inherit; font-size: 0.8rem; background: var(--bg-input); color: var(--text); }
.gf-poison { font-size: 0.85rem; color: var(--text-dim); margin-left: 0.4rem; }
.gf-tools { margin-left: auto; }
.gf-tools button { font-size: 0.75rem; padding: 0.28rem 0.8rem; }
.gf-topbar .primary { padding: 0.45rem 1.1rem; font-size: 0.85rem; }

.gf-results { display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0; margin: 0.4rem 0 0.8rem; font-size: 0.85rem; }
.gf-results .badge b { color: var(--ink); }
.gf-results .sim-badge { border-color: var(--accent); color: var(--accent); }
.gf-results-clear { font-size: 0.7rem; padding: 0.15rem 0.7rem; margin-left: 0.4rem; }

.gf-win {
  background: linear-gradient(120deg, rgba(2, 189, 255, 0.15), rgba(110, 100, 218, 0.15));
  border: 1px solid var(--accent); border-radius: 12px; padding: 0.7rem 1rem; margin: 0.4rem 0 0.8rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: 1rem; color: var(--ink);
}
.gf-win .primary { padding: 0.4rem 1.1rem; font-size: 0.85rem; }

.gf-layout { display: grid; grid-template-columns: 1fr 170px; gap: 0.8rem; }
@media (max-width: 800px) { .gf-layout { grid-template-columns: 1fr; } .gf-side { flex-direction: row; flex-wrap: wrap; } .gf-side .gf-zone { flex: 1 1 140px; } }
.gf-main { display: flex; flex-direction: column; gap: 0.8rem; }
.gf-side { display: flex; flex-direction: column; gap: 0.8rem; }
.gf-zone {
  background: var(--bg-panel); border: 1px dashed var(--border-hi); border-radius: 12px; padding: 0.5rem 0.7rem 0.7rem;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.gf-zone.drop { border-color: var(--accent); background: rgba(110, 100, 218, 0.08); border-style: solid; }
.gf-zone-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 0.4rem; }
.gf-battlefield { min-height: 330px; background: var(--bg-soft); }
.gf-row { display: flex; flex-wrap: wrap; gap: 8px; min-height: 132px; align-content: flex-start; align-items: flex-start; }
.gf-row-lands { border-top: 1px dashed var(--border); padding-top: 0.6rem; margin-top: 0.6rem; }
.gf-hand .gf-row { min-height: 132px; }
.gf-side .gf-row { min-height: 60px; }
.gf-pile { flex-direction: row-reverse; justify-content: flex-end; }
.gf-empty { color: var(--text-dim); font-size: 0.78rem; align-self: center; padding: 0.4rem; width: 100%; text-align: center; }

.gf-card {
  position: relative; width: 92px; height: 128px; flex: 0 0 auto; cursor: pointer; user-select: none;
  border-radius: 5px; transition: width 0.15s ease, height 0.15s ease, transform 0.12s ease;
}
.gf-card img, .gf-token {
  position: absolute; left: 50%; top: 50%; width: 92px; height: 128px; transform: translate(-50%, -50%);
  border-radius: 5px; box-shadow: 0 2px 8px rgba(15, 5, 28, 0.3); transition: transform 0.15s ease; display: block;
}
.gf-card:hover { transform: translateY(-3px); z-index: 2; }
.gf-card.tapped { width: 128px; height: 92px; }
.gf-card.tapped img, .gf-card.tapped .gf-token { transform: translate(-50%, -50%) rotate(90deg); filter: brightness(0.75); }
.gf-card.selected img { outline: 3px solid var(--bad); }
.gf-token {
  background: linear-gradient(160deg, #e9e4d3, #cfc8b0); color: #2c2b33; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 6px; font-size: 0.72rem; font-weight: 700;
  border: 2px solid #a59d80;
}
.gf-token-pt { font-size: 1rem; margin-top: 4px; }
.gf-token-badge {
  position: absolute; left: 4px; top: 4px; background: #a59d80; color: #fff; font-size: 0.65rem; font-weight: 800;
  width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.gf-counter {
  position: absolute; right: 4px; top: 4px; font-size: 0.75rem; font-weight: 800; color: #fff;
  padding: 0.05rem 0.4rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.5);
}
.gf-counter.pos { background: var(--good); }
.gf-counter.neg { background: var(--bad); }
.gf-card-menu {
  position: absolute; right: 3px; bottom: 3px; width: 22px; height: 18px; border: none; border-radius: 4px;
  background: rgba(15, 5, 28, 0.8); color: #fff; font-size: 0.8rem; line-height: 1; cursor: pointer; opacity: 0;
  transition: opacity 0.12s ease;
}
.gf-card:hover .gf-card-menu { opacity: 1; }

.gf-libpile {
  width: 92px; height: 128px; border-radius: 5px; cursor: pointer; margin: 0 auto;
  background: linear-gradient(160deg, #472b8f, #290d4a 70%); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(15, 5, 28, 0.35);
  border: 3px solid #1b0d36; font-size: 0.85rem;
}
.gf-libpile:hover { filter: brightness(1.15); }
.gf-libtools { display: flex; gap: 3px; justify-content: center; margin-top: 0.5rem; flex-wrap: wrap; }
.gf-libtools button { font-size: 0.72rem; padding: 0.2rem 0.45rem; }

.gf-mulligan { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-size: 0.88rem; font-weight: 600; color: var(--ink); margin-bottom: 0.4rem; }
.gf-mulligan:empty { display: none; }
.gf-mulligan button { font-size: 0.8rem; padding: 0.3rem 0.9rem; }

.gf-log {
  margin-top: 0.8rem; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.6rem 0.9rem; font-size: 0.78rem; max-height: 200px; overflow-y: auto; color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.gf-log.hidden { display: none; }

.gf-menu {
  position: fixed; z-index: 120; min-width: 200px; background: var(--bg-panel); border: 1px solid var(--border-hi);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 5, 28, 0.3); padding: 0.3rem; display: flex; flex-direction: column;
}
.gf-menu.hidden { display: none; }
.gf-menu-title { font-size: 0.72rem; font-weight: 700; color: var(--text-dim); padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--border); margin-bottom: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.gf-menu button {
  background: none; border: none; text-align: left; font: inherit; font-size: 0.85rem; color: var(--text);
  padding: 0.35rem 0.6rem; border-radius: 6px; cursor: pointer;
}
.gf-menu button:hover { background: var(--bg-soft); color: var(--ink); }

.gf-list-box { display: block; max-width: 640px; }
.gf-list-box h2 { margin: 0 0 0.2rem; }
.gf-list-body { max-height: 60vh; overflow-y: auto; margin: 0.6rem 0; }
.gf-list-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.gf-list-row img { width: 40px; border-radius: 3px; }
.gf-list-name { flex: 1; font-weight: 600; color: var(--ink); font-size: 0.9rem; }
.gf-list-actions { display: flex; gap: 3px; flex-wrap: wrap; }
.gf-list-actions button {
  background: var(--bg-input); border: 1px solid var(--border-hi); color: var(--text); border-radius: 6px;
  padding: 0.2rem 0.5rem; font: inherit; font-size: 0.72rem; font-weight: 700; cursor: pointer;
}
.gf-list-actions button:hover { border-color: var(--accent); color: var(--accent); }
#goldfish-setup.hidden, #goldfish-table.hidden, .gf-command.hidden { display: none; }

/* ---------------- Goldfish: rules engine UI ---------------- */
.gf-mana { display: flex; align-items: center; gap: 0.4rem; }
.gf-pool { display: inline-flex; gap: 3px; min-width: 40px; align-items: center; }
.gf-pool .mana { font-size: 0.95rem; width: 1.25em; height: 1.25em; }
.gf-mana button { background: none; border: 1px solid var(--border-hi); border-radius: 6px; color: var(--text-dim); font-size: 0.7rem; padding: 0.15rem 0.4rem; cursor: pointer; }
.gf-mana button:hover { color: var(--bad); border-color: var(--bad); }
.gf-land-drop { color: var(--good); font-weight: 800; text-transform: none; letter-spacing: 0; }
.gf-land-drop.used { color: var(--text-dim); }
.gf-rules.free { border-color: var(--warn); color: var(--warn); }
#gf-attack.hidden { display: none; }
.gf-attack-bar {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-weight: 700; color: var(--ink);
  background: rgba(220, 38, 38, 0.07); border: 1px solid var(--bad); border-radius: 12px; padding: 0.55rem 1rem; margin-bottom: 0.6rem;
}
.gf-attack-bar.hidden { display: none; }
.gf-attack-bar .primary { padding: 0.4rem 1.1rem; font-size: 0.85rem; background: var(--bad); }
.gf-attack-bar .secondary { font-size: 0.75rem; padding: 0.28rem 0.8rem; }

.gf-notes { display: flex; flex-direction: column; gap: 3px; margin: 0.3rem 0 0.5rem; }
.gf-notes:empty { display: none; }
.gf-note {
  font-size: 0.82rem; padding: 0.3rem 0.7rem; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
}
.gf-note-manual { border-color: var(--warn); color: var(--warn); font-weight: 600; }
.gf-note-error { border-color: var(--bad); color: var(--bad); font-weight: 700; }

.gf-card.sick::after {
  content: "zZ"; position: absolute; left: 4px; bottom: 4px; font-size: 0.65rem; font-weight: 800;
  background: rgba(15, 5, 28, 0.75); color: #fff; padding: 0.05rem 0.35rem; border-radius: 999px;
}
.gf-card.can-attack img, .gf-card.can-attack .gf-token { outline: 3px solid rgba(220, 38, 38, 0.45); }
.gf-card.attacking img, .gf-card.attacking .gf-token { outline: 4px solid var(--bad); }
.gf-card.attacking { transform: translateY(-8px); }
.gf-card.cant-attack { opacity: 0.45; }
.gf-pt {
  position: absolute; right: 4px; bottom: 26px; font-size: 0.75rem; font-weight: 800; color: #fff;
  background: rgba(15, 5, 28, 0.85); padding: 0.05rem 0.4rem; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.4);
}
.gf-playable {
  position: absolute; left: 4px; top: 4px; background: var(--good); color: #fff; font-size: 0.65rem;
  width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.gf-menu { max-width: 340px; }
.gf-menu-info { font-size: 0.72rem; color: var(--text-dim); padding: 0.2rem 0.6rem 0.35rem; border-bottom: 1px solid var(--border); margin-bottom: 0.2rem; }
.gf-menu-info div { padding: 1px 0; }

.gf-prompt-box { display: block; max-width: 720px; }
.gf-prompt-box h2 { margin: 0 0 0.8rem; font-size: 1.1rem; }
.gf-prompt-body { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.gf-choice {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem; width: 120px;
  background: var(--bg-soft); border: 2px solid var(--border); border-radius: 10px; padding: 0.5rem; cursor: pointer; font: inherit; font-size: 0.75rem; color: var(--text);
}
.gf-choice img { width: 92px; border-radius: 5px; }
.gf-choice:hover { border-color: var(--accent); }
.gf-mode { text-align: left; white-space: normal; max-width: 100%; }
/* Goldfish hover preview: keep the tooltip above modals and the attack bar */
.card-tooltip { z-index: 130; }

/* ---------- Deck Coach: intake questions & follow-up chat ---------- */
.intake-card {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.9rem 1.1rem; margin: 0.75rem 0; max-width: 720px;
}
.intake-intro { font-size: 0.92rem; margin-bottom: 0.35rem; }
.intake-q { margin: 0.7rem 0 0.35rem; font-weight: 600; font-size: 0.88rem; }
.intake-opts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.35rem; }
.chip {
  border: 1px solid var(--border); background: transparent; border-radius: 999px;
  padding: 0.28rem 0.75rem; font: inherit; font-size: 0.8rem; cursor: pointer; color: var(--text);
}
.chip:hover { border-color: var(--accent); }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.intake-custom { width: 100%; font: inherit; font-size: 0.85rem; padding: 0.35rem 0.5rem; }
.intake-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.intake-summary { font-size: 0.82rem; color: var(--text-dim); }

.coach-chat { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.75rem 0; max-width: 780px; }
.coach-chat:empty { display: none; }
.chat-msg { max-width: 88%; padding: 0.55rem 0.85rem; border-radius: 10px; font-size: 0.9rem; line-height: 1.5; }
.chat-msg.coach { background: var(--bg-soft); border: 1px solid var(--border); align-self: flex-start; }
.chat-msg.user { background: rgba(110, 100, 218, 0.13); align-self: flex-end; white-space: pre-wrap; }
.chat-msg.coach p:first-child, .chat-msg.coach h1:first-child, .chat-msg.coach h2:first-child, .chat-msg.coach h3:first-child { margin-top: 0; }
.chat-msg.coach p:last-child { margin-bottom: 0; }

.coach-followup { display: flex; gap: 0.6rem; margin: 0.75rem 0 1.5rem; max-width: 780px; align-items: stretch; }
.coach-followup.hidden { display: none; }
.coach-followup textarea { flex: 1; min-height: 64px; font-family: var(--sans); font-size: 0.9rem; }
.coach-followup-actions { display: flex; flex-direction: column; gap: 0.4rem; justify-content: flex-start; }

/* ---------- Deck Builder ---------- */
.builder-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0; }

/* ---------- Tab icons: hidden on desktop, shown in the mobile bottom bar ---------- */
.tab-ico { display: none; }

/* ---------- Mobile: app-style bottom tab bar + touch polish ---------- */
@media (max-width: 700px) {
  header { padding: 0.8rem 1rem 0.6rem; align-items: center; }
  .brand h1.site-title { font-size: 1.05rem; }
  .health { font-size: 0.68rem; }

  /* Bottom navigation bar */
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 120;
    display: flex; padding: 0;
    background: var(--bg);
    border-top: 1px solid var(--border); border-bottom: none;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    box-shadow: 0 -2px 10px rgba(15, 5, 28, 0.08);
  }
  .tab {
    flex: 1 1 0; min-width: 3.5rem;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 0.45rem 0.15rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    font-size: 0.6rem; font-weight: 600; letter-spacing: -0.01em;
    border-bottom: none; border-top: 3px solid transparent;
  }
  .tab.active { border-top-color: var(--accent); border-bottom-color: transparent; }
  .tab-ico { display: block; margin-right: 0; font-size: 1.25rem; line-height: 1.1; }

  /* Content: room for the bottom bar, tighter padding */
  main { padding: 0.9rem 0.9rem calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
  .controls { gap: 0.6rem; }
  .controls label { flex: 1 1 100%; }
  select { min-width: 0; width: 100%; }

  /* 16px inputs stop iOS Safari from zooming in on focus */
  select, textarea, input { font-size: 16px; }

  button.primary, button.secondary { padding: 0.6rem 1.2rem; }

  /* Wide tables scroll sideways instead of squishing */
  .sim-table { display: block; overflow-x: auto; white-space: nowrap; max-width: 100%; }

  .coach-followup { flex-direction: column; }
  .coach-followup-actions { flex-direction: row; }
  .chat-msg { max-width: 100%; }
  .intake-actions { flex-wrap: wrap; }
}

/* ---------- Generic hidden helper ---------- */
.hidden { display: none !important; }

/* ---------- Card Library (Collection tab) ---------- */
.subtabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.subtab {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-dim);
  font: inherit; font-size: 0.85rem; font-weight: 600; border-radius: 999px;
  padding: 0.4rem 1rem; cursor: pointer;
}
.subtab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.lib-controls { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
#lib-search {
  width: 100%; font: inherit; font-size: 1rem; padding: 0.6rem 0.8rem;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 10px;
}
#lib-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110, 100, 218, 0.15); }
.lib-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.lib-filters select { min-width: 0; font-size: 0.82rem; padding: 0.35rem 0.5rem; }
.lib-colors { display: flex; gap: 0.3rem; }
.lib-color { padding: 0.25rem 0.55rem; font-size: 0.78rem; }

#lib-back { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem; }
.lib-context { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; }

/* Years accordion */
.lib-year { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 0.5rem; background: var(--bg-panel); }
.lib-year summary {
  cursor: pointer; padding: 0.6rem 0.9rem; font-weight: 700; color: var(--ink);
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.lib-year summary::-webkit-details-marker { display: none; }
.lib-year summary::after { content: "▸"; color: var(--text-dim); transition: transform 120ms; }
.lib-year[open] summary::after { transform: rotate(90deg); }
.lib-year-count { font-size: 0.75rem; color: var(--text-dim); font-weight: 500; margin-left: auto; padding-right: 0.6rem; }
.lib-year-sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.4rem; padding: 0.4rem 0.6rem 0.7rem; }
.lib-set {
  display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 0.55rem;
  align-items: center; text-align: left; font: inherit; cursor: pointer;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem 0.6rem;
  color: var(--text);
}
.lib-set:hover { border-color: var(--accent); }
.lib-set-ico { grid-row: 1 / 3; width: 24px; height: 24px; object-fit: contain; }
:root[data-theme="dark"] .lib-set-ico { filter: invert(1); }
.lib-set-name { font-weight: 600; font-size: 0.82rem; line-height: 1.25; }
.lib-set-meta { font-size: 0.7rem; color: var(--text-dim); }

/* Card grid */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
.lib-card {
  border: none; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--text);
  display: flex; flex-direction: column; gap: 0.25rem; text-align: left;
}
.lib-card img { width: 100%; border-radius: 4.5%/3.5%; box-shadow: 0 1px 4px rgba(15, 5, 28, 0.25); }
.lib-card:hover img { box-shadow: 0 3px 10px rgba(110, 100, 218, 0.5); }
.lib-card-cap { font-size: 0.72rem; line-height: 1.25; color: var(--text-dim); }
.lib-card-cap em { font-style: normal; color: var(--good); }
.lib-card-noimg {
  aspect-ratio: 63/88; display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; font-size: 0.8rem; padding: 0.5rem;
}
.lib-more { text-align: center; margin: 1.2rem 0; }

/* Card modal */
.lib-modal {
  position: fixed; inset: 0; z-index: 200; background: rgba(15, 5, 28, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.lib-modal-box {
  background: var(--bg-panel); border-radius: 14px; max-width: 860px; width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 1.2rem 1.4rem; position: relative;
  box-shadow: 0 10px 40px rgba(15, 5, 28, 0.4);
}
.lib-modal-close {
  position: absolute; top: 0.6rem; right: 0.7rem; border: none; background: none;
  font-size: 1.1rem; cursor: pointer; color: var(--text-dim); padding: 0.3rem;
}
.lib-modal-grid { display: grid; grid-template-columns: 300px 1fr; gap: 1.2rem; }
.lib-modal-imgs img { width: 100%; border-radius: 4.5%/3.5%; margin-bottom: 0.6rem; }
.lib-modal-info h3 { margin: 0 0 0.2rem; color: var(--ink); }
.lib-mana { font-size: 0.8rem; color: var(--text-dim); font-weight: 500; }
.lib-type { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.lib-oracle { font-size: 0.9rem; line-height: 1.55; }
.lib-pt { font-weight: 700; margin-top: 0.3rem; }
.lib-meta { margin-top: 0.8rem; font-size: 0.78rem; color: var(--text-dim); }
.lib-modal-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; align-items: center; }
.lib-scry-link {
  display: inline-block; text-decoration: none; border: 1px solid var(--accent); color: var(--link);
  border-radius: 999px; padding: 0.35rem 0.9rem; font-size: 0.85rem; font-weight: 600;
}

@media (max-width: 700px) {
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.45rem; }
  .lib-year-sets { grid-template-columns: 1fr; }
  .lib-modal-grid { grid-template-columns: 1fr; }
  .lib-modal-imgs img { max-width: 300px; margin: 0 auto 0.6rem; display: block; }
  .lib-modal-box { padding: 1rem; }
}

/* ---------- First Hand (opening-hand cycling) ---------- */
.fh-head { font-size: 0.85rem; color: var(--text-dim); margin: 0.5rem 0; }
.fh-cards { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; max-width: 900px; }
.fh-card { width: 100%; border-radius: 4.5%/3.5%; cursor: pointer; box-shadow: 0 1px 4px rgba(15, 5, 28, 0.25); }
.fh-card:hover { box-shadow: 0 3px 10px rgba(110, 100, 218, 0.5); }
.fh-actions { display: flex; gap: 0.5rem; margin: 0.7rem 0; flex-wrap: wrap; }
@media (max-width: 700px) { .fh-cards { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Printings strip (card popups) ---------- */
.prints-head { font-size: 0.78rem; font-weight: 700; color: var(--ink); margin: 0.9rem 0 0.35rem; }
.print-strip { display: flex; gap: 0.45rem; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 0.4rem; }
.print-thumb {
  flex: 0 0 auto; width: 74px; border: none; background: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; text-align: left;
}
.print-thumb img { width: 100%; border-radius: 6px; box-shadow: 0 1px 3px rgba(15, 5, 28, 0.3); }
.print-thumb:hover img { box-shadow: 0 2px 8px rgba(110, 100, 218, 0.55); }
.print-thumb.sel img { outline: 2px solid var(--accent); outline-offset: 1px; }
.print-cap { font-size: 0.62rem; line-height: 1.2; white-space: nowrap; }

/* ---------- Community feed: inline deck expansion ---------- */
.community-item { display: block; }
.community-item .history-summary { cursor: pointer; }
.community-deck { padding: 0.5rem 0 0.3rem; }
.community-deck-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.community-deck .decklist-pre { max-height: 320px; overflow-y: auto; }

/* ---------- Hub link back to game-time.io ---------- */
.hub-link { display: block; font-size: 0.72rem; font-weight: 700; color: var(--accent); text-decoration: none; margin-bottom: 0.15rem; }
.hub-link:hover { text-decoration: underline; }

/* ---------- Home tab: omnibox + tool cards (Table Hub) ---------- */
.home-hero { text-align: center; padding: 1.2rem 0 0.4rem; }
.home-hero h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); letter-spacing: -0.03em; margin: 0 0 0.4rem; }
.home-hero .hint { max-width: 52ch; margin: 0 auto 1.1rem; }
.omnibox {
  max-width: 640px; margin: 0 auto; background: var(--bg-panel); border: 2px solid var(--border);
  border-radius: 18px; padding: 0.45rem 0.5rem 0.45rem 1rem; display: flex; align-items: center; gap: 0.6rem;
  box-shadow: 0 10px 30px rgba(110, 100, 218, 0.10);
}
.omnibox:focus-within { border-color: var(--accent); }
.omnibox textarea {
  flex: 1; border: none; outline: none; resize: none; background: transparent; box-shadow: none;
  font: inherit; font-size: 1rem; color: var(--text); padding: 0.35rem 0; line-height: 1.4;
}
.omnibox .primary { padding: 0.55rem 1.3rem; }
.omni-ico { font-size: 1.1rem; }
.home-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 0.8rem; margin-top: 1.6rem; }
.tool {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 18px; padding: 1rem 1.05rem;
  cursor: pointer; text-align: left; font: inherit; color: var(--text);
  transition: transform 0.12s, box-shadow 0.12s;
}
.tool:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(42, 36, 56, 0.12); }
.tool-glyph {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 1.1rem;
  margin-bottom: 0.55rem; color: #fff;
}
.tool h3 { margin: 0 0 0.2rem; font-size: 0.98rem; letter-spacing: -0.01em; color: var(--ink); }
.tool p { margin: 0; color: var(--text-dim); font-size: 0.8rem; line-height: 1.45; }
.g-purple { background: #6e64da; } .g-amber { background: #efa23c; } .g-pink { background: #ef7ab8; }
.g-blue { background: #02bdff; } .g-green { background: #3fb96f; } .g-slate { background: #5b5470; }
.g-ink { background: #2a2438; } .g-blue2 { background: #4a7dd6; }
@media (max-width: 700px) { .home-tools { grid-template-columns: 1fr 1fr; gap: 0.55rem; } .tool { padding: 0.8rem; } }
