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

:root { 
    --digital-white: #FFFFFF; 
    --record-red: #FF0000;
    --gray: #888;
}

body { 
    background: #000; 
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport — respects mobile browser chrome */
    display: flex;
    flex-direction: column;
    justify-content: center; 
    align-items: center; 
    transition: background 0.3s ease;
    position: relative; 
    padding-bottom: 60px; 
    font-family: 'Digital Numbers', sans-serif;
}

/* --- Universe States --- */
body.inverted { background: #fff; }
body.inverted #main-gif { filter: invert(1); }
body.inverted #playlist-entries li,
body.inverted .broadcast-root-title,
body.inverted .video-title,
body.inverted .digital-meta,
body.inverted .status-text,
body.inverted footer { color: #000; }

body.inverted #playlist-entries li:hover, 
body.inverted .broadcast-root-title:hover, 
body.inverted .video-title:hover {
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

body.inverted .square-stop { background-color: #000; }
body.inverted .triangle-right { border-left-color: #000; }
body.inverted .broadcast-container { border-top-color: rgba(0, 0, 0, 0.15); }

/* ============================================================
   LAYOUT — Desktop first, then mobile overrides below
============================================================ */

.main-wrapper { 
    display: flex; 
    width: 90vw; 
    max-width: 1200px; 
    gap: 60px; 
    align-items: flex-start; 
}

.side-panel { 
    flex: 0 0 20%; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    align-items: center; 
}

.interface-section { flex: 2.2; }

/* --- GIF --- */
.gif-section { width: 100%; }
#main-gif { width: 100%; height: auto; display: block; }

/* --- Text & Lists --- */
#playlist-entries { list-style: none; padding: 0; margin: 0; }

#playlist-entries li, 
.broadcast-root-title, 
.video-title {
    font-size: 0.9rem; 
    color: var(--digital-white);
    padding: 10px 0;
    cursor: pointer;
    text-transform: uppercase;
    list-style: none;
    transition: text-shadow 0.2s ease;
    display: flex;
    align-items: center;
}

#playlist-entries li:hover, 
.broadcast-root-title:hover, 
.video-title:hover {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.digital-meta { 
    color: var(--digital-white); 
    font-size: 0.7rem; 
    font-family: monospace; 
    margin-bottom: 8px;
}

.meta-text { 
    display: block; 
    font-family: Arial, sans-serif; 
    font-size: 0.6rem; 
    opacity: 0.7; 
    margin-top: 2px; 
}

/* --- Copyright --- */
.copyright {
    text-align: center;
    padding: 60px 10vw;
    background: #000;
    position: relative;
    z-index: 10;
    font-size: 11px; 
    letter-spacing: 0.3em;
    color: var(--gray); 
    font-weight: 700;
    text-transform: uppercase;
}

.copyright a {
    color: var(--gray);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.copyright a:hover { opacity: 0.7; }

/* --- Broadcast --- */
.broadcast-container { 
    margin-top: 20px; 
    border-top: 1px solid rgba(255, 255, 255, 0.1); 
}

.video-list { padding-left: 20px; }
.video-item { margin-bottom: 5px; }

.broadcast-root-title::-webkit-details-marker,
.video-title::-webkit-details-marker { display: none; }

/* Smooth open animation */
details[open] summary ~ * {
    animation: slideDown 0.18s ease-out;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Video wrapper — responsive 16:9 --- */
.video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; 
    height: 0;
    margin: 15px 0;
    border: 1px solid #333;
}
.video-wrapper iframe { 
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    border: none;
}

/* --- UI Elements --- */
.status-hidden { opacity: 0; pointer-events: none; height: 20px; }
.status-visible { 
    opacity: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    height: 20px; 
}

.status-text { 
    color: var(--digital-white); 
    font-size: 0.7rem; 
    letter-spacing: 0.15em;
}

.pulse-dot { 
    width: 6px; height: 6px; 
    background-color: var(--record-red); 
    border-radius: 50%; 
    flex-shrink: 0;
    animation: pulse 1.5s infinite; 
}
@keyframes pulse { 
    0%, 100% { transform: scale(1); } 
    50% { transform: scale(1.5); opacity: 0.5; } 
}

footer { 
    position: absolute; 
    bottom: 20px; 
    color: var(--digital-white); 
    font-family: monospace; 
    font-size: 0.7rem; 
    letter-spacing: 2px; 
}

#album-art-container { 
    margin-top: 30px; 
    max-width: 300px; 
    display: none; 
}
#album-art-container.visible { display: block; }
#album-art { width: 100%; height: auto; display: block; }

/* --- Transport Controls --- */
.transport-controls { 
    display: flex; 
    gap: 30px; 
    margin-top: 10px;
    align-items: center;
}

.icon-trigger {
    /* Tap target wrapper — invisible padding makes it 44×44 without changing visual size */
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.triangle-right { 
    width: 0; height: 0; 
    border-top: 10px solid transparent; 
    border-bottom: 10px solid transparent; 
    border-left: 20px solid var(--digital-white); 
    cursor: pointer; 
}

.square-stop { 
    width: 20px; height: 20px; 
    background-color: var(--digital-white); 
    cursor: pointer; 
}

/* ============================================================
   TABLET — 600px to 900px
============================================================ */
@media (max-width: 900px) {

    body {
        justify-content: flex-start;
        padding-bottom: 0;
        align-items: stretch;
    }

    .main-wrapper {
        flex-direction: column;
        width: 100%;
        gap: 0;
        align-items: stretch;
    }

    /* Horizontal strip across the top */
    .side-panel {
        flex-direction: row;
        width: 100%;
        padding: 12px 20px;
        gap: 16px;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
        flex-shrink: 0;
    }

    body.inverted .side-panel {
        border-bottom-color: rgba(0, 0, 0, 0.12);
    }

    .gif-section {
        width: clamp(56px, 15vw, 110px);
        flex-shrink: 0;
    }

    #playback-status {
        flex: 1;
        justify-content: center;
    }

    .transport-controls {
        margin-top: 0;
        gap: 8px;
        flex-shrink: 0;
    }

    .interface-section {
        width: 100%;
        padding: 16px 20px 80px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
    }

    footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        background: #000;
        padding: 14px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        letter-spacing: 0.15em;
    }

    body.inverted footer {
        background: #fff;
        border-top-color: rgba(0, 0, 0, 0.08);
    }

    .copyright { padding: 14px 5vw; }

    /* Playlist items — thumb-friendly */
    #playlist-entries li {
        padding: 12px 0;
        min-height: 44px;
        font-size: clamp(0.75rem, 3vw, 0.9rem);
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    body.inverted #playlist-entries li {
        border-bottom-color: rgba(0, 0, 0, 0.06);
    }

    .broadcast-root-title,
    .video-title {
        min-height: 44px;
        font-size: clamp(0.75rem, 3vw, 0.9rem);
        padding: 12px 0;
    }

    .video-list { padding-left: 16px; }

    #album-art-container {
        max-width: 240px;
        margin: 16px auto;
    }
}

/* ============================================================
   PHONE — under 480px
============================================================ */
@media (max-width: 480px) {

    .side-panel {
        padding: 10px 14px;
        gap: 10px;
    }

    .gif-section {
        width: clamp(44px, 16vw, 72px);
    }

    .interface-section {
        padding: 14px 14px 80px;
    }

    .digital-meta {
        font-size: 0.65rem;
        word-break: break-all;
    }

    #playlist-entries li,
    .broadcast-root-title,
    .video-title {
        font-size: 0.8rem;
    }

    .video-list { padding-left: 10px; }

    .transport-controls { gap: 4px; }
}

/* ============================================================
   LANDSCAPE PHONE — wide but short
   Reverts to side-by-side so the gif isn't wasted vertical space
============================================================ */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 480px) {

    body {
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        overflow: hidden;
        height: 100dvh;
    }

    .main-wrapper {
        flex-direction: row;
        height: 100%;
        overflow: hidden;
    }

    .side-panel {
        flex-direction: column;
        width: clamp(100px, 22vw, 160px);
        height: 100%;
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.12);
        padding: 10px;
        overflow-y: auto;
        justify-content: flex-start;
        gap: 10px;
    }

    body.inverted .side-panel {
        border-right-color: rgba(0, 0, 0, 0.12);
    }

    .gif-section { width: 100%; }

    .transport-controls {
        flex-direction: row;
        justify-content: center;
        width: 100%;
        gap: 12px;
        margin-top: 6px;
    }

    .interface-section {
        flex: 1;
        height: 100%;
        overflow-y: auto;
        padding: 10px 14px 60px;
    }

    footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }
}