:root {
    --primary-color: #00d4ff;
    --accent-color: #ff0055;
    --bg-dark: #0a0a12;
    --glass-bg: rgba(20, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-dark);
    color: white;
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    background: #000;
    /* Gradient Frame Logic using pseudo-element or box-shadow */
    position: relative;
    z-index: 1;
    /* We'll use a pseudo element for the border to support gradients and transitions better, 
       or just box-shadows. User asked for "gradient for the frame". 
       Let's use a conic gradient border hack. */
    background: linear-gradient(#000, #000) padding-box,
        conic-gradient(from var(--angle, 0deg), #333, #666, #333) border-box;
    box-shadow: inset 0 0 50px 20px rgba(0, 0, 0, 0.8);
    /* Inner blur/vignette */
    border: 4px solid transparent;

    /* Variable for rotation if we want to animate it, or just static gradient */
    --angle: 0deg;
    transition: --angle 1s linear;
    /* Note: requires @property for smooth angle transition, otherwise instant */
}

/* Define custom property for animation (modern browsers) */
@property --angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* Animations for status */
@keyframes rot {
    to {
        --angle: 360deg;
    }
}

#game-container.status-ok {
    /* Green Gradient */
    background: linear-gradient(#000, #000) padding-box,
        linear-gradient(to bottom, #00ff00, #004400) border-box;
    box-shadow: inset 0 0 50px 20px rgba(0, 255, 0, 0.4);
}

#game-container.status-fail {
    /* Red Gradient */
    background: linear-gradient(#000, #000) padding-box,
        linear-gradient(to bottom, #ff0000, #440000) border-box;
    box-shadow: inset 0 0 50px 20px rgba(255, 0, 0, 0.4);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 80%;
    max-width: 400px;
}

.logo {
    width: 80px;
    margin-bottom: 1rem;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), #0088cc);
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    color: #fff;
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: transform 0.2s;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
}

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

/* Layout Fix: Ensure interface takes full height */
#interface {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Video Section */
.video-container {
    position: relative;
    width: 100%;
    /* Default to 16:9, but allow taller on mobile not exceeding 1:1 visually if needed*/
    aspect-ratio: 16/9;
    background: #000;
    overflow: hidden;
}

/* Gradient Fade for Video Bottom */
.video-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: linear-gradient(to bottom, transparent, #000);
    pointer-events: none;
    z-index: 5;
}

/* On Mobile Portrait, ensure video takes significant space but doesn't crop horribly */
@media (max-aspect-ratio: 1/1) {
    .video-container {
        aspect-ratio: 1/1;
        /* Max square crop */
    }
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Crop to fit container */
}

/* HUD */
.hud-overlay {
    position: absolute;
    top: 1rem;
    padding: 0.5rem 1rem;
}

.top-left {
    left: 1rem;
}

.top-right {
    right: 1rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(4px);
}

.label {
    font-size: 0.7rem;
    opacity: 0.8;
    letter-spacing: 1px;
}

.value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

.unit {
    font-size: 0.7rem;
    font-weight: 600;
}

/* Controls / Game Area */
.controls-container {
    flex: 1;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000000 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
}

.steer-feedback {
    position: absolute;
    top: 20%;
    /* Position nicely in the game area */
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
    pointer-events: none;
}

.steer-text {
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0);
    /* Hidden by default */
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.2s ease;
}

.steer-text.left.active {
    color: #ffff00;
    text-shadow: 0 0 10px #ffaa00, 0 0 20px #ffaa00;
    transform: translateX(-10px);
}

.steer-text.right.active {
    color: #ffff00;
    text-shadow: 0 0 10px #ffaa00, 0 0 20px #ffaa00;
    transform: translateX(10px);
}

.score-live {
    position: absolute;
    bottom: 10px;
    /* Position at bottom of video */
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    font-weight: 400;
    opacity: 1;
    /* Make fully visible on top of fade */
    background: rgba(0, 0, 0, 0.5);
    /* Semi-transparent pill */
    padding: 5px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    /* Above the fade */
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

@media (max-width: 600px) {
    .score-live {
        font-size: 1.5rem;
        padding: 4px 12px;
        bottom: 5px;
    }
}