:root {
    --primary: #fc2651;
    --primary-hover: #ff4d75;
    --primary-light: rgba(252, 38, 81, 0.15);
    --accent: #a855f7;
    --accent-light: rgba(168, 85, 247, 0.15);
    --success: #34d399;
    --warning: #fbbf24;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --border-light: #475569;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --gradient-primary: linear-gradient(135deg, #fc2651 0%, #ff4d75 100%);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s ease;
}

/* ===== Header ===== */
header {
    background: var(--gradient-primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.search-container {
    display: flex;
    gap: 0.75rem;
    flex: 1;
    min-width: 200px;
    max-width: 600px;
}

#searchBar,
#sortOptions,
#filterOptions {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#searchBar {
    flex: 1;
    min-width: 0;
}

#searchBar::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#searchBar:focus,
#sortOptions:focus,
#filterOptions:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

#sortOptions,
#filterOptions {
    min-width: 120px;
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
}

.control-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    padding: 0.625rem;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.control-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.control-button img {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.control-button:hover img {
    transform: scale(1.1);
}

/* ===== Main Content ===== */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    padding-bottom: 6rem;
}

details {
    margin-bottom: 2rem;
}

details summary {
    color: var(--text);
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.75rem 0;
    user-select: none;
    transition: color 0.3s ease;
}

details summary:hover {
    color: var(--primary);
}

#container,
#featuredZones {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

/* ===== Zone Items ===== */
.zone-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.zone-item:hover {
    transform: translateY(-6px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(252, 38, 81, 0.2);
}

.zone-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--border);
    transition: transform 0.3s ease;
}

.zone-item:hover img {
    transform: scale(1.05);
}

.zone-item button {
    flex: 1;
    background: transparent;
    color: var(--text);
    border: 0;
    padding: 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.zone-item:hover button {
    color: var(--primary);
    background: var(--primary-light);
}

/* ===== Zone Viewer ===== */
#zoneViewer {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.zone-header {
    background: var(--gradient-primary);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.zone-title {
    flex: 1;
}

#zoneName {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}

#zoneAuthor {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.2s ease;
}

#zoneAuthor:hover {
    color: white;
    text-decoration: underline;
}

.zone-controls {
    display: flex;
    gap: 0.5rem;
}

.zone-controls button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.zone-controls button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

#zoneFrame {
    flex: 1;
    border: none;
    width: 100%;
}

/* ===== Popup ===== */
#popupOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.popup {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    animation: popUp 0.3s ease;
}

@keyframes popUp {
    from { transform: scale(0.95) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.popup-header {
    background: var(--gradient-primary);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#popupTitle {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

#popupClose {
    background: rgba(255, 255, 255, 0.15);
    border: 0;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#popupClose:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

#popupBody {
    padding: 1.5rem;
    overflow-y: auto;
    color: var(--text);
}

#popupBody input[type="text"],
#popupBody input[type="file"] {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

#popupBody input[type="text"]:focus,
#popupBody input[type="file"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ===== Buttons in Popup ===== */
.settings-button {
    background: var(--gradient-primary);
    color: white;
    border: 0;
    padding: 0.75rem 1.5rem;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    width: 100%;
    margin-bottom: 0.75rem;
}

.settings-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.settings-button:active {
    transform: translateY(0);
}

/* ===== Footer ===== */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1rem;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 50;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
}

.footer-links a:hover {
    color: var(--primary-hover);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
    }

    .search-container {
        width: 100%;
        max-width: none;
    }

    #container,
    #featuredZones {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .zone-item button {
        font-size: 12px;
        padding: 0.75rem;
    }

    .zone-controls {
        flex-wrap: wrap;
    }

    .zone-controls button {
        font-size: 12px;
        padding: 0.5rem 0.75rem;
    }

    .footer-links {
        gap: 1rem;
    }

    .footer-links a {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    main {
        padding: 1rem 0.75rem;
    }

    #container,
    #featuredZones {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.75rem;
    }

    .zone-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .zone-controls {
        width: 100%;
        justify-content: space-between;
    }

    .popup {
        max-width: 90vw;
    }

    .footer-links a {
        font-size: 11px;
    }
}

/* ===== Info Button ===== */
.info-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    margin-left: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.2s ease;
    color: inherit;
}

.info-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.info-button svg {
    display: block;
}
