    :root {
        --bg: #f4f4f9; --card-bg: #ffffff; --text: #333; --border: #ddd;
        --pk-blue: #3b4cca; --pk-yellow: #ffde00; --pk-red: #cc0000;
        --drawer-width: 420px;
    }
    body.dark-mode { --bg: #1a1a1a; --card-bg: #2d2d2d; --text: #f0f0f0; --border: #444; }
    * { box-sizing: border-box; }
    body { font-family: "Segoe UI", sans-serif; background: var(--bg); color: var(--text); padding: 12px; transition: background 0.3s, color 0.3s; margin: 0; overflow-x: hidden; }
    .header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
    /* ── OVERLAY ── */
    .drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; }
    .drawer-overlay.open { display: block; }

    /* ── BOTTOM SHEET (desktop default) ── */
    .team-drawer {
        position: fixed; left: 0; right: 0; bottom: -100%;
        max-height: 65vh; min-height: 220px;
        background: var(--bg); z-index: 201;
        transition: bottom 0.35s cubic-bezier(.4,0,.2,1);
        display: flex; flex-direction: column;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.35);
        border-radius: 16px 16px 0 0;
    }
    .team-drawer.open { bottom: 0; }

    /* Header bar with pokeball + title + show toggles + close */
    .drawer-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 2px solid var(--border);
        background: var(--pk-blue); color: white; flex-shrink: 0;
        border-radius: 16px 16px 0 0;
    }
    /* Show row spans full width on second row when needed */
    .drawer-header-left { grid-column: 1; display: flex; align-items: center; gap: 6px; }
    .drawer-show-row { grid-column: 2; display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; align-items: center; }
    .drawer-close-btn-wrap { grid-column: 3; }
    .drawer-header-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .drawer-header-left h2 { margin: 0; font-size: 0.95rem; white-space: nowrap; }
    .drawer-pokeball { width: 22px; height: 22px; image-rendering: pixelated; vertical-align: middle; }

    /* Show toggles inside drawer header */
    .drawer-show-row { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; justify-content: center; }
    .drawer-show-btn {
        padding: 3px 8px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.4);
        background: rgba(255,255,255,0.15); color: white; cursor: pointer;
        font-weight: bold; font-size: 0.65rem; white-space: nowrap;
        transition: 0.15s; -webkit-tap-highlight-color: transparent;
    }
    .drawer-show-btn.dsb-active { background: #27ae60; border-color: #27ae60; }
    .drawer-close-btn { background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; line-height: 1; flex-shrink: 0; }

    /* Scrollable body */
    .drawer-body { flex: 1; overflow-y: auto; padding: 8px 10px; }

    /* Footer */
    .drawer-footer { padding: 6px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }

    /* ── TEAM CONTAINER ── */
    .team-container {
        background: rgba(0,0,0,0.05); padding: 6px 8px;
        border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--border);
    }
    .team-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
    .team-name-input { background: transparent; border: none; border-bottom: 1px solid var(--border); color: var(--text); font-weight: bold; font-size: 0.85rem; width: 160px; outline: none; padding: 2px 4px; }

    /* Horizontal 1-row layout for desktop bottom sheet */
    .team-slots {
        display: flex; flex-direction: row; gap: 6px;
        overflow-x: auto; overflow-y: hidden;
        padding-bottom: 4px; /* space for scrollbar */
    }
    .team-slots::-webkit-scrollbar { height: 3px; }
    .team-slots::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

    /* Each slot grows to fill available width equally */
    .slot {
        flex: 1 1 0; min-width: 120px; max-width: 220px;
        background: rgba(0,0,0,0.05); border: 2px dashed var(--border);
        border-radius: 8px; display: flex; align-items: flex-start; justify-content: center;
        cursor: pointer; position: relative; overflow: visible;
        transition: border-color 0.2s, background 0.2s;
        min-height: 50px;
    }
    .slot.empty-slot { align-items: center; min-height: 100px; }
    .slot.empty-slot::after { content: "+"; font-size: 1.8rem; opacity: 0.2; pointer-events: none; }
    .slot.empty-slot:hover { border-color: var(--pk-blue); background: rgba(59,76,202,0.08); }

    /* Cards inside slots: fill slot, scaled down */
    .slot .card {
        width: 100%; margin: 0;
        border: 1px solid var(--border) !important;
        border-radius: 6px; cursor: default; padding: 5px;
    }
    .slot .card:active { transform: none; }
    /* Proportional scale — sprite and text shrink together */
    .slot .card img { width: 52px; height: 52px; }
    .slot .card .id-badge { font-size: 0.6rem; }
    .slot .card .card-name { font-size: 0.72rem; }
    .slot .card .type-pill { font-size: 0.5rem; padding: 2px 5px; }
    .slot .card .stats-box { font-size: 0.6rem; padding: 4px 5px; gap: 2px; }
    .slot .card .stat-label { width: 22px; }
    .slot .card .stat-bar-bg { height: 5px; }
    .slot .card .card-total { font-size: 0.62rem; margin-top: 4px; }
    /* Evo chain: smaller sprites, text still legible */
    .slot .card .evo-node img { width: 28px; height: 28px; }
    .slot .card .evo-name { font-size: 0.46rem; max-width: 34px; }
    .slot .card .evo-num { font-size: 0.38rem; }
    .slot .card .evo-arrow { font-size: 0.75rem; padding: 0 1px; }
    .slot .card .evo-arrow-label { font-size: 0.38rem; max-width: 30px; }
    /* Moves: compact */
    .slot .card .moves-table { font-size: 0.55rem; }
    .slot .card .moves-table th { padding: 2px 4px; font-size: 0.5rem; }
    .slot .card .moves-table td { padding: 1px 4px; }
    /* Type chart */
    .slot .card .tc-pill { font-size: 0.48rem; padding: 1px 3px; gap: 2px; }
    .slot .card .typechart-label { font-size: 0.48rem; }
    .slot .card .tc-section-head { font-size: 0.46rem; }
    .slot .card .typechart-row { gap: 2px; margin-bottom: 2px; }

    /* Filled slot resets */
    .slot.slot-filled { border: none; background: none; cursor: default; padding: 0; overflow: visible; min-height: auto; align-items: flex-start; }

    /* Remove btn stays top-right */
    .slot-remove-btn {
        position: absolute; top: 3px; right: 3px; z-index: 10;
        background: var(--pk-red); color: white; border: none; border-radius: 50%;
        width: 16px; height: 16px; font-size: 0.65rem; cursor: pointer;
        display: flex; align-items: center; justify-content: center; padding: 0; line-height: 1;
    }

    /* FAB */
    .fab-team {
        position: fixed; bottom: 20px; right: 20px; z-index: 150;
        background: var(--pk-blue); color: var(--pk-yellow);
        border: 3px solid var(--pk-yellow); border-radius: 50px;
        padding: 8px 16px; font-weight: bold; font-size: 0.9rem;
        cursor: pointer; box-shadow: 0 4px 15px rgba(59,76,202,0.5);
        display: flex; align-items: center; gap: 6px;
        -webkit-tap-highlight-color: transparent; user-select: none; transition: transform 0.15s;
    }
    .fab-team:active { transform: scale(0.95); }
    .fab-pokeball { width: 20px; height: 20px; image-rendering: pixelated; }
    .fab-badge { background: var(--pk-red); color: white; border-radius: 10px; padding: 1px 7px; font-size: 0.7rem; min-width: 20px; text-align: center; }

    /* ── TABLET/MOBILE: right-side drawer (≤1024px) ── */
    @media (max-width: 1024px) {
        .team-drawer {
            top: 0; bottom: unset; left: unset; right: -100%; width: min(520px, 100vw);
            max-height: 100vh; height: 100%;
            border-radius: 0; transition: right 0.35s cubic-bezier(.4,0,.2,1);
            box-shadow: -4px 0 24px rgba(0,0,0,0.35);
        }
        .team-drawer.open { bottom: unset; right: 0; }
        .drawer-header { border-radius: 0; }
        /* Tablet/mobile: 2-column grid per team row */
        .team-slots {
            display: grid !important;
            grid-template-columns: repeat(2, 1fr);
            gap: 6px;
            overflow-x: hidden; overflow-y: visible;
        }
        .slot { flex: none; width: 100%; min-height: 80px; max-width: none; }
        .slot.empty-slot { min-height: 70px; }
        /* Restore slightly larger text/sprite in wider right drawer */
        .slot .card img { width: 56px; height: 56px; }
        .slot .card .card-name { font-size: 0.78rem; }
        .slot .card .stats-box { font-size: 0.63rem; }
    }
    .controls { background: var(--card-bg); padding: 12px; border-radius: 12px; margin-bottom: 12px; position: sticky; top: 0; z-index: 100; border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
    .filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
    .filter-row:last-child { margin-bottom: 0; }
    .filter-row strong { font-size: 0.8rem; white-space: nowrap; }
    .type-pill { padding: 4px 10px; border-radius: 20px; cursor: pointer; border: 2px solid transparent; font-size: 0.65rem; font-weight: bold; text-transform: uppercase; color: white; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); -webkit-tap-highlight-color: transparent; user-select: none; }
    .type-pill.active { border-color: var(--pk-yellow); box-shadow: 0 0 8px var(--pk-yellow); }
    .toggle-btn, .btn-sort, .btn-display { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); cursor: pointer; font-weight: bold; font-size: 0.75rem; -webkit-tap-highlight-color: transparent; user-select: none; white-space: nowrap; transition: 0.15s; }
    .active { background: var(--pk-blue) !important; color: white !important; border-color: var(--pk-blue) !important; }
    .btn-display.active { background: #27ae60 !important; border-color: #27ae60 !important; color: white !important; }
    .btn-display.coming-soon { border-style: dashed; opacity: 0.55; cursor: default; }

    /* Card grid - wide enough for 3-stage evo chain on one line (~220px min) */
    #main-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; padding: 4px; padding-bottom: 80px; }

    /* Base card */
    .card { padding: 10px; display: flex; flex-direction: column; position: relative; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; transition: transform 0.12s; }
    .card:active { transform: scale(0.97); }
    .card.in-team { border-color: var(--pk-yellow); box-shadow: 0 0 0 2px var(--pk-yellow); }

    /* Version-exclusive glows — subtle inner shadow on card border */
    .card.fr-exclusive { border-color: #e05555; box-shadow: 0 0 0 2px rgba(204,60,60,0.35), inset 0 0 12px rgba(204,60,60,0.08); }
    .card.lg-exclusive { border-color: #4a9e5c; box-shadow: 0 0 0 2px rgba(60,160,80,0.35), inset 0 0 12px rgba(60,160,80,0.08); }
    /* in-team overrides version color but keeps the glow subtle underneath */
    .card.in-team.fr-exclusive { border-color: var(--pk-yellow); box-shadow: 0 0 0 2px var(--pk-yellow), 0 0 8px rgba(204,60,60,0.3); }
    .card.in-team.lg-exclusive { border-color: var(--pk-yellow); box-shadow: 0 0 0 2px var(--pk-yellow), 0 0 8px rgba(60,160,80,0.3); }

    /* Version badge */
    .ver-badge { position: absolute; top: 4px; left: 4px; font-size: 0.5rem; font-weight: bold; padding: 1px 4px; border-radius: 3px; letter-spacing: 0.02em; z-index: 4; }
    .ver-badge.fr { background: rgba(204,60,60,0.8); color: white; }
    .ver-badge.lg { background: rgba(60,160,80,0.8); color: white; }

    .team-count-badge { display: none; position: absolute; top: 4px; right: 4px; background: var(--pk-red); color: white; border-radius: 50%; width: 20px; height: 20px; font-size: 0.65rem; font-weight: bold; align-items: center; justify-content: center; z-index: 5; box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
    .card.in-team .team-count-badge { display: flex; }
    .id-badge { display: block; text-align: center; font-size: 0.7rem; opacity: 0.55; font-family: monospace; }
    .card img { width: 72px; height: 72px; image-rendering: pixelated; margin: 0 auto; display: block; }
    .card-header { text-align: center; margin: 6px 0; }
    .card-name { text-transform: capitalize; font-size: 0.88rem; font-weight: bold; }
    .type-box { display: flex; justify-content: center; gap: 4px; margin-top: 4px; flex-wrap: wrap; }

    /* Stats */
    .section-stats.hidden { display: none; }
    .stats-box { background: rgba(0,0,0,0.08); border-radius: 5px; padding: 7px; display: flex; flex-direction: column; gap: 3px; font-family: monospace; font-size: 0.68rem; }
    .stat-row { display: flex; align-items: center; gap: 6px; border-radius: 2px; }
    .stat-label { width: 28px; font-weight: bold; }
    .stat-bar-bg { flex-grow: 1; height: 6px; background: rgba(0,0,0,0.1); border-radius: 3px; overflow: hidden; }
    .stat-bar-fill { height: 100%; border-radius: 3px; }
    .bar-low { background: #ff4d4d; } .bar-mid { background: #ffcc00; } .bar-high { background: #4caf50; }
    .stat-row.max-stat { outline: 2px solid #000; outline-offset: 1px; background: rgba(255,255,255,0.1); }
    body.dark-mode .stat-row.max-stat { outline-color: #fff; background: rgba(255,255,255,0.15); }
    .card-total { text-align: center; font-size: 0.75rem; font-weight: bold; margin-top: 6px; opacity: 0.85; }

    /* Evolution */
    .section-evo.hidden { display: none; }
    .evo-chain { margin-top: 6px; background: rgba(0,0,0,0.06); border-radius: 6px; padding: 5px 4px; display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; gap: 1px; overflow-x: auto; }
    .evo-node { display: flex; flex-direction: column; align-items: center; gap: 1px; flex-shrink: 0; }
    .evo-node img { width: 42px; height: 42px; image-rendering: pixelated; }
    .evo-node .evo-name { font-size: 0.6rem; text-transform: capitalize; text-align: center; font-weight: bold; opacity: 0.9; max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .evo-node .evo-num { font-size: 0.52rem; opacity: 0.55; font-family: monospace; }
    .evo-node.current-mon img { filter: drop-shadow(0 0 3px var(--pk-yellow)); }
    .evo-arrow { display: flex; flex-direction: column; align-items: center; font-size: 0.9rem; padding: 0 2px; flex-shrink: 0; line-height: 1; }
    .evo-arrow-label { font-size: 0.52rem; text-align: center; opacity: 0.75; max-width: 40px; line-height: 1.2; white-space: nowrap; }

    /* Moves */
    .section-moves.hidden { display: none; }
    .moves-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.68rem; font-family: monospace; }
    .moves-table caption { text-align: left; font-size: 0.62rem; font-weight: bold; opacity: 0.6; padding-bottom: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
    .moves-table th { background: rgba(0,0,0,0.12); padding: 3px 5px; text-align: left; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
    .moves-table td { padding: 2px 5px; border-bottom: 1px solid rgba(0,0,0,0.05); }
    .moves-table tr:last-child td { border-bottom: none; }
    .moves-table td:first-child { width: 36px; opacity: 0.65; font-weight: bold; text-align: right; padding-right: 8px; }
    .moves-table tr:nth-child(even) td { background: rgba(0,0,0,0.04); }

    /* Banner / misc */
    .select-banner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 300; background: var(--pk-blue); color: white; text-align: center; padding: 10px; font-weight: bold; font-size: 0.9rem; }
    .select-banner.show { display: block; }
    .select-banner button { background: var(--pk-red); color: white; border: none; border-radius: 4px; padding: 4px 10px; margin-left: 10px; cursor: pointer; font-weight: bold; }
    .delete-row-btn { background: none; border: none; color: var(--pk-red); font-size: 1rem; cursor: pointer; padding: 2px 6px; }
    @media (max-width: 520px) {
        #main-list { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
        body { padding: 8px; }
    }
    ::-webkit-scrollbar { width: 5px; }
    ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

    /* Type Chart */
    .section-typechart.hidden { display: none; }
    .typechart-wrap { margin-top: 6px; }
    .typechart-label { font-size: 0.6rem; font-weight: bold; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.6; margin-bottom: 3px; }
    .typechart-row { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 4px; }
    .tc-pill {
        display: inline-flex; align-items: center; gap: 3px;
        padding: 2px 6px; border-radius: 4px; font-size: 0.58rem; font-weight: bold;
        color: white; text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
        white-space: nowrap;
    }
    .tc-pill .tc-mult { font-size: 0.65rem; opacity: 0.9; }
    .tc-section-head { font-size: 0.58rem; font-weight: bold; opacity: 0.55; margin-top: 4px; margin-bottom: 2px; letter-spacing: 0.03em; }
    