:root {
    --bg-dark: #0a0a14;
    --bg-card: #12121f;
    --bg-card-hover: #1a1a2e;
    --bg-gradient: linear-gradient(135deg, #0a0a14 0%, #1a1a2e 100%);
    --text-primary: #fff;
    --text-muted: #888;
    --accent: #ff4757;
    --accent-glow: rgba(255, 71, 87, 0.3);
    --online: #2ed573;
    --gold: #ffd32a;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    background-attachment: fixed;
}

/* Compact Top Bar */
.top-bar {
    background: rgba(18, 18, 31, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.back-btn {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    width: 36px;
    height: 36px;
}

.top-bar img {
    height: 24px;
    opacity: 0.9;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px 12px 8px 34px;
    border-radius: 20px;
    font-size: 14px;
    transition: all 0.3s;
}

select {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.btn-refresh {
    background: var(--accent);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-refresh:active { transform: rotate(180deg); }

/* Stats Bar */
.stats-bar {
    background: rgba(18, 18, 31, 0.6);
    padding: 6px 12px;
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-label { color: var(--text-muted); }
.stat-num { font-weight: 700; }
.stat-num.viewers { color: var(--gold); }

/* Grid */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 12px;
    max-width: 1600px;
    margin: 0 auto;
}

@media (max-width: 480px) {
    .models-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }
}

/* Card */
.model-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
    position: relative;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
}

.model-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-overlay-top {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 3px;
}

.thumbnail-overlay-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    padding: 15px 8px 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.overlay-viewers {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 3px;
}

.overlay-viewers i { color: var(--gold); }

.model-name {
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
    color: #fff;
}
.badge-hd { background: #3498db; }
.badge-new { background: #f39c12; }

/* Popup Player */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.popup.active { display: flex; }

.popup-content {
    background: var(--bg-card);
    border-radius: 12px;
    width: 100%;
    max-width: 1000px;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #12121f;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.popup-header img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.popup-header span {
    font-weight: 700;
    font-size: 16px;
    flex: 1;
}

.popup-close {
    font-size: 28px;
    padding: 5px 10px;
    cursor: pointer;
    line-height: 1;
}

.video-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 0; /* Important for flex child */
}

#popupPlayer {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}

.popup-controls {
    display: flex;
    padding: 12px;
    gap: 10px;
    background: #12121f;
    justify-content: center;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}

.volume-control button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.volume-control .volume-level {
    font-size: 12px;
    font-weight: 700;
    min-width: 35px;
    text-align: center;
}

.popup-controls a {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    background: #1a1a2e;
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s;
}

.popup-controls a:hover {
    background: var(--accent);
    transform: translateY(-2px);
}

/* Mobile specific tweaks */
@media (max-width: 768px) {
    .popup { padding: 0; }
    .popup-content { border-radius: 0; max-height: 100vh; }
    .top-bar-right select { display: none; }
    .search-box { max-width: none; }
}
