* {
    box-sizing: border-box;
}

:root {
    --bg: #0b0e13;
    --bg2: #11151c;
    --panel: #171c24;
    --panel2: #1d232d;
    --panel3: #242b36;
    --border: #303846;
    --border-light: #414b5b;
    --text: #f4f6f8;
    --muted: #8f99a8;
    --dim: #5f6877;
    --accent: #e63946;
    --accent-dark: #b91f2c;
    --blue: #4f8cff;
    --gold: #ffcb05;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(
            circle at 50% -10%,
            #283140 0%,
            #151a22 38%,
            #0b0e13 72%
        );
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

#app {
    width: min(1480px, 100%);
    min-height: 100vh;
    margin: auto;
}


/* ================= TOP BAR ================= */

.topbar {
    min-height: 104px;
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;

    border-bottom: 1px solid var(--border);

    background:
        linear-gradient(
            180deg,
            rgba(16,20,27,.98),
            rgba(12,15,20,.95)
        );
}

.logo {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--gold);
    text-shadow:
        2px 2px 0 #3466af,
        0 0 18px rgba(255,203,5,.08);
}

.subtitle {
    margin-top: 2px;
    font-size: 11px;
    letter-spacing: 6px;
    color: var(--muted);
}

.step-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.step {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #626c7b;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: .5px;
}

.step span {
    width: 29px;
    height: 29px;
    display: grid;
    place-items: center;

    border-radius: 50%;
    border: 1px solid var(--border);

    background: #12161d;
}

.step.active {
    color: var(--text);
}

.step.active span {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(230,57,70,.2);
}

.step-line {
    width: 38px;
    height: 1px;
    background: var(--border);
}


/* ================= MAIN ================= */

main {
    padding: 34px;
}

.screen-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2px;
}

.screen-heading h1 {
    margin: 0;
    font-size: 31px;
    letter-spacing: -.5px;
}

.screen-heading p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 14px;
}


/* ================= COUNTER ================= */

.team-counter {
    display: flex;
    align-items: baseline;
    gap: 4px;

    padding: 10px 18px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--panel);

    box-shadow:
        inset 0 1px rgba(255,255,255,.025),
        0 8px 25px rgba(0,0,0,.12);
}

.team-counter strong {
    font-size: 28px;
}

.team-counter span {
    color: var(--muted);
}


/* ================= TEAM ================= */

.team-panel {
    position: relative;

    padding: 15px;

    border: 1px solid var(--border);
    border-radius: 14px;

    background:
        linear-gradient(
            145deg,
            rgba(29,35,45,.95),
            rgba(18,22,29,.95)
        );

    margin-bottom: 18px;
}

.panel-label {
    margin-bottom: 11px;

    color: var(--dim);

    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2px;
}

.team-slots {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 9px;
}

.empty-slot,
.team-slot {
    min-height: 108px;

    border-radius: 10px;
    border: 1px dashed var(--border);

    background: rgba(10,13,18,.45);
}

.empty-slot {
    display: grid;
    place-items: center;

    color: #414957;
    font-size: 30px;
}

.team-slot {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    border-style: solid;
    border-color: #333c4a;

    background:
        radial-gradient(
            circle at center,
            rgba(79,140,255,.08),
            transparent 65%
        );
}

.team-slot img {
    width: 82px;
    height: 82px;
    object-fit: contain;
}

.team-slot::after {
    content: attr(data-name);

    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 5px;

    overflow: hidden;

    text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;

    color: #d8dde5;

    font-size: 10px;
    font-weight: bold;
}

.team-slot .remove {
    position: absolute;
    z-index: 2;

    top: 5px;
    right: 5px;

    width: 23px;
    height: 23px;

    border: 0;
    border-radius: 50%;

    background: #343b47;
    color: white;

    line-height: 23px;
    padding: 0;
}

.team-slot .remove:hover {
    background: var(--accent);
}


/* ================= SEARCH ================= */

.search-panel {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) 220px 190px;
    gap: 10px;

    margin-bottom: 14px;
}

.search-main {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-51%);

    color: var(--muted);

    font-size: 22px;
    pointer-events: none;
}

.search-main input,
.search-panel select,
.trainer-filters select {
    width: 100%;
    height: 46px;

    border: 1px solid var(--border);
    border-radius: 9px;

    outline: none;

    background: var(--panel);
    color: var(--text);

    transition:
        border-color .15s ease,
        background .15s ease;
}

.search-main input {
    padding: 0 14px 0 42px;
}

.search-panel select,
.trainer-filters select {
    padding: 0 13px;
}

.search-main input:focus,
.search-panel select:focus,
.trainer-filters select:focus {
    border-color: var(--blue);
    background: #1b212b;
}


/* ================= RESULTS HEADER ================= */

.results-header {
    min-height: 38px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 3px;

    color: var(--muted);

    font-size: 12px;
}

.results-header strong {
    color: var(--text);
}

.page-size-label {
    color: var(--dim);
}


/* ================= POKEMON GRID ================= */

.pokemon-grid {
    display: grid;

    grid-template-columns:
        repeat(6, minmax(130px, 1fr));

    gap: 11px;
}

.pokemon-card {
    position: relative;

    min-height: 205px;

    padding: 9px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background:
        linear-gradient(
            145deg,
            #202630,
            #15191f
        );

    color: var(--text);
    text-align: center;

    transition:
        transform .14s ease,
        border-color .14s ease,
        box-shadow .14s ease,
        background .14s ease;
}

.pokemon-card:hover {
    transform: translateY(-3px);

    border-color: #596577;

    background:
        linear-gradient(
            145deg,
            #252d38,
            #171c23
        );

    box-shadow:
        0 8px 22px rgba(0,0,0,.2);
}

.pokemon-card.selected {
    border-color: var(--accent);

    box-shadow:
        inset 0 0 0 1px rgba(230,57,70,.18),
        0 0 18px rgba(230,57,70,.08);
}

.pokemon-card.selected::after {
    content: "✓";

    position: absolute;
    top: 8px;
    right: 8px;

    width: 23px;
    height: 23px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: var(--accent);
    color: white;

    font-size: 13px;
    font-weight: bold;
}

.pokemon-number {
    position: absolute;

    top: 9px;
    left: 10px;

    color: #687384;

    font-size: 10px;
    font-weight: bold;
    letter-spacing: .4px;
}

.pokemon-card img {
    width: 135px;
    height: 135px;

    object-fit: contain;

    margin-top: 4px;
}

.pokemon-name {
    margin-top: -1px;

    overflow: hidden;

    font-size: 14px;
    font-weight: bold;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.pokemon-types {
    margin-top: 7px;

    display: flex;
    justify-content: center;

    gap: 4px;
}

.type {
    padding: 3px 7px;

    border-radius: 5px;

    background: #303844;
    color: #dce1e8;

    font-size: 8px;
    font-weight: 900;

    text-transform: uppercase;
    letter-spacing: .3px;
}


/* ================= PAGINATION ================= */

.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;

    align-items: center;

    margin-top: 18px;
    padding: 12px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: rgba(20,24,31,.8);
}

.page-button {
    min-height: 40px;

    padding: 0 18px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: var(--panel2);
    color: var(--text);

    font-size: 11px;
    font-weight: 900;
    letter-spacing: .5px;
}

.page-button:first-child {
    justify-self: start;
}

.page-button:last-child {
    justify-self: end;
}

.page-button:hover:not(:disabled) {
    border-color: var(--border-light);
    background: var(--panel3);
}

.page-button:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.page-center {
    display: flex;
    align-items: center;
    gap: 14px;
}

.page-label {
    color: var(--muted);

    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
}

.page-label strong {
    color: var(--text);
}

.page-jump {
    display: flex;
    gap: 5px;
}

.page-jump input {
    width: 58px;
    height: 32px;

    padding: 0 7px;

    border: 1px solid var(--border);
    border-radius: 6px;

    background: #11151b;
    color: var(--text);

    text-align: center;
}

.page-jump button {
    height: 32px;

    padding: 0 10px;

    border: 1px solid var(--border);
    border-radius: 6px;

    background: #2a313c;
    color: var(--text);

    font-size: 10px;
    font-weight: bold;
}


/* ================= BOTTOM ACTION ================= */

.bottom-action {
    display: flex;
    justify-content: flex-end;

    margin-top: 20px;
}

.bottom-action.dual {
    justify-content: space-between;
}

.bottom-action button {
    min-height: 48px;

    padding: 0 22px;

    border: 0;
    border-radius: 9px;

    background: var(--accent);
    color: white;

    font-weight: 900;
    letter-spacing: .5px;

    transition:
        background .15s ease,
        transform .12s ease;
}

.bottom-action button span {
    margin-left: 8px;
}

.bottom-action button:hover:not(:disabled) {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.bottom-action button:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.secondary-button {
    background: #252c36 !important;
    border: 1px solid var(--border) !important;
}


/* ================= TRAINERS ================= */

.trainer-filters {
    display: grid;

    grid-template-columns: 220px 220px;

    gap: 10px;

    margin-bottom: 20px;
}

.trainer-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.trainer-card {
    position: relative;

    min-height: 150px;

    padding: 12px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background:
        linear-gradient(
            145deg,
            #202630,
            #15191f
        );

    color: var(--text);
    text-align: center;

    transition:
        transform .14s ease,
        border-color .14s ease,
        box-shadow .14s ease,
        background .14s ease;
}

.trainer-card:hover {
    transform: translateY(-3px);

    border-color: #596577;

    background:
        linear-gradient(
            145deg,
            #252d38,
            #171c23
        );

    box-shadow:
        0 8px 22px rgba(0,0,0,.2);
}

.trainer-card.selected {
    border-color: var(--accent);

    box-shadow:
        inset 0 0 0 1px rgba(230,57,70,.18),
        0 0 18px rgba(230,57,70,.08);
}

.trainer-card.selected::after {
    content: "✓";

    position: absolute;
    top: 8px;
    right: 8px;

    width: 23px;
    height: 23px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: var(--accent);
    color: white;

    font-size: 13px;
    font-weight: bold;
}

.trainer-card h3 {
    margin: 0 0 8px;

    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.trainer-type-badge {
    display: inline-block;
    padding: 3px 8px;

    border-radius: 5px;

    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.5px;
    text-transform: uppercase;

    margin-bottom: 8px;
}

.trainer-type-badge.champion {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a2e;
}

.trainer-type-badge.rival {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: white;
}

.trainer-type-badge.gym {
    background: linear-gradient(135deg, #4ecdc4, #44a3a0);
    color: white;
}

.trainer-type-badge.elite4 {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
}

.trainer-type-badge.boss {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.trainer-type-badge.admin {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: white;
}

.trainer-type-badge.important {
    background: linear-gradient(135deg, #1abc9c, #16a085);
    color: white;
}

.trainer-card-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    color: var(--muted);

    font-size: 10px;
}

.trainer-card-info .generation {
    padding: 2px 6px;

    border-radius: 4px;

    background: rgba(79,140,255,.1);
    color: var(--blue);

    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.trainer-card-info .region {
    color: var(--dim);
}

.trainer-region-heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 0 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    width: 100%;
}

.trainer-region-name {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}

.trainer-region-subtitle {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.trainer-region-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 11px;
}

.trainer-region-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;

    margin-top: 24px;
    padding: 14px 20px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: rgba(20,24,31,.8);
}

.trainer-region-pagination button {
    min-height: 40px;
    padding: 0 18px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: var(--panel2);
    color: var(--text);

    font-size: 11px;
    font-weight: 900;
    letter-spacing: .5px;

    transition:
        border-color .15s ease,
        background .15s ease;
}

.trainer-region-pagination button:hover:not(:disabled) {
    border-color: var(--border-light);
    background: var(--panel3);
}

.trainer-region-pagination button:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.trainer-region-pagination span {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;

    color: var(--muted);

    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
}

.trainer-region-pagination span strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.trainer-region-pagination span small {
    font-size: 9px;
}


/* ================= PLACEHOLDER ================= */

.battle-placeholder {
    min-height: 500px;

    display: grid;
    place-items: center;
    align-content: center;

    gap: 20px;

    text-align: center;
}

.battle-title {
    font-size: 25px;
    font-weight: bold;
    letter-spacing: 3px;
}


/* ================= UTILITIES ================= */

.hidden {
    display: none !important;
}


/* ================= RESPONSIVE ================= */

@media (max-width: 1100px) {

    .pokemon-grid {
        grid-template-columns:
            repeat(5, minmax(125px, 1fr));
    }

}

@media (max-width: 900px) {

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .step-indicator {
        width: 100%;
        justify-content: space-between;
    }

    .pokemon-grid {
        grid-template-columns:
            repeat(4, minmax(125px, 1fr));
    }

    .search-panel {
        grid-template-columns: 1fr 1fr;
    }

    .search-main {
        grid-column: 1 / -1;
    }

}

@media (max-width: 700px) {

    main {
        padding: 20px;
    }

    .team-slots {
        grid-template-columns: repeat(3, 1fr);
    }

    .pokemon-grid {
        grid-template-columns:
            repeat(3, minmax(110px, 1fr));
    }

    .pagination {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .page-center {
        grid-column: 1 / -1;
        grid-row: 1;

        justify-content: center;
    }

    .page-button:first-child,
    .page-button:last-child {
        justify-self: stretch;
    }

}

@media (max-width: 500px) {

    .topbar {
        padding: 18px;
    }

    .logo {
        font-size: 27px;
    }

    main {
        padding: 14px;
    }

    .screen-heading h1 {
        font-size: 25px;
    }

    .team-slots {
        grid-template-columns: repeat(2, 1fr);
    }

    .search-panel {
        grid-template-columns: 1fr;
    }

    .search-main {
        grid-column: auto;
    }

    .pokemon-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pokemon-card img {
        width: 110px;
        height: 110px;
    }

    .trainer-filters {
        grid-template-columns: 1fr;
    }

    .trainer-grid,
    .trainer-region-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bottom-action.dual {
        gap: 10px;
    }

    .bottom-action.dual button {
        flex: 1;
        padding: 0 10px;
    }

}


/* compact-cards */

.pokemon-grid {
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
    gap: 8px;
}

.pokemon-card {
    height: 148px;
    min-height: 0;
    padding: 6px 6px 8px;

    display: grid;
    grid-template-rows: 96px auto auto;
    justify-items: center;
    align-items: end;
    row-gap: 4px;
}

/* JS sets exact pixel sizes (whole-number scaling) so pixels stay crisp */
.pokemon-card img,
.team-slot img {
    width: auto;
    height: auto;
    margin: 0;
    max-width: none;
    image-rendering: pixelated;
}

.pokemon-name {
    margin: 0;
    max-width: 100%;
    font-size: 12px;
}

.pokemon-types { margin-top: 0; }
.type { padding: 2px 6px; font-size: 7px; }

.pokemon-number { top: 6px; left: 8px; font-size: 9px; }

.pokemon-card.selected::after {
    top: 5px;
    right: 5px;
    width: 19px;
    height: 19px;
    font-size: 11px;
}

.team-slots { gap: 8px; }
.team-slot { min-height: 96px; }

/* Keep Pokémon sprites inside their existing card area.
   Normal sprites remain unchanged; oversized sprites shrink
   proportionally instead of escaping the card. */

.pokemon-card img {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
}
