  @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Lora:ital,wght@0,400;0,500;0,600;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

  :root{
    --bg: #1b120e;
    --bg-2: #241a15;
    --panel: #2b1f19;
    --parchment: #ece1c8;
    --parchment-dim: #d8c9a4;
    --gold: #c8a44d;
    --gold-bright: #e0be6f;
    --ink: #201510;
    --text: #efe6d2;
    --muted: #a8927a;
    --line: rgba(200,164,77,0.25);

    --c-oro: #d4af37;
    --c-totem: #6f8f52;
    --c-arma: #a13a2f;
    --c-talisman: #8a63b0;
    --c-aliado: #3f8ea3;
    --c-accent: #294f1c;
    --c-todos: #5a5248;
  }

  *{ box-sizing: border-box; }
  html,body{ margin:0; padding:0; height:100%; overflow:hidden; }
  body{
    background: radial-gradient(ellipse at top, #2a1d16 0%, #150e0a 70%);
    color: var(--text);
    font-family: 'Lora', serif;
    height:100vh; /* fallback para navegadores viejos sin soporte dvh */
    height:100dvh; /* alto real visible: descuenta la barra de navegación de Android y toolbars dinámicas */
  }
  ::selection{ background: var(--gold); color: var(--ink); }

  h1,h2,h3,.display{
    font-family: 'Cinzel', serif;
    letter-spacing: 0.02em;
    font-weight: 600;
    margin: 0;
  }
  .mono{ font-family: 'JetBrains Mono', monospace; }

  button{
    font-family: 'Lora', serif;
    cursor: pointer;
  }
  input, select, button{ font-size: 14px; }

  /* ---------- shell ---------- */
  .shell{ display:flex; flex-direction:column; height:100vh; height:100dvh; }

  header.topbar{
    display:flex; align-items:center; gap:16px;
    padding: 14px 20px;
    background: linear-gradient(180deg, #241a14, #1b1310);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
    position: sticky; top:0; z-index: 20;
  }
  .brand{ display:flex; align-items:center; gap:10px; margin-right: 6px; }
  .seal{
    width:38px; height:38px; border-radius:50%;
    background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold) 55%, #8a6a24 100%);
    display:flex; align-items:center; justify-content:center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 0 0 2px rgba(0,0,0,0.25);
    flex-shrink:0;
  }
  .seal span{ font-family:'Cinzel',serif; font-weight:700; color:#2a1a08; font-size:15px; }
  .brand-text h1{ font-size: 19px; color: var(--parchment); }
  .brand-text p{ margin:0; font-size:11px; color: var(--muted); letter-spacing:0.08em; text-transform: uppercase; }

  .tabs{ display:flex; gap:4px; background: var(--bg-2); border:1px solid var(--line); border-radius:8px; padding:3px; }
  .tab-btn{
    border:none; background:transparent; color: var(--muted);
    padding: 7px 16px; border-radius:6px; font-family:'Cinzel',serif; font-size:12.5px; letter-spacing:0.05em;
    transition: all .15s ease;
  }
  .tab-btn.active{ background: var(--gold); color: var(--ink); font-weight:700; }

  .topbar-right{ display:flex; align-items:center; gap:10px; margin-left:auto; }
  .search-box{
    display:flex; align-items:center; gap:6px;
    background: var(--bg-2); border:1px solid var(--line); border-radius:8px;
    padding: 6px 10px; min-width: 180px;
  }
  .search-box:focus-within{ border-color: var(--c-accent); }
  .search-box-rail{ width:100%; }
  .search-box input{
    background:transparent; border:none; outline:none; color:var(--text); width:100%;
  }
  .search-box input::placeholder{ color: var(--muted); }

  .btn{
    border:1px solid var(--line); background: var(--bg-2); color: var(--parchment);
    padding: 8px 14px; border-radius:8px; font-size:13px; display:flex; align-items:center; gap:6px;
    transition: all .15s ease;
  }
  .btn:hover{ border-color: var(--gold); color: var(--gold-bright); }
  .btn-gold{
    background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight:600;
  }
  .btn-gold:hover{ background: var(--gold-bright); color: var(--ink); }
  .btn-ghost-danger{ color:#c98066; border-color: rgba(201,128,102,0.3); }
  .btn-ghost-danger:hover{ color:#e0846a; border-color:#e0846a; }
  .btn:disabled{ opacity:0.4; cursor:not-allowed; }
  input[type="file"]{ display:none; }

  /* ---------- layout ---------- */
  .main{ flex:1; display:flex; min-height:0; }

  .rail{
    width: 230px; flex-shrink:0; padding: 18px 14px; border-right:1px solid var(--line);
    background: rgba(0,0,0,0.15);
    overflow-y:auto;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  }
  .rail h3, .rail button, .rail select, .rail input, .rail label{
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  }
  .rail h3{ font-size:11px; text-transform:uppercase; letter-spacing:0.1em; color: var(--muted); margin-bottom:10px; }
  .filter-group{ margin-bottom: 22px; }
  .type-chip{
    display:flex; align-items:center; gap:8px; width:100%;
    background: transparent; border:1px solid var(--line); color: var(--text);
    padding: 7px 10px; border-radius:7px; margin-bottom:6px; font-size:13px;
    text-align:left;
  }
  .type-chip .dot{ width:10px; height:10px; border-radius:50%; flex-shrink:0; }
  .type-chip.active{ background: rgba(200,164,77,0.14); border-color: var(--gold); }
  .type-chip .count{ margin-left:auto; font-size:11px; color: var(--muted); }

  select.filter-select{
    width:100%; background: var(--bg-2); border:1px solid var(--line); color: var(--text);
    padding: 7px 8px; border-radius:7px; margin-bottom: 8px;
  }

  .content{ flex:1; min-width:0; display:flex; flex-direction:column; }

  /* ---------- empty state ---------- */
  .empty-state{
    margin: auto; text-align:center; max-width: 460px; padding: 40px 20px;
  }
  .empty-state .seal{ width:64px; height:64px; margin: 0 auto 18px; }
  .empty-state .seal span{ font-size:24px; }
  .empty-state h2{ font-size: 24px; color: var(--parchment); margin-bottom: 10px; }
  .empty-state p{ color: var(--muted); line-height:1.6; margin-bottom: 22px; }

  /* ---------- grid ---------- */
  .grid-scroll{ flex:1; overflow-y:auto; padding: 18px 20px; }
  .grid-meta{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
  .grid-meta .count{ color: var(--muted); font-size: 13px; }
  .card-grid{
    display:grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap:14px;
  }
  .card-tile{
    position:relative;
    background: linear-gradient(160deg, var(--parchment) 0%, var(--parchment-dim) 100%);
    color: var(--ink);
    border-radius: 8px;
    padding: 12px 12px 10px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.35);
    display:flex; flex-direction:column; gap:8px;
    border: 1px solid rgba(0,0,0,0.15);
    cursor: pointer;
    transition: box-shadow .15s ease;
  }
  .card-tile:hover{ box-shadow: 0 4px 12px rgba(0,0,0,0.45); }
  .card-tile .row1{ display:flex; align-items:center; gap:8px; }
  .type-emblem{
    display:inline-flex; align-items:center; justify-content:center;
    padding: 4px 12px; border-radius: 20px; flex-shrink:0; width:auto; white-space:nowrap;
    font-family:'Cinzel',serif; font-weight:700; font-size:10.5px; letter-spacing:0.04em;
    text-transform:uppercase; color:#fff;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.35);
  }
  .card-tile .nombre{ font-family:'Cinzel',serif; font-size:15px; font-weight:700; line-height:1.28; }
  .card-tile .meta-line{ font-size:11px; color: var(--ink); font-weight:600; display:flex; flex-wrap:wrap; gap:6px; }
  .meta-line.meta-low{ font-size:10.5px; opacity:0.8; display:none; }
  .card-tile.expanded .meta-line.meta-low{ display:flex; }
  .badge-raza{ font-size:13px; font-weight:700; padding:3px 10px; }
  .card-tile.expanded .badge-raza{ font-size:15px; }
  .stats-row{ display:flex; flex-wrap:wrap; gap:6px; }
  .stat-badge{
    display:inline-flex; align-items:baseline; gap:4px;
    padding: 3px 10px; border-radius:8px;
    background: rgba(41,79,28,0.10); border:1px solid rgba(41,79,28,0.45);
  }
  .stat-badge .label{ font-family:'Lora',serif; font-size:9.5px; font-weight:700; text-transform:uppercase; letter-spacing:0.04em; color: var(--c-accent); opacity:0.95; }
  .stat-badge .value{ font-family:'JetBrains Mono',monospace; font-weight:700; font-size:13px; color:#16290e; }
  .card-tile.expanded .stat-badge .value{ font-size:15px; }
  .card-tile.expanded .stat-badge .label{ font-size:10.5px; }
  .badge{
    display:inline-block; padding:2px 8px; border-radius:20px; font-size:10px; font-weight:600;
    background: rgba(32,21,16,0.12); border:1px solid rgba(32,21,16,0.32); color: var(--ink); text-transform:capitalize;
  }
  .card-thumb{
    width:100%; aspect-ratio: 5/7; border-radius:6px; overflow:hidden;
    background: rgba(32,21,16,0.06); display:flex; align-items:center; justify-content:center;
  }
  .card-thumb img{ width:100%; height:100%; object-fit:cover; }
  .card-thumb .ph{ font-family:'Cinzel',serif; font-size:26px; color: rgba(32,21,16,0.25); }
  .card-tile.expanded{
    grid-column: span 2;
    padding: 16px 16px 14px;
  }
  .card-tile.expanded .card-thumb{ aspect-ratio: 5/7; }
  .card-tile.expanded .nombre{ font-size:17px; }
  .card-tile.expanded .meta-line{ font-size:12.5px; }
  .card-tile.expanded .badge{ font-size:11px; padding:2px 9px; }
  .card-desc{
    font-size:11.5px; color:#33281c; font-weight:500; line-height:1.45; white-space: pre-line;
    display:none; max-height:none; overflow:visible;
    padding-top:8px; margin-top:2px; border-top:1px dashed rgba(32,21,16,0.25);
  }
  .card-tile.expanded .card-desc{ display:block; font-size:13px; }
  .expand-hint{
    font-size:10px; color:#6b5636; font-weight:600; text-align:center; letter-spacing:0.05em;
    text-transform:uppercase; opacity:0.9;
  }
  .card-actions{ display:flex; align-items:center; gap:8px; margin-top:auto; }
  .qty-stepper{ display:flex; align-items:center; gap:6px; }
  .qty-stepper button{
    width:24px; height:24px; border-radius:6px; border:1px solid rgba(32,21,16,0.25);
    background: rgba(32,21,16,0.06); color: var(--ink); font-weight:700; line-height:1;
  }
  .qty-stepper .n{ min-width:16px; text-align:center; font-weight:600; font-size:13px; }
  .add-btn{
    flex:1; background: var(--ink); color: var(--parchment); border:none; border-radius:6px;
    padding:6px 8px; font-size:12px; font-weight:600; letter-spacing:0.03em;
  }
  .add-btn:hover{ background:#3a2a1e; }
  .clear-all-btn{
    background: rgba(161,58,47,0.12); border:1px solid rgba(161,58,47,0.4); color:#7a2318;
    border-radius:6px; width:28px; height:24px; font-size:12px; line-height:1; flex-shrink:0;
  }
  .clear-all-btn:hover{ background: rgba(161,58,47,0.22); }
  .clear-all-btn{ display:flex; align-items:center; justify-content:center; }
  .icon-trash{ width:14px; height:14px; object-fit:contain; }
  .icon-trash-sm{ width:11px; height:11px; filter: brightness(0) invert(1); }

  /* ---------- deck panel ---------- */
  .deck-panel{
    width: 300px; flex-shrink:0; border-left:1px solid var(--line);
    background: rgba(0,0,0,0.18);
    display:flex; flex-direction:column;
  }
  .deck-header{ padding: 16px 16px 10px; border-bottom:1px solid var(--line); }
  .deck-name-input{
    width:100%; background:transparent; border:none; border-bottom:1px dashed var(--line);
    color: var(--parchment); font-family:'Cinzel',serif; font-size:16px; padding:4px 0; outline:none;
  }
  .deck-name-input:focus{ border-color: var(--gold); }
  .deck-stats{ display:flex; gap:12px; margin-top:10px; font-size:12px; color: var(--muted); flex-wrap:wrap; }
  .deck-stats b{ color: var(--gold-bright); }
  .deck-stats b.over-limit{ color:#ff6b5b; }
  .under-min{ color:#ff6b5b !important; }
  .race-bubble{
    display:inline-flex; align-items:center; width:fit-content;
    margin-top:9px; padding:3px 13px; border-radius:20px;
    border:1px solid var(--gold); background:transparent;
    color: var(--gold-bright); font-family:'Cinzel',serif; font-size:11px; letter-spacing:0.04em;
  }
  .race-bubble.race-mixed{ border-color:#a13a2f; color:#e0846a; }
  .race-bubble.race-undefined{ border-color:var(--muted); color:var(--muted); }
  .format-select{
    width:fit-content; margin-top:9px; background: var(--bg-2); border:1px solid var(--line);
    color: var(--text); padding: 5px 8px; border-radius:7px; font-size:11.5px;
  }
  .format-badge{
    display:inline-flex; align-items:center; width:fit-content; margin-top:9px; margin-left:8px;
    padding:3px 13px; border-radius:20px; border:1px solid var(--muted); background:transparent;
    color: var(--muted); font-family:'Cinzel',serif; font-size:11px; letter-spacing:0.04em;
  }
  .format-badge-illegal{ border-color:#a13a2f; color:#e0846a; }
  .side-deck-header .mono.over-limit{ color:#ff6b5b; font-weight:700; }
  .dest-toggle{
    display:flex; align-items:center; gap:7px; cursor:pointer; user-select:none;
    font-size:11px; color: var(--muted); width:fit-content; flex-shrink:0;
  }
  .dest-toggle-label{ transition: color .15s ease, font-weight .15s ease; }
  .dest-toggle-label.active{ color: var(--parchment); font-weight:700; }
  .dest-toggle-track{
    width:38px; height:19px; border-radius:20px; background: var(--bg-2); border:1px solid var(--line);
    position:relative; flex-shrink:0;
  }
  .dest-toggle-thumb{
    position:absolute; top:2px; left:2px; width:13px; height:13px; border-radius:50%;
    background: var(--gold); transition: transform .18s ease, background .18s ease;
  }
  .dest-toggle.side .dest-toggle-thumb{ transform: translateX(19px); background: var(--c-accent); }
  .type-bar{ display:flex; height:6px; border-radius:4px; overflow:hidden; margin-top:8px; background: rgba(255,255,255,0.05);}
  .type-bar span{ height:100%; }
  .type-legend{ display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
  .type-legend .item{ display:flex; align-items:center; gap:5px; font-size:11px; color: var(--muted); }
  .type-legend .item .dot{ width:8px; height:8px; border-radius:50%; flex-shrink:0; }
  .type-legend .item b{ color: var(--parchment); font-weight:700; }
  .copy-warning{
    display:flex; align-items:flex-start; gap:8px;
    background: rgba(161,58,47,0.16); border:1px solid rgba(161,58,47,0.5);
    color:#e6a897; font-size:11.5px; line-height:1.4; padding:8px 10px; border-radius:8px; margin-top:10px;
  }
  .copy-warning-close{
    background:none; border:none; color:#e6a897; font-size:16px; line-height:1; cursor:pointer;
    margin-left:auto; padding:0 2px; flex-shrink:0;
  }
  .side-deck-section{ border-top:1px solid var(--line); }
  .side-deck-header{ display:flex; align-items:center; justify-content:space-between; padding:10px 14px 2px; }
  .side-deck-header h3{ font-size:11px; text-transform:uppercase; letter-spacing:0.08em; color: var(--muted); }
  .side-deck-header .mono{ font-size:11px; color: var(--muted); }
  .side-deck-list{ max-height:180px; }

  .deck-list{ flex:1; overflow-y:auto; padding: 10px 14px; }
  .deck-empty{ color: var(--muted); font-size:13px; text-align:center; margin-top:30px; padding: 0 10px; line-height:1.5; }
  .deck-row{
    display:flex; align-items:center; gap:8px; padding: 7px 0; border-bottom:1px solid rgba(255,255,255,0.05);
  }
  .deck-row .dot{ width:8px; height:8px; border-radius:50%; flex-shrink:0; }
  .deck-row .name{ flex:1; font-size:12.5px; color: var(--text); }
  .deck-row .missing{ color:#c98066; font-size:10px; margin-left:4px; }
  .deck-footer{ padding: 12px 16px 16px; border-top:1px solid var(--line); display:flex; gap:8px; }
  .deck-footer .btn{ flex:1; justify-content:center; }

  /* ---------- my decks tab ---------- */
  .decks-list{ padding: 20px; overflow-y:auto; flex:1; }
  .decks-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap:14px; }
  .deck-card{
    background: var(--panel); border:1px solid var(--line); border-radius:10px; padding:16px;
    display:flex; flex-direction:column; gap:10px;
  }
  .deck-card h3{ color: var(--parchment); font-size:16px; }
  .deck-card .sub{ color: var(--muted); font-size:12px; }
  .deck-card .type-bar{ margin-top:2px; }
  .deck-card .actions{ display:grid; grid-template-columns: 1fr 1fr; gap:8px; margin-top:4px; }
  .deck-card .actions .btn{
    justify-content:center; font-size:12px; padding:6px 8px; min-width:0;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  }
  .deck-card .actions .btn-ghost-danger{ grid-column: 1 / -1; }

  /* ---------- deck detail (ver mazo) ---------- */
  .deck-detail{ flex:1; min-height:0; display:flex; flex-direction:column; overflow:hidden; }
  .detail-topbar{ padding: 16px 24px 0; display:flex; align-items:center; flex-wrap:wrap; gap:10px; }
  .detail-scroll{ flex:1; overflow-y:auto; padding: 14px 24px 40px; }
  .deck-detail-name{
    width:100%; max-width:640px; background:transparent; border:none; border-bottom:1px dashed var(--line);
    color: var(--parchment); font-family:'Cinzel',serif; font-size:24px; padding:6px 0; outline:none; margin-bottom:12px;
  }
  .deck-detail-name:focus{ border-color: var(--gold); }
  .deck-detail-player{
    width:100%; max-width:640px; background:transparent; border:none; border-bottom:1px dashed var(--line);
    color: var(--muted); font-family:'Lora',serif; font-size:13px; padding:4px 0 10px; outline:none; margin-bottom:12px;
  }
  .deck-detail-player:focus{ border-color: var(--gold); color: var(--parchment); }
  .detail-counts{ display:flex; flex-wrap:wrap; gap:10px 18px; margin-bottom:26px; }
  .detail-counts .item{ display:flex; align-items:center; gap:6px; font-size:13px; color: var(--muted); }
  .detail-counts .item b{ color: var(--gold-bright); font-family:'JetBrains Mono',monospace; }
  .detail-counts .item .dot{ width:9px; height:9px; border-radius:50%; flex-shrink:0; }
  .detail-heading{ font-size:13px; text-transform:uppercase; letter-spacing:0.08em; color: var(--muted); margin: 22px 0 12px; }

  .cascade-groups{ display:flex; flex-direction:column; gap:28px; }
  .cascade-type-group .group-title{ display:flex; align-items:center; gap:10px; margin-bottom:12px; }
  .cascade-row{ display:flex; flex-wrap:wrap; gap:26px 16px; }
  .hand-sim-controls{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:18px; }
  .hand-sim-pool-count{ color:var(--muted); font-size:12px; margin-left:auto; }
  #handSimIntro{ text-align:center; display:flex; flex-direction:column; align-items:center; padding: 10px 0 4px; }
  .hand-sim-hint{ color:var(--muted); font-size:12.5px; margin:8px 0 0; }
  .hand-sim-row{ min-height:236px; }
  .hand-sim-empty{ color:var(--muted); font-size:13px; }
  .hand-card-discard{
    position:absolute; top:-8px; right:-8px; width:22px; height:22px; border-radius:50%;
    background:#a13a2f; color:#fff; border:none; font-size:12px; font-weight:700; cursor:pointer;
    display:flex; align-items:center; justify-content:center; box-shadow:0 2px 4px rgba(0,0,0,0.4); z-index:20;
  }
  .hand-card-discard:hover{ background:#c94a3a; }
  .side-row{ padding: 4px 0 6px; }
  .cascade-stack{ position:relative; width:132px; flex-shrink:0; }
  .cascade-stack[data-id]{ cursor:pointer; }
  .cascade-stack[data-id]:hover .mini-card{ box-shadow: 0 3px 10px rgba(0,0,0,0.5); }
  .mini-card{
    position:absolute; left:0; width:132px;
    background: linear-gradient(160deg, var(--parchment) 0%, var(--parchment-dim) 100%);
    border-radius:8px; padding:8px 9px; box-shadow:0 2px 5px rgba(0,0,0,0.35); border:1px solid rgba(0,0,0,0.15);
    color: var(--ink);
  }
  .mini-card .mini-thumb{
    width:100%; aspect-ratio: 5/7; border-radius:5px; overflow:hidden; margin-bottom:6px;
    background: rgba(32,21,16,0.06); display:flex; align-items:center; justify-content:center;
  }
  .mini-card .mini-thumb img{ width:100%; height:100%; object-fit:cover; }
  .mini-card .mini-thumb .ph{ font-family:'Cinzel',serif; font-size:22px; color: rgba(32,21,16,0.25); }
  .mini-card .mini-name{
    font-family:'Cinzel',serif; font-weight:700; font-size:11.5px; line-height:1.25;
    display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; overflow:hidden; min-height:2.5em;
  }
  .mini-card .mini-stats{ display:flex; gap:5px; margin-top:5px; }
  .mini-card .mini-stats span{
    font-size:9.5px; font-weight:700; background: rgba(41,79,28,0.12); color:#16290e;
    padding:1px 6px; border-radius:6px;
  }
  .mini-card .mini-missing{ font-size:9.5px; color:#a13a2f; margin-top:4px; }
  .stack-copies-badge{
    position:absolute; top:-7px; right:-7px; background:var(--gold); color:var(--ink);
    font-size:10px; font-weight:700; border-radius:50%; width:21px; height:21px;
    display:flex; align-items:center; justify-content:center; box-shadow:0 2px 4px rgba(0,0,0,0.4); z-index:10;
  }
  .stack-clear-btn{
    position:absolute; top:-7px; left:-7px; background:#a13a2f; color:#fdf3e7;
    font-size:10px; font-weight:700; border:none; border-radius:50%; width:21px; height:21px;
    display:flex; align-items:center; justify-content:center; box-shadow:0 2px 4px rgba(0,0,0,0.4); z-index:10;
    cursor:pointer; line-height:1; padding:0;
  }
  .stack-clear-btn:hover{ background:#c04a3b; }

  .detail-top-grid{ display:flex; gap:36px; flex-wrap:wrap; align-items:flex-start; }
  .detail-identity{ flex:1 1 360px; min-width:280px; }
  .detail-charts{ display:flex; flex-wrap:wrap; gap:32px; flex:0 0 auto; }
  .hand-sim-open-row{ display:flex; justify-content:flex-start; margin-top:14px; }
  .hand-sim-modal{ max-width:680px; }
  .hand-sim-modal-body{ padding:26px; }
  .hand-sim-modal-body > .detail-heading{ text-align:center; }
  .chart-block{ display:flex; flex-direction:column; align-items:center; min-width:220px; }
  .donut-wrap{ display:flex; flex-direction:column; align-items:center; gap:14px; }
  .chart-legend{ display:flex; flex-direction:column; gap:6px; width:100%; max-width:220px; }
  .chart-legend-row{ display:flex; align-items:center; gap:8px; font-size:12px; }
  .chart-legend-row .dot{ width:9px; height:9px; border-radius:50%; flex-shrink:0; }
  .chart-legend-row .lbl{ flex:1; color: var(--text); }
  .chart-legend-row .val{ color: var(--muted); font-family:'JetBrains Mono',monospace; font-size:11px; }
  .chart-empty{ color: var(--muted); font-size:12.5px; padding: 30px 0; }

  /* ---------- toast ---------- */
  /* ---------- card detail modal (usado en Mis mazos > Ver) ---------- */
  .card-modal-overlay{
    position: fixed; inset:0; background: rgba(10,6,4,0.72);
    display:flex; align-items:center; justify-content:center; padding:20px;
    z-index: 200;
  }
  .card-modal{
    background: linear-gradient(160deg, var(--parchment) 0%, var(--parchment-dim) 100%);
    color: var(--ink); border-radius:12px; max-width:900px; width:100%;
    max-height: 94vh; overflow-y:auto; position:relative;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6); border:1px solid rgba(0,0,0,0.2);
  }
  .card-modal-close{
    position:absolute; top:10px; right:12px; background:transparent; border:none;
    font-size:22px; line-height:1; color: var(--ink); opacity:0.6; z-index:2;
  }
  .card-modal-close:hover{ opacity:1; }
  .card-modal-body{ display:flex; gap:26px; padding:26px; flex-wrap:wrap; }
  .cm-thumb{
    width:100%; max-width:420px; flex:0 1 420px; aspect-ratio:5/7; border-radius:10px; overflow:hidden;
    background: rgba(32,21,16,0.06); display:flex; align-items:center; justify-content:center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  }
  .cm-thumb img{ width:100%; height:100%; object-fit:cover; }
  .cm-thumb .ph{ font-family:'Cinzel',serif; font-size:56px; color: rgba(32,21,16,0.25); }
  .cm-info{ flex:1; min-width:260px; display:flex; flex-direction:column; gap:10px; }
  .cm-name{ font-family:'Cinzel',serif; font-size:26px; font-weight:700; }
  .card-modal .type-emblem{ font-size:13px; padding:6px 15px; }
  .card-modal .badge{ font-size:13px; padding:4px 12px; }
  .card-modal .badge-raza{ font-size:15px; padding:4px 13px; }
  .card-modal .stat-badge{ padding:5px 13px; }
  .card-modal .stat-badge .label{ font-size:12px; }
  .card-modal .stat-badge .value{ font-size:17px; }
  .card-modal .card-desc{ display:block; font-size:15px; line-height:1.55; }
  .cm-badges{ display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
  .cm-qty-row{ display:flex; flex-wrap:wrap; gap:22px; margin-top:8px; }
  .cm-qty-group{ display:flex; align-items:center; gap:10px; }
  .cm-qty-label{ font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:0.04em; color:#6b5636; }
  .cm-qty-group .mono{ font-size:16px; min-width:20px; text-align:center; }
  .cm-qty-group button{
    border:1px solid rgba(32,21,16,0.32); background: rgba(32,21,16,0.06); color:var(--ink);
    border-radius:8px; width:36px; height:36px; font-size:18px; font-weight:700;
  }
  .cm-qty-group button:disabled{ opacity:0.35; cursor:not-allowed; }
  .cm-move-row{ display:flex; flex-wrap:wrap; gap:12px; margin-top:6px; }
  .cm-move-row button{
    border:1px solid rgba(32,21,16,0.32); background: rgba(32,21,16,0.06); color:var(--ink);
    border-radius:9px; padding:11px 18px; font-size:14px; font-weight:600;
  }
  .cm-move-row button:disabled{ opacity:0.35; cursor:not-allowed; }
  .cm-move-row button:not(:disabled):hover, .cm-qty-group button:not(:disabled):hover{ background: rgba(32,21,16,0.14); }


  .toast{
    position: fixed; bottom: 20px; left:50%; transform: translateX(-50%);
    background: var(--gold); color: var(--ink); padding: 10px 20px; border-radius:8px;
    font-size:13px; font-weight:600; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    z-index: 100; opacity:0; pointer-events:none; transition: opacity .25s ease, transform .25s ease;
  }
  .toast.show{ opacity:1; transform: translateX(-50%) translateY(-4px); }

  /* ---------- mobile ---------- */
  .mobile-deck-toggle{ display:none; }
  @media (max-width: 880px){
    .rail{
      position: fixed; left:0; top:0; bottom:0; z-index: 40; transform: translateX(-100%);
      transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,0.5); width: 250px;
      background: var(--bg-2);
    }
    .rail.open{ transform: translateX(0); }
    .rail-backdrop{ display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:30; }
    .rail-backdrop.show{ display:block; }
    .deck-panel{
      position: fixed; right:0; left:0; bottom:0; top: 30%; z-index: 45;
      transform: translateY(100%); transition: transform .25s ease; width:auto;
      border-left:none; border-top:1px solid var(--line); border-radius: 16px 16px 0 0;
      background: var(--panel); box-shadow: 0 -8px 30px rgba(0,0,0,0.6);
    }
    .deck-panel.open{ transform: translateY(0); }
    .mobile-deck-toggle{
      display:flex; position: fixed; right:16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 41;
      border-radius: 30px; padding: 12px 18px; box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    }
    .deck-panel-backdrop{ display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:44; }
    .deck-panel-backdrop.show{ display:block; }
    .deck-panel-close{ display:inline-flex; flex-shrink:0; }
    .filters-toggle{ display:flex !important; }
    .brand-text p{ display:none; }
    /* Deja espacio al fondo de la galería para que el botón flotante "Mazo" y la
       barra de gestos/navegación del teléfono no tapen la última fila de cartas
       (y sus botones +/-/Agregar). */
    .grid-scroll{ padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    /* Lo mismo para el pie del panel de mazo (botón "Guardar mazo"), que también
       queda pegado al borde físico inferior de la pantalla en mobile. */
    .deck-footer{ padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  }
  .filters-toggle{ display:none; }
  .deck-panel-close{ display:none; }
