*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: system-ui, sans-serif; background: #0f1117; color: #e2e8f0; min-height: 100vh;
  padding-bottom: calc(58px + env(safe-area-inset-bottom)); }

/* ── Header ── */
header { background: #1a1d2e; border-bottom: 1px solid #2d3148; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
header h1 { font-size: 18px; font-weight: 600; color: #a78bfa; white-space: nowrap; }
.hdr-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.hdr-stats { color: #64748b; }
#hdr-user { color: #a78bfa; font-weight: 500; }
.btn-sm { padding: 5px 12px; border-radius: 6px; border: 1px solid #2d3148;
  background: #1e2235; color: #e2e8f0; cursor: pointer; font-size: 12px; }
.btn-sm:hover { background: #2d3148; }

/* ── Notifications ── */
.notif-wrap { position: relative; }
.notif-bell { position: relative; background: none; border: none; color: #e2e8f0;
  font-size: 18px; cursor: pointer; padding: 4px 6px; line-height: 1; }
.notif-bell:hover { opacity: .8; }
.notif-badge { position: absolute; top: -2px; right: -2px; background: #dc2626; color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.notif-panel { display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 340px;
  max-width: 90vw; max-height: 420px; background: #1a1d2e; border: 1px solid #2d3148;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 120; overflow: hidden;
  flex-direction: column; }
.notif-panel.open { display: flex; }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid #2d3148; font-size: 13px; font-weight: 600; color: #e2e8f0; }
.notif-panel-list { overflow-y: auto; flex: 1; }
.notif-item { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px;
  border-bottom: 1px solid #22263a; cursor: pointer; }
.notif-item:hover { background: #1e2235; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #1c1b30; }
.notif-item.unread::before { content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: #a78bfa; margin-top: 5px; flex-shrink: 0; }
.notif-item:not(.unread)::before { content: ''; width: 7px; flex-shrink: 0; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-text { font-size: 12.5px; color: #e2e8f0; line-height: 1.4; }
.notif-item-date { font-size: 11px; color: #64748b; margin-top: 2px; }
.notif-item-toggle { background: none; border: none; color: #94a3b8; font-size: 14px;
  cursor: pointer; padding: 2px 4px; flex-shrink: 0; }
.notif-item-toggle:hover { color: #e2e8f0; }

/* ── Notification toast ── */
.notif-toast { position: fixed; bottom: calc(72px + env(safe-area-inset-bottom)); right: 16px;
  z-index: 250; background: #1a1d2e; border: 1px solid #7c3aed; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 14px; width: 300px; max-width: calc(100vw - 32px); }
.notif-toast-text { font-size: 13px; color: #e2e8f0; line-height: 1.4; margin-bottom: 10px; }
.notif-toast-actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (min-width: 640px) { .notif-toast { bottom: 20px; } }

/* ── Deck comments ── */
.deck-comment { padding: 10px 0; border-bottom: 1px solid #22263a; }
.deck-comment:last-child { border-bottom: none; }
.deck-comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.deck-comment-author { font-size: 12.5px; font-weight: 600; color: #a78bfa; }
.deck-comment-date { font-size: 11px; color: #64748b; }
.deck-comment-del, .deck-comment-reply-btn { background: none; border: none; cursor: pointer;
  font-size: 11px; padding: 0; color: #94a3b8; }
.deck-comment-del:hover, .deck-comment-reply-btn:hover { color: #e2e8f0; }
.deck-comment-text { font-size: 13px; color: #cbd5e1; line-height: 1.5; white-space: pre-wrap; }
.deck-comment-replies { margin-left: 22px; padding-left: 12px; border-left: 2px solid #2d3148; margin-top: 6px; }
.deck-comment-reply-row { display: none; margin-top: 8px; gap: 8px; flex-direction: column; }
.deck-comment-reply-row.open { display: flex; }
.deck-comment-reply-row textarea { width: 100%; min-height: 56px; }
.deck-comment-reply-row .row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Tabs (fixed bottom nav, thumb-reachable) ── */
.tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  border-top: 1px solid #2d3148; background: #1a1d2e;
  padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 2px; font-size: 10.5px; cursor: pointer; color: #94a3b8;
  border-radius: 8px; white-space: nowrap; }
.tab .tab-icon { font-size: 18px; line-height: 1; }
.tab.active { color: #a78bfa; background: #241f3d; }

/* ── Panes ── */
.pane { display: none; padding: 16px 16px 20px; }
.pane.active { display: block; }
@media (min-width: 640px) { .pane { padding: 20px 24px; } }

/* ── Buttons ── */
button { padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: opacity .15s; }
button:hover:not(:disabled) { opacity: .85; }
button:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary   { background: #7c3aed; color: #fff; }
.btn-secondary { background: #1e2235; border: 1px solid #2d3148; color: #e2e8f0; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-success   { background: #16a34a; color: #fff; }

/* ── Inputs ── */
input[type=text], input[type=password], input[type=number], textarea, select {
  padding: 8px 12px; background: #1e2235; border: 1px solid #2d3148;
  border-radius: 6px; color: #e2e8f0; font-size: 13px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: #a78bfa; }
select { cursor: pointer; }
textarea { width: 100%; resize: vertical; min-height: 60px; }

/* ── Search bar ── */
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
  position: sticky; top: 0; z-index: 20; background: #0f1117; padding: 12px 0 14px; }
.search-bar input[type=text] { flex: 1; min-width: 200px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid #2d3148; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 10px; background: #1a1d2e; color: #94a3b8;
  font-weight: 500; border-bottom: 1px solid #2d3148; position: sticky; top: 0; white-space: nowrap; z-index: 4; }
#pane-search .table-wrap th { top: var(--search-sticky-h, 0px); }
#pane-builder .table-wrap th { top: var(--builder-sticky-h, 0px); }
td { padding: 7px 10px; border-bottom: 1px solid #1e2235; vertical-align: top; }
tr:hover td { background: #1e2235; }

/* ── Mana ── */
.mana { display: inline-flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.mana span { display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.mana-G{background:#15803d;color:#fff} .mana-R{background:#b91c1c;color:#fff}
.mana-U{background:#1d4ed8;color:#fff} .mana-W{background:#d97706;color:#fff}
.mana-B{background:#1f2937;color:#fff;border:1px solid #374151}
.mana-N{background:#374151;color:#d1d5db}

/* ── Rarity badges ── */
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-M{background:#b45309;color:#fde68a} .badge-R{background:#7c3aed;color:#c4b5fd}
.badge-U{background:#065f46;color:#6ee7b7} .badge-C{background:#374151;color:#d1d5db}

/* ── Pagination ── */
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 13px; color: #64748b; flex-wrap: wrap; }

/* ── Scrape pane ── */
.scrape-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.check-group { background: #1a1d2e; border: 1px solid #2d3148; border-radius: 8px; padding: 14px; }
.check-group h3 { font-size: 12px; font-weight: 600; color: #94a3b8; margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .05em; }
.check-group label { display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 3px 0; cursor: pointer; color: #cbd5e1; }
.check-group input[type=checkbox] { accent-color: #7c3aed; }
.select-all { font-size: 11px; color: #a78bfa; cursor: pointer; margin-bottom: 8px; display: block; }
.job-log { background: #0d1117; border: 1px solid #2d3148; border-radius: 6px;
  padding: 10px; font-family: monospace; font-size: 12px; color: #94a3b8;
  max-height: 260px; overflow-y: auto; white-space: pre-wrap; margin-top: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-pending{background:#64748b} .dot-running{background:#f59e0b;animation:pulse 1s infinite}
.dot-done{background:#22c55e} .dot-error{background:#ef4444}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}

/* ── Auth modal ── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 100; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal { background: #1a1d2e; border: 1px solid #2d3148; border-radius: 12px;
  padding: 28px; width: 340px; max-width: 90vw; }
.modal h2 { font-size: 18px; margin-bottom: 20px; color: #e2e8f0; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: #94a3b8; margin-bottom: 6px; }
.form-row input { width: 100%; }
.form-err { color: #f87171; font-size: 12px; margin-top: 8px; min-height: 18px; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.link-btn { background: none; border: none; color: #a78bfa; font-size: 12px;
  cursor: pointer; padding: 0; text-decoration: underline; }

/* ── Decks pane ── */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.deck-card { background: #1a1d2e; border: 1px solid #2d3148; border-radius: 10px; padding: 16px;
  cursor: pointer; transition: border-color .15s; }
.deck-card:hover { border-color: #7c3aed; }
.deck-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.deck-card .meta { font-size: 12px; color: #64748b; display: flex; gap: 10px; margin-bottom: 8px; }
.deck-card .desc { font-size: 12px; color: #94a3b8; }
.public-badge { background: #065f46; color: #6ee7b7; font-size: 10px; padding: 2px 6px;
  border-radius: 4px; font-weight: 600; }
.private-badge { background: #374151; color: #9ca3af; font-size: 10px; padding: 2px 6px;
  border-radius: 4px; font-weight: 600; }
.section-title { font-size: 13px; font-weight: 600; color: #94a3b8; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.divider { height: 1px; background: #2d3148; margin: 20px 0; }

/* ── Clone / Save-as modal ── */
#clone-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:200; align-items:center; justify-content:center; }
#clone-modal.open { display:flex; }
#clone-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; min-width:320px; }
#clone-modal h3 { margin:0 0 16px; font-size:16px; color:#e2e8f0; }
#clone-modal input { width:100%; box-sizing:border-box; margin-bottom:14px; }
#clone-modal .modal-btns { display:flex; gap:8px; justify-content:flex-end; }

#replace-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:200; align-items:center; justify-content:center; }
#replace-modal.open { display:flex; }
#replace-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:400px; max-width:95vw; }
#replace-modal h3 { margin:0 0 10px; font-size:16px; color:#e2e8f0; }
#replace-modal select { width:100%; box-sizing:border-box; }
#replace-modal .modal-btns { display:flex; gap:8px; justify-content:flex-end; margin-top:14px; }

/* ── Starting hand generator ── */
#hand-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:200; align-items:center; justify-content:center; padding:20px; }
#hand-modal.open { display:flex; }
#hand-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:600px; max-width:95vw; max-height:90vh; overflow-y:auto; }
#hand-modal h3 { margin:0 0 6px; font-size:16px; color:#e2e8f0; }
.hand-legend { font-size:11px; color:#64748b; margin-bottom:14px; display:flex; gap:14px; flex-wrap:wrap; }
.hand-legend span { display:inline-flex; align-items:center; gap:4px; }
.hand-auto-toggle { display:flex; align-items:center; gap:7px; font-size:12.5px; color:#c4b5fd; background:#241a3d;
  border:1px solid #4c1d95; border-radius:8px; padding:8px 10px; margin-bottom:14px; cursor:pointer; user-select:none; }
.hand-auto-toggle input { cursor:pointer; }
.hand-good-tag { font-size:11px; font-weight:700; color:#4ade80; background:#0f2e1c; border-radius:6px; padding:1px 8px; margin-left:6px; }
.hand-bad-tag { font-size:11px; font-weight:700; color:#fbbf24; background:#3f2d0a; border-radius:6px; padding:1px 8px; margin-left:6px; }
.hand-status { font-size:13px; color:#94a3b8; margin-bottom:12px; line-height:1.5; }
.hand-status b { color:#e2e8f0; }
.hand-instructions { font-size:12px; color:#fbbf24; margin-bottom:12px; padding:8px 10px; background:#3f2d0a; border-radius:6px; }
.hand-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap:10px; margin-bottom:18px; }
.hand-card { background:#12141f; border:1px solid #2d3148; border-radius:8px; padding:10px; font-size:12px;
  display:flex; flex-direction:column; gap:6px; position:relative; transition:border-color .15s, opacity .15s; }
.hand-card.selectable { cursor:pointer; }
.hand-card.selectable:hover { border-color:#7c3aed; }
.hand-card.selected { border-color:#ef4444; background:#1e1224; opacity:.7; }
.hand-card .hname { font-weight:600; color:#e2e8f0; overflow-wrap:break-word; }
.hand-card .hbadge { font-size:10px; font-weight:700; padding:2px 6px; border-radius:10px; align-self:flex-start; }
.hand-card .hbadge.tier-normal { background:#78350f; color:#fbbf24; }
.hand-card .hbadge.tier-super { background:#4c1d95; color:#c4b5fd; }
.hand-card .putback-check { position:absolute; top:6px; right:6px; font-size:15px; }
.hand-modal-btns { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.hand-empty { font-size:13px; color:#64748b; padding:20px 0; text-align:center; }

/* ── Goldfish mode ── */
.gf-toolbar { touch-action:manipulation; display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.gf-life-box { display:flex; align-items:center; gap:8px; background:#1a1d2e; border:1px solid #2d3148;
  border-radius:10px; padding:8px 12px; }
.gf-life-box .gf-life-label { font-size:11px; color:#94a3b8; text-transform:uppercase; letter-spacing:.05em; min-width:64px; }
.gf-life-box .gf-life-val { font-size:20px; font-weight:700; color:#e2e8f0; min-width:32px; text-align:center; }
.gf-life-btn { touch-action:manipulation; width:26px; height:26px; padding:0; border-radius:50%; background:#2d3148; color:#e2e8f0;
  border:none; font-size:15px; font-weight:700; line-height:1; cursor:pointer; }
.gf-life-btn:hover { background:#3b4162; }
.gf-poison-box .gf-life-val { color:#4ade80; }
.gf-poison-box .gf-life-btn { background:#1e3a2e; }
.gf-poison-box .gf-life-btn:hover { background:#2a5340; }
.gf-turn-badge { font-size:12px; color:#64748b; margin-left:auto; }
.gf-board { touch-action:manipulation; display:flex; flex-direction:column; gap:14px; }
.gf-zone { background:#141726; border:1px solid #2d3148; border-radius:10px; padding:10px 12px; min-width:0; }
.gf-pile-row { display:grid; grid-template-columns: repeat(3, 1fr); gap:14px; }
.gf-zone-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.gf-zone-head h4 { font-size:12px; font-weight:700; color:#94a3b8; text-transform:uppercase; letter-spacing:.05em; }
.gf-zone-count { font-size:11px; color:#64748b; background:#0f1117; border-radius:10px; padding:1px 8px; }
/* Mana pool: six small pips (one per colour + colourless) shown next to a
   player's battlefield header, filled in as lands are tapped for mana and
   cleared at end of turn. */
.gf-mana-pool { display:flex; gap:6px; margin-bottom:8px; }
.gf-mana-pip { width:22px; height:22px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:700; color:#0f1117; border:1px solid rgba(0,0,0,.25); flex:0 0 auto; }
.gf-mana-pip.gf-mana-empty { opacity:.35; }
.gf-mana-pip.gf-mana-W { background:#f4f1e8; }
.gf-mana-pip.gf-mana-U { background:#4aa3e0; color:#0f1117; }
.gf-mana-pip.gf-mana-B { background:#6b6f76; color:#0f1117; }
.gf-mana-pip.gf-mana-R { background:#e0603f; }
.gf-mana-pip.gf-mana-G { background:#4fa876; }
.gf-mana-pip.gf-mana-C { background:#a8adba; }
.gf-mana-undo { width:22px; height:22px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-size:12px; flex:0 0 auto; margin-left:2px; border:1px solid #2d3148; background:#141726; color:#94a3b8;
  cursor:pointer; padding:0; }
.gf-mana-undo:hover:not(:disabled) { border-color:#7c3aed; color:#e2e8f0; }
.gf-mana-undo:disabled { opacity:.25; cursor:default; }
.gf-zone-body { display:flex; flex-wrap:wrap; gap:8px; min-height:56px; }
/* Battlefield: lands sit on their own row below the other permanents, but the
   split has no visible border/background — same gap as between cards, so it
   still reads as one zone. */
.gf-zone-body.gf-bf-body { flex-direction:column; flex-wrap:nowrap; align-items:stretch; }
.gf-bf-row { display:flex; flex-wrap:wrap; gap:8px; }
.gf-bf-row:empty { display:none; }
/* Hand: single horizontal, scrollable row instead of wrapping */
.gf-zone-body.gf-hand-body { flex-wrap:nowrap; overflow-x:auto; padding-bottom:4px; }
.gf-zone-body.gf-hand-body .gf-card { flex:0 0 auto; }
.gf-card { position:relative; background:#1e2235; border:1px solid #2d3148; border-radius:7px;
  padding:8px 9px; font-size:11.5px; width:104px; min-height:60px; cursor:pointer; user-select:none;
  -webkit-user-select:none; -webkit-touch-callout:none; transition:border-color .12s, transform .12s;
  /* Removes the browser's ~300ms delayed "ghost click" after a touch tap.
     Without this, that delayed synthetic click lands at the same screen
     coordinates as the original tap a moment later — which, if a
     colour-choice modal (see #mana-color-modal) has just opened centred
     on the card's position, can silently click through one of its
     buttons before the player ever sees the modal. */
  touch-action:manipulation; }
.gf-card:hover { border-color:#7c3aed; }
.gf-card .gf-cname { font-weight:600; color:#e2e8f0; overflow-wrap:break-word; display:block; margin-bottom:4px; }
.gf-card .gf-cmana { transform:scale(.85); transform-origin:left; }
.gf-card .gf-cmana-modified { display:inline-flex; align-items:center; gap:3px; }
.gf-cost-badge { display:inline-block; font-size:10px; font-weight:800; border-radius:5px; padding:0 5px;
  font-family:ui-monospace,monospace; line-height:1.5; }
.gf-cost-badge-down { color:#bbf7d0; background:#052e16; border:1px solid #16a34a; }
.gf-cost-badge-up { color:#fecaca; background:#450a0a; border:1px solid #dc2626; }
.gf-card .gf-card-stat { display:inline-block; margin-top:3px; font-size:10px; font-weight:700; color:#e2e8f0;
  background:#2d3148; border-radius:5px; padding:1px 6px; font-family:ui-monospace,monospace; }
.gf-card.gf-tapped { border-color:#eab308; transform:rotate(6deg); }
.gf-card.gf-attacking { border-color:#dc2626; box-shadow:0 0 0 1px #dc2626; }
.gf-card.gf-mage { cursor:pointer; }
.gf-card.gf-blockable { cursor:grab; }
.gf-card.gf-blockable:active { cursor:grabbing; }
.gf-card.gf-attack-target { box-shadow:0 0 0 2px #f59e0b; }
.gf-card.gf-attack-eligible { cursor:pointer; box-shadow:0 0 0 1px #4ade80; }
/* Battlefield cards in playtest are dragged (blocker assignment, manual
   arrows) via gfCardPointerDown()'s pointer/touch handlers. The base
   .gf-card touch-action:manipulation above still lets the browser start a
   native vertical pan on the same gesture (it only suppresses double-tap
   zoom, not panning), which raced against the JS drag on mobile — a finger
   moving up to drop a blocker on a card above would scroll the page instead
   of/along with dragging the arrow. touch-action:none hands the whole
   gesture to JS, so no native scroll competes with the drag. */
.gf-card.gf-draggable { touch-action:none; }
.gf-damage-badge { position:absolute; bottom:-8px; left:-8px; background:#7f1d1d; color:#fecaca; font-size:10px;
  font-weight:700; padding:1px 5px; border-radius:8px; border:1px solid #dc2626; }
.gf-card .gf-keyword-badges { display:block; margin-top:3px; }
.gf-card .gf-kw-badge { display:inline-block; margin:0 2px 2px 0; font-size:9px; font-weight:800; color:#c4b5fd;
  background:#241a3d; border:1px solid #4c1d95; border-radius:4px; padding:0 5px; font-family:ui-monospace,monospace; }
.gf-card .gf-counter-badge { display:inline-block; margin:3px 3px 0 0; font-size:10px; font-weight:800; color:#bbf7d0;
  background:#052e16; border:1px solid #16a34a; border-radius:5px; padding:0 6px; font-family:ui-monospace,monospace; }
.gf-card .gf-counter-badge-minus { color:#fecaca; background:#450a0a; border-color:#dc2626; }
.gf-card .gf-counter-badge-aion { color:#bfdbfe; background:#0c1e3d; border-color:#2563eb; }
.gf-card .gf-counter-badge-charge { color:#fde68a; background:#422006; border-color:#d97706; }
.gf-card .gf-counter-badge-quest { color:#fecdd3; background:#450a1a; border-color:#be123c; }
.gf-card .gf-counter-badge { display:inline-block; margin-top:3px; font-size:10px; font-weight:700; color:#bbf7d0;
  background:#14532d; border:1px solid #16a34a; border-radius:5px; padding:1px 6px; font-family:ui-monospace,monospace; }

#mentor-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#mentor-modal.open { display:flex; }
#mentor-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:360px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#mentor-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#mentor-modal .mentor-modal-options { display:flex; flex-direction:column; gap:8px; }
#mentor-modal .mentor-modal-options button { background:#241a3d; border:1px solid #4c1d95; color:#e2e8f0;
  border-radius:8px; padding:8px 12px; font-size:13px; cursor:pointer; text-align:left; }
#mentor-modal .mentor-modal-options button:hover { border-color:#7c3aed; }

#discover-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#discover-modal.open { display:flex; }
#discover-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:420px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#discover-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#discover-modal .discover-modal-options { display:flex; flex-direction:column; gap:8px; }
#discover-modal .discover-option { display:block; width:100%; text-align:left; background:#0f2e3d; border:1px solid #1d6b8f; color:#e2e8f0;
  border-radius:8px; padding:10px 12px; cursor:pointer; font:inherit; }
#discover-modal .discover-option:hover { border-color:#38bdf8; }
#discover-modal .discover-option-name { font-weight:700; margin-bottom:2px; }
#discover-modal .discover-option-mana { margin-bottom:4px; }
#discover-modal .discover-option-type { font-size:11px; color:#94a3b8; margin-bottom:4px; }
#discover-modal .discover-option-desc { font-size:12px; color:#cbd5e1; }

.gf-phase-bar { touch-action:manipulation; display:none; align-items:center; gap:10px; flex-wrap:wrap; background:#141726; border:1px solid #2d3148;
  border-radius:10px; padding:10px 14px; margin-bottom:4px; position:-webkit-sticky; position:sticky; top:0; z-index:55; }
.gf-phase-steps { display:flex; align-items:center; gap:6px; flex-wrap:wrap; font-size:12px; }
.gf-phase-step { padding:5px 10px; border-radius:6px; background:#1a1d2e; color:#64748b; font-weight:600; white-space:nowrap; }
.gf-phase-step.active { background:#241a3d; color:#e2e8f0; border:1px solid #7c3aed; }
.gf-phase-arrow-sep { color:#3b4162; }
.gf-phase-turn-label { flex-basis:100%; margin-left:0; font-size:12px; color:#94a3b8; }
.gf-phase-hint { flex-basis:100%; font-size:11.5px; color:#64748b; }

/* Compact top-corner HUD, mobile-only (see max-width:859.98px block below):
   replaces the 4-step row + turn label above with a single "N/4 - Phase X"
   pill top-left and the turn/active-player pill top-right, both pinned to
   the true top of the screen (position:fixed) so they stay visible no
   matter how far down the board is scrolled. Hidden here so nothing shows
   on desktop, where the fuller versions above remain inline in the bar. */
.gf-phase-mini, .gf-turn-mini, .gf-life-mini, .gf-poison-mini, .gf-life-wheel, .gf-poison-wheel { display: none; }

/* Token/arrow buttons: inline (as before) on desktop, tucked behind the "⋯"
   toggle on mobile — see the max-width:859.98px block below. `display:
   contents` makes the wrapper itself invisible to layout, so on desktop
   these four buttons sit directly among their .gf-phase-bar siblings. */
.gf-phase-more-menu { display: contents; }
.gf-phase-more-btn { display: none; }

/* Help-hint toggle next to the mode label: hidden on desktop, where the
   hint text below it is just always shown (see max-width:859.98px block). */
.gf-help-toggle { display: none; }
.gf-controls-hint { font-size:12px; color:#64748b; margin-top:4px; }

/* Journal ("📜") toggle next to the mode label: unlike .gf-help-toggle
   above, this one has no desktop equivalent to fall back on — the journal
   panel is opened either by this button (desktop) or by swiping in from
   the left edge (mobile, see index.html's comment above #gf-journal-panel
   and the swipe listeners at the end of goldfish-ui.js) — so it must stay
   visible on every viewport width, not just inside the max-width:859.98px
   block below where .gf-help-toggle reappears. Same visual treatment as
   that block gives .gf-help-toggle, just not gated behind the media query. */
.gf-journal-toggle { display: inline-flex; align-items:center; justify-content:center;
  width:20px; height:20px; border-radius:50%; border:1px solid #2d3148; background:#1e2235;
  color:#94a3b8; font-size:11px; padding:0; margin-left:6px; cursor:pointer; vertical-align:middle; }
.gf-journal-toggle.open { background:#241f3d; border-color:#7c3aed; color:#e2e8f0; }
#gf-arrow-mode-btn.active { background:#0c4a6e; border-color:#38bdf8; color:#e0f2fe; }
.gf-card.gf-arrow-picked { box-shadow:0 0 0 2px #38bdf8; }

.gf-toast { position:fixed; left:50%; bottom:24px; transform:translateX(-50%) translateY(20px); background:#1a1d2e;
  border:1px solid #7c3aed; color:#e2e8f0; padding:10px 16px; border-radius:8px; font-size:13px; z-index:200;
  opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; max-width:80vw; text-align:center; }
.gf-toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* ── Game over modal (Playtest — win/loss end conditions) ── */
/* ═══ Playtest journal panel — desktop: 📜 button next to the pane title;
   mobile: swipe right from the left screen edge (see the touchstart/
   touchend listeners at the end of goldfish-ui.js). Slides in from the
   left rather than a centered .modal-box like every other dialog here —
   a running text log reads better as a tall narrow strip than a centered
   box. Same overlay+.open convention as the other modals otherwise. ═══ */
#gf-journal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:340; }
#gf-journal-overlay.open { display:block; }
#gf-journal-panel {
  position:fixed; top:0; left:0; height:100%; width:380px; max-width:88vw;
  background:#12141f; border-right:1px solid #2d3148; z-index:341;
  display:flex; flex-direction:column; transform:translateX(-100%);
  transition:transform .22s ease; box-shadow:2px 0 24px rgba(0,0,0,.4);
}
#gf-journal-panel.open { transform:translateX(0); }
.gf-journal-panel-header { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid #2d3148; flex-shrink:0; }
.gf-journal-panel-header h3 { margin:0; font-size:15px; color:#e2e8f0; }
.gf-journal-panel-body { flex:1; overflow-y:auto; margin:0; padding:12px 16px; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:12.5px; line-height:1.55; color:#cbd5e1; white-space:pre-wrap; word-break:break-word; }
.gf-journal-panel-footer { padding:10px 16px; border-top:1px solid #2d3148; flex-shrink:0; }

#match-log-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.72); z-index:320; align-items:center; justify-content:center; }
#match-log-modal.open { display:flex; }
#match-log-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:560px; max-width:95vw; max-height:85vh; display:flex; flex-direction:column; }

#gf-gameover-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.72); z-index:300;
  align-items:center; justify-content:center; padding:20px; }
#gf-gameover-modal.open { display:flex; }
#gf-gameover-modal .modal-box { background:#1a1d2e; border:2px solid #2d3148; border-radius:14px; padding:30px;
  width:420px; max-width:95vw; text-align:center; }
#gf-gameover-modal.gf-gameover-win .modal-box { border-color:#22c55e; box-shadow:0 0 40px rgba(34,197,94,.25); }
#gf-gameover-modal.gf-gameover-lose .modal-box { border-color:#ef4444; box-shadow:0 0 40px rgba(239,68,68,.25); }
#gf-gameover-title { margin:0 0 6px; font-size:26px; font-weight:800; color:#e2e8f0; }
#gf-gameover-modal.gf-gameover-win #gf-gameover-title { color:#4ade80; }
#gf-gameover-modal.gf-gameover-lose #gf-gameover-title { color:#f87171; }
#gf-gameover-subtitle { margin:0 0 16px; font-size:15px; color:#cbd5e1; font-weight:600; }
#gf-gameover-reason { font-size:13px; color:#94a3b8; margin-bottom:14px; line-height:1.5; }
#gf-gameover-score { font-size:12.5px; color:#64748b; margin-bottom:22px; padding:10px; background:#12141f;
  border-radius:8px; border:1px solid #2d3148; }
#gf-gameover-modal .modal-footer { justify-content:center; gap:10px; margin-top:0; }
#gf-gameover-modal .modal-footer + .modal-footer { margin-top:12px; }

#gf-block-arrows { position:fixed; top:0; left:0; pointer-events:none; z-index:60; }
.gf-card .gf-loyalty-badge { display:inline-block; margin-top:3px; font-size:11px; font-weight:800; color:#f5d0fe;
  background:#4c1d95; border-radius:5px; padding:1px 7px; font-family:ui-monospace,monospace; }
.gf-loyalty-click { display:inline-block; padding:1px 6px; margin:2px 2px 2px 0; border-radius:5px;
  background:#2d3148; color:#e2e8f0; font-weight:700; cursor:pointer; user-select:none; }
.gf-loyalty-click:hover { background:#7c3aed; color:#fff; }
.gf-loyalty-current { font-size:14px; font-weight:800; color:#f5d0fe; background:#4c1d95; border-radius:6px;
  padding:2px 10px; display:inline-block; margin-bottom:10px; font-family:ui-monospace,monospace; }
.gf-tap-mark { position:absolute; top:-8px; right:-8px; width:24px; height:24px; border-radius:50%;
  background:#dc2626; color:#fff; font-weight:800; font-size:14px; display:flex; align-items:center;
  justify-content:center; box-shadow:0 0 0 2px #141726; }
.gf-attack-mark { position:absolute; top:-8px; right:-8px; width:24px; height:24px; border-radius:50%;
  background:#b91c1c; color:#fff; font-weight:800; font-size:13px; display:flex; align-items:center;
  justify-content:center; box-shadow:0 0 0 2px #141726, 0 0 0 4px rgba(220,38,38,.35); }
.gf-secret-mark { position:absolute; bottom:-8px; right:-8px; width:24px; height:24px; border-radius:50%;
  background:#7c3aed; color:#fff; font-weight:800; font-size:13px; display:flex; align-items:center;
  justify-content:center; box-shadow:0 0 0 2px #141726, 0 0 0 4px rgba(124,58,237,.35); }
.gf-stack-badge { position:absolute; top:-8px; left:-8px; min-width:24px; height:24px; padding:0 5px; border-radius:12px;
  background:#7c3aed; color:#fff; font-weight:800; font-size:11px; display:flex; align-items:center;
  justify-content:center; box-shadow:0 0 0 2px #141726; }
.gf-library-card { width:104px; min-height:60px; border-radius:7px; background:linear-gradient(135deg,#2d3148,#1a1d2e);
  border:1px solid #3b4162; display:flex; align-items:center; justify-content:center; flex-direction:column;
  gap:2px; font-size:11px; color:#94a3b8; cursor:context-menu; }
.gf-library-card b { font-size:18px; color:#e2e8f0; }
.gf-empty-zone { font-size:11.5px; color:#3a3f55; padding:6px 2px; }

/* Small context menu for moving a card between zones */
#gf-card-menu { position:fixed; z-index:195; display:none; background:#1a1d2e; border:1px solid #2d3148;
  border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.4); padding:6px; min-width:170px; }
#gf-card-menu.open { display:block; }
#gf-card-menu .gf-menu-title { font-size:11px; color:#64748b; padding:4px 8px 6px; border-bottom:1px solid #2d3148; margin-bottom:4px; }
#gf-card-menu button { display:block; width:100%; text-align:left; background:none; border:none; color:#e2e8f0;
  padding:7px 8px; border-radius:6px; font-size:12.5px; cursor:pointer; }
#gf-card-menu button:hover { background:#2d3148; }
.gf-menu-topx { display:flex; align-items:center; gap:6px; flex-wrap:wrap; padding:8px 8px 4px; margin-top:4px;
  border-top:1px solid #2d3148; font-size:11.5px; color:#e2e8f0; }
.gf-menu-topx input { width:44px; background:#0f1117; border:1px solid #2d3148; border-radius:6px;
  color:#e2e8f0; padding:4px 5px; text-align:center; font-size:12px; }
.gf-menu-topx button { display:inline-block; width:auto; padding:4px 10px; background:#7c3aed; color:#fff; }
.gf-menu-topx button:hover { background:#6d28d9; }

.gf-card.gf-token { border-style:dashed; border-color:#c084fc; }
.gf-token-badge { display:inline-block; font-size:9px; font-weight:700; color:#c084fc; background:#2e1065;
  border-radius:8px; padding:1px 6px; margin-bottom:3px; }
.gf-card .gf-ctext { display:block; color:#94a3b8; font-size:10.5px; margin-top:3px; overflow-wrap:break-word; }

/* Token creation modal */
#token-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#token-modal.open { display:flex; }
#token-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:420px; max-width:95vw; }
#token-modal h3 { margin:0 0 16px; font-size:16px; color:#e2e8f0; }
#token-modal input, #token-modal textarea { width:100%; margin-bottom:14px; }
#token-modal textarea { min-height:70px; }

#land-fetch-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#land-fetch-modal.open { display:flex; }
#land-fetch-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:360px; max-width:95vw; }
#land-fetch-modal h3 { margin:0 0 8px; font-size:16px; color:#e2e8f0; }

#mana-color-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#mana-color-modal.open { display:flex; }
#mana-color-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:340px; max-width:95vw; }
#mana-color-modal h3 { margin:0 0 8px; font-size:16px; color:#e2e8f0; }

#sac-discard-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#sac-discard-modal.open { display:flex; }
#sac-discard-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:360px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#sac-discard-modal h3 { margin:0 0 8px; font-size:16px; color:#e2e8f0; }

#random-destroy-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#random-destroy-modal.open { display:flex; }
#random-destroy-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#random-destroy-modal h3 { margin:0 0 8px; font-size:16px; color:#e2e8f0; }


#card-edit-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#card-edit-modal.open { display:flex; }
#card-edit-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:420px; max-width:95vw; }
#card-edit-modal h3 { margin:0 0 10px; font-size:16px; color:#e2e8f0; }
#card-edit-modal textarea { width:100%; min-height:90px; margin-bottom:14px; }

/* Card description modal (Goldfish mode — "Voir la description" from the card menu) */
#card-desc-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#card-desc-modal.open { display:flex; }
#card-desc-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px;
  width:420px; max-width:95vw; max-height:80vh; display:flex; flex-direction:column; }
#card-desc-modal h3 { margin:0 0 12px; font-size:16px; color:#e2e8f0; }
.card-desc-modal-body { font-size:13px; color:#cbd5e1; line-height:1.6; margin-bottom:14px; overflow-y:auto; }
.gf-desc-type { font-size:11px; font-weight:600; color:#a78bfa; text-transform:uppercase; letter-spacing:.04em; margin-bottom:8px; }

/* Quantity prompt modal (Goldfish mode — "how many copies?" for stacked battlefield cards) */
#pt-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#pt-modal.open { display:flex; }
#pt-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:360px; max-width:95vw; }
#pt-modal h3 { margin:0 0 14px; font-size:16px; color:#e2e8f0; }
#pt-modal .pt-modal-row { margin-bottom:12px; }
#pt-modal .pt-modal-row label { display:block; font-size:12px; color:#94a3b8; margin-bottom:4px; }
#pt-modal select, #pt-modal input[type="number"] { width:100%; }
#pt-modal .pt-modal-deltas { display:flex; gap:10px; }
#pt-modal .pt-modal-deltas > div { flex:1; }
#pt-modal .pt-modal-check { display:flex; align-items:center; gap:8px; font-size:13px; color:#cbd5e1; margin-bottom:10px; cursor:pointer; }
#pt-modal .pt-modal-check input { width:auto; }
#pt-modal .pt-modal-err { color:#f87171; font-size:12px; min-height:16px; margin-bottom:4px; }

#kw-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#kw-modal.open { display:flex; }
#kw-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:360px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#kw-modal h3 { margin:0 0 14px; font-size:16px; color:#e2e8f0; }
#kw-modal .pt-modal-row { margin-bottom:12px; }
#kw-modal .pt-modal-row label { display:block; font-size:12px; color:#94a3b8; margin-bottom:4px; }
#kw-modal select { width:100%; }
#kw-modal .pt-modal-check { display:flex; align-items:center; gap:8px; font-size:13px; color:#cbd5e1; margin-bottom:10px; cursor:pointer; }
#kw-modal .pt-modal-check input { width:auto; }
#kw-modal .pt-modal-err { color:#f87171; font-size:12px; min-height:16px; margin-bottom:4px; }
#kw-modal .kw-modal-list { display:flex; flex-direction:column; gap:6px; max-height:260px; overflow-y:auto; padding:8px; background:#12141f; border:1px solid #2d3148; border-radius:8px; }
#kw-modal .kw-modal-list label { display:flex; align-items:center; gap:8px; font-size:13px; color:#e2e8f0; cursor:pointer; margin:0; }
#kw-modal .kw-modal-list input { width:auto; }

#gf-discard-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-discard-modal.open { display:flex; }
#gf-discard-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-discard-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-discard-modal .gf-discard-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-discard-modal .gf-discard-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#241a1a; border:1px solid #7c2d2d; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-discard-modal .gf-discard-modal-list button:hover { border-color:#ef4444; }

#gf-loot-discard-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-loot-discard-modal.open { display:flex; }
#gf-loot-discard-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-loot-discard-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-loot-discard-modal .gf-discard-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-loot-discard-modal .gf-discard-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#241a1a; border:1px solid #7c2d2d; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-loot-discard-modal .gf-discard-modal-list button:hover { border-color:#ef4444; }

#gf-mage-discard-draw-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-mage-discard-draw-modal.open { display:flex; }
#gf-mage-discard-draw-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-mage-discard-draw-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-mage-discard-draw-modal .gf-discard-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-mage-discard-draw-modal .gf-discard-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#241a1a; border:1px solid #7c2d2d; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-mage-discard-draw-modal .gf-discard-modal-list button:hover { border-color:#ef4444; }

#gf-copy-hand-card-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-copy-hand-card-modal.open { display:flex; }
#gf-copy-hand-card-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-copy-hand-card-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-copy-hand-card-modal .gf-discard-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-copy-hand-card-modal .gf-discard-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#241a1a; border:1px solid #7c2d2d; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-copy-hand-card-modal .gf-discard-modal-list button:hover { border-color:#ef4444; }

#gf-library-search-hand-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-library-search-hand-modal.open { display:flex; }
#gf-library-search-hand-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-library-search-hand-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-library-search-hand-modal .gf-discard-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-library-search-hand-modal .gf-discard-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#241a1a; border:1px solid #7c2d2d; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-library-search-hand-modal .gf-discard-modal-list button:hover { border-color:#ef4444; }

#gf-bottom-library-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-bottom-library-modal.open { display:flex; }
#gf-bottom-library-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-bottom-library-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-bottom-library-modal .gf-discard-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-bottom-library-modal .gf-discard-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#241a1a; border:1px solid #7c2d2d; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-bottom-library-modal .gf-discard-modal-list button:hover { border-color:#ef4444; }

#gf-mage-return-lands-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-mage-return-lands-modal.open { display:flex; }
#gf-mage-return-lands-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-mage-return-lands-modal h3 { margin:0 0 8px; font-size:15px; color:#e2e8f0; }

#gf-return-ephemere-ritual-exile-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-return-ephemere-ritual-exile-modal.open { display:flex; }
#gf-return-ephemere-ritual-exile-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-return-ephemere-ritual-exile-modal h3 { margin:0 0 8px; font-size:15px; color:#e2e8f0; }

#gf-mage-destroy-nonlands-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-mage-destroy-nonlands-modal.open { display:flex; }
#gf-mage-destroy-nonlands-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-mage-destroy-nonlands-modal h3 { margin:0 0 8px; font-size:15px; color:#e2e8f0; }

#gf-sacrifice-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-sacrifice-modal.open { display:flex; }
#gf-sacrifice-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-sacrifice-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-sacrifice-modal .gf-sacrifice-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-sacrifice-modal .gf-sacrifice-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#241a1a; border:1px solid #7c2d2d; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-sacrifice-modal .gf-sacrifice-modal-list button:hover { border-color:#ef4444; }

#gf-land-search-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-land-search-modal.open { display:flex; }
#gf-land-search-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:380px; max-width:95vw; max-height:85vh; overflow-y:auto; }
#gf-land-search-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; }
#gf-land-search-modal .gf-sacrifice-modal-list { display:flex; flex-direction:column; gap:8px; }
#gf-land-search-modal .gf-sacrifice-modal-list button { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#1a2a1f; border:1px solid #2d7c4a; color:#e2e8f0; border-radius:8px; padding:10px 12px; font-size:13px; cursor:pointer; text-align:left; }
#gf-land-search-modal .gf-sacrifice-modal-list button:hover { border-color:#22c55e; }

#gf-qty-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:220; align-items:center; justify-content:center; padding:20px; }
#gf-qty-modal.open { display:flex; }
#gf-qty-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px; width:320px; max-width:95vw; }
#gf-qty-modal h3 { margin:0 0 14px; font-size:15px; color:#e2e8f0; font-weight:600; }
#gf-qty-modal input { width:100%; margin-bottom:6px; text-align:center; font-size:16px; }
.gf-qty-hint { font-size:11.5px; color:#64748b; margin-bottom:14px; }

/* Library viewer modal (Regarder toute la bibliothèque / les X premières cartes) */
#gf-library-view-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#gf-library-view-modal.open { display:flex; }
#gf-library-view-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px;
  width:520px; max-width:95vw; max-height:80vh; display:flex; flex-direction:column; }
#gf-library-view-modal h3 { margin:0 0 14px; font-size:16px; color:#e2e8f0; }
.gf-lv-search { width:100%; box-sizing:border-box; background:#141726; border:1px solid #2d3148; border-radius:8px;
  color:#e2e8f0; font-size:13px; padding:8px 10px; margin-bottom:10px; }
.gf-lv-search:focus { outline:none; border-color:#7c3aed; }
.gf-lv-search::placeholder { color:#6b7280; }
.gf-library-view-list { overflow-y:auto; display:flex; flex-direction:column; gap:8px; margin-bottom:14px; flex:1; }
.gf-lv-row { display:flex; align-items:center; justify-content:space-between; gap:10px; background:#141726;
  border:1px solid #2d3148; border-radius:8px; padding:8px 10px; }
.gf-lv-info { display:flex; flex-direction:column; gap:2px; font-size:12.5px; color:#e2e8f0; min-width:0; }
.gf-lv-actions { display:flex; gap:4px; flex-wrap:wrap; flex-shrink:0; }
.gf-lv-actions button { font-size:11px; padding:4px 8px; border-radius:6px; border:none; background:#2d3148;
  color:#e2e8f0; cursor:pointer; }
.gf-lv-actions button:hover { background:#3b4162; }
.gf-lv-actions button.gf-scry-chosen { background:#7c3aed; color:#fff; font-weight:600; }
.gf-lv-actions button.gf-scry-chosen:hover { background:#7c3aed; }

/* Playtest opponent-deck picker modal */
#playtest-deck-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:210; align-items:center; justify-content:center; padding:20px; }
#playtest-deck-modal.open { display:flex; }
#playtest-deck-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px;
  width:560px; max-width:95vw; max-height:85vh; display:flex; flex-direction:column; }
#playtest-deck-modal h3 { margin:0 0 4px; font-size:16px; color:#e2e8f0; }
#playtest-deck-modal .sub { font-size:12px; color:#64748b; margin-bottom:14px; }
#playtest-deck-list { overflow-y:auto; display:flex; flex-direction:column; gap:14px; flex:1; margin-bottom:14px; }
.pt-deck-group h4 { margin:0 0 8px; font-size:12px; color:#94a3b8; text-transform:uppercase; letter-spacing:.05em; }
.pt-deck-row { display:flex; align-items:center; justify-content:space-between; gap:10px; background:#141726;
  border:1px solid #2d3148; border-radius:8px; padding:9px 12px; cursor:pointer; }
.pt-deck-row:hover { border-color:#7c3aed; }
.pt-deck-row .name { font-size:13px; font-weight:600; color:#e2e8f0; }
.pt-deck-row .meta { font-size:11px; color:#64748b; margin-top:2px; }

.pt-mode-toggle { display:flex; gap:8px; margin-bottom:10px; }
.pt-mode-btn { flex:1; padding:9px 10px; border-radius:8px; border:1px solid #2d3148; background:#141726;
  color:#94a3b8; font-size:12.5px; font-weight:600; cursor:pointer; text-align:center; }
.pt-mode-btn:hover { border-color:#7c3aed; color:#e2e8f0; }
.pt-mode-btn.active { border-color:#7c3aed; background:#241a3d; color:#e2e8f0; }
#pt-mode-desc { margin-top:-6px; }

#bot-config-modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:230; align-items:center; justify-content:center; padding:20px; }
#bot-config-modal.open { display:flex; }
#bot-config-modal .modal-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:12px; padding:24px;
  width:480px; max-width:95vw; max-height:88vh; display:flex; flex-direction:column; overflow-y:auto; }
#bot-config-modal h3 { margin:0 0 6px; font-size:16px; color:#e2e8f0; }
#bot-config-modal .sub { font-size:12px; color:#64748b; margin-bottom:16px; line-height:1.5; }
.bot-config-profile-row { display:flex; align-items:flex-end; gap:8px; margin-bottom:16px; }
.bot-config-profile-row select { width:100%; }
.bot-config-profile-actions { display:flex; gap:6px; }
.bot-config-profile-actions button { padding:7px 9px; font-size:13px; }
.bot-config-fields { display:flex; flex-direction:column; gap:12px; margin-bottom:16px; }
.bot-config-field { background:#141726; border:1px solid #2d3148; border-radius:8px; padding:10px 12px; }
.bot-config-field-top { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:4px; }
.bot-config-field-top label { font-size:13px; color:#e2e8f0; font-weight:600; }
.bot-config-field-top input[type="number"] { width:70px; text-align:center; margin:0; }
.bot-config-field-hint { font-size:11px; color:#64748b; line-height:1.4; }
.bot-config-new-row { display:flex; gap:8px; margin-bottom:6px; }
.bot-config-new-row input { flex:1; margin:0; }
.bot-config-strategy-text { width:100%; box-sizing:border-box; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:12px; line-height:1.5; margin-bottom:10px; resize:vertical; }
.bot-strategy-box { border:1px solid var(--border,#334155); border-radius:8px; padding:12px 14px; margin-bottom:14px; }
.bot-strategy-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.bot-strategy-row label { font-size:13px; font-weight:600; color:#e2e8f0; margin-right:4px; }
.bot-strategy-row select { flex:0 1 260px; }
.bot-strategy-box .sub { font-size:12px; color:#64748b; margin:6px 0 10px; }

/* Opponent hand hidden behind a face-down pile in Bot mode */
.gf-hidden-hand-note { font-size:10px; color:#64748b; text-align:center; margin-top:2px; }

/* Playtest opponent board — mirrors the player's board above it */
#gf-opp-board { display:none; flex-direction:column; gap:14px; margin-bottom:14px; padding-bottom:14px;
  border-bottom:1px dashed #2d3148; }
#gf-opp-actions { display:none; }

@media (max-width: 640px) {
  .gf-pile-row { gap:10px; }
}
/* Playtest mode (mobile only): the bottom quick-nav isn't needed while a
   game is on the board, so hide it and give its spot at the bottom of the
   screen to the phase/life bar instead (normally sticky at the top) — a
   little extra vertical room where it matters most on small screens. Left
   untouched above the 860px table/mobile-card-list breakpoint used
   elsewhere in this file, since desktop has room to spare. Body class is
   toggled from JS — see gfSyncPhaseBarHeight()/the MutationObserver in
   goldfish-bot-arrows.js. */
@media (max-width: 859.98px) {
  body.gf-playtest-active .tabs { display: none; }
  body.gf-playtest-active { padding-bottom: 0; }
  body.gf-playtest-active .gf-phase-bar {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    z-index: 60; border-radius: 0; margin-bottom: 0;
    border-left: none; border-right: none; border-bottom: none;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  /* padding-bottom reserves room so the fixed bottom bar doesn't cover the
     last row of cards (--gf-phase-bar-h tracked live by gfSyncPhaseBarHeight());
     padding-top does the same for the two fixed top HUD rows below (phase/
     turn/life, then poison), so "← Retour au deck" and the mode title
     aren't hidden under them when scrolled to the very top. */
  body.gf-playtest-active #pane-goldfish { padding-bottom: var(--gf-phase-bar-h, 160px); padding-top: calc(72px + env(safe-area-inset-top)); }

  /* Replace the 4-step row and turn label inside the bottom bar with the
     compact top-corner HUD below — they were the two biggest space users
     in the bar (the step row wraps across 4 badges + arrows, the turn
     label always claimed its own full-width line). Life and poison totals
     move up here too (see .gf-life-mini/.gf-poison-mini below), so the
     boxes that used to carry them in the bar/toolbar are hidden as well. */
  body.gf-playtest-active .gf-phase-steps,
  body.gf-playtest-active .gf-phase-turn-label,
  body.gf-playtest-active .gf-phase-bar > .gf-life-box,
  body.gf-playtest-active .gf-toolbar > .gf-poison-box { display: none; }
  body.gf-playtest-active .gf-phase-mini,
  body.gf-playtest-active .gf-turn-mini {
    display: block; position: fixed; top: calc(8px + env(safe-area-inset-top));
    z-index: 62; font-size: 11.5px; font-weight: 600; color: #e2e8f0;
    background: rgba(20,23,38,.92); border: 1px solid #2d3148; border-radius: 999px;
    padding: 5px 11px; max-width: 34vw; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  }
  body.gf-playtest-active .gf-phase-mini { left: 10px; }
  body.gf-playtest-active .gf-turn-mini { right: 10px; text-align: right; }

  /* Life totals: a small "20 - 20" pill centered on the same top row as the
     phase/turn pills either side of it. Each number is independently
     tappable (see gfToggleLifeWheel() in goldfish-bot-arrows.js) and the
     side whose turn it currently is gets highlighted, so you can read who's
     ahead/behind at a glance without needing the labels the old boxes had. */
  body.gf-playtest-active .gf-life-mini {
    display: block; position: fixed; top: calc(8px + env(safe-area-inset-top));
    left: 50%; transform: translateX(-50%); z-index: 62;
    background: rgba(20,23,38,.92); border: 1px solid #2d3148; border-radius: 999px;
    padding: 5px 10px; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  }
  .gf-life-mini-val { font-size: 13px; font-weight: 700; color: #64748b; padding: 2px 4px; cursor: pointer; }
  .gf-life-mini-val.active-turn { color: #e2e8f0; }
  .gf-life-mini-sep { font-size: 12px; color: #3b4162; padding: 0 1px; }

  /* Poison totals: same idea as the life pill, directly below it, in green
     with ☠ as the separator instead of "-". Tapping a number opens the same
     kind of wheel (see gfTogglePoisonWheel() in goldfish-bot-arrows.js). */
  body.gf-playtest-active .gf-poison-mini {
    display: block; position: fixed; top: calc(40px + env(safe-area-inset-top));
    left: 50%; transform: translateX(-50%); z-index: 62;
    background: rgba(20,23,38,.92); border: 1px solid #2d3148; border-radius: 999px;
    padding: 3px 9px; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  }
  .gf-poison-mini-val { font-size: 11.5px; font-weight: 700; color: #15803d; padding: 2px 4px; cursor: pointer; }
  .gf-poison-mini-val.active-turn { color: #4ade80; }
  .gf-poison-mini-sep { font-size: 10.5px; color: #166534; padding: 0 1px; }

  /* Life picker wheel: opened by tapping either number above. Current life
     in the middle, +1 above, -1 below — tap either to apply immediately via
     gfLifeWheelStep(), which re-renders the wheel around the new value so
     several taps in a row can move the total further without reopening.
     Stays open until a tap lands outside it (see the outside-click handler
     in goldfish-bot-arrows.js). */
  body.gf-playtest-active .gf-life-wheel.open {
    display: block; position: fixed; top: calc(42px + env(safe-area-inset-top));
    left: 50%; transform: translateX(-50%); z-index: 63; text-align: center;
    background: #141726; border: 1px solid #2d3148; border-radius: 14px;
    padding: 6px 0; min-width: 130px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  }
  /* Same wheel, positioned below the poison row instead — gfPoisonWheelStep()
     mirrors gfLifeWheelStep() but goes through gfPoisonChange(), which
     clamps at 0 same as the "-" button the wheel replaces. */
  body.gf-playtest-active .gf-poison-wheel.open {
    display: block; position: fixed; top: calc(74px + env(safe-area-inset-top));
    left: 50%; transform: translateX(-50%); z-index: 63; text-align: center;
    background: #141726; border: 1px solid #2d3148; border-radius: 14px;
    padding: 6px 0; min-width: 130px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  }
  .gf-life-wheel-label { font-size: 10.5px; color: #64748b; padding: 2px 16px 6px; margin-bottom: 4px; border-bottom: 1px solid #2d3148; }
  .gf-life-wheel-row { padding: 8px 22px; }
  .gf-life-wheel-step { font-size: 15px; font-weight: 700; color: #94a3b8; cursor: pointer; }
  .gf-life-wheel-step:active { background: #1e2235; }
  .gf-life-wheel-current { font-size: 23px; font-weight: 700; color: #e2e8f0; cursor: default; }
  #gf-poison-wheel .gf-life-wheel-current { color: #4ade80; }

  /* Token/arrow buttons collapse into a "⋯" overflow menu instead of sitting
     inline in the bar — they're used far less often than phase/life
     controls, so they don't need permanent bottom-bar space. Opens upward
     since the bar itself is pinned to the bottom of the screen here. */
  .gf-phase-more-btn { display: inline-flex; align-items:center; justify-content:center;
    width:34px; height:34px; padding:0; font-size:18px; line-height:1; flex-shrink:0; }
  .gf-phase-more-btn.open { background:#2d3148; }
  .gf-phase-more-menu { display: none; flex-direction: column; gap:6px;
    position: absolute; right:14px; bottom: 100%; margin-bottom:8px;
    background:#1a1d2e; border:1px solid #2d3148; border-radius:10px; padding:8px;
    min-width:180px; box-shadow:0 8px 24px rgba(0,0,0,.45); z-index:61; }
  .gf-phase-more-menu.open { display: flex; }
  .gf-phase-more-menu button { width:100%; text-align:left; }

  /* Controls hint collapses behind the "❔" toggle instead of always
     showing — worth reading once, not permanent real estate every turn. */
  .gf-help-toggle { display: inline-flex; align-items:center; justify-content:center;
    width:20px; height:20px; border-radius:50%; border:1px solid #2d3148; background:#1e2235;
    color:#94a3b8; font-size:11px; padding:0; margin-left:6px; cursor:pointer; vertical-align:middle; }
  .gf-help-toggle.open { background:#241f3d; border-color:#7c3aed; color:#e2e8f0; }
  .gf-controls-hint { display: none; }
  .gf-controls-hint.open { display: block; }
}

@media (max-width: 480px) {
  /* Keep Bibliothèque / Cimetière / Exil on one row instead of stacking. */
  .gf-pile-row { gap:6px; }
  .gf-pile-row .gf-zone { padding:8px 6px; }
  .gf-pile-row .gf-zone-head h4 { font-size:10.5px; }
  .gf-library-card { width:100%; min-height:48px; padding:6px 4px; font-size:9.5px; }
  .gf-library-card b { font-size:14px; }

  /* Keep both life counters on one row instead of wrapping. */
  .gf-toolbar, .gf-phase-bar { gap:6px; }
  .gf-turn-badge { flex-basis:100%; margin-left:0; text-align:center; order:3; }
  .gf-life-box { flex:1 1 0; min-width:0; padding:6px 8px; gap:4px; justify-content:center; }
  .gf-life-box .gf-life-label { min-width:0; font-size:9px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .gf-life-box .gf-life-val { min-width:20px; font-size:16px; }
  .gf-life-btn { width:22px; height:22px; font-size:13px; flex-shrink:0; }
}

.detail-pane-header { display:flex; gap:12px; align-items:flex-start; margin-bottom:20px; flex-wrap:wrap; }
.detail-back { background:none; border:1px solid #2d3148; color:#94a3b8; padding:6px 12px; border-radius:6px; cursor:pointer; font-size:13px; flex-shrink:0; }
.detail-back:hover { background:#1e2235; }
.detail-title-block { min-width:0; flex:1 1 200px; }
.detail-title-block > div:first-child { word-break:break-word; }
.detail-actions { margin-left:auto; display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.type-section { margin-bottom:18px; }
.type-header { font-size:12px; font-weight:700; color:#94a3b8; text-transform:uppercase; letter-spacing:.06em;
  border-bottom:1px solid #2d3148; padding-bottom:6px; margin-bottom:8px; display:flex; justify-content:space-between; }
.type-count { color:#64748b; font-weight:400; }
.deck-detail-card { padding:6px 8px; border-radius:6px; font-size:13px; cursor:pointer;
  transition:background .1s; display:flex; align-items:center; gap:10px; }
.deck-detail-card:hover { background:#1e2235; }
.deck-detail-card .qty { color:#a78bfa; font-weight:700; min-width:20px; font-size:12px; }
.deck-detail-card .cname { flex:1; min-width:0; overflow-wrap:break-word; }
.deck-detail-card .mana-cost { margin-left:auto; flex-shrink:0; }
.creature-stat { flex-shrink:0; font-size:11px; font-weight:700; color:#e2e8f0;
  background:#2d3148; border-radius:5px; padding:2px 6px; font-family:ui-monospace,monospace; }
.missing-tag { flex-shrink:0; font-size:11px; font-weight:600; color:#eab308;
  background:rgba(234,179,8,.12); border:1px solid rgba(234,179,8,.35); border-radius:5px; padding:2px 7px; }
.card-desc-panel { display:none; background:#0f1117; border-left:3px solid #7c3aed;
  padding:8px 12px; margin:2px 0 4px 28px; border-radius:0 6px 6px 0; font-size:12px; color:#94a3b8; line-height:1.6; }
.card-desc-panel.open { display:block; }
.detail-lnk { display:inline-block; margin-top:6px; color:#a78bfa; font-size:11px; text-decoration:none; }
.detail-lnk:hover { text-decoration:underline; }
td.desc .detail-lnk { margin-left:8px; margin-top:0; white-space:nowrap; }
.charts-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:20px; }
.chart-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:10px; padding:16px; min-width:0; }
.chart-box h4 { font-size:12px; font-weight:600; color:#94a3b8; text-transform:uppercase; letter-spacing:.05em; margin-bottom:12px; }
.curve-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:10px; padding:16px; margin-bottom:20px; min-width:0; overflow-x:auto; }
.curve-box h4 { font-size:12px; font-weight:600; color:#94a3b8; text-transform:uppercase; letter-spacing:.05em; margin-bottom:12px; }
.cmc-avg-label { text-transform:none; letter-spacing:normal; font-weight:700; color:#c4b5fd; font-size:12px; }
.missing-box { background:#1a1d2e; border:1px solid #3a2d1a; border-radius:10px; padding:14px 16px; margin-bottom:20px; min-width:0; }
.similar-decks-banner { background:#1a1d2e; border:1px solid #1a2d3a; border-radius:10px; padding:12px 16px; margin-bottom:16px; font-size:13px; color:#94a3b8; }
.similar-decks-banner a { color:#38bdf8; text-decoration:none; font-weight:600; }
.similar-decks-banner a:hover { text-decoration:underline; }

/* ═══ Match history — deck detail page, see renderDeckMatchHistory()
   (auth-decks.js). One row per saved playtest journal for this deck. ═══ */
.match-history-box { background:#1a1d2e; border:1px solid #2d3148; border-radius:10px; padding:14px 16px; margin-bottom:16px; }
.match-history-box h4 { margin:0 0 10px; font-size:14px; color:#e2e8f0; }
.match-history-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:8px 0; border-top:1px solid #232742; font-size:13px; }
.match-history-row:first-of-type { border-top:none; }
.match-history-row .mh-main { color:#cbd5e1; }
.match-history-row .mh-main .mh-vs { color:#64748b; }
.match-history-row .mh-meta { color:#64748b; font-size:12px; margin-top:2px; }
.match-history-row .mh-actions { display:flex; gap:6px; flex-shrink:0; }
.match-history-result { font-size:11px; font-weight:700; padding:2px 8px; border-radius:6px; margin-left:6px; }
.match-history-result.win { background:rgba(34,197,94,.15); color:#4ade80; }
.match-history-result.loss { background:rgba(239,68,68,.15); color:#f87171; }
.match-history-result.draw { background:rgba(148,163,184,.15); color:#94a3b8; }
.match-history-summary { margin-bottom:6px; }
.match-history-summary .mh-summary-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:6px 10px; border-radius:6px; background:#15182a; margin-bottom:6px; font-size:13px; }
.match-history-summary .mh-summary-row .mh-main { color:#cbd5e1; }
.match-history-summary .mh-summary-rate { color:#94a3b8; font-size:12px; white-space:nowrap; }
.mh-more-btn { display:block; margin:10px auto 0; }
.missing-box h4 { font-size:12px; font-weight:600; color:#eab308; text-transform:uppercase; letter-spacing:.05em; margin-bottom:10px; }
.missing-rows { display:flex; flex-wrap:wrap; gap:8px 20px; font-size:13px; color:#cbd5e1; margin-bottom:10px; }
.missing-rows span.n { color:#f8fafc; font-weight:700; }
.missing-total { font-size:14px; font-weight:700; color:#e2e8f0; border-top:1px solid #2d3148; padding-top:10px; }
.missing-total .cost { color:#eab308; }
.missing-complete { font-size:13px; color:#4ade80; }
canvas { display:block; max-width:100%; }
.mana-colors { display:inline-flex; gap:3px; align-items:center; }

/* ── Deck detail: mobile tweaks ── */
@media (max-width: 700px) {
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .detail-pane-header { flex-direction: column; align-items: stretch; }
  .detail-back { align-self: flex-start; }
  .detail-actions { margin-left: 0; width: 100%; }
  .detail-actions button { flex: 1 1 auto; min-width: 110px; padding: 9px 12px; }
}
@media (max-width: 480px) {
  .deck-detail-card { padding: 9px 8px; flex-wrap: wrap; row-gap: 4px; }
  .deck-detail-card .qty { order: 0; }
  .deck-detail-card .cname {
    order: 1;
    flex-basis: 100%;
    white-space: normal;
  }
  .deck-detail-card .mana-cost { order: 2; margin-left: 30px; }
  .deck-detail-card .creature-stat {
    order: 3;
    margin-left: 0;
  }
  .deck-detail-card .badge,
  .deck-detail-card .missing-tag { order: 4; }
  .card-desc-panel { margin-left: 12px; }
}

/* ── Deckbuilder: mobile-first, two-screen flow ── */
.builder-layout { display: block; }
.builder-card-list, .builder-sidebar { display: none; }
.builder-card-list.mobile-active, .builder-sidebar.mobile-active { display: block; }
.deck-info-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.deck-info-bar input[type=text] { flex: 1; min-width: 160px; }
#deck-desc { flex: 1 1 220px; min-width: 160px; max-width: 100%; min-height: 36px; resize: both; overflow: hidden; box-sizing: border-box; }
.deck-info-bar .deck-info-actions { display: none; }
.qty-badge { display: inline-flex; align-items: center; gap: 4px; }
.qty-badge button { padding: 2px 7px; font-size: 12px; border-radius: 4px; }
.card-in-deck { background: #1a1d2e; border: 1px solid #2d3148; border-radius: 6px;
  padding: 8px 10px; display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; margin-bottom: 4px; }
.card-in-deck .cname { flex: 1; }
.landcalc-box { background: #1a1d2e; border: 1px solid #2d3148; border-radius: 6px;
  padding: 8px 10px; font-size: 12px; line-height: 1.6; margin-bottom: 8px; }
.landcalc-head { display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; color: #94a3b8; margin-bottom: 6px; }
.landcalc-turns-label { font-weight: 400; font-size: 12px; color: #cbd5e1;
  display: flex; align-items: center; gap: 4px; }
.landcalc-turns-label input { width: 46px; }
#landcalc-body { color: #cbd5e1; }
#landcalc-chart { display: block; width: 100%; height: 90px; margin-top: 6px; }
.landcalc-good { color: #22c55e; }
.landcalc-warn { color: #f59e0b; }

/* Segmented control switching between "Rechercher" and "Mon deck" */
.builder-subnav { display: flex; gap: 6px; margin-bottom: 12px; }
.builder-subnav button { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid #2d3148;
  background: transparent; color: #94a3b8; font-size: 13px; font-weight: 500; }
.builder-subnav button.active { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.subnav-badge { background: rgba(255,255,255,.18); border-radius: 10px; padding: 1px 6px;
  font-size: 11px; margin-left: 5px; }
.builder-subnav button:not(.active) .subnav-badge { background: #312e5c; color: #c4b5fd; }

/* Card-list rows (mobile alternative to the results table) */
.mobile-card-row { display: flex; align-items: center; gap: 8px; padding: 8px;
  border-radius: 8px; background: #1a1d2e; border: 1px solid #2d3148; margin-bottom: 6px; }
.mobile-card-row .stripe { width: 4px; align-self: stretch; border-radius: 2px; flex-shrink: 0; }
.mobile-card-row .info { flex: 1; min-width: 0; cursor: pointer; }
.mobile-card-row .info .n { display: flex; align-items: center; gap: 4px; font-size: 13px; color: #e2e8f0; }
.mobile-card-row .info .n .ntext { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-card-row .info .n .chev { flex-shrink: 0; display: inline-block; color: #64748b; font-size: 10px;
  transition: transform .15s; }
.mobile-card-row .info .n .chev.open { transform: rotate(180deg); }
.mobile-card-row .info .m { font-size: 11px; color: #64748b; margin-top: 2px; }
.mobile-card-row .detail { display: none; margin-top: 8px; padding-top: 8px; border-top: 1px solid #2d3148; }
.mobile-card-row .detail.open { display: block; }
.mobile-card-row .detail .detail-type { font-size: 11px; font-weight: 600; color: #a78bfa;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.mobile-card-row .detail .detail-desc { font-size: 12px; color: #94a3b8; line-height: 1.55; white-space: normal; }
.mobile-card-row .stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mobile-card-row .stepper button { width: 28px; height: 28px; padding: 0; border-radius: 6px;
  border: 1px solid #2d3148; background: #0f1117; color: #cbd5e1; font-size: 15px; line-height: 1; }
.mobile-card-row .stepper button.add { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.mobile-card-row .stepper .q { min-width: 14px; text-align: center; font-size: 13px; }

/* Collapsible filter panel, toggled by a button next to the search field */
.builder-search-sticky { position: sticky; top: 0; z-index: 20; background: #0f1117; padding-top: 2px; }
.builder-search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.builder-search-row input[type=text] { flex: 1; width: 100%; }
#btn-toggle-filters, .btn-toggle-filters, .btn-clear-filters { width: 40px; padding: 0; font-size: 15px; }
.builder-filters-panel { display: none; }
.builder-filters-panel.open { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.builder-filters-panel select { width: 100%; }
.bf-cmc-exact { display: flex; gap: 6px; }
.bf-cmc-exact select { flex: 1; min-width: 0; }
.bf-cmc-exact input[type=number] { width: 56px; flex-shrink: 0; }

/* Sticky action bar for the deck screen, pinned above the global bottom nav */
.builder-mobile-actionbar { position: sticky; bottom: calc(58px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 10px 0 0; margin-top: 10px; background: #0f1117;
  border-top: 1px solid #2d3148; }
.builder-mobile-actionbar button { flex: 1; }

@media (min-width: 860px) {
  .builder-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; height: calc(100vh - 190px); }
  .builder-card-list, .builder-sidebar { display: block; overflow-y: auto; }
  /* Horizontal scroll must live on the same element that scrolls vertically (.builder-card-list),
     not on .table-wrap: overflow-x:auto on .table-wrap forces its computed overflow-y to "auto"
     too, turning it into its own scroll container. Since it never actually overflows, the sticky
     <th> ends up anchored to that never-scrolling box instead of .builder-card-list, which is why
     the header detached from the top and appeared to drift below the first row instead of
     staying fixed while scrolling. */
  .builder-card-list { overflow-x: auto; }
  .builder-card-list .table-wrap { overflow: visible; }
  .builder-sidebar { display: flex; flex-direction: column; gap: 10px; }
  .deck-info-bar .deck-info-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .builder-subnav, .builder-search-row #btn-toggle-filters, .builder-search-row .btn-toggle-filters, .builder-mobile-actionbar { display: none; }
  .builder-search-row { display: block; }
  .builder-filters-panel { display: flex !important; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
  .builder-filters-panel select { width: auto; }
  .mobile-card-list { display: none; }
  .builder-card-list .table-wrap { display: block; }
}
@media (max-width: 859.98px) {
  .builder-card-list .table-wrap { display: none; }
}
.empty { text-align: center; padding: 40px; color: #475569; }
.desc { color: #94a3b8; font-size: 12px; line-height: 1.5; }
.detail-link { color: #a78bfa; font-size: 11px; text-decoration: none; }
.detail-link:hover { text-decoration: underline; }
