:root {
    --screen-bg: #111;
    --phosphor-green: #33ff00;
    --phosphor-amber: #ffb000;
    --bezel-color: #3b3b3b;
    --wood-grain: #5c3a21;
}

* {
    box-sizing: border-box;
    user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'VT323', monospace;
    overflow: hidden;
}

.tv-container {
    position: relative;
    width: 800px;
    height: 650px;
}

.tv-frame {
    width: 100%;
    height: 100%;
    background-color: var(--bezel-color);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 0 50px rgba(0,0,0,0.5);
    border-bottom: 10px solid #222;
    border-right: 10px solid #222;
    border-top: 2px solid #555;
    border-left: 2px solid #555;
    position: relative;
}

/* Wood grain effect for side panel if desired, strictly sticking to heavy plastic look for 80s Videoton vibe */

.brand {
    color: #aaa;
    font-family: sans-serif;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 10px;
    text-align: center;
    text-shadow: 1px 1px 0 #000;
    font-size: 1.2rem;
}

.screen-border {
    background: #000;
    padding: 15px;
    border-radius: 40px;
    box-shadow: inset 0 0 10px #000;
    flex-grow: 1;
    position: relative;
}

.screen {
    width: 100%;
    height: 100%;
    background-color: var(--screen-bg);
    border-radius: 40px; /* Curvature of the tube */
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 80px rgba(0,0,0,0.9);
}

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.2) 50%,
        rgba(0,0,0,0.2)
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10;
}

.screen::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 10;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.02; }
    50% { opacity: 0.05; }
    100% { opacity: 0.02; }
}

canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    display: block;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    color: var(--phosphor-green);
    text-shadow: 0 0 5px var(--phosphor-green), 0 0 10px var(--phosphor-green);
}

#ui-layer {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 2rem;
    position: relative; /* Context for absolute positioning if needed */
    height: 100%;
}

#torley-logo {
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-family: 'Times New Roman', serif;
    font-weight: bold;
    color: #fff;
    background: #000;
    padding: 5px 10px;
    border: 2px solid #fff;
    font-size: 1.5rem;
    pointer-events: none;
}

.modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0,0,0,0.8);
    padding: 20px;
    border: 2px solid var(--phosphor-green);
    box-shadow: 0 0 10px var(--phosphor-green);
}

.hidden {
    display: none;
}

h1 {
    font-size: 4rem;
    margin: 0;
    color: var(--phosphor-amber);
    text-shadow: 0 0 5px var(--phosphor-amber);
}

.blink {
    animation: blinker 1s linear infinite;
}

@keyframes blinker {
    50% { opacity: 0; }
}

.controls-panel {
    height: 60px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    padding-right: 30px;
}

.knob {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #222;
    border: 2px solid #111;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
}

.speaker-grill {
    flex-grow: 1;
    height: 30px;
    background-image: linear-gradient(to right, #222 50%, transparent 50%);
    background-size: 4px 100%;
    margin-right: 50px;
    margin-left: 20px;
    opacity: 0.5;
}

/* Mobile Landscape - Aspect Ratio Fix */

/* Portrait on Mobile - Maintain 4:3 Aspect Ratio */
@media screen and (orientation: portrait) and (max-width: 600px) {
    body {
        margin: 0;
        padding: 0;
        overflow: hidden;
        background: #000;
    }
    
    .tv-container {
        width: 100vw;
        height: auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .tv-frame {
        /* Maintain 4:3 aspect ratio based on width */
        width: 100vw;
        height: auto;
        aspect-ratio: 4 / 3;
        border-radius: 0;
        padding: 0;
        border: none;
        box-shadow: none;
    }
    
    .screen-border {
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 0;
        margin: 0;
    }
    
    .screen {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    #gameCanvas {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .brand, .controls-panel {
        display: none;
    }
}

/* Landscape Fullscreen on Mobile */
@media screen and (orientation: landscape) and (max-height: 500px) {
    body {
        margin: 0;
        padding: 0;
        overflow: hidden;
        background: #000;
    }
    
    .tv-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .tv-frame {
        /* Maintain 4:3 aspect ratio */
        width: auto;
        height: 100vh;
        aspect-ratio: 4 / 3;
        max-width: 100vw;
        border-radius: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .screen-border {
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 0;
        margin: 0;
    }
    
    .screen {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    #gameCanvas {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .brand, .controls-panel {
        display: none;
    }
}
