:root {
    --color-primary: #ee1515;
    --color-primary-soft: rgba(238, 21, 21, 0.08);
    --color-dark: #222224;
    --color-light: #f4f4f5;
    --color-surface: #ffffff;
    --color-muted: #8a8a90;
    --color-border: rgba(34, 34, 36, 0.08);

    /* Gradients and shadows for premium feel */
    --gradient-primary: linear-gradient(135deg, #ff4141 0%, #ee1515 100%);
    --shadow-soft: 0 8px 30px rgba(34, 34, 36, 0.08);
    --shadow-strong: 0 10px 40px rgba(238, 21, 21, 0.2);
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;
}

/* Slim, subtle scrollbars everywhere */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(34, 34, 36, 0.2);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(34, 34, 36, 0.35);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--color-light);
    color: var(--color-dark);
    min-height: 100vh;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    width: 100%;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background-color: var(--color-dark);
    color: var(--color-light);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    z-index: 10;
    overflow-x: hidden;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 3rem;
}

.toxadex-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(238, 21, 21, 0.4));
    transition: transform 0.3s ease, filter 0.3s ease;
}

.toxadex-icon:hover {
    transform: scale(1.1) rotate(10deg);
    filter: drop-shadow(0 6px 15px rgba(238, 21, 21, 0.6));
}

.logo-container h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(to right, var(--color-light), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

/* Main Content Styling */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--color-light);
    position: relative;
    overflow-y: auto;
    /* clip, not hidden: hidden still leaves this a horizontal scroll container (momentum swipes can shift it); clip removes sideways scrolling entirely */
    overflow-x: clip;
    min-width: 0;
}

.top-header {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 3rem;
    background: rgba(240, 240, 240, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1px solid rgba(34, 34, 36, 0.05);
}

/* Pokeball-dot accent next to the view title */
#view-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    letter-spacing: 0.3px;
}
#view-title::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gradient-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
    flex-shrink: 0;
}

.content-display {
    flex: 1;
    padding: 3rem;
    position: relative;
}

/* ===== Home ===== */
.home-hero {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2.5rem;
    background: var(--color-dark);
    color: var(--color-light);
    border-radius: 24px;
    padding: 3rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(34, 34, 36, 0.25);
    z-index: 1;
}
.home-hero::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -60px;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(238,21,21,0.35), transparent 70%);
    pointer-events: none;
}
.hero-text {
    flex: 1.2;
    position: relative;
}
.hero-eyebrow {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #ff8a8a;
    background: rgba(238, 21, 21, 0.15);
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-pill);
    margin-bottom: 1.2rem;
}
.hero-text h1 {
    font-size: clamp(2rem, 4vw, 3.2rem);
    line-height: 1.1;
    font-weight: 700;
    margin-bottom: 1rem;
}
.hero-accent {
    background: linear-gradient(90deg, #ff6b6b, var(--color-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-text p {
    color: #b9b9bf;
    max-width: 46ch;
    margin-bottom: 1.8rem;
    line-height: 1.6;
}
.hero-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}
.btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.85rem 1.6rem;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(238, 21, 21, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(238, 21, 21, 0.45);
}
.btn-ghost {
    background: transparent;
    color: var(--color-light);
    border: 1.5px solid rgba(255,255,255,0.25);
    padding: 0.85rem 1.6rem;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.btn-ghost:hover {
    border-color: white;
    background: rgba(255,255,255,0.06);
}

.potd-card {
    position: relative;
    flex: 0 0 240px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: transform 0.25s, border-color 0.25s;
}
.potd-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
}
.potd-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #ff8a8a;
}
.potd-card img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    filter: drop-shadow(0 12px 20px rgba(0,0,0,0.4));
}
.potd-card h3 {
    text-transform: capitalize;
    font-size: 1.15rem;
    font-weight: 700;
}
.potd-types {
    display: flex;
    gap: 0.5rem;
}
.potd-placeholder {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
}

.home-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 1;
}
.stat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 1.1rem 1rem;
    text-align: center;
}
.stat-tile strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-tile span {
    font-size: 0.85rem;
    color: var(--color-muted);
    font-weight: 500;
}

.home-section {
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 1;
}
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
}
.section-head h2 {
    font-size: 1.25rem;
    font-weight: 700;
}
.link-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.category-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 1.4rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-dark);
    transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.category-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-strong);
}
.cat-emoji {
    font-size: 1.6rem;
}

/* Subtle background accent — anchored inside the layout so it never widens the page */
.content-display::before {
    content: '';
    position: absolute;
    top: -100px;
    right: 0;
    width: 400px;
    height: 400px;
    max-width: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 75% 25%, rgba(238,21,21,0.05) 0%, rgba(240,240,240,0) 70%);
    z-index: 0;
    pointer-events: none;
}

/* Pokemon Grid */
.pokemon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2rem;
    position: relative;
    z-index: 1;
}

.pokemon-card {
    position: relative;
    overflow: hidden;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    border: 1px solid var(--color-border);
}

/* Faint pokeball-red halo behind the artwork */
.pokemon-card::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--color-primary-soft) 0%, transparent 70%);
    pointer-events: none;
}

.pokemon-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-strong);
    border-color: var(--color-primary);
}

.pokemon-card img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
    position: relative;
}

.pokemon-card:hover img {
    transform: scale(1.08);
}

.pokemon-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: capitalize;
    color: var(--color-dark);
    text-align: center;
}

.pokemon-card span {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    background: rgba(34, 34, 36, 0.05);
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-pill);
    margin-bottom: 0.6rem;
    position: relative;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(34, 34, 36, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--color-dark);
    color: var(--color-light);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255,255,255,0.1);
}

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

/* Team Simulator picker modal */
.team-picker-content {
    max-width: 800px;
    width: 92%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.team-picker-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.team-picker-search {
    width: 100%;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: var(--color-light);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}
.team-picker-search::placeholder {
    color: #999;
}
.team-picker-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-right: 0.3rem;
}
.pick-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}
.pick-row:hover {
    background: rgba(238, 21, 21, 0.12);
    border-color: var(--color-primary);
}
.pick-row img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 0;
}
.pick-name {
    text-transform: capitalize;
    font-weight: 600;
    font-size: 0.95rem;
}
.pick-id {
    margin-left: auto;
    color: var(--color-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #ff4141;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(238, 21, 21, 0.4);
}

.close-btn:hover {
    background: #cc0000;
    transform: scale(1.1) rotate(90deg);
}

.modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.modal-image-container {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(238,21,21,0.2) 0%, transparent 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.modal-image-container img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.3));
}

.modal-title {
    text-align: center;
    margin-bottom: 1rem;
}

.modal-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: capitalize;
    margin-bottom: 0.2rem;
}

.modal-title span {
    font-size: 1rem;
    color: #aaa;
    font-weight: 600;
}

.modal-types {
    display: flex;
    gap: 0.8rem;
}

.type-badge {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: white;
}

/* Modal Body */
.stats-section, .moves-section {
    margin-bottom: 1.5rem;
}

.stats-section h3, .moves-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ccc;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.8rem;
}

.stat-name {
    width: 80px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
}

.stat-bar-container {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    margin: 0 1rem;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    width: 0; /* Will be set via JS */
    transition: width 1s ease-out;
}

.stat-value {
    width: 30px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: right;
}

.mega-section {
    margin-bottom: 1.5rem;
}
.mega-forms {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.mega-form-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 110px;
}
.mega-form-card img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.3));
}
.mega-form-card span {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
    margin-top: 0.4rem;
    text-align: center;
}

.moves-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.moves-list li {
    background: rgba(255,255,255,0.05);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-transform: capitalize;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Sidebar & Nav Extensions */
.sidebar {
    transition: width 0.3s ease, padding 0.3s ease;
}
.sidebar.collapsed {
    width: 90px;
    padding: 2rem 0.5rem;
    align-items: center;
}
.sidebar.collapsed .logo-container h1,
.sidebar.collapsed .nav-text {
    display: none;
}
.sidebar.collapsed .logo-container {
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}
.sidebar.collapsed .toxadex-icon {
    width: 45px;
    height: 45px;
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--color-dark);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1.5rem;
    padding: 0.4rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}
.hamburger-btn:hover {
    background: rgba(34, 34, 36, 0.06);
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2rem;
    width: 100%;
}
.nav-item {
    color: #aaa;
    text-decoration: none;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    white-space: nowrap;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 1rem 0;
}
.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}
.nav-item.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(238,21,21,0.3);
}

/* SPA Views */
.view-container {
    flex: 1;
    position: relative;
    padding: 3rem;
    padding-top: 0;
}
.view {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}
.view.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Remove original padding on content-display if needed, but it should be fine */
.content-display {
    padding: 3rem 0;
}

/* Search Filters */
.search-filters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 2;
}

.search-bar {
    position: relative;
    width: 100%;
}
.search-icon {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-muted);
    pointer-events: none;
    transition: color 0.2s;
}
.search-bar:focus-within .search-icon {
    color: var(--color-primary);
}
.search-bar input {
    width: 100%;
    padding: 1rem 1.2rem 1rem 3.1rem;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--color-border);
    font-family: inherit;
    font-size: 1rem;
    background: var(--color-surface);
    outline: none;
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 8px 30px rgba(238, 21, 21, 0.12);
}
.search-bar input::placeholder {
    color: var(--color-muted);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
}
.filter-grid select {
    width: 100%;
    padding: 0.75rem 2.4rem 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--color-border);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--color-dark);
    background-color: var(--color-surface);
    outline: none;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a90' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 14px;
    transition: border-color 0.2s;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}
.filter-grid select:focus,
.filter-grid select:hover {
    border-color: var(--color-primary);
}

.search-count {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-muted);
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 1;
    min-height: 1.2em;
}

/* Items Dex Filters */
.item-filters {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

/* Team Simulator Grid */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    position: relative;
    z-index: 2;
}
.team-slot {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 380px;
}
.team-slot.empty {
    justify-content: center;
    align-items: center;
    border: 2px dashed rgba(0,0,0,0.2);
    background: transparent;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.2s;
}
.team-slot.empty:hover {
    background: rgba(0,0,0,0.05);
}
.add-btn {
    font-size: 4rem;
    color: rgba(0,0,0,0.2);
    font-weight: 300;
}
.slot-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.slot-header img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}
.slot-header h3 {
    text-transform: capitalize;
    font-size: 1.2rem;
    font-weight: 700;
}
.slot-remove {
    margin-left: auto;
    background: #ff4141;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-weight: 600;
}
.move-select, .item-select {
    width: 100%;
    padding: 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.1);
    font-family: inherit;
    background: #f9f9f9;
}
.moves-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.2rem;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    position: relative;
    z-index: 2;
}
.item-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    text-align: center;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--color-border);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.item-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-strong);
    border-color: var(--color-primary);
}
.item-card img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    margin-bottom: 0.8rem;
}
.item-card h4 {
    font-size: 1rem;
    text-transform: capitalize;
    margin-bottom: 0.5rem;
    font-weight: 700;
}
.item-card p {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.4;
}
.item-cat-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-dark);
    box-shadow: var(--shadow-soft);
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.item-cat-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-surface);
}
.item-cat-btn.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 15px rgba(238, 21, 21, 0.3);
}

/* Sidebar backdrop for mobile off-canvas drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.sidebar-backdrop.visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* ============ Tablet ============ */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        padding: 1.5rem 1rem;
    }
    .content-display, .view-container {
        padding: 2rem;
    }
    .top-header {
        padding: 0 1.5rem;
    }
    .pokemon-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1.5rem;
    }
    .team-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

/* ============ Mobile ============ */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        max-width: 80vw;
        padding: 2rem 1.5rem;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.3s ease, visibility 0.3s;
        z-index: 50;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
        box-shadow: 0 0 40px rgba(0,0,0,0.5);
    }
    .hamburger-btn {
        margin-right: 1rem;
    }
    /* On mobile, the icon-only "collapsed" desktop state doesn't apply */
    .sidebar.collapsed {
        width: 280px;
        padding: 2rem 1.5rem;
        align-items: stretch;
    }
    .sidebar.collapsed .logo-container h1,
    .sidebar.collapsed .nav-text {
        display: block;
    }
    .sidebar.collapsed .logo-container {
        flex-direction: row;
        justify-content: flex-start;
    }

    .main-content {
        width: 100%;
    }
    .top-header {
        height: 64px;
        padding: 0 1.25rem;
    }
    /* One clear spacing scale: the view container owns the side gutters, content-display only vertical rhythm */
    .view-container {
        padding: 0 1.25rem 2.5rem;
    }
    .content-display {
        padding: 1.5rem 0;
    }
    .pokemon-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.9rem;
    }
    .pokemon-card {
        padding: 1.1rem 0.6rem 1rem;
        border-radius: 14px;
    }
    .pokemon-card img {
        width: 76px;
        height: 76px;
        margin-bottom: 0.7rem;
    }
    .pokemon-card h3 {
        font-size: 0.95rem;
    }

    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    /* Items Dex chips: tidy grid, every category visible without scrolling */
    .item-filters {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    .item-cat-btn {
        padding: 0.55rem 0.4rem;
        font-size: 0.82rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Compact, proportional item cards */
    .items-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }
    .item-card {
        padding: 0.85rem 0.5rem;
        border-radius: var(--radius-md);
    }
    .item-card img {
        width: 40px;
        height: 40px;
        margin-bottom: 0.5rem;
    }
    .item-card h4 {
        font-size: 0.78rem;
        margin-bottom: 0;
    }

    /* Home sections stack */
    .home-hero {
        flex-direction: column;
        padding: 2rem 1.5rem;
        gap: 1.75rem;
        border-radius: 20px;
    }
    .potd-card {
        flex: none;
        width: 100%;
    }
    .home-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 2rem;
    }
    .category-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .team-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: calc(100% - 2.5rem);
        padding: 1.75rem 1.25rem;
        max-height: calc(100vh - 4rem);
        border-radius: var(--radius-lg);
    }
    .modal-image-container {
        width: 100px;
        height: 100px;
    }

    .stat-name {
        width: 60px;
        font-size: 0.8rem;
    }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* ============ Small mobile ============ */
@media (max-width: 420px) {
    .pokemon-grid {
        gap: 0.75rem;
    }
    .items-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    .logo-container h1 {
        font-size: 24px;
    }
}
