:root {
    --primary: #ef5350;
    --secondary: #42a5f5;
    --accent: #66bb6a;
    --white-accent: #f8f9fa;
    --dark: #172033;
    --darker: #f6f7fb;
    --light: #172033;
    --light-dim: rgba(23, 32, 51, 0.67);
    --gradient: linear-gradient(120deg, var(--primary) 0%, var(--primary) 24%, var(--secondary) 57%, var(--accent) 100%);
    --gradient-accent: linear-gradient(120deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
    --starter-glow: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    --glass-bg: rgba(255, 255, 255, 0.84);
    --glass-bg-strong: rgba(255, 255, 255, 0.98);
    --glass-border: 1px solid rgba(23, 32, 51, 0.09);
    --shadow: 0 10px 30px rgba(32, 48, 82, 0.08);
    --shadow-lg: 0 22px 62px rgba(32, 48, 82, 0.13);
    --matrix-effect: repeating-linear-gradient(0deg, rgba(23, 32, 51, 0.018) 0, rgba(23, 32, 51, 0.018) 2px, transparent 2px, transparent 5px);
    --radius: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --transition: all .4s cubic-bezier(.16, 1, .3, 1);
    --transition-slow: all .38s cubic-bezier(.16, 1, .3, 1);
    --type-normal: #a8a77a;
    --type-fire: #ee8130;
    --type-water: #6390f0;
    --type-electric: #e8ba20;
    --type-grass: #7ac74c;
    --type-ice: #63c7c3;
    --type-fighting: #c22e28;
    --type-poison: #a33ea1;
    --type-ground: #c99e42;
    --type-flying: #8d78d9;
    --type-psychic: #f95587;
    --type-bug: #94a51b;
    --type-rock: #a88d30;
    --type-ghost: #735797;
    --type-dragon: #6f35fc;
    --type-dark: #705746;
    --type-steel: #9f9fb8;
    --type-fairy: #d685ad;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body {
    margin: 0;
    min-width: 300px;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--light);
    background:
        radial-gradient(circle at 10% 2%, rgba(239, 83, 80, .09), transparent 27%),
        radial-gradient(circle at 88% 6%, rgba(66, 165, 245, .09), transparent 29%),
        radial-gradient(circle at 55% 96%, rgba(102, 187, 106, .08), transparent 28%),
        var(--darker);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: .7;
    pointer-events: none;
    background: var(--matrix-effect);
    animation: scanlines 60s linear infinite;
}

a { color: inherit; }

@keyframes scanlines {
    from { transform: translateY(-100%); }
    to { transform: translateY(100%); }
}

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

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes detailEnter {
    from { transform: translateY(25px) scale(.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.dex-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .84);
    border-bottom: var(--glass-border);
    backdrop-filter: blur(18px) saturate(180%);
    box-shadow: var(--shadow);
}

.dex-nav {
    max-width: 1400px;
    height: 84px;
    padding: 0 30px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 17px;
    text-decoration: none;
    transition: var(--transition);
}

.brand:hover { transform: translateX(5px); }

.brand strong {
    display: block;
    font-size: 27px;
    line-height: 1.05;
    letter-spacing: -.045em;
    background: linear-gradient(to right, var(--dark) 55%, var(--secondary) 76%, var(--accent));
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
}

.brand small {
    display: block;
    color: var(--light-dim);
    letter-spacing: .12em;
    text-transform: uppercase;
    font-size: 10px;
    margin-top: 4px;
}

.brand-orb {
    width: 54px;
    height: 54px;
    display: block;
    border-radius: 17px;
    position: relative;
    background: var(--gradient);
    box-shadow: 0 8px 19px rgba(239, 83, 80, .2);
    transition: var(--transition-slow);
}

.brand:hover .brand-orb {
    transform: rotate(12deg) scale(1.08);
    box-shadow: 0 10px 28px rgba(66, 165, 245, .23);
}

.brand-orb::before {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: linear-gradient(var(--primary) 0 46%, #fff 46% 54%, var(--dark) 54%);
}

.brand-orb::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 9px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #fff;
    background: var(--white-accent);
    border-radius: 50%;
}

.dex-nav nav {
    display: flex;
    gap: 20px;
}

.dex-nav nav a {
    color: var(--light-dim);
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    padding: 12px 17px;
    border-radius: var(--radius);
    transition: var(--transition);
    position: relative;
}

.dex-nav nav a::after {
    content: "";
    position: absolute;
    height: 2px;
    left: 17px;
    right: 17px;
    bottom: 6px;
    transform: scaleX(0);
    background: var(--gradient);
    transition: transform .35s ease;
}

.dex-nav nav a:hover {
    color: var(--light);
    background: rgba(66, 165, 245, .06);
}

.dex-nav nav a:hover::after { transform: scaleX(1); }

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px 66px;
}

.hero {
    min-height: 535px;
    display: grid;
    grid-template-columns: 1.14fr .86fr;
    align-items: center;
    gap: 56px;
}

.kicker {
    margin: 0 0 14px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .22em;
    font-size: 13px;
    font-weight: 700;
}

.hero h1 {
    max-width: 720px;
    margin: 0 0 22px;
    font-size: clamp(48px, 5.35vw, 72px);
    line-height: 1.02;
    letter-spacing: -.068em;
}

.hero h1 span {
    background: var(--gradient);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    animation: gradientFlow 4s ease infinite;
}

.hero-text {
    max-width: 585px;
    color: var(--light-dim);
    font-size: 18px;
    line-height: 1.7;
    margin: 0 0 36px;
}

.hero-button {
    display: inline-flex;
    text-decoration: none;
    color: #fff;
    background: var(--gradient);
    padding: 17px 29px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 10px 30px rgba(239, 83, 80, .22);
    transition: var(--transition);
}

.hero-button:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 38px rgba(66, 165, 245, .2);
}

.hero-card {
    justify-self: end;
    height: 398px;
    width: min(415px, 100%);
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    border: var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    box-shadow: var(--shadow-lg);
}

.hero-card::before {
    content: "";
    position: absolute;
    inset: -1px;
    background: var(--gradient);
    opacity: .1;
}

.hero-pokeball {
    position: absolute;
    width: 293px;
    height: 293px;
    top: 32px;
    right: -42px;
    opacity: .17;
    border-radius: 50%;
    border: 20px solid rgba(23, 32, 51, .12);
    background: linear-gradient(var(--primary) 0 47%, rgba(23, 32, 51, .12) 47% 54%, transparent 54%);
    animation: float 5s ease-in-out infinite;
}

.hero-pokeball::after {
    content: "";
    position: absolute;
    width: 54px;
    height: 54px;
    background: #fff;
    border: 14px solid rgba(23, 32, 51, .12);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.hero-stat {
    position: absolute;
    bottom: 37px;
    left: 38px;
}

.hero-stat b {
    display: block;
    font-size: 52px;
    color: var(--secondary);
    letter-spacing: -.06em;
    text-shadow: 0 0 18px rgba(66, 165, 245, .24);
}

.hero-stat span {
    color: var(--light-dim);
    font-size: 15px;
}

.dex-section {
    padding: 34px;
    border-radius: var(--radius-xl);
    border: var(--glass-border);
    background: var(--glass-bg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(13px);
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 27px;
}

.section-heading h2, .about h2 {
    font-size: 34px;
    line-height: 1.05;
    letter-spacing: -.045em;
    margin: 0;
}

.count {
    margin: 0;
    color: var(--secondary);
    font-weight: 600;
}

.filters {
    display: grid;
    grid-template-columns: 1fr 245px;
    gap: 20px;
    padding: 22px;
    margin: 0 0 32px;
    background: rgba(246, 247, 251, .84);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.filters:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.filters label span {
    display: block;
    margin-bottom: 9px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.filters input, .filters select {
    height: 56px;
    width: 100%;
    padding: 0 21px;
    color: var(--dark);
    font: inherit;
    font-size: 16px;
    border-radius: 999px;
    border: 1px solid rgba(23, 32, 51, .12);
    background: #fff;
    outline: none;
    transition: var(--transition);
}

.filters select {
    cursor: pointer;
    border-radius: var(--radius);
    background-color: #fff;
}

.filters option {
    background: #fff;
    color: var(--dark);
}

.filters input::placeholder { color: rgba(23, 32, 51, .43); }

.filters input:focus, .filters select:focus {
    background: #fff;
    border-color: rgba(66, 165, 245, .68);
    box-shadow: 0 0 0 3px rgba(66, 165, 245, .2);
}

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

.pokemon-card {
    min-height: 301px;
    position: relative;
    overflow: hidden;
    padding: 18px;
    cursor: pointer;
    color: var(--dark);
    font: inherit;
    text-align: left;
    border: 1px solid rgba(23, 32, 51, .09);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow);
    transition: transform .23s ease, border-color .23s ease, box-shadow .23s ease, background .23s ease;
}

.pokemon-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0;
    background:
        linear-gradient(90deg, var(--card-accent, var(--primary)), var(--secondary), var(--accent)) top / 100% 3px no-repeat,
        radial-gradient(circle at 50% 32%, rgba(66, 165, 245, .065), transparent 48%);
    transition: opacity .23s ease;
}

.pokemon-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: radial-gradient(circle at 50% 44%, transparent 16%, rgba(23, 32, 51, .028) 100%);
}

.pokemon-card:hover {
    transform: translateY(-3px);
    border-color: rgba(66, 165, 245, .23);
    background: #fff;
    box-shadow: 0 17px 34px rgba(32, 48, 82, .14);
}

.pokemon-card:hover::before { opacity: 1; }

.pokemon-card:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 3px;
}

.pokemon-card > * {
    position: relative;
    z-index: 1;
}

.pokemon-number {
    display: inline-block;
    color: var(--secondary);
    font-size: 13px;
    font-weight: 700;
}

.pokemon-card img {
    display: block;
    width: 100%;
    height: 174px;
    margin: 5px auto 3px;
    object-fit: contain;
    filter: drop-shadow(0 12px 13px rgba(32, 48, 82, .13));
    transition: transform .24s ease, filter .24s ease;
}

.pokemon-card:hover img {
    transform: scale(1.035);
    filter: drop-shadow(0 14px 15px rgba(32, 48, 82, .17));
}

.pokemon-card h3 {
    margin: 8px 0 11px;
    font-size: 20px;
    text-transform: capitalize;
    letter-spacing: -.025em;
}

.types {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.type {
    color: #fff;
    background: var(--type-color, var(--secondary));
    padding: 5px 11px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(32, 48, 82, .12);
}

.loading, .empty {
    grid-column: 1 / -1;
    color: var(--light-dim);
    text-align: center;
    padding: 54px 0;
}

.about {
    max-width: 780px;
    margin: 0 auto;
    padding: 76px 0 28px;
}

.about h2 {
    background: var(--gradient);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.about p {
    color: var(--light-dim);
    font-size: 16px;
    line-height: 1.75;
}

.about a { color: var(--secondary); }

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(230, 235, 245, .76);
    backdrop-filter: blur(8px);
}

.pokemon-detail {
    width: min(900px, 100%);
    max-height: calc(100vh - 48px);
    position: relative;
    z-index: 1;
    overflow: auto;
    padding: 35px;
    border-radius: var(--radius-xl);
    border: var(--glass-border);
    background: var(--glass-bg-strong);
    box-shadow: var(--shadow-lg), 0 0 38px rgba(66, 165, 245, .1);
    animation: detailEnter .52s cubic-bezier(.16, 1, .3, 1);
}

.close-modal {
    height: 46px;
    width: 46px;
    position: absolute;
    top: 15px;
    right: 17px;
    border: var(--glass-border);
    border-radius: 50%;
    color: var(--dark);
    background: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    transform: rotate(90deg);
    background: var(--primary);
    color: #fff;
}

.detail-head {
    display: grid;
    grid-template-columns: 275px 1fr;
    gap: 30px;
    align-items: center;
}

.detail-head img {
    height: 265px;
    width: 265px;
    object-fit: contain;
    filter: drop-shadow(0 18px 26px rgba(66, 165, 245, .13));
}

.detail-head h2 {
    margin: 5px 0 13px;
    font-size: 45px;
    line-height: 1;
    letter-spacing: -.055em;
    text-transform: capitalize;
}

.description {
    color: var(--light-dim);
    line-height: 1.65;
    margin: 18px 0 0;
}

.fact-row {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    color: var(--light-dim);
}

.fact-row b {
    display: block;
    color: var(--secondary);
    font-size: 20px;
}

.detail-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 34px;
    padding-top: 26px;
    border-top: var(--glass-border);
}

.detail-panels h3 {
    margin: 0 0 15px;
    color: var(--primary);
    font-size: 18px;
}

.stat {
    display: grid;
    grid-template-columns: 95px 40px 1fr;
    gap: 9px;
    align-items: center;
    margin: 11px 0;
    color: var(--light-dim);
    font-size: 13px;
}

.bar {
    height: 9px;
    overflow: hidden;
    border-radius: 9px;
    background: rgba(23, 32, 51, .09);
}

.bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--gradient);
}

.ability-list, .evolution-list {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.chip {
    padding: 10px 13px;
    font-size: 13px;
    text-transform: capitalize;
    border: var(--glass-border);
    border-radius: 10px;
    background: rgba(246, 247, 251, .9);
}

.dex-footer {
    max-width: 1400px;
    padding: 30px 30px 45px;
    margin: 0 auto;
    color: var(--light-dim);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    border-top: var(--glass-border);
    font-size: 14px;
}

.dex-footer a { color: var(--secondary); }

.status-page {
    min-height: 100vh;
    max-width: 560px;
    margin: 0 auto;
    padding: 80px 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 18px;
}

.status-page .brand-orb {
    width: 72px;
    height: 72px;
    margin-bottom: 18px;
}

.status-page .kicker { margin: 0; }

.status-page h1 {
    margin: 0;
    font-size: clamp(35px, 6vw, 50px);
    letter-spacing: -.06em;
}

.status-page p:not(.kicker) {
    color: var(--light-dim);
    font-size: 17px;
    margin: 0 0 14px;
}

@media (max-width: 820px) {
    .dex-nav { height: 76px; padding: 0 18px; }
    .dex-nav nav { display: none; }
    .brand strong { font-size: 23px; }
    .brand-orb { width: 48px; height: 48px; }
    main { padding: 0 16px 42px; }
    .hero {
        display: block;
        min-height: 0;
        padding: 56px 0 48px;
    }
    .hero-card { display: none; }
    .hero h1 { font-size: clamp(40px, 12vw, 48px); }
    .hero-text { font-size: 16px; }
    .dex-section {
        padding: 22px 16px;
        border-radius: var(--radius-lg);
    }
    .section-heading { display: block; }
    .count { margin-top: 10px; }
    .filters {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    .pokemon-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
    .pokemon-card {
        min-height: 238px;
        border-radius: var(--radius);
        padding: 12px;
    }
    .pokemon-card img { height: 127px; }
    .pokemon-card h3 { font-size: 17px; }
    .pokemon-detail { padding: 25px 18px; }
    .detail-head { display: block; text-align: center; }
    .detail-head img { width: 195px; height: 195px; }
    .detail-head h2 { font-size: 35px; }
    .detail-head .types, .fact-row { justify-content: center; }
    .detail-panels { grid-template-columns: 1fr; }
    .dex-footer { display: block; padding: 26px 18px 36px; }
    .dex-footer a { display: block; margin-top: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition-duration: .01ms !important;
    }

    .pokemon-card:hover,
    .hero-button:hover,
    .brand:hover {
        transform: none;
    }
}
