/* Design tokens */
:root {
    --bg-start: #0e1b2b;
    --bg-end:   #23364a;
    --surface: rgba(255,255,255,0.08);
    --surface-strong: rgba(255,255,255,0.14);
    --text: #f5f7fb;
    --text-invert: #0c0f14;
    --brand: #db3c36;
    --brand-2: #ceff9d;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0,0,0,.25);
}

/* --- Base Styles --- */
body { 
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg-start), var(--bg-end));
    color: var(--text);
    margin: 0;
    padding: 16px;
    box-sizing: border-box;
    min-height: 100vh;
    background-repeat: no-repeat;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* Reduce motion when requested */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* --- Cursor Pointer for Clickable Elements --- */
button,
a,
.pokemon-card,
label.isLegendary,
label.isMythical,
.type-filter label,
#type-filter label,
.pokedex-header h1,
#slider-filters input,
input[type='range'] {
    cursor: pointer !important;
}

 
/* Utility */
.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden; clip: rect(1px,1px,1px,1px);
    white-space: nowrap; border: 0; padding: 0; margin: -1px;
}


/* --- Pokedex Container Layout --- */
.pokedex-container {
    overflow: visible;
    display: grid;
    grid-template-areas:
        "pokedex-text"
        "search-bar"
        "type-filter"
        "slider-filters"
        "pokemon-list"
        "pagination";
    grid-template-rows: auto auto auto auto 1fr auto;
    gap: 20px;
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 12px;
}

/* --- Grid Areas --- */
.pokedex-text {
    grid-area: pokedex-text;
    margin: 0;
}

#search-bar {
    grid-area: search-bar;
}

#type-filter {
    grid-area: type-filter;
}
/* Header */
.pokedex-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.pokedex-header h1 {
    font-size: clamp(1.6rem, 2.5vw, 2.4rem);
    color: var(--brand-2);
    margin: 0;
    letter-spacing: .5px;
}
.header-actions { display:flex; gap: 8px; align-items:center; }


#slider-filters.hidden {
    opacity: 0;
    display: none;
}

/* --- Pokedex Grid --- */
.pokedex {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    justify-content: center;
}

/* --- Search Bar Styles --- */
#search-bar {
    width: 100%;
    background-color: rgba(206,255,157,0.15);
    padding: 14px 16px;
    border-radius: 999px;
    border: 1px solid rgba(206,255,157,0.35);
    color: var(--text);
    outline: none;
    backdrop-filter: blur(6px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

#search {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1em;
    margin-bottom: 10px; /* Added margin for spacing */
}


/* --- Search Bar Flex Container --- */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
    margin-bottom: 20px;
}

/* --- Type Filter Styles --- */
#type-filter {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border: none;
    align-items: center;
    justify-content: center;
}

.type-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.type-filter label {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 999px;
    transition: transform 0.2s ease, background-color 0.2s, color 0.2s, box-shadow .2s;
    font-weight: 600;
    background: var(--surface);
    box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, var(--shadow);
}

.type-filter label:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(0,0,0,.25);
}

/* Place the search wrapper in the grid and give breathing room */
.search-container{
    grid-area: search-bar;
    width: min(720px, 100%);
    margin: 0 auto 16px; /* keeps it off the filters */
}

/* --- Legendary and Mythical Labels (ensure they beat `.type-filter label`) --- */
/* Use higher specificity by qualifying with the parent .type-filter + element */
.type-filter label.legendary-label {
    background: linear-gradient(135deg, gold, #ffd36b) !important;
    color: #111 !important;
    border-color: #b08d00 !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, var(--shadow);
}
.type-filter label.mythic-label {
    background: linear-gradient(135deg, silver, #e7e7e7) !important;
    color: #111 !important;
    border-color: #9c9c9c !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, var(--shadow);
}

/* Selected/active states keep their color and get a stronger ring */
#type-filter label.legendary-label.checked,
#type-filter label.legendary-label.active {
    box-shadow: 0 0 0 2px rgba(0,0,0,.25) inset, 0 0 0 2px rgba(255,255,255,.35);
    transform: translateY(-1px) scale(1.02);
    border-color: #b08d00 !important;
}
#type-filter label.mythic-label.checked,
#type-filter label.mythic-label.active {
    box-shadow: 0 0 0 2px rgba(0,0,0,.25) inset, 0 0 0 2px rgba(255,255,255,.35);
    transform: translateY(-1px) scale(1.02);
    border-color: #9c9c9c !important;
}

label.legendary {
    background: gold;
    color: #000;
}

label.mythical {
    background: silver;
    color: #000;
}

/* --- Checked Checkbox Labels within Type Filter Only --- */
#type-filter label.checked {
    font-weight: 800;
    transform: translateY(-1px) scale(1.02);
    border-color: var(--brand-2);
    box-shadow: 0 0 0 2px rgba(206,255,157,0.35) inset, 0 6px 22px rgba(0,0,0,.25);
}

/* --- Rainbow Animation --- */
@keyframes rainbow {
    0% { background-color: #ff0000; }
    14% { background-color: #ff7f00; }
    28% { background-color: #ffff00; }
    42% { background-color: #00ff00; }
    56% { background-color: #0000ff; }
    70% { background-color: #4b0082; }
    84% { background-color: #9400d3; }
    100% { background-color: #ff0000; }
}

@keyframes rainbow_animation {
    0%, 100% { background-position: 0 0; }
    50% { background-position: 100% 0; }
}

/* --- Checkbox Custom Styles --- */
.checkbox-label {
    position: relative;
    display: inline-block;
    margin-right: 10px;
}

.checkbox-label input {
    position: absolute;
    opacity: 0;
}

.checkbox-custom {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 1px solid #ccc;
    background-color: #fff;
    cursor: pointer;
}

.checkbox-custom.checked {
    background-color: #007bff;
}

.checkbox-label span {
    margin-left: 5px;
}

.Homepage {

    padding: 10px 16px;
    background-color: var(--surface);
    color: var(--text);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: .95em;
    font-weight: bold;
    transition: transform .2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow .2s ease;
    margin: 10px;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: var(--shadow);
}

.Homepage:hover{
    transform: translateY(-1px);
    background-color: rgba(206,255,157,0.2);
    color: var(--text);
}



/* --- Pokémon Card Styles --- */
.pokemon-card,
.pokemon {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease;
    cursor: pointer;
    box-shadow: var(--shadow);
    will-change: transform;
}

.pokemon-card:hover,
.pokemon:hover,
.search-suggestion-item:hover,
.pagination-button:hover {
    /* Remove scale to avoid image resampling blur; just lift */
    transform: translateY(-2px);
}

.pokemon-card h2,
.pokemon-card p {
    text-transform: capitalize;
}

.pokemon-card h2 {

    font-size: 1.25rem;
    font-weight: 800;
     word-wrap: break-word;
    margin: 8px 0 6px;
}

.pokemon-card p {
    font-size: 1rem;
    font-weight: 700;
}
/* Sprites on the listing: fixed size + crisp scaling */
.pokemon-image {
    width: 192px;              /* integer multiple to keep pixel-perfect scaling */
    height: 192px;
    display: block;
    margin: 8px auto 0;
    object-fit: contain;
    image-rendering: optimizeSpeed;            /* legacy hint */
    image-rendering: -moz-crisp-edges;         /* Firefox */
    image-rendering: -o-crisp-edges;           /* Opera */
    image-rendering: -webkit-optimize-contrast;/* Safari (closest) */
    image-rendering: pixelated !important;               /* Standard-ish */
    -ms-interpolation-mode: nearest-neighbor;  /* IE */
}

/* Ensure hover scaling doesn’t trigger smoothing */
.pokemon-card:hover .pokemon-image {
    image-rendering: pixelated !important;
}

/* Optional: give the card a stronger lift without scaling the content */
.pokemon-card:hover {
    box-shadow: 0 14px 40px rgba(0,0,0,.35);
}
/* Keep official art smooth if/when shown */
img.officialimage {
    image-rendering: auto;
}

/* --- Pokémon List Grid --- */
#pokemon-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* --- Pagination Styles --- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: var(--shadow);
}

button {
    padding: 10px 20px;
    border: 1px solid rgba(255,255,255,0.25);
    background-color: var(--brand);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow .2s ease;
    box-shadow: var(--shadow);
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

button:hover:enabled {
background-color: #ceff9d; /* Lighter yellow on hover */
}

.pagination-button {
    padding: 10px;
    background-color: var(--brand);
    color: #fff;
    border-radius: 10px;
    font-size: 1em;
    transition: transform 0.2s ease;
}

.pagination-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.pagination-select {
    padding: 10px;
    font-size: 1em;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.25);
    background: var(--surface);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    -webkit-text-fill-color: var(--text); /* ensure visible on WebKit */
    backdrop-filter: blur(6px);
}
/* Make sure dropdown items aren't white-on-white in UA menus */
.pagination-select option {
    background: #1a2838;   /* solid fallback inside native popup */
    color: #f5f7fb;
}
.pagination-select:focus {
    outline: 2px solid var(--brand-2);
    outline-offset: 2px;
}

/* --- Modal Styles --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000; /* Ensure it overlays other elements */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    padding-top: 50px;
    padding-bottom: 50px;
    transition: opacity 0.5s ease;
}

.modal-content {
    margin: auto;
    padding: 0;
    width: 90%;
    max-width: 800px;
    border-radius: var(--radius);
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateY(-50px);
    transition: transform 0.5s ease;
        background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
        border: 1px solid rgba(255,255,255,0.2);
        box-shadow: var(--shadow);
        backdrop-filter: blur(10px);
}

.modal.show .modal-content {
    transform: translateY(0);
}

/* --- Pokedex Outer Layout --- */
.pokedex-outer {
    display: flex;
    background: rgba(219,60,54,0.9);
    border: 3px solid rgba(0,0,0,0.35);
    border-radius: 2%;
    padding: 1px;
    padding-top: 0;
    color: #fff;
    height: 100%;
}

.pokedex-left {
    flex: 0.8;
    padding: 10px;
    text-align: center;
    display: inline-block;
    max-width: fit-content;
}

.pokedex-right {
    flex: 1;
    padding: 10px;
    max-width: fit-content;
}

/* --- Screen Header --- */
.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    display: block;
    margin-top: -10px;
}

.screen-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.screen-header .close {
    font-size: 1.2em;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
        background: var(--surface-strong);
        border: 1px solid rgba(255,255,255,0.2);
}

.screen-header .close:hover {
    background-color: #777;
}

/* --- Pokémon Image Container --- */
.pokemon-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255,255,255,0.9);
    border: 2px solid #333;
    padding: 10px;
    margin-bottom: 10px;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgb(159, 159, 159) 0px, transparent 0.5px),
        linear-gradient(to bottom, rgb(159, 159, 159) 0px, transparent 0.5px);
    max-width: 150px; /* Adjusted for mobile */
    position: relative; /* Changed from absolute */
    opacity: 1; /* Ensure visibility */
}

.pokemon-image-container img {
    width: 100%;
    height: auto;
    border-radius: 5px;
}

/* --- Pokémon Stats --- */
.pokemon-stats {
    background-color: #fff;
    color: #000;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    margin-bottom: 10px;
    font-size: 120%;
    font-weight: 800;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgb(159, 159, 159) 0px, transparent 0.5px),
        linear-gradient(to bottom, rgb(159, 159, 159) 0px, transparent 0.5px);
    -webkit-text-stroke: 0.4px #000;
}

.pokemon-stat-bar {
    display: flex;
    align-items: center;
    margin: 10px 0;
    position: relative;
    height: 30px;
}

.pokemon-stat-bar .stat-label {
    width: 50%;
    text-align: left;
    z-index: 1;
}

.pokemon-stat-bar .stat-value {
    width: 40%;
    text-align: center;
    z-index: 1;
}

.pokemon-stat-bar .stat-bar {
    width: 100%;
    height: 100%;
    margin-left: 10px;
    border: 1px solid #333;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
}

.pokemon-stat-bar .stat-bar-inner {
    height: 100%;
    border-radius: 5px;
    position: absolute;
    top: 0;
    left: 0;
}

.stat-hp { background-color: #ff0000; }
.stat-attack { background-color: #ff6600; }
.stat-defense { background-color: #ffcc00; }
.stat-special-attack { background-color: #3399ff; }
.stat-special-defense { background-color: #66cc33; }
.stat-speed { background-color: #ff3399; }
.stat-total { background-color: rgb(201, 5, 255); }

/* --- Stat Text --- */
.stat-text {
  color: #fff; /* default white text for contrast */
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}

body:not(.dark-mode) .stat-text {
  color: #111; /* dark text in light mode */
  background-color: rgba(255,255,255,0.8); /* soft white backing */
  border-radius: 6px;
  padding: 0 6px;
  text-shadow: none;
}

body.dark-mode .stat-text {
  color: #fff; /* bright white text in dark mode */
  background-color: rgba(0,0,0,0.5); /* dark backing for contrast */
  border-radius: 6px;
  padding: 0 6px;
}

/* --- Pokémon Details --- */
.pokemon-details {
    background-color: #fff;
    color: #000;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 10px;
    text-transform: capitalize;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgb(159, 159, 159) 0px, transparent 0.5px),
        linear-gradient(to bottom, rgb(159, 159, 159) 0px, transparent 0.5px);
    display: block; /* Changed from table-cell for better responsiveness */
    text-align: center;
    overflow-y: auto;
    font-size: 120%;
    font-weight: 800;
}

.pokemon-details img {
    width: 100%;
    height: auto;
    max-width: 100%;
    border-radius: 5px;
}

.pokemon-details div {
    font-size: 200%;
    -webkit-text-stroke: 0.4px #000;
}

.height,
.weight {
    text-transform: none;
}

/* --- Close Button --- */
span.close {
    font-size: 150%;
    justify-content: center;
}

.close {
    color: #fff;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    background-color: #333;
    border-radius: 5px;
    padding: 5px 10px;
    text-align: center;
    display: block;
    margin-top: 10px;
    transition: background-color 0.3s ease;
        background: var(--surface-strong);
        border: 1px solid rgba(255,255,255,0.2);
        box-shadow: var(--shadow);
        color: #fff;
        text-decoration: none;
}

.close:hover,
.close:focus {
    background-color: #444;
}

/* --- Type Effectiveness --- */
.type-effectiveness {
    background-color: #fff;
    color: #000;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    margin-top: 10px;
    font-size: 120%;
    font-weight: 700;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgb(159, 159, 159) 0px, transparent 0.5px),
        linear-gradient(to bottom, rgb(159, 159, 159) 0px, transparent 0.5px);
}

.type-effectiveness h3 {
    margin: 5px 0;
    font-size: 120%;
    font-weight: 800;
}

.type-effectiveness p {
    margin: 5px 0;
    font-size: 100%;
    -webkit-text-stroke: 0.2px #000;
    font-weight: 900;
}

/* --- Slider Filters --- */
#slider-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#slider-filters label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #000; /* Default color */
    font-weight: 700;
}

body.dark-mode #slider-filters label {
    color: #fff; /* White text in dark mode */
}

#slider-filters input[type="range"] {
    flex: 1;
}

/* --- Slider Range Input Styles --- */
input[type="range"] {
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    opacity: 0.7;
    -webkit-transition: .2s;
    transition: opacity .2s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

/* --- Specific Styles for Each Stat Slider --- */
#hp-slider {
    background: linear-gradient(to right, #ff0000, #ff0000);
}

#hp-slider::-webkit-slider-thumb {
    background: #ff0000;
}

#hp-slider::-moz-range-thumb {
    background: #ff0000;
}

#attack-slider {
    background: linear-gradient(to right, #ff6600, #ff6600);
}

#attack-slider::-webkit-slider-thumb {
    background: #ff6600;
}

#attack-slider::-moz-range-thumb {
    background: #ff6600;
}

#defense-slider {
    background: linear-gradient(to right, #ffcc00, #ffcc00);
}

#defense-slider::-webkit-slider-thumb {
    background: #ffcc00;
}

#defense-slider::-moz-range-thumb {
    background: #ffcc00;
}

#special-attack-slider {
    background: linear-gradient(to right, #3399ff, #3399ff);
}

#special-attack-slider::-webkit-slider-thumb {
    background: #3399ff;
}

#special-attack-slider::-moz-range-thumb {
    background: #3399ff;
}

#special-defense-slider {
    background: linear-gradient(to right, #66cc33, #66cc33);
}

#special-defense-slider::-webkit-slider-thumb {
    background: #66cc33;
}

#special-defense-slider::-moz-range-thumb {
    background: #66cc33;
}

#speed-slider {
    background: linear-gradient(to right, #ff3399, #ff3399);
}

#speed-slider::-webkit-slider-thumb {
    background: #ff3399;
}

#speed-slider::-moz-range-thumb {
    background: #ff3399;
}

#total-base-stats-slider {
    background: linear-gradient(to right, rgb(201, 5, 255), rgb(201, 5, 255));
}

#total-base-stats-slider::-webkit-slider-thumb {
    background: rgb(201, 5, 255);
}

#total-base-stats-slider::-moz-range-thumb {
    background: rgb(201, 5, 255);
}

/* --- Additional Text Styles --- */
.PPP {
    text-align: center;
    text-decoration: underline;
    font-weight: 900;
    -webkit-text-stroke: 0.5px #000;
    text-decoration: none;
}

.Pleg,
.Pmyth {
    font-size: 130%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbow_animation 6s alternate-reverse linear infinite;
    background-size: 400% 100%;
}

.Pleg {
    background: linear-gradient(to right, #6666ff, #0099ff, #00ff00, #ff3399, #6666ff);
}

.Pmyth {
    background: linear-gradient(to right, #6666ff, #0099ff, #00ff00, #ff3399, #6666ff);
}

/* --- Rainbow Animation --- */
@keyframes rainbow_animation {
    0%, 100% {
        background-position: 0 0;
    }
    50% {
        background-position: 100% 0;
    }
}

/* --- Official Image --- */
img.officialimage {
    width: 0;
}

/* --- Paragraph Styles --- */
p {
    display: block;
    margin-block-start: 0.5em;
    margin-block-end: 0.5em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    unicode-bidi: isolate;
    overflow: auto;
    max-width: 100%;
    height: fit-content;
}

/* --- Transitions for Interactive Elements --- */
.pokemon-card,
.modal-content,
.pagination-button,
.search-suggestion-item {
    transition: all 0.3s ease;
}

/* --- Modal Transitions --- */
.modal {
    transition: opacity 0.5s ease;
}

.modal-content {
    transform: translateY(-50px);
}

.modal.show .modal-content {
    transform: translateY(0);
}

/* --- Toggle Sliders Button --- */
#toggle-sliders {
    margin: 10px 0;
    padding: 10px 20px;
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    box-shadow: var(--shadow);
}

#toggle-sliders:hover {
    transform: translateY(-1px);
}

/* --- Dark Mode Styles --- */
.dark-mode {
    background: linear-gradient(180deg, #0b0b0b, #2a2a2a);
    color: #eee;
}

body.dark-mode .auth-form {
    color: white;
}

.dark-mode-toggle {
    padding: 10px 20px;
    background-color: var(--surface);
    color: var(--text);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 10px;
        border: 1px solid rgba(255,255,255,0.25);
        box-shadow: var(--shadow);
}

.dark-mode-toggle:hover {
    background-color: #444;
    color: #fff;
}

/* --- Override Styles for Legendary and Mythical Labels Inside the Modal --- */
.modal .PPP.Pleg,
.modal .PPP.Pmyth {
    background: linear-gradient(to right, #6666ff, #0099ff, #00ff00, #ff3399, #6666ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbow_animation 15s alternate-reverse linear infinite;
    background-size: 400% 100%;
}

.rainbow-text {
    background: linear-gradient(to right, #6666ff, #0099ff, #00ff00, #ff3399, #6666ff);
    -webkit-background-clip: text; background-clip: text; color: transparent; animation: rainbow_animation 10s alternate-reverse linear infinite; background-size: 400% 100%;
}

/* --- Additional Small Screen Styles --- */
@media only screen and (max-width: 768px) {
    .pokedex-container {
        padding: 10px;
        grid-template-areas:
            "pokedex-text"
            "search-bar"
            "type-filter"
            "slider-filters"
            "pokemon-list"
            "pagination";
        grid-template-rows: auto auto auto auto 1fr auto;
        gap: 10px;
    }

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

    .pokedex-header h1 {
        font-size: 1.8em;
        text-align: center;
    }

    #search-bar {
        width: 100%;
    }

    .search-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .type-filter {
        justify-content: flex-start;
        width: 100%;
    }

    .pokedex {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .pokemon-card {
        padding: 10px;
        font-size: 0.9em;
    }

    .modal-content {
        width: 95%;
        max-width: 500px;
        padding: 10px;
    }

    .pokemon-details,
    .pokemon-stats {
        font-size: 1em;
    }

    .pokemon-stats p,
    .pokemon-details p {
        font-size: 1em;
    }

    .pagination {
        flex-direction: column;
        align-items: center;
    }

    .pagination-button {
        width: 100%;
        margin-bottom: 10px;
    }

    .prev-button,
    .next-button {
        font-size: 1em;
        padding: 10px;
    }
}

/* --- Additional Small Screen Styles --- */
@media only screen and (max-width: 480px) {
    .pokedex-header h1 {
        font-size: 1.5em;
    }

    #pokemon-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .pokemon-card {
        padding: 5px;
    }

    .modal-content {
        padding: 5px;
    }

    .pokemon-details img {
        width: 100px;
        height: auto;
    }
}

/* --- Responsive Modal Layout Enhancements --- */
@media only screen and (max-width: 768px) {
    /* Adjust modal-content for better spacing */
    .modal-content {
        width: 95%;
        max-width: 500px;
        padding: 10px;
        margin-top: 10%; /* Reduced top margin for smaller screens */
        margin-bottom: 10%; /* Reduced bottom margin for smaller screens */
        border-radius: 10px;
    }

    /* Stack pokedex-outer vertically */
    .pokedex-outer {
        flex-direction: column;
        align-items: center;
        margin-bottom: 100px;
    }

    /* Ensure pokedex-left and pokedex-right take full width */
    .pokedex-left,
    .pokedex-right {
        width: 100%;
        padding: 10px;
    }

    /* Make pokemon-details responsive */
    .pokemon-details {
        width: 100%;
        height: auto; /* Remove fixed height */
        max-height: none;
    }

    /* Adjust images to fit within containers */
    .pokemon-details img {
        width: 100%;
        height: auto;
        max-width: 100%;
    }

    .pokemon-image-container {
        position: relative; /* Remove absolute positioning */
        opacity: 1; /* Make visible on mobile */
        max-width: 150px; /* Adjust as needed */
        margin-bottom: 20px; /* Add spacing below image container */
    }

    .pokemon-image-container img {
        width: 100%;
        height: auto;
    }

    /* Adjust font sizes for readability */
    .pokemon-details p,
    .pokemon-details div,
    .pokemon-stats p,
    .pokemon-stats div {
        font-size: 1em;
    }

    /* Ensure type-effectiveness section fits well */
    .type-effectiveness {
        font-size: 1em;
    }
}
@media only screen and (max-width: 480px) {
    /* Further adjustments for very small screens */

    /* Adjust modal-content padding */
    .modal-content {
        padding: 5px;
        margin-top: 5%;
        margin-bottom: 5%;
        max-width: 90%;
    }

    /* Stack pokedex-outer vertically and center content */
    .pokedex-outer {
        flex-direction: column;
        align-items: center;
    }

    /* Reduce padding for pokedex-left and pokedex-right */
    .pokedex-left,
    .pokedex-right {
        width: 100%;
        padding: 5px;
    }

    /* Make pokemon-details fully responsive */
    .pokemon-details {
        width: 100%;
        height: auto;
        max-height: none;
    }

    /* Ensure images do not overflow */
    .pokemon-details img {
        width: 100%;
        height: auto;
        max-width: 100%;
    }

    .pokemon-image-container {
        max-width: 120px; /* Smaller image on very small screens */
        margin-bottom: 15px; /* Adjust spacing */
    }

    .pokemon-image-container img {
        width: 100%;
        height: auto;
    }

    /* Adjust font sizes for optimal readability */
    .pokemon-details p,
    .pokemon-details div,
    .pokemon-stats p,
    .pokemon-stats div {
        font-size: 0.9em;
    }

    /* Ensure type-effectiveness section fits well */
    .type-effectiveness {
        font-size: 0.9em;
    }
}

/* --- Ensuring .pokemon-image-container Displays Correctly --- */
.pokemon-image-container {
    flex:1 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    border: 2px solid #333;
    padding: 10px;
    margin-bottom: 10px;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgb(159, 159, 159) 0px, transparent 0.5px),
        linear-gradient(to bottom, rgb(159, 159, 159) 0px, transparent 0.5px);
    max-width: 150px; /* Adjusted for mobile */
    position: relative; /* Changed from absolute */
    opacity: 1; /* Ensure visibility */
}

/* --- Optimizing .pokemon-details --- */
.pokemon-details {
    place-content: center;
    height: 90%;
    background-color: #fff;
    color: #000;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 10px;
    text-transform: capitalize;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgb(159, 159, 159) 0px, transparent 0.5px),
        linear-gradient(to bottom, rgb(159, 159, 159) 0px, transparent 0.5px);
    display: grid; /* Changed from table-cell for better responsiveness */
    text-align: center;
    overflow-y: auto;
    font-size: 120%;
    font-weight: 800;
    max-width: fit-content;
    justify-items: center;
}

/* --- Responsive Images in Modal --- */
.modal-content img {
    width: auto;
    max-height: 50vw;
    max-width: 100%;
    height: auto; 
    border-radius: 5px;
}

/* --- Ensuring Modal Overlays Correctly --- */
.modal {
    z-index: 1000; /* Higher than other elements */
}

/* --- Smooth Scrolling for Modal Content --- */
.modal-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Enables momentum scrolling on iOS */
}

.sprite-container{
    display: flex;
}

#autocomplete-list{
    background-color: #ceff9d;
    opacity: .8;
    border: none;
    color: #db3c36;
    border-radius: 1em;
}
/* --- Search / Autocomplete cleanup --- */
.search-container{
    position: relative;             /* anchor dropdown */
    border-radius: 50px;
    background-color: transparent;
    /* keep it off the type filter so it doesn't visually collide */
    width: min(720px, 100%);
    margin: 0 auto 16px;
}
#search-bar{ border: none; }

/* Autocomplete dropdown: hidden by default; only shows when JS sets it visible */
#autocomplete-list{
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: none;                  /* default: hidden */
    background: #fff;
    color: #111;
    border: 1px solid #dcdcdc;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,.18);
    z-index: 99;
    max-height: 240px;
    overflow-y: auto;
}
/* Don’t reserve space when empty or aria-hidden */
#autocomplete-list:empty,
#autocomplete-list[aria-hidden="true"] { display: none !important; }

.autocomplete-items { /* keep for compatibility; ensure same look */
    border: none;
    background: transparent;
}
.autocomplete-suggestion {
    padding: 10px 12px;
    cursor: pointer;
}
.autocomplete-suggestion:hover {
    background-color: #f0f0f0;
}

/* Tame autofill/UA quirks so no “white bar” appears */
#search-bar:-webkit-autofill,
#search-bar:-webkit-autofill:hover,
#search-bar:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
   box-shadow: 0 0 0 1000px rgba(206,255,157,0.15) inset;
   transition: background-color 9999s ease-out 0s;

}

/* --- Colored type chips on cards & modal (restored to root scope) --- */
.type-list{
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin: 4px 0 6px;
}
.type-chip{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .9rem;
    line-height: 1;
    border: 1.5px solid var(--type-color, #999);
    color: var(--type-color, #333);
    background: color-mix(in srgb, var(--type-color, #999) 10%, #ffffff);
}
@supports not (color-mix(in srgb, white, black)) {
  .type-chip{ background: #fff; } /* fallback */
}

/* Slightly larger chips in the modal for readability */
.modal .type-list .type-chip{
    font-size: 1rem;
    padding: 6px 10px;
}

/* Legendary / Mythical filter pills with rainbow text AND a pill background */
.type-filter label.legendary-label,
.type-filter label.mythic-label {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  border: 2px solid rgba(255,255,255,0.25);
  background-color: rgba(255,255,255,0.08); /* semi-transparent surface background */
}

.type-filter label.legendary-label::before,
.type-filter label.mythic-label::before {
  content: attr(data-text); /* fallback if needed */
}

.type-filter label.legendary-label span,
.type-filter label.mythic-label span {
  background: linear-gradient(
    to right,
    #6666ff,
    #0099ff,
    #00ff00,
    #ff3399,
    #6666ff
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbow_animation 10s alternate-reverse linear infinite;
  background-size: 400% 100%;
}

/* Slider label and value colors */
#slider-filters label {
  color: var(--text) !important;
  font-weight: 700;
}

#slider-filters span {
  margin-left: 4px;
  color: var(--text) !important;
  font-weight: 700;
}
