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

:root {
    --spacing-xs: clamp(0.25rem, 1vw, 0.5rem);
    --spacing-sm: clamp(0.5rem, 2vw, 1rem);
    --spacing-md: clamp(1rem, 3vw, 1.5rem);
    --spacing-lg: clamp(1.5rem, 4vw, 2rem);
    --spacing-xl: clamp(2rem, 5vw, 2.5rem);
    
    --font-xs: clamp(0.7rem, 2vw, 0.85rem);
    --font-sm: clamp(0.8rem, 2.5vw, 0.95rem);
    --font-md: clamp(0.9rem, 3vw, 1rem);
    --font-lg: clamp(1.2rem, 4vw, 1.5rem);
    --font-xl: clamp(1.8rem, 6vw, 2.4rem);
    
    --border-radius-sm: clamp(20px, 5vw, 40px);
    --border-radius-md: clamp(12px, 3vw, 20px);
    --border-radius-lg: clamp(40px, 8vw, 60px);
    
    --player-height: clamp(100px, 20vh, 140px);
    --waveform-height: clamp(40px, 8vh, 60px);
}

body {
    background: #0b0b12;
    background-image: radial-gradient(circle at 30% 40%, rgba(80, 140, 255, 0.08) 0%, transparent 30%),
                      radial-gradient(circle at 80% 70%, rgba(170, 0, 255, 0.06) 0%, transparent 35%);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    padding: var(--spacing-lg) var(--spacing-md) var(--player-height);
    color: #eaeef5;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: min(1200px, 95vw);
    margin: 0 auto;
    width: 100%;
}

/* Контейнер заголовка с фоновым canvas */
.title-container {
    position: relative;
    display: inline-block;
}

.title-waveform {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius-md);
    opacity: 0.6;
    pointer-events: none; /* чтобы клики проходили на текст */
    z-index: 0;
}

.animated-title {
    position: relative;
    z-index: 1;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: var(--font-xl);
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
    display: inline-block;
    text-shadow: 0 0 10px currentColor;
    transition: text-shadow 0.05s ease;
}

.title-text {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    color: #ffffff;
    transition: color 0.05s linear, text-shadow 0.05s linear;
}

.header-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.status-badge {
    background: rgba(0, 255, 200, 0.1);
    border: 1px solid rgba(0, 255, 200, 0.3);
    color: #aafff0;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-weight: 500;
    font-size: var(--font-sm);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 0 15px rgba(0, 255, 200, 0.2);
    white-space: nowrap;
}

.stream-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.stream-card {
    display: flex;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(10, 12, 20, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-lg);
    transition: 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    width: 100%;
    min-height: clamp(60px, 10vh, 80px);
    cursor: pointer;
}

.stream-card:hover {
    border-color: rgba(100, 180, 255, 0.35);
    background: rgba(15, 18, 30, 0.65);
    transform: translateY(-2px);
}

.stream-card.active {
    border-color: rgba(0, 255, 200, 0.5);
    background: rgba(0, 255, 200, 0.1);
}

.stream-mount {
    font-weight: 600;
    font-size: var(--font-md);
    background: rgba(0, 255, 200, 0.15);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(0, 255, 200, 0.4);
    color: #aafff0;
    white-space: nowrap;
    min-width: clamp(70px, 15vw, 100px);
    text-align: center;
    margin-right: var(--spacing-sm);
    flex-shrink: 0;
    cursor: pointer;
    transition: 0.2s ease;
}

.stream-mount:hover {
    background: rgba(0, 255, 200, 0.3);
    transform: scale(1.05);
}

.stream-info {
    flex: 1;
    min-width: 0;
    margin-right: var(--spacing-sm);
}

.stream-title {
    font-weight: 500;
    color: #fff;
    font-size: var(--font-md);
    margin-bottom: var(--spacing-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listener-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-lg);
    font-size: var(--font-xs);
    color: #6effe8;
    margin: 0 var(--spacing-xs);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.listener-badge::before {
    content: "👂";
    font-size: var(--font-sm);
}

.history-button {
    background: rgba(100, 180, 255, 0.15);
    border: 1px solid rgba(100, 180, 255, 0.4);
    color: #9bb8ff;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-lg);
    font-size: var(--font-xs);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: 0.15s;
    margin: 0 var(--spacing-xs);
    flex-shrink: 0;
}

.history-button:hover {
    background: rgba(100, 180, 255, 0.3);
    color: #fff;
    transform: scale(1.05);
}

.history-button::before {
    content: "📜";
    font-size: var(--font-sm);
    margin-right: 4px;
}

.play-indicator {
    width: clamp(36px, 8vw, 44px);
    height: clamp(36px, 8vw, 44px);
    border-radius: 50%;
    background: rgba(40, 140, 255, 0.15);
    border: 1.5px solid rgba(80, 170, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: white;
    margin-left: var(--spacing-xs);
    flex-shrink: 0;
    transition: 0.15s;
    cursor: pointer;
}

.play-indicator.playing {
    background: #1f6cff;
    border-color: #9cd4ff;
    box-shadow: 0 0 25px #0077ff;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-md);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: rgba(10, 12, 20, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(120, 160, 255, 0.35);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid rgba(120, 160, 255, 0.35);
}

.modal-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: #aafff0;
}

.modal-close {
    background: none;
    border: none;
    color: #9bb8ff;
    font-size: var(--font-xl);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.15s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.history-list {
    list-style: none;
    padding: 0;
}

.history-item {
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-md);
    border-left: 3px solid #0ff;
    font-size: var(--font-sm);
    color: #d3e2ff;
    word-break: break-word;
}

.history-time {
    font-size: var(--font-xs);
    color: #6effe8;
    margin-bottom: 4px;
}

.loading-spinner {
    text-align: center;
    padding: var(--spacing-lg);
    color: #0ff;
}

/* MINIPLAYER */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(8, 10, 18, 0.95);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border-top: 1px solid rgba(120, 160, 255, 0.35);
    box-shadow: 0 -10px 30px -5px #00000080;
    padding: var(--spacing-sm) var(--spacing-md);
    z-index: 1000;
    max-height: var(--player-height);
}

.waveform-container {
    width: 100%;
    height: var(--waveform-height);
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(160, 200, 255, 0.25);
    box-shadow: inset 0 0 18px #000000, 0 0 15px #0044ff20;
    overflow: hidden;
    margin-bottom: var(--spacing-xs);
}

#waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
}

.player-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: var(--spacing-md);
}

.player-track-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    overflow: hidden;
}

.player-current-title {
    font-weight: 600;
    font-size: var(--font-sm);
    color: white;
    text-shadow: 0 0 10px #97bdff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.player-current-mount {
    font-size: var(--font-xs);
    color: #9bb8ff;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-controls {
    display: flex;
    gap: clamp(0.3rem, 2vw, 1rem);
    flex-shrink: 0;
    justify-content: center;
}

.ctrl-btn {
    background: none;
    border: none;
    font-size: clamp(1.5rem, 4vw, 2rem);
    cursor: pointer;
    color: #eaf2ff;
    filter: drop-shadow(0 0 6px #49b2ff);
    width: clamp(36px, 6vw, 44px);
    height: clamp(36px, 6vw, 44px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.1s;
    padding: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:hover {
    background: rgba(255,255,255,0.05);
    transform: scale(1.05);
}

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

.player-time {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    min-width: 80px;
}

.time {
    font-size: var(--font-md);
    font-variant-numeric: tabular-nums;
    color: #a5c0ff;
    font-weight: 500;
}

.volume-control {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    min-width: clamp(100px, 20vw, 140px);
}

.volume-icon {
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: #8cb4ff;
    cursor: pointer;
    width: 25px;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.volume-slider {
    flex: 1;
    height: clamp(3px, 0.8vh, 4px);
    background: rgba(120, 120, 140, 0.3);
    border-radius: 10px;
    cursor: pointer;
    position: relative;
}

.volume-fill {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #6effe8, #8cb4ff);
    border-radius: 10px;
    box-shadow: 0 0 15px #6effe8;
    transition: width 0.05s ease;
}

.footer-note {
    margin-top: var(--spacing-lg);
    text-align: center;
    font-size: var(--font-xs);
    color: #64748b;
    border-top: 1px solid rgba(160, 200, 255, 0.1);
    padding-top: var(--spacing-md);
}

@media (min-width: 1920px) {
    :root {
        --player-height: 160px;
        --waveform-height: 80px;
    }
    .container {
        max-width: 1600px;
    }
    .stream-card {
        padding: var(--spacing-lg) var(--spacing-xl);
    }
}

@media (max-width: 768px) {
    .stream-card {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }
    .stream-mount {
        margin-bottom: 0;
    }
    .stream-info {
        width: calc(100% - 100px);
    }
    .player-main-row {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    .player-track-info {
        width: 100%;
        text-align: center;
    }
    .player-controls {
        width: 100%;
    }
    .player-time {
        width: 100%;
        justify-content: center;
    }
    .volume-control {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    :root {
        --player-height: 180px;
    }
    body {
        padding: var(--spacing-md) var(--spacing-sm) var(--player-height);
    }
    .stream-card {
        padding: var(--spacing-sm);
    }
    .stream-mount {
        min-width: 60px;
        font-size: var(--font-sm);
        margin-right: var(--spacing-xs);
    }
    .listener-badge {
        font-size: var(--font-xs);
        padding: 2px 6px;
    }
    .play-indicator {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    .player-controls {
        justify-content: center;
        width: 100%;
    }
    .ctrl-btn {
        width: 44px;
        height: 44px;
        font-size: 1.8rem;
    }
}

@media (max-width: 360px) {
    .stream-mount {
        min-width: 50px;
        font-size: var(--font-xs);
    }
    .stream-title {
        font-size: var(--font-sm);
    }
    .listener-badge::before {
        content: "";
    }
    .listener-badge {
        font-size: 0;
        padding: 4px 8px;
    }
    .listener-badge::after {
        content: "👂";
        font-size: var(--font-sm);
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --player-height: 140px;
    }
    .mini-player {
        padding: 5px var(--spacing-md);
    }
    .waveform-container {
        height: 35px;
    }
    .player-main-row {
        flex-direction: row;
    }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .stream-card {
        border-width: 0.5px;
    }
}

@media (hover: hover) and (pointer: fine) {
    .stream-card:focus-visible,
    .ctrl-btn:focus-visible,
    .modal-close:focus-visible {
        outline: 2px solid #0ff;
        outline-offset: 2px;
    }
}

audio {
    display: none;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}
