.filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-item {
    flex: 1 1 auto;
    min-width: 120px;
}

/* Mobile: 2 filters per row */
@media (max-width: 768px) {
    .filter-item {
        flex: 1 1 calc(50% - 5px);
        min-width: auto;
    }
}

/* Tablet: 3 filters per row */
@media (min-width: 769px) and (max-width: 1024px) {
    .filter-item {
        flex: 1 1 calc(33.333% - 7px);
        min-width: auto;
    }
}

/* Desktop: flexible layout */
@media (min-width: 1025px) {
    .filter-item {
        flex: 0 1 auto;
    }
}
:root {
    --binder-red: #c0392b;
    --page-bg: #ffffff;
    --gold: #d4af37;
    --text-dark: #2d3436;
    --text-light: #636e72;
    --header-height: 18vh;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #1a1a1a;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2vh;
    color: var(--text-dark);
    min-height: 100vh;
    height: 100vh; 
    overflow: hidden;
}

/* --- Binder Container & Layout --- */
.binder-container {
    background-color: var(--binder-red);
    padding: 1.5vh;
    border-radius: 15px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
    width: 100%;
    max-width: 1400px;
    height: 94vh;
    position: relative;
    transition: all 0.3s ease;
}

.spread-container {
    display: flex;
    background: #333; 
    gap: 4px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.binder-page {
    background: var(--page-bg);
    flex: 1;
    padding: 2.5vh;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* --- Trainer Records (Main Dashboard) --- */
.dashboard-container { 
    padding: 1vh; 
    flex-grow: 1;
}

.trainer-profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2vh;
    padding-bottom: 1.5vh;
    border-bottom: 2px solid #eee;
}

.identity h2 { font-size: 1.6rem; margin-bottom: 5px; }

.edit-btn {
    background: none;
    border: none;
    color: var(--binder-red);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
}

.logout-link {
    background: #f1f2f6;
    border: 1px solid #dfe6e9;
    padding: 6px 15px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: #e74c3c;
    font-weight: bold;
}

.main-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2vh;
    margin-bottom: 2vh;
}

.stat-card {
    background: #f8f9fa;
    padding: 2vh;
    border-radius: 15px;
    border: 1px solid #eee;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-value { font-size: 1.8rem; }

.progress-subtext {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 8px;
    font-weight: 600;
}

.gen-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1vh;
}

.gen-stat-tag {
    background: #ffffff;
    border: 1px solid #eee;
    padding: 1vh;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
}

.gen-stat-tag:hover {
    border-color: var(--binder-red);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* --- Mini Stats Header --- */
.mini-trainer-header {
    padding: 1.2vh;
    background: #f8f9fa;
    border: 1px solid #eee;
    margin-bottom: 2vh; 
    border-radius: 10px;
}

.mini-stats-upper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1vh;
}

.gen-mini-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 5px;
}

.mini-gen-tag {
    font-size: 0.55rem;
    padding: 4px 2px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.mini-gen-tag b { color: var(--binder-red); font-size: 0.6rem; }
.mini-ar-val { color: var(--gold); font-weight: bold; }

/* --- Pokémon Grid & Cards --- */
.grid-3x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr) !important;
    gap: 1.5vh;
    flex-grow: 1;
}

.card {
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 1vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    position: relative;
    height: 100%;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, z-index 0s;
    z-index: 1;
}

.card:hover:not(.hidden-slot) {
    transform: scale(1.08);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    z-index: 10;
    border-color: var(--binder-red);
}

.card.caught { background: #f0fff4; border-color: #c6f6d5; }
.card.art-rare-plus { border: 2px solid var(--gold); background: linear-gradient(145deg, #fff, #fffdf5); }

.card img {
    height: 14vh;
    width: auto;
    object-fit: contain;
    margin-bottom: 5px;
}

.card-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    position: absolute;
    top: 8px;
    padding: 0 10px;
}

.art-rare-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    filter: grayscale(1);
    transition: transform 0.1s;
}
.art-rare-btn:active { transform: scale(0.9); }
.art-rare-btn.active { filter: grayscale(0); transform: scale(1.1); }

.card.collapsed-hidden {
    display: none !important;
}

/* --- Integrated Navigation Footers --- */
.page-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5vh 10px;
    border-top: 1px solid #eee;
    margin-top: auto;
    background: #fcfcfc;
    border-radius: 0 0 10px 10px;
    height: 7vh;
}

.nav-btn {
    background: var(--binder-red);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    min-width: 100px;
}

.nav-btn:hover { background: #a93226; transform: scale(1.05); }
.nav-btn:disabled { visibility: hidden; }

.jump-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #eee;
    padding: 4px 10px;
    border-radius: 15px;
}

.jump-box input {
    width: 40px;
    border: none;
    background: transparent;
    text-align: center;
    font-weight: bold;
}

.jump-box button {
    background: var(--text-dark);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.7rem;
    cursor: pointer;
}

/* --- Search, Suggestions & Filters --- */
.search-header {
    height: var(--header-height);
    margin-bottom: 2vh;
    border-bottom: 2px solid #eee;
}

.search-row { display: flex; gap: 10px; margin-bottom: 1.5vh; }

.search-container {
    position: relative;
    display: flex;
    flex: 1;
}

.search-container input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dfe6e9;
    border-radius: 8px;
}

.suggestion-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dfe6e9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 30vh;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f2f6;
    font-size: 0.85rem;
}

.suggestion-item:hover { background-color: #f8f9fa; }
.suggestion-item img { width: 30px; height: 30px; margin-right: 12px; object-fit: contain; }
.suggestion-item b { text-transform: capitalize; }
.suggestion-item span { margin-left: auto; color: var(--text-light); font-size: 0.7rem; }

.filter-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #f8f9fa;
    padding: 1vh;
    border-radius: 8px;
    font-size: 0.8rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* --- Spine & Aesthetic Details --- */
.binder-spine {
    width: 35px;
    background: linear-gradient(to right, #000, #333, #000);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
}

.ring { width: 25px; height: 5px; background: #111; border-radius: 3px; }

#left-page-num, #right-page-num {
    font-size: 0.8rem;
    color: #bbb;
    font-weight: bold;
}

.gold-text { color: var(--gold) !important; font-weight: bold; }

/* --- Art Rare Sparkle Effects --- */
.card.art-rare-plus {
    overflow: hidden; 
}

.card.art-rare-plus::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(30deg);
    transition: none;
    animation: glint 6s infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes glint {
    0% { left: -60%; }
    15% { left: 130%; }
    100% { left: 130%; }
}

.art-rare-btn.active {
    animation: star-pulse 2s infinite ease-in-out;
    display: inline-block;
}

@keyframes star-pulse {
    0%, 100% { transform: scale(1.1); filter: drop-shadow(0 0 2px var(--gold)); }
    50% { transform: scale(1.3); filter: drop-shadow(0 0 8px var(--gold)); }
}

.card.art-rare-plus img {
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.3));
}

/* --- Type Badges & Colors --- */
.type-container { display: flex; gap: 4px; margin-top: 5px; }
.type-badge {
    font-size: 0.55rem; padding: 1px 5px; border-radius: 4px;
    color: white; text-transform: uppercase; font-weight: bold;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.2);
}

.normal { background: #A8A878; } .fire { background: #F08030; }
.water { background: #6890F0; } .grass { background: #78C850; }
.electric { background: #F8D030; } .ice { background: #98D8D8; }
.fighting { background: #C03028; } .poison { background: #A040A0; }
.ground { background: #E0C068; } .flying { background: #A890F0; }
.psychic { background: #F85888; } .bug { background: #A8B820; }
.rock { background: #B8A038; } .ghost { background: #705898; }
.dragon { background: #7038F8; } .dark { background: #705848; }
.steel { background: #B8B8D0; } .fairy { background: #EE99AC; }

.suggestion-info { display: flex; flex-direction: column; width: 100%; padding-left: 10px; }
.suggestion-top-row { display: flex; justify-content: space-between; align-items: center; text-transform: capitalize; }
.suggestion-id { font-size: 0.7rem; color: #888; }

.suggestion-item .type-container { display: flex !important; flex-direction: row !important; gap: 4px !important; margin-top: 4px !important; justify-content: flex-start !important; }
.suggestion-item .type-badge { margin: 0 !important; font-size: 0.55rem !important; padding: 1px 5px !important; border-radius: 3px !important; min-width: 45px !important; text-align: center !important; }

/* --- Authentication Overlay --- */
.auth-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000; border-radius: 5px; 
}

.auth-card {
    background: var(--binder-red); padding: 4vh; border-radius: 15px;
    border: 3px solid var(--gold); text-align: center; color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-width: 450px; width: 90%;
}

.login-btn, .guest-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; width: 100%; margin-top: 2vh; padding: 1.5vh;
    border-radius: 8px; border: none; cursor: pointer; font-weight: bold;
}

/* ============================================================
   RESPONSIVE OVERRIDES
   ============================================================ */

@media (max-width: 1024px) {
    body { height: auto; overflow-y: auto; }
    .binder-container { height: auto; margin: 20px 0; padding: 10px; }
    .spread-container { flex-direction: column; gap: 15px; background: transparent; }
    .binder-spine { display: none; }
    .binder-page { height: auto; min-height: 85vh; border-radius: 10px; overflow: visible; }
    .grid-3x3 { grid-template-rows: auto !important; }
}

@media (max-width: 600px) {
    .binder-page { padding: 1.5vh; overflow: visible !important; }
    .identity h2 { font-size: 1.1rem !important; }
    .main-stats-grid { grid-template-columns: 1fr; gap: 8px; }
    .stat-card { padding: 1.5vh; }
    .stat-value { font-size: 1.5rem; }
    .gen-dashboard-grid { grid-template-columns: repeat(3, 1fr); gap: 5px; }
    .gen-mini-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
    
    .search-header { height: auto; padding-bottom: 10px; }
    .search-row { flex-direction: column; gap: 5px; }
    .filter-row { flex-wrap: wrap; gap: 10px; justify-content: flex-start; font-size: 0.65rem; }

    .grid-3x3 { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .card { padding: 4px; border-radius: 6px; }
    .card img { height: 60px !important; margin-bottom: 2px; }
    .card-header { font-size: 0.45rem; top: 3px; padding: 0 4px; }
    .art-rare-btn { font-size: 0.6rem; }
    .type-badge { font-size: 0.35rem; padding: 1px 2px; min-width: 25px; }

    .page-footer { flex-direction: row; padding: 10px 5px; height: auto; }
    .nav-btn { padding: 6px 10px; font-size: 0.65rem; min-width: 65px; }
    .jump-box { gap: 4px; padding: 2px 5px; }
    .jump-box input { width: 25px; font-size: 0.65rem; }
}