/* Reset e base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: 
        radial-gradient(1px 1px at 20px 30px, #eee, transparent),
        radial-gradient(1px 1px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 160px 30px, #ddd, transparent),
        linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 25%, #16213e 50%, #0f3460 75%, #0a0a0a 100%);
    background-size: 300px 300px, 400px 400px, 500px 500px, 600px 600px, 700px 700px, 100% 100%;
    background-position: 0 0, 50px 50px, 100px 100px, 150px 150px, 200px 200px, 0 0;
    animation: spaceFloat 25s ease-in-out infinite;
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    animation: nebulaFloat 15s ease-in-out infinite;
    z-index: -1;
}

@keyframes spaceFloat {
    0% { 
        background-position: 0 0, 50px 50px, 100px 100px, 150px 150px, 200px 200px, 0% 0%;
    }
    25% { 
        background-position: 50px 25px, 100px 75px, 150px 125px, 200px 175px, 250px 225px, 25% 25%;
    }
    50% { 
        background-position: 100px 50px, 150px 100px, 200px 150px, 250px 200px, 300px 250px, 50% 50%;
    }
    75% { 
        background-position: 150px 75px, 200px 125px, 250px 175px, 300px 225px, 350px 275px, 75% 75%;
    }
    100% { 
        background-position: 200px 100px, 250px 150px, 300px 200px, 350px 250px, 400px 300px, 100% 100%;
    }
}

@keyframes nebulaFloat {
    0% { 
        transform: translate(0, 0) rotate(0deg);
        opacity: 0.8;
    }
    33% { 
        transform: translate(30px, -20px) rotate(120deg);
        opacity: 0.6;
    }
    66% { 
        transform: translate(-20px, 30px) rotate(240deg);
        opacity: 0.9;
    }
    100% { 
        transform: translate(0, 0) rotate(360deg);
        opacity: 0.8;
    }
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

/* TV Frame - Modern Design */
.tv-frame {
    position: relative;
    width: 800px;
    height: 600px;
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    border-radius: 30px;
    box-shadow: 
        0 30px 60px rgba(0,0,0,0.9),
        inset 0 4px 8px rgba(255,255,255,0.1),
        0 0 50px rgba(0,255,255,0.3);
    border: 12px solid #333;
    margin-bottom: 40px;
    transform: perspective(1000px) rotateX(5deg);
}

/* TV Screen */
.tv-screen {
    position: absolute;
    top: 30px;
    left: 30px;
    right: 30px;
    bottom: 100px;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    border: 4px solid #555;
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.8),
        0 0 30px rgba(0,255,255,0.2);
}

#backgroundVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

/* Static TV Effect */
.tv-static {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255,255,255,0.03) 2px,
            rgba(255,255,255,0.03) 4px
        );
    animation: static 0.1s infinite linear;
    display: none;
}

/* TV Loading */
.tv-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #1a1a2e, #16213e);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #00ffff;
    text-align: center;
    font-family: 'Courier New', monospace;
}

.loading-icon {
    position: relative;
    margin-bottom: 30px;
}

.tv-screen-icon {
    width: 80px;
    height: 60px;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border: 3px solid #444;
    border-radius: 8px;
    margin: 0 auto 20px;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.tv-screen-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 40px;
    background: linear-gradient(45deg, #00ffff, #0080ff);
    border-radius: 4px;
    animation: screenGlow 2s ease-in-out infinite alternate;
}

.signal-waves {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
}

.wave {
    position: absolute;
    border: 2px solid #00ffff;
    border-radius: 50%;
    animation: signalPulse 2s ease-in-out infinite;
}

.wave:nth-child(1) {
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0s;
}

.wave:nth-child(2) {
    width: 40px;
    height: 40px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0.3s;
}

.wave:nth-child(3) {
    width: 60px;
    height: 60px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 0.6s;
}

@keyframes screenGlow {
    from {
        box-shadow: 0 0 10px #00ffff;
    }
    to {
        box-shadow: 0 0 20px #00ffff, 0 0 30px #00ffff;
    }
}

@keyframes signalPulse {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

.loading-content h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #00ffff;
    animation: neonPulse 2s ease-in-out infinite alternate;
}

.loading-bar {
    width: 200px;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #00ffff;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 15px;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #00ffff, #0088cc);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.loading-content p {
    font-size: 0.9rem;
    color: #ffaa00;
    margin: 0;
}

/* TV Fallback */
.tv-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #1a1a2e, #16213e);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #00ffff;
    text-align: center;
    font-family: 'Courier New', monospace;
}

.fallback-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    text-shadow: 0 0 10px #00ffff;
    animation: neonPulse 2s ease-in-out infinite alternate;
}

.fallback-content p {
    font-size: 1rem;
    color: #ffaa00;
    margin-bottom: 20px;
}

.fallback-animation {
    width: 100px;
    height: 100px;
    position: relative;
}

.pixel-grid {
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 4px,
            rgba(0, 255, 255, 0.3) 4px,
            rgba(0, 255, 255, 0.3) 8px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 4px,
            rgba(0, 255, 255, 0.3) 4px,
            rgba(0, 255, 255, 0.3) 8px
        );
    animation: pixelGlow 3s ease-in-out infinite;
}

@keyframes neonPulse {
    from { text-shadow: 0 0 10px #00ffff; }
    to { text-shadow: 0 0 20px #00ffff, 0 0 30px #00ffff; }
}

@keyframes pixelGlow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

@keyframes static {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* Controlli TV */
.tv-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: center;
}

.power-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ff4444, #cc0000);
    border: 3px solid #333;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.power-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.power-button.active {
    background: linear-gradient(145deg, #44ff44, #00cc00);
    box-shadow: 0 0 20px rgba(68, 255, 68, 0.5);
}

.channel-knob, .volume-knob {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(145deg, #666, #333);
    border: 2px solid #444;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* Antenne TV */
.antenna {
    position: absolute;
    top: -30px;
    width: 3px;
    height: 40px;
    background: #666;
    border-radius: 2px;
}

.antenna.left {
    left: 100px;
    transform: rotate(-15deg);
}

.antenna.right {
    right: 100px;
    transform: rotate(15deg);
}

.antenna::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -2px;
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
}

/* Silver Surfer Animation */
.silver-surfer-container {
    position: absolute;
    top: 50%;
    left: -100px;
    transform: translateY(-50%);
    z-index: 10;
}

.silver-surfer {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
    animation: surf 4s ease-in-out infinite;
}

@keyframes surf {
    0% {
        transform: translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    50% {
        transform: translateX(calc(100vw + 100px)) rotate(5deg);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateX(calc(100vw + 200px)) rotate(0deg);
        opacity: 0;
    }
}

/* Titolo */
.title {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 5;
}

.title-logo {
    max-width: 400px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 20px #00ffff) drop-shadow(0 0 40px #00ffff);
    animation: neonGlow 2s ease-in-out infinite alternate;
    margin-bottom: 10px;
}

.title .subtitle {
    font-size: 1.2rem;
    color: #ffaa00;
    text-shadow: 0 0 5px #ffaa00;
    margin-top: 10px;
    animation: subtitleGlow 3s ease-in-out infinite alternate;
}

@keyframes neonGlow {
    from {
        text-shadow: 
            0 0 10px #00ffff,
            0 0 20px #00ffff,
            0 0 30px #00ffff;
    }
    to {
        text-shadow: 
            0 0 5px #00ffff,
            0 0 10px #00ffff,
            0 0 15px #00ffff;
    }
}

@keyframes subtitleGlow {
    from {
        text-shadow: 0 0 5px #ffaa00;
    }
    to {
        text-shadow: 0 0 10px #ffaa00, 0 0 15px #ffaa00;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .tv-frame {
        width: 90vw;
        height: 67.5vw;
        max-width: 700px;
        max-height: 525px;
    }
}

@media (max-width: 768px) {
    .tv-frame {
        width: 95vw;
        height: 71.25vw;
        max-width: 600px;
        max-height: 450px;
        transform: perspective(800px) rotateX(3deg);
    }
    
    .title-logo {
        max-width: 300px;
    }
    
    .silver-surfer {
        width: 60px;
    }
}

@media (max-width: 480px) {
    .tv-frame {
        width: 98vw;
        height: 73.5vw;
        max-width: 500px;
        max-height: 375px;
        transform: none;
    }
    
    .title-logo {
        max-width: 250px;
    }
    
    .silver-surfer {
        width: 50px;
    }
}

/* Volume Control */
.volume-control {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

.volume-btn {
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border: 2px solid #444;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.volume-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.volume-btn.muted {
    background: linear-gradient(145deg, #4a2a2a, #3a1a1a);
    border-color: #666;
}

@media (max-width: 768px) {
    .volume-control {
        bottom: 10px;
        left: 10px;
    }
    
    .volume-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}
