/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f8;
    color: #333;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* Sticky wrapper */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Header */
.header {
    background: linear-gradient(135deg, #ff6b6b, #ffc94c, #51cf66);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.3rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    cursor: default;
}

.mode-toggle {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.mode-btn {
    padding: 6px 16px;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 16px;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 36px;
}

.mode-btn.active {
    background: #fff;
    color: #333;
    border-color: #fff;
}

/* Filter Navigation */
.filter-nav {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-scroll {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.filter-btn .type-icon {
    flex-shrink: 0;
    border-radius: 50%;
}

.type-badge .type-icon {
    vertical-align: middle;
    margin-right: 4px;
    border-radius: 50%;
}

.filter-btn:active {
    transform: scale(0.95);
}

.filter-btn.active-filter {
    box-shadow: 0 0 0 3px #333;
    transform: scale(1.05);
}

.hidden {
    display: none !important;
}

/* Color buttons */
.color-red { background: #ff6b6b; color: #fff; }
.color-blue { background: #4dabf7; color: #fff; }
.color-yellow { background: #ffd43b; color: #333; }
.color-green { background: #51cf66; color: #fff; }
.color-pink { background: #f06595; color: #fff; }
.color-purple { background: #9775fa; color: #fff; }
.color-brown { background: #a0522d; color: #fff; }
.color-black { background: #343a40; color: #fff; }
.color-white { background: #f8f9fa; color: #333; border: 2px solid #ddd; }
.color-gray { background: #adb5bd; color: #fff; }

/* Type buttons */
.type-btn {
    background: #fff;
    color: #333;
    border: 2px solid #e9ecef;
    padding: 4px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.type-btn .type-icon {
    width: 30px;
    height: 30px;
}

/* Type badges in detail view */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    margin: 4px;
    background: #f1f3f5;
    color: #333;
    border: 2px solid #e9ecef;
}

.type-badge .type-icon {
    width: 22px;
    height: 22px;
}

/* Pokémon Grid */
.pokemon-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.pokemon-card {
    background: #fff;
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.15s;
}

.pokemon-card:active {
    transform: scale(0.95);
}

.pokemon-img {
    width: 100%;
    max-width: 120px;
    aspect-ratio: 1;
    object-fit: contain;
}

.pokemon-name {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 8px;
    text-align: center;
}

.hint {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.2rem;
    color: #868e96;
    padding: 40px 20px;
}

/* Detail Overlay */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.detail-overlay.hidden {
    display: none;
}

.detail-card {
    background: #fff;
    border-radius: 24px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    position: relative;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #adb5bd;
    cursor: pointer;
    min-width: 48px;
    min-height: 48px;
}

.detail-artwork {
    width: 180px;
    height: 180px;
    object-fit: contain;
    margin: 0 auto;
}

.detail-name {
    font-size: 1.8rem;
    margin: 12px 0 8px;
    cursor: pointer;
}

.detail-name:active {
    color: #4dabf7;
}

.detail-types {
    margin: 8px 0;
}

.detail-size {
    font-size: 1.2rem;
    color: #495057;
    margin: 12px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background 0.15s;
}

.detail-size:active {
    background: #e9ecef;
}

.size-speaker {
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* Evolution Chain */
.evolution-chain {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #f1f3f5;
}

.evolution-chain h3 {
    font-size: 1.1rem;
    color: #868e96;
    margin-bottom: 12px;
}

.evolution-list {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.evolution-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    transition: background 0.15s;
    min-width: 48px;
}

.evolution-item.current {
    background: #e7f5ff;
    border: 2px solid #4dabf7;
}

.evolution-item:active {
    background: #e7f5ff;
}

.evolution-sprite {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.evolution-name {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 4px;
}

.evolution-arrow {
    font-size: 1.4rem;
    color: #adb5bd;
}

/* Settings Page */
.settings-page {
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

.settings-form {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.settings-form h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.settings-hint {
    font-size: 0.9rem;
    color: #868e96;
    margin-bottom: 16px;
}

.gen-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.gen-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.gen-label input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    accent-color: #4dabf7;
}

.gen-box {
    font-size: 1.1rem;
    font-weight: 500;
}

.settings-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    min-height: 48px;
}

.save-btn {
    background: #51cf66;
    color: #fff;
}

.seed-btn {
    background: #ffd43b;
    color: #333;
}

.back-btn {
    background: #e9ecef;
    color: #333;
    margin-top: 8px;
}

/* Tablet (iPad) */
@media (min-width: 768px) {
    .pokemon-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        padding: 24px;
    }

    .pokemon-img {
        max-width: 150px;
    }

    .detail-card {
        max-width: 500px;
        padding: 32px;
    }

    .detail-artwork {
        width: 220px;
        height: 220px;
    }

    .logo {
        font-size: 1.6rem;
    }

    .filter-scroll {
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* Large tablet / landscape */
@media (min-width: 1024px) {
    .pokemon-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
