:root {
    --bg-color: #05050f;
    --primary: #9146FF;
    --primary-glow: rgba(145, 70, 255, 0.5);
    --secondary: #00e5ff;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --glass-bg: rgba(20, 20, 35, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
}

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

html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overflow-y: auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

/* Background Effects */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(100px);
    opacity: 0.5;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 10%) scale(1.1); }
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 1000px;
    height: 100vh;
    height: 100dvh;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

header {
    text-align: center;
    animation: fadeInDown 0.8s ease-out forwards;
    flex-shrink: 0;
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo span {
    color: var(--primary);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 400;
    margin-top: 0.5rem;
}

.search-mode-pill {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    padding: 0.3rem;
    border: 1px solid var(--glass-border);
}

.header-actions {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.btn-vault {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.btn-vault:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem 1.2rem;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Glassmorphism */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.viewer-area {
    flex: 1;
    min-height: 0;
    display: grid;
}

.viewer-area > * {
    grid-area: 1 / 1;
}

/* States */
.state-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    text-align: center;
    gap: 1.5rem;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.hidden {
    display: none !important;
}

.state-panel.hidden {
    display: flex !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Liquid Aura Orb */
.aura-orb-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.aura-orb {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    animation: morph 4s ease-in-out infinite, spinOrb 8s linear infinite;
    z-index: 2;
    box-shadow: inset 10px 0 20px rgba(0,0,0,0.2), inset -10px 0 20px rgba(255,255,255,0.4);
}

.aura-glow {
    position: absolute;
    width: 130%;
    height: 130%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.6;
    animation: pulseGlow 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes morph {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
    34% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; }
    67% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; }
    100% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
}

@keyframes spinOrb {
    to { transform: rotate(360deg); }
}

@keyframes pulseGlow {
    0% { transform: scale(0.8); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(0.8); opacity: 0.3; }
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    transition: opacity 0.3s ease;
    animation: breatheText 3s infinite ease-in-out;
    max-width: 80%;
    margin: 0 auto;
    line-height: 1.5;
}

.loading-text.fade-text {
    opacity: 0;
}

@keyframes breatheText {
    0% { color: var(--text-muted); }
    50% { color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.4); }
    100% { color: var(--text-muted); }
}

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

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Premium Error State */
.error-illustration {
    color: var(--primary);
    margin-bottom: 0.5rem;
    animation: floatError 3s ease-in-out infinite;
    filter: drop-shadow(0 0 15px rgba(168, 85, 247, 0.4));
}

.error-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #fff;
}

.error-content p {
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto 1.5rem auto;
    font-size: 1rem;
}

.error-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 auto;
}

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

.stream-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    animation: fadeIn 0.8s ease-out forwards;
    min-height: 0;
    padding: 0 !important;
    overflow: hidden;
    background: rgba(15, 15, 20, 0.3); /* Restored high transparency for glass look */
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

.streamer-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    flex: 1;
}

.streamer-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary);
    object-fit: cover;
    border: 2px solid var(--primary);
}

.name-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.2rem;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

.streamer-text h2 {
    font-size: 1.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.category-badge {
    background-color: var(--secondary);
    color: var(--bg-color);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.streamer-text p {
    color: var(--text-muted);
    font-size: 0.9rem;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uptime-text {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.3rem;
}

.uptime-text svg {
    opacity: 0.8;
}

.stream-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.viewer-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    color: #ff4444;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(255, 0, 0, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 0, 0, 0.2);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #ff0000;
    border-radius: 50%;
}

/* Media Container */
.media-container {
    display: flex;
    flex-direction: row;
    gap: 0; /* Changed from 1rem to 0 to prevent gap when chat is hidden */
    flex: 1;
    min-height: 0;
    width: 100%;
}

/* Player (Desktop Default) */
.player-wrapper {
    flex: 1;
    position: relative;
    padding: 0;
    min-height: 300px; /* Twitch STRICTLY requires minimum height */
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), margin 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Chat (Desktop Default) */
.chat-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 0;
    opacity: 0;
    margin-left: 0;
    border-radius: 12px;
    overflow: hidden;
    background-color: #0e0e1a;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    pointer-events: none;
}

/* Desktop Active (Side-by-side) */
.media-container.chat-active {
    gap: 1rem;
}

.media-container.chat-active .chat-wrapper {
    width: 350px;
    opacity: 1;
    margin-left: 0;
    pointer-events: auto;
}

#twitch-embed, #twitch-chat-embed {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1.8rem;
    border: none;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), #b07cff);
    color: white;
}

.btn.primary.glowing {
    box-shadow: 0 0 20px var(--primary-glow);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px var(--primary-glow);
}

.btn.secondary {
    background: var(--glass-bg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 0.5rem;
        gap: 0.5rem;
        height: 100dvh;
    }
    
    header {
        margin-bottom: 0.2rem;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
        margin-top: 0.2rem;
    }

    .stream-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
        padding: 0.8rem 1rem;
        width: 100%;
    }
    
    .streamer-info {
        width: 100%;
    }
    
    .avatar {
        width: 45px;
        height: 45px;
        flex-shrink: 0;
    }
    
    .streamer-text h2 {
        font-size: 1.2rem;
    }
    
    .stream-stats {
        align-items: center;
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }
    
    .category-badge {
        flex: 0 1 auto;
        min-width: 0;
    }
    
    .controls {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.5rem 0.5rem;
    }
    
    .media-container {
        flex: 1;
        flex-direction: column;
        gap: 0;
        margin: auto 0;
        position: relative;
    }
    
    .player-wrapper, .chat-wrapper {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        margin-left: 0;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    .chat-wrapper {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.98);
        z-index: 1;
    }
    
    .player-wrapper {
        opacity: 1;
        pointer-events: auto;
        transform: scale(1);
        z-index: 2;
    }
    
    .media-container.chat-active .player-wrapper {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.98);
        z-index: 1;
    }
    
    .media-container.chat-active .chat-wrapper {
        opacity: 1;
        pointer-events: auto;
        transform: scale(1);
        z-index: 2;
        width: 100%;
    }
    
    .stream-panel {
        flex: 1;
        justify-content: space-between;
    }
    
    .btn {
        flex: 1;
        width: auto;
        justify-content: center;
        padding: 0.7rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* Vault Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    padding: 1.5rem;
    background: rgba(15, 15, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
}

.modal-header h2 {
    font-size: 1.4rem;
    margin: 0;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
}

.btn-close:hover {
    color: var(--primary);
}

.vault-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding-right: 0.5rem;
}

.vault-list::-webkit-scrollbar { width: 6px; }
.vault-list::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }
.vault-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 10px; }

.vault-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.vault-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--glass-border);
    transform: translateY(-2px);
}

.vault-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--secondary);
    flex-shrink: 0;
}

.vault-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.vault-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vault-category {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-watch {
    background: rgba(186, 124, 255, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-watch:hover {
    background: var(--primary);
    color: white;
}
