/* Menu + Auth + Rules - extracted from index.html */
  /* =====================================================================
     MAIN MENU
  ===================================================================== */
  .main-menu {
    position: fixed; inset: 0;
    display: flex; align-items: flex-start; justify-content: center;
    background: radial-gradient(ellipse at 50% 30%, #1a0505 0%, #080810 60%);
    overflow-x: hidden; overflow-y: auto;
    box-sizing: border-box;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .main-menu-bg {
    position: absolute; inset: 0;
    background-image:
      radial-gradient(circle at 20% 50%, rgba(180,20,20,.12) 0%, transparent 50%),
      radial-gradient(circle at 80% 50%, rgba(20,20,180,.1) 0%, transparent 50%);
    pointer-events: none;
  }
  .main-menu-content {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center;
    gap: clamp(14px, 2.8vh, 40px); width: 100%; max-width: 520px; padding: clamp(12px, 2.6vh, 40px) 20px;
    box-sizing: border-box;
  }
  .main-menu-logo { text-align: center; }
  .logo-img {
    width: min(320px, 90%, 36vh); height: auto;
    filter: drop-shadow(0 0 24px rgba(220,50,50,.7));
    margin-bottom: 4px;
  }
  .logo-subtitle {
    font-size: 1rem; color: #94a3b8; letter-spacing: .3em; margin: 4px 0 16px;
    text-transform: uppercase;
  }
  .logo-divider { width: 120px; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); margin: 0 auto; }
  .main-menu-options { display: flex; flex-direction: column; gap: clamp(8px, 1.5vh, 16px); width: 100%; }
  .menu-btn {
    display: flex; align-items: center; gap: 16px;
    padding: clamp(10px, 1.8vh, 18px) clamp(14px, 2vw, 24px); border-radius: 12px; border: none; cursor: pointer;
    text-align: left; transition: all .25s; width: 100%;
    box-sizing: border-box; overflow: hidden;
  }
  .menu-btn-story {
    background: #0d1117; border: 1px solid #1e293b; border-left: 4px solid #6366f1;
  }
  .menu-btn-story:hover {
    transform: translateY(-2px); box-shadow: 0 4px 24px rgba(99,102,241,.25); border-color: #6366f1;
  }
  .menu-btn-arcade {
    background: #0d1117; border: 1px solid #1e293b; border-left: 4px solid #ef4444;
  }
  .menu-btn-arcade:hover {
    transform: translateY(-2px); box-shadow: 0 4px 24px rgba(239,68,68,.25); border-color: #ef4444;
  }
  .menu-btn-online {
    background: #0d1117; border: 1px solid #1e293b; border-left: 4px solid #0ea5e9;
  }
  .menu-btn-online:hover {
    transform: translateY(-2px); box-shadow: 0 4px 24px rgba(14,165,233,.25); border-color: #0ea5e9;
  }
  .menu-btn-online .menu-btn-title { color: #38bdf8; }
  .menu-btn-online .menu-btn-desc  { color: #7dd3fc; }
  .menu-btn-trade {
    background: #0d1117; border: 1px solid #1e293b; border-left: 4px solid #10b981;
  }
  .menu-btn-trade:hover {
    transform: translateY(-2px); box-shadow: 0 4px 24px rgba(16,185,129,.25); border-color: #10b981;
  }
  .menu-btn-trade .menu-btn-title { color: #34d399; }
  .menu-btn-trade .menu-btn-desc  { color: #6ee7b7; }
  .menu-btn-rules {
    background: #0d1117; border: 1px solid #1e293b; border-left: 4px solid #f59e0b;
  }
  .menu-btn-rules:hover {
    transform: translateY(-2px); box-shadow: 0 4px 24px rgba(245,158,11,.25); border-color: #f59e0b;
  }
  .menu-btn-rules .menu-btn-title { color: #fde68a; }
  .menu-btn-rules .menu-btn-desc  { color: #fcd34d; }

  .menu-btn-icon { font-size: clamp(1.2rem, 1.8vh, 2rem); flex-shrink: 0; }
  .menu-btn-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 0; overflow: hidden; }
  .menu-btn-title { font-size: clamp(.9rem, 1.5vh, 1.2rem); font-weight: 700; color: #f1f5f9; white-space: normal; word-break: break-word; }
  .menu-btn-desc { font-size: clamp(.63rem, 1.05vh, .75rem); color: #94a3b8; white-space: normal; word-break: break-word; }
  .main-menu-footer { color: #475569; font-size: .7rem; letter-spacing: .2em; display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; }
  .btn-notif-enable {
    background: transparent; border: 1px solid #6366f1; color: #a5b4fc; border-radius: 6px;
    padding: 4px 12px; font-size: .65rem; cursor: pointer; transition: all .2s;
  }
  .btn-notif-enable:hover { background: #6366f1; color: #fff; }
  .notif-enabled-badge { color: #34d399; font-size: .8rem; }

  @media (max-height: 760px) {
    .main-menu-content { padding-top: 10px; padding-bottom: 10px; }
    .logo-img { width: min(250px, 80vw, 30vh); }
    .logo-subtitle { margin: 2px 0 8px; font-size: .82rem; letter-spacing: .2em; }
    .logo-divider { width: 90px; }
    .main-menu-user { padding: 6px 10px; font-size: .72rem; }
    .btn-logout { padding: 3px 8px; font-size: .65rem; }
    .menu-btn { border-radius: 10px; }
  }

  @media (max-width: 600px) {
    .main-menu-content {
      gap: 20px;
      padding: 20px 12px 20px;
      max-width: 100vw;
      width: 100%;
      box-sizing: border-box;
      overflow: hidden;
    }
    .main-menu-options {
      overflow: hidden;
    }
    .logo-img {
      width: 180px;
    }
    .logo-subtitle {
      font-size: .75rem;
      letter-spacing: .15em;
    }
    .main-menu-options {
      gap: 10px;
      width: 100%;
    }
    .menu-btn {
      padding: 12px 14px;
      gap: 10px;
      border-radius: 10px;
      width: 100%;
      box-sizing: border-box;
    }
    .menu-btn-icon {
      font-size: 1.4rem;
      width: 28px;
      text-align: center;
    }
    .menu-btn-title {
      font-size: .95rem;
    }
    .menu-btn-desc {
      font-size: .68rem;
      line-height: 1.35;
    }
    .main-menu-user {
      font-size: .75rem;
      padding: 7px 12px;
      box-sizing: border-box;
    }
    .main-menu-footer {
      font-size: .65rem;
    }
  }

  /* =====================================================================
     STORY DECK SELECT
  ===================================================================== */
  .story-deck-select {
    min-height: 100vh; padding: 20px;
    background: radial-gradient(ellipse at 50% 0%, rgba(30,27,75,.4) 0%, transparent 60%), var(--bg);
  }
  .story-deck-header {
    text-align: center; margin-bottom: 30px;
  }
  .story-deck-header h1 { font-size: 1.8rem; color: #f1f5f9; margin: 8px 0 4px; }
  .story-deck-header p  { color: #94a3b8; font-size: .9rem; }
  .starter-decks-grid {
    display: flex; flex-wrap: wrap; gap: 18px;
    justify-content: center; max-width: 1000px; margin: 0 auto;
  }
  .starter-deck-card {
    position: relative; width: 180px;
    background: #0d1117;
    border: 1px solid #1e293b;
    border-radius: 12px; padding: 20px 16px 16px;
    cursor: pointer; overflow: hidden; transition: all .25s;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-align: center;
  }
  .starter-deck-card.hovered,
  .starter-deck-card:hover {
    transform: translateY(-6px);
    border-color: var(--deck-color, #facc15);
    box-shadow: 0 8px 30px color-mix(in srgb, var(--deck-color, #facc15) 30%, transparent);
  }
  .sdk-glow {
    position: absolute; inset: 0;
    background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--deck-color, #facc15) 20%, transparent) 0%, transparent 60%);
    pointer-events: none;
  }
  .sdk-icon { font-size: 2.2rem; }
  .sdk-leader-icon { font-size: 1.4rem; opacity: .7; }
  .sdk-name { font-size: .95rem; font-weight: 700; color: #f1f5f9; margin-top: 4px; }
  .sdk-desc { font-size: .65rem; color: #94a3b8; line-height: 1.4; flex: 1; }
  .sdk-leader-name { font-size: .65rem; color: #cbd5e1; }
  .sdk-leader-label { color: #64748b; margin-right: 4px; }
  .sdk-rank-badge {
    margin-left: 5px;
    background: rgba(251,191,36,.2);
    border: 1px solid rgba(251,191,36,.5);
    color: #fbbf24;
    font-size: .6rem;
    font-weight: 700;
    border-radius: 3px;
    padding: 0 3px;
    line-height: 1.4;
  }
  .sdk-rank-badge-img {
    margin-left: 5px;
    width: 18px;
    height: auto;
    image-rendering: pixelated;
    vertical-align: middle;
    filter: drop-shadow(0 0 2px rgba(251,191,36,.6));
  }
  .sdk-card-count { font-size: .6rem; color: #475569; }
  .sdk-select-btn {
    margin-top: 8px; padding: 6px 14px; border-radius: 6px; border: none;
    background: color-mix(in srgb, var(--deck-color, #facc15) 20%, #1e293b);
    color: var(--deck-color, #facc15);
    font-size: .7rem; font-weight: 700; cursor: pointer;
    border: 1px solid var(--deck-color, #facc15);
    transition: all .2s;
  }
  .sdk-select-btn:hover { background: var(--deck-color, #facc15); color: #0f172a; }


  /* =====================================================================
     AUTH SCREEN
  ===================================================================== */
  .auth-screen {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at 50% 30%, #1a0505 0%, #080810 70%);
  }
  .auth-bg {
    position: absolute; inset: 0;
    background: radial-gradient(circle at 30% 70%, rgba(37,99,235,.06) 0%, transparent 50%);
    pointer-events: none;
  }
  .auth-box {
    position: relative; z-index: 1;
    background: rgba(13,17,23,.95);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 16px; padding: 36px 32px;
    width: 100%; max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
  }
  .auth-logo { font-size: 3rem; text-align: center; margin-bottom: 4px; filter: drop-shadow(0 0 16px rgba(200,50,50,.8)); }
  .auth-title { font-size: 1.6rem; font-weight: 900; text-align: center; color: var(--gold); margin: 0 0 20px; }
  .auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); }
  .auth-tab {
    flex: 1; padding: 8px; border: none; cursor: pointer;
    background: rgba(255,255,255,.04); color: #64748b; font-size: .85rem; font-weight: 600; transition: all .2s;
  }
  .auth-tab.active { background: rgba(37,99,235,.25); color: #60a5fa; }
  .auth-form { display: flex; flex-direction: column; gap: 14px; }
  .auth-field { display: flex; flex-direction: column; gap: 5px; }
  .auth-field label { font-size: .7rem; color: #94a3b8; font-weight: 600; letter-spacing: .05em; }
  .auth-field input {
    padding: 10px 12px; border-radius: 8px;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
    color: #f1f5f9; font-size: .9rem; outline: none; transition: border-color .2s;
  }
  .auth-field input:focus { border-color: #2563eb; }
  .auth-error { font-size: .75rem; color: #f87171; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); padding: 8px 10px; border-radius: 6px; }
  .auth-submit {
    margin-top: 4px; padding: 12px; border-radius: 8px; border: none; cursor: pointer;
    background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; font-size: .95rem; font-weight: 700;
    transition: all .2s;
  }
  .auth-submit:hover:not(:disabled) { background: linear-gradient(135deg, #3b82f6, #2563eb); transform: translateY(-1px); }
  .auth-submit:disabled { opacity: .6; cursor: not-allowed; }

  /* =====================================================================
     MAIN MENU — user bar + admin button
  ===================================================================== */
  .main-menu-user {
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px; padding: 8px 14px; width: 100%;
    font-size: .8rem; color: #94a3b8;
  }
  .btn-logout {
    background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
    color: #f87171; padding: 4px 10px; border-radius: 5px; font-size: .7rem; cursor: pointer;
    transition: all .2s;
  }
  .btn-logout:hover { background: rgba(239,68,68,.25); }
  .menu-btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }
  .menu-btn-admin {
    background: #0d1117; border: 1px solid #1e293b; border-left: 4px solid #ec4899;
  }
  .menu-btn-admin:hover { transform: translateY(-2px); box-shadow: 0 4px 24px rgba(236,72,153,.25); border-color: #ec4899; }

  /* =====================================================================
     RULES SCREEN
  ===================================================================== */
  .rules-screen {
    height: 100vh;
    background: linear-gradient(160deg, #080810 0%, #0f0f1a 60%, #10101e 100%);
    display: flex; flex-direction: column;
    color: #e2e8f0;
    font-family: inherit;
    overflow: hidden;
  }
  .rules-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: #0d1117;
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    z-index: 10;
  }
  .rules-title {
    font-size: 1.3rem; font-weight: 700; margin: 0;
    color: #f1f5f9;
    text-shadow: none;
  }
  .rules-back-btn {
    background: rgba(148,163,184,.1); border: 1px solid rgba(148,163,184,.2);
    color: #94a3b8; border-radius: 8px; padding: 6px 14px;
    cursor: pointer; font-size: .85rem; transition: all .2s; flex-shrink: 0;
  }
  .rules-back-btn:hover { background: rgba(148,163,184,.2); color: #e2e8f0; }

  /* Hamburger button — hidden on desktop */
  .rules-hamburger {
    display: none;
    flex-direction: column; justify-content: center; align-items: center;
    gap: 5px; width: 36px; height: 36px;
    background: rgba(148,163,184,.1); border: 1px solid rgba(148,163,184,.2);
    border-radius: 8px; cursor: pointer; padding: 0; flex-shrink: 0;
  }
  .rules-hamburger span {
    display: block; width: 18px; height: 2px;
    background: #94a3b8; border-radius: 2px; transition: all .2s;
  }

  .rules-layout {
    display: flex; flex: 1; overflow: hidden;
    min-height: 0;
  }

  /* Nav overlay (mobile) */
  .rules-nav-overlay {
    display: none;
  }

  /* Nav sidebar */
  .rules-nav {
    width: 190px; min-width: 150px; flex-shrink: 0;
    background: rgba(0,0,0,.3);
    border-right: 1px solid rgba(255,255,255,.08);
    display: flex; flex-direction: column; gap: 2px;
    padding: 12px 8px;
    overflow-y: auto;
  }

  /* Close button inside drawer — hidden on desktop */
  .rules-nav-close { display: none; }

  @media (max-width: 640px) {
    .rules-hamburger { display: flex; }
    .rules-header { padding: 10px 14px; gap: 8px; }
    .rules-title { font-size: 1rem; }

    .rules-nav-overlay {
      display: block;
      position: fixed; inset: 0; z-index: 99;
      background: rgba(0,0,0,.55);
    }

    /* Hide nav by default on mobile; show as drawer when open */
    .rules-nav {
      display: none;
    }
    .rules-nav.rules-nav-open {
      display: flex;
      position: fixed; top: 0; left: 0; bottom: 0;
      z-index: 100;
      width: 76vw; max-width: 280px;
      flex-direction: column;
      gap: 4px;
      padding: 12px 10px 24px;
      background: #0e0e1a;
      border-right: 1px solid rgba(148,163,184,.15);
      box-shadow: 4px 0 32px rgba(0,0,0,.7);
      overflow-y: auto;
    }

    .rules-nav-close {
      display: flex;
      align-items: center;
      gap: 6px;
      background: rgba(239,68,68,.12);
      border: 1px solid rgba(239,68,68,.25);
      color: #f87171;
      border-radius: 8px;
      padding: 8px 14px;
      font-size: .85rem;
      cursor: pointer;
      margin-bottom: 8px;
      width: 100%;
      transition: background .2s;
    }
    .rules-nav-close:hover { background: rgba(239,68,68,.25); }

    .rules-content { padding: 16px 14px 40px; }
  }
  .rules-nav-btn {
    display: flex; align-items: center; gap: 8px;
    background: transparent; border: 1px solid transparent;
    color: #94a3b8; border-radius: 8px; padding: 8px 10px;
    cursor: pointer; font-size: .82rem; text-align: left;
    transition: all .18s;
  }
  .rules-nav-btn:hover { background: rgba(148,163,184,.08); color: #cbd5e1; }
  .rules-nav-btn.active {
    background: rgba(37,99,235,.1); border-color: rgba(37,99,235,.3);
    color: #60a5fa; font-weight: 600;
  }

  /* Content */
  .rules-content {
    flex: 1; overflow-y: auto;
    padding: 24px 40px 48px;
  }
  .rules-section { max-width: 100%; }
  .rules-section-title {
    font-size: 1.15rem; font-weight: 700;
    color: #f1f5f9; margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #1e293b;
  }
  .rules-section-body { display: flex; flex-direction: column; gap: 10px; }
  .rules-section-body > p {
    color: #cbd5e1; line-height: 1.7; margin: 0 0 4px;
  }
  .rules-row {
    background: rgba(255,255,255,.03);
    border: 1px solid #1e293b;
    border-radius: 12px; padding: 10px 14px;
  }
  .rules-row-head {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 4px;
  }
  .rules-row-head strong { color: #e2e8f0; font-size: .9rem; }
  .rules-row-body {
    color: #94a3b8; font-size: .82rem; line-height: 1.7;
    padding-left: 26px;
  }
  .rules-row-body ul { margin: 4px 0 0 4px; padding: 0; }

  /* Terrain table */
  .rules-terrain-wrap { overflow-x: auto; margin-top: 10px; }
  .rules-terrain-table {
    width: 100%; border-collapse: collapse;
    font-size: .82rem;
  }
  .rules-terrain-table thead tr {
    background: rgba(37,99,235,.08);
  }
  .rules-terrain-table th {
    padding: 10px 14px; text-align: left;
    color: #94a3b8; font-size: .8rem; text-transform: uppercase;
    letter-spacing: .06em; border-bottom: 1px solid #1e293b;
  }
  .rules-terrain-table td {
    padding: 9px 14px; border-bottom: 1px solid rgba(255,255,255,.04);
    color: #cbd5e1; vertical-align: middle;
  }
  .rules-terrain-table tr:last-child td { border-bottom: none; }
  .rules-terrain-table tr:hover td { background: rgba(255,255,255,.03); }
  .rules-terrain-wall td { color: #9ca3af !important; font-style: italic; }
  .rules-terrain-crash td { color: #f87171 !important; font-weight: 600; }
  .rules-terrain-boost { color: #4ade80 !important; }
  .rules-terrain-weaken { color: #f87171 !important; }

  /* ── Rank & Patentes section (Rules Screen) ── */
  .rules-xp-table { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
  .rules-xp-row { display: flex; align-items: center; gap: 8px; }
  .rules-diff {
    font-size: .72rem; font-weight: 700; padding: 3px 10px;
    border-radius: 12px; text-transform: uppercase; letter-spacing: .5px;
  }
  .rules-diff-easy   { background: #052e16; color: #4ade80; border: 1px solid #166534; }
  .rules-diff-normal { background: #1e3a5f; color: #60a5fa; border: 1px solid #1d4ed8; }
  .rules-diff-hard   { background: #431407; color: #fb923c; border: 1px solid #c2410c; }
  .rules-diff-master { background: #2e1065; color: #c4b5fd; border: 1px solid #7c3aed; }
  .rules-xp-val { color: #38bdf8; font-weight: 700; font-size: .85rem; }

  .rules-rank-table-wrap { overflow-x: auto; }
  .rules-rank-table {
    width: 100%; border-collapse: collapse; font-size: .78rem; margin-top: 2px;
  }
  .rules-rank-table thead tr { background: #1e293b; }
  .rules-rank-table th {
    padding: 8px 10px; text-align: left; color: #94a3b8;
    font-size: .68rem; text-transform: uppercase; letter-spacing: .6px;
    border-bottom: 1px solid #334155;
  }
  .rules-rank-table td {
    padding: 7px 10px; border-bottom: 1px solid rgba(51,65,85,.4); color: #cbd5e1;
  }
  .rules-rank-table tr:hover td { background: rgba(255,255,255,.03); }
  .rr-low  td { color: #94a3b8; }
  .rr-mid  td { color: #e2e8f0; }
  .rr-high td { color: #fde68a; }
  .rr-top  td { color: #fbbf24; }

  .rules-rank-badge {
    display: inline-block; background: rgba(245,158,11,.15);
    border: 1px solid rgba(245,158,11,.35); color: #f59e0b;
    font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  }
  .rules-rank-img {
    height: 28px; width: auto; vertical-align: middle;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 4px rgba(251,191,36,.5));
  }
  .rules-terrain-img {
    height: 40px; width: auto; vertical-align: middle; border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,.5); margin-right: 8px; object-fit: cover;
  }

  .rules-abilities-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px; margin-top: 4px;
  }
  .rules-ability-card {
    background: #0d1117; border: 1px solid #1e293b; border-radius: 12px;
    padding: 10px 12px; transition: border-color .15s;
  }
  .rules-ability-card:hover { border-color: #2563eb; }
  .rules-ability-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
  }
  .rules-ability-main {
    display: inline-flex; align-items: center; gap: 8px; min-width: 0;
  }
  .rules-relic-thumb {
    width: 34px; height: 34px; border-radius: 7px; object-fit: cover;
    border: 1px solid rgba(245,158,11,.5);
    box-shadow: 0 2px 8px rgba(0,0,0,.35), 0 0 12px rgba(245,158,11,.2);
    background: linear-gradient(135deg, #36210a, #6b3f0f 45%, #a16207);
    flex-shrink: 0;
  }
  .rules-ability-label { font-size: .8rem; font-weight: 700; color: #e2e8f0; }
  .rules-ability-rank {
    font-size: .65rem; font-weight: 700; color: #f59e0b;
    background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.3);
    padding: 2px 6px; border-radius: 4px;
    display: flex; align-items: center;
  }
  .rules-ability-rank .rules-rank-img { height: 22px; }
  .rules-ability-desc { font-size: .7rem; color: #94a3b8; line-height: 1.5; }

  @media (max-width: 600px) {
    .rules-content { padding: 16px; }
    .rules-nav-btn { font-size: .72rem; padding: 6px 8px; }
  }

  /* ── Fusion List (Rules Screen) ── */
  .rules-fusion-list {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 460px; overflow-y: auto;
    padding: 6px 0;
  }
  .rules-fusion-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 6px;
    background: rgba(255,255,255,.03);
    font-size: .78rem; color: #cbd5e1;
    transition: background .15s;
  }
  .rules-fusion-row:hover { background: rgba(255,255,255,.07); }
  .rules-fusion-mats { color: #93c5fd; min-width: 0; flex-shrink: 1; }
  .rules-fusion-arrow { color: #facc15; font-weight: 700; font-size: .9rem; flex-shrink: 0; }
  .rules-fusion-result { flex: 1; min-width: 0; }
  .rules-fusion-result strong { color: #fde68a; }
  .rules-fusion-stats { color: #94a3b8; font-size: .72rem; margin-left: 4px; }
  .rules-fusion-minlv { color: #64748b; font-size: .68rem; margin-left: 4px; }
  .rules-fusion-type-row .rules-fusion-mats { color: #a5b4fc; font-style: italic; }
  .rules-fusion-subs {
    display: flex; flex-wrap: wrap; gap: 6px;
  }
  .rules-fusion-sub-chip {
    background: rgba(168,85,247,.15); border: 1px solid rgba(168,85,247,.3);
    border-radius: 12px; padding: 4px 10px; font-size: .72rem;
    color: #c4b5fd;
  }

  /* ── Visual Fusion Display (with card images) ── */
  .rules-fusion-visual {
    flex-wrap: wrap; align-items: flex-start; gap: 12px;
    padding: 12px;
  }
  .rules-fusion-materials {
    display: flex; align-items: flex-start; gap: 8px;
    flex-wrap: wrap;
  }
  .rules-fusion-mat-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    position: relative;
  }
  .rules-fusion-mat-img {
    width: 48px; height: 72px; object-fit: cover;
    border-radius: 4px; border: 2px solid #3b82f6;
    background: #1e293b;
  }
  .rules-fusion-cnt {
    position: absolute; bottom: -8px; right: -8px;
    background: #ef4444; color: white; font-weight: 700; font-size: .65rem;
    padding: 2px 5px; border-radius: 10px; min-width: 22px; text-align: center;
  }
  .rules-fusion-op {
    color: #facc15; font-weight: 700; font-size: 1.2rem;
    align-self: center;
  }
  .rules-fusion-equals {
    color: #4ade80; font-weight: 700; font-size: 1.2rem;
    align-self: center;
  }
  .rules-fusion-result-item {
    display: flex; align-items: flex-start; gap: 10px;
    flex: 1; min-width: 150px;
  }
  .rules-fusion-result-img {
    width: 48px; height: 72px; object-fit: cover;
    border-radius: 4px; border: 2px solid #fbbf24;
    background: #1e293b; flex-shrink: 0;
  }
  .rules-fusion-result-info {
    display: flex; flex-direction: column; gap: 2px; flex: 1;
  }
  .rules-fusion-result-name {
    color: #fde68a; font-weight: 700; font-size: .8rem;
    line-height: 1.2;
  }
  .rules-fusion-result-stats {
    color: #94a3b8; font-size: .7rem;
  }
  .rules-fusion-type-mats {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
  }
  .rules-fusion-type-item {
    background: rgba(165,180,252,.1); border: 1px solid rgba(165,180,252,.3);
    border-radius: 4px; padding: 6px 10px; font-size: .75rem;
    color: #a5b4fc; font-style: italic;
  }
  .rules-fusion-type-result-item {
    display: flex; align-items: flex-start; gap: 10px;
    flex: 1; min-width: 150px;
  }
  .rules-fusion-minlv {
    color: #64748b; font-size: .65rem;
  }

  /* ── Spell/Trap Card Catalog ── */
  .rules-spell-cat-title {
    margin: 20px 0 10px; padding-bottom: 6px;
    border-bottom: 1px solid #334155;
    color: #e2e8f0; font-size: .95rem; font-weight: 700;
  }
  .rules-spell-cat-count {
    color: #64748b; font-weight: 400; font-size: .8rem;
  }
  .rules-spell-grid {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 16px;
  }
  .rules-spell-card {
    display: flex; gap: 10px; padding: 8px 10px;
    background: rgba(30,41,59,.7); border: 1px solid #334155;
    border-radius: 8px; transition: background .15s;
    border-left: 3px solid #3b82f6;
  }
  .rules-spell-card:hover {
    background: rgba(51,65,85,.6);
  }
  .rules-spell-trap {
    border-left-color: #ef4444;
    background: rgba(127,29,29,.15);
  }
  .rules-spell-trap:hover {
    background: rgba(127,29,29,.25);
  }
  .rules-spell-ritual {
    border-left-color: #a78bfa;
    background: rgba(88,28,135,.15);
  }
  .rules-spell-ritual:hover {
    background: rgba(88,28,135,.25);
  }
  .rules-spell-img-wrap {
    flex-shrink: 0; width: 48px; height: 68px;
  }
  .rules-spell-img {
    width: 48px; height: 68px; object-fit: cover;
    border-radius: 4px; border: 1px solid #475569;
    background: #1e293b; font-size: 1.5rem;
    display: flex; align-items: center; justify-content: center;
  }
  .rules-spell-info {
    display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0;
  }
  .rules-spell-name {
    color: #f1f5f9; font-weight: 700; font-size: .82rem;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  }
  .rules-spell-cost {
    font-size: .68rem; font-weight: 600; color: #facc15;
    background: rgba(250,204,21,.12); padding: 1px 6px;
    border-radius: 4px; white-space: nowrap;
  }
  .rules-spell-type {
    font-size: .7rem; color: #94a3b8;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  }
  .rules-spell-perm {
    font-size: .62rem; font-weight: 600; color: #4ade80;
    background: rgba(74,222,128,.12); padding: 1px 5px;
    border-radius: 3px;
  }
  .rules-spell-trigger {
    font-size: .62rem; font-weight: 600; color: #fb923c;
    background: rgba(251,146,60,.12); padding: 1px 5px;
    border-radius: 3px;
  }
  .rules-spell-desc {
    font-size: .76rem; color: #cbd5e1; line-height: 1.35;
  }
  @media (max-width: 600px) {
    .rules-spell-img-wrap { width: 40px; height: 56px; }
    .rules-spell-img { width: 40px; height: 56px; font-size: 1.2rem; }
    .rules-spell-name { font-size: .76rem; }
    .rules-spell-desc { font-size: .72rem; }
    .rules-spell-card { padding: 6px 8px; gap: 8px; }
  }

  /* ── All-Cards Browser (Deck Editor) ── */
  .de-browse-btn {
    padding: 6px 14px; border-radius: 6px; font-size: .78rem; font-weight: 700;
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    color: #dbeafe; border: 1px solid rgba(59,130,246,.3);
    cursor: pointer; transition: all .2s;
  }
  .de-browse-btn:hover { background: linear-gradient(135deg, #2563eb, #3b82f6); }

  .ac-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
  }
  .ac-modal {
    background: #12121e; border: 1px solid #2d2d50;
    border-radius: 12px; width: 92vw; max-width: 1100px;
    height: 88vh; max-height: 88vh;
    display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.8);
  }
  .ac-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px; border-bottom: 1px solid #2d2d50;
    background: rgba(0,0,0,.3);
  }
  .ac-title { font-size: 1.05rem; color: #e2e8f0; margin: 0; }
  .ac-close {
    width: 32px; height: 32px; border-radius: 6px;
    background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3);
    color: #f87171; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
  }
  .ac-close:hover { background: rgba(239,68,68,.3); }
  .ac-filters {
    padding: 10px 18px; border-bottom: 1px solid rgba(255,255,255,.04);
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  }
  .ac-search {
    padding: 6px 10px; border-radius: 6px; border: 1px solid #334155;
    background: #1e1e2e; color: #e2e8f0; font-size: .78rem;
    width: 220px; outline: none;
  }
  .ac-search:focus { border-color: #3b82f6; }
  .ac-type-filters {
    display: flex; gap: 4px; flex-wrap: wrap; flex: 1;
  }
  .ac-count {
    font-size: .72rem; color: #64748b; margin-left: auto; white-space: nowrap;
  }
  .ac-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,.04);
  }
  .ac-pagination button {
    padding: 4px 10px; border-radius: 5px; font-size: .78rem;
    background: #1e293b; color: #94a3b8; border: 1px solid #334155;
    cursor: pointer; transition: all .15s;
  }
  .ac-pagination button:disabled { opacity: .3; cursor: default; }
  .ac-pagination button:not(:disabled):hover { background: #334155; color: #e2e8f0; }
  .ac-page-info { font-size: .78rem; color: #94a3b8; }
  .ac-grid {
    flex: 1; overflow-y: auto; padding: 12px 18px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 8px;
  }
  .ac-card-item {
    background: rgba(255,255,255,.04); border-radius: 8px;
    padding: 6px; text-align: center; cursor: default;
    transition: background .15s; position: relative;
  }
  .ac-card-item:hover { background: rgba(255,255,255,.08); }
  .ac-card-not-owned { opacity: .45; }
  .ac-card-not-owned:hover { opacity: .7; }
  .ac-card-thumb-wrap { position: relative; }
  .ac-not-owned-badge {
    position: absolute; top: 2px; right: 2px;
    background: rgba(0,0,0,.65); border-radius: 4px;
    padding: 1px 4px; font-size: .65rem;
  }
  .ac-owned-badge {
    position: absolute; top: 2px; right: 2px;
    background: rgba(34,197,94,.2); border: 1px solid rgba(34,197,94,.4);
    border-radius: 4px; padding: 0 4px; font-size: .6rem;
    color: #4ade80; font-weight: 700;
  }

  @media (max-width: 600px) {
    .ac-modal { width: 98vw; height: 95vh; }
    .ac-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
    .ac-search { width: 100%; }
    .ac-filters { flex-direction: column; }
  }

