:root {
    --wood-color: #5c3a21;
    --wood-dark: #3a2211;
    --plastic-color: #d1d1d1;
    --plastic-dark: #8a8a8a;
    --screen-bg: #111;
    --phosphor-green: #39ff14;
    --crt-curve: 50px;
}

body {
    margin: 0;
    padding: 0;
    background-color: #2b2b2b;
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
}

.room {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Antennas */
.antenna {
    position: relative;
    width: 100%;
    height: 100px;
    z-index: 1;
}

.rod {
    position: absolute;
    bottom: 0;
    width: 6px;
    height: 150px;
    background: linear-gradient(to right, #ccc, #888);
    border-radius: 5px;
}

.rod.left {
    left: 45%;
    transform: rotate(-30deg);
    transform-origin: bottom center;
}

.rod.right {
    right: 45%;
    transform: rotate(30deg);
    transform-origin: bottom center;
}

/* TV Box */
.tv-set {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 50px;
}

.tv-cabinet {
    width: 800px;
    height: 550px;
    background: linear-gradient(135deg, var(--wood-color), var(--wood-dark));
    border: 15px solid #2a1b10;
    border-radius: 20px;
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.8),
        10px 10px 30px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: row;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
    z-index: 2;
}

/* Screen Layout */
.screen-frame {
    flex: 3;
    background-color: var(--plastic-color);
    border-radius: 30px;
    padding: 25px;
    box-shadow: 
        inset 5px 5px 15px rgba(255,255,255,0.2),
        inset -5px -5px 15px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen-glass {
    width: 100%;
    height: 100%;
    background-color: var(--screen-bg);
    border-radius: var(--crt-curve);
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset 0 0 50px rgba(0,0,0,0.9),
        0 0 10px rgba(0,0,0,0.8);
    border: 8px solid #000;
}

/* Screen inner elements */
#player-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    /* Make the iframe fill the screen, scale up a bit to hide black bars if needed */
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0; /* Starts off */
    transition: opacity 0.5s ease-in-out;
}

#youtube-player {
    width: 105%;
    height: 105%;
    pointer-events: none; /* Let clicks pass through if needed, but we'll use our buttons */
}

/* The power ON effect */
.tv-on #player-container {
    opacity: 1;
}

/* CRT Overlay Effect */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 10;
    pointer-events: none;
    box-shadow: inset 0 0 60px rgba(0,0,0,0.8);
}

.noise-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)"/%3E%3C/svg%3E');
    opacity: 0.15;
    z-index: 11;
    pointer-events: none;
}

/* Power Off State Noise */
.tv-off .noise-layer {
    opacity: 0.5;
    animation: staticNoise 0.2s infinite;
}

.tv-off #player-container {
    opacity: 0;
}

@keyframes staticNoise {
    0% { transform: translate(0,0); }
    10% { transform: translate(-5%,-5%); }
    20% { transform: translate(-10%,5%); }
    30% { transform: translate(5%,-10%); }
    40% { transform: translate(-5%,15%); }
    50% { transform: translate(-10%,5%); }
    60% { transform: translate(15%,0); }
    70% { transform: translate(0,10%); }
    80% { transform: translate(-15%,0); }
    90% { transform: translate(10%,5%); }
    100% { transform: translate(5%,0); }
}

/* OSD Channel Display */
.channel-display {
    position: absolute;
    top: 20px;
    right: 30px;
    color: var(--phosphor-green);
    font-family: 'VT323', monospace;
    font-size: 2.5rem;
    z-index: 20;
    opacity: 0;
    text-shadow: 0 0 10px var(--phosphor-green);
    transition: opacity 0.3s;
}

.channel-display.show {
    opacity: 1;
}

/* Control Panel Sidebar */
.control-panel {
    flex: 1;
    background-color: var(--plastic-color);
    margin-left: 20px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: inset 2px 2px 10px rgba(255,255,255,0.3), inset -2px -2px 10px rgba(0,0,0,0.5);
    padding: 15px;
}

.speaker-grill {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px;
    background: #bbb;
    border-radius: 5px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.hole {
    height: 15px;
    background-color: #222;
    border-radius: 50%;
    box-shadow: 1px 1px 2px rgba(255,255,255,0.4);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    flex-grow: 1;
}

.knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    margin-top: 5px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Buttons and Dials */
.knob {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #eee, #999);
    border: 3px solid #666;
    box-shadow: 3px 3px 8px rgba(0,0,0,0.5), inset -2px -2px 5px rgba(0,0,0,0.3);
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s;
}

.knob:active {
    transform: scale(0.95);
}

.power-btn {
    width: 70px;
    height: 70px;
}

.indicator {
    width: 10px;
    height: 10px;
    background-color: red;
    border-radius: 50%;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.8);
    transition: background-color 0.3s;
}

.tv-on .indicator {
    background-color: #39ff14;
    box-shadow: 0 0 10px #39ff14;
}

/* Channel and Volume Buttons */
.channel-buttons, .vol-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ch-btn, .vol-btn {
    width: 50px;
    height: 35px;
    background: linear-gradient(to bottom, #dcdcdc, #a0a0a0);
    border: 2px solid #777;
    border-radius: 5px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    box-shadow: 0 4px 0 #555, 0 5px 5px rgba(0,0,0,0.4);
    transition: all 0.1s;
}

.ch-btn:active, .vol-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #555, 0 1px 2px rgba(0,0,0,0.4);
}

/* Action Buttons (Play/Stop) */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.action-btn {
    padding: 10px 15px;
    background: #880000;
    color: #fff;
    border: 2px solid #440000;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 3px 0 #330000, 2px 4px 5px rgba(0,0,0,0.5);
    transition: all 0.1s;
}

#play-btn {
    background: #006600;
    border-color: #003300;
    box-shadow: 0 3px 0 #002200, 2px 4px 5px rgba(0,0,0,0.5);
}

.action-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #000, 1px 1px 2px rgba(0,0,0,0.5);
}

/* TV Stand */
.tv-stand {
    width: 600px;
    height: 20px;
    background: var(--wood-dark);
    border-radius: 0 0 10px 10px;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.5);
}

/* Footer Credits */
.credits {
    margin-top: 50px;
    margin-bottom: 30px;
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    background: rgba(0,0,0,0.5);
    padding: 10px 20px;
    border-radius: 5px;
    letter-spacing: 2px;
    text-align: center;
}

/* =========================================
   RESPONSIVIDADE (Tablets e Celulares)
   ========================================= */

/* Tablets / Telas Médias */
@media (max-width: 900px) {
    .tv-cabinet {
        width: 90vw;
        max-width: 800px;
        height: auto;
        min-height: 450px;
        padding: 15px;
        border-width: 10px;
    }
    
    .tv-stand {
        width: 70vw;
        max-width: 600px;
    }
    
    .screen-frame {
        padding: 15px;
        min-height: 350px;
    }
    
    .control-panel {
        margin-left: 15px;
    }
    
    .knob { width: 50px; height: 50px; }
    .power-btn { width: 60px; height: 60px; }
    .ch-btn, .vol-btn { width: 45px; height: 35px; }
}

/* Celulares / Telas Pequenas */
@media (max-width: 600px) {
    .tv-cabinet {
        flex-direction: column;
        width: 95vw;
        height: auto;
        border-radius: 15px;
    }
    
    .screen-frame {
        flex: none;
        width: 100%;
        box-sizing: border-box;
        aspect-ratio: 4 / 3;
        min-height: auto;
        padding: 10px;
        border-radius: 15px;
    }

    .screen-glass {
        border-width: 5px;
        border-radius: 20px;
    }
    
    .channel-display {
        font-size: 1.5rem;
        top: 10px;
        right: 15px;
    }
    
    .control-panel {
        flex: none;
        margin-left: 0;
        margin-top: 15px;
        width: 100%;
        box-sizing: border-box;
        flex-direction: column;
        padding: 15px;
    }
    
    .speaker-grill {
        display: flex;
        justify-content: space-around;
        padding: 5px 15px;
        margin-bottom: 15px;
    }
    
    .speaker-grill .hole {
        width: 10px;
        height: 10px;
    }
    
    .controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 10px;
    }
    
    .knob-container {
        flex: 1 1 30%;
        min-width: 80px;
    }
    
    .channel-buttons, .vol-buttons {
        flex-direction: row;
        gap: 10px;
    }
    
    .action-buttons {
        flex: 1 1 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    .antenna {
        height: 60px;
    }
    
    .rod {
        height: 100px;
    }
    
    .tv-stand {
        width: 80vw;
    }
}
