/* ===== CSS Variables ===== */
:root {
    --primary-color: #00d4aa;
    --secondary-color: #0a1628;
    --accent-color: #ff6b35;
    --danger-color: #ff4757;
    --success-color: #2ed573;
    --warning-color: #ffa502;
    --text-color: #ffffff;
    --text-muted: #a0aec0;
    --glass-bg: rgba(10, 22, 40, 0.85);
    --glass-border: rgba(0, 212, 170, 0.3);
    --transition-fast: 0.2s ease;
    --transition-medium: 0.4s ease;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
    background: #0a0a0a;
    color: var(--text-color);
    overflow: hidden;
    cursor: crosshair;
}

/* ===== Game Container ===== */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 30px;
    z-index: 100;
    pointer-events: none;
}

.hud-item {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hud-icon {
    font-size: 1.4rem;
}

#timer-display.warning {
    border-color: var(--warning-color);
    animation: pulse-warning 1s infinite;
}

#timer-display.danger {
    border-color: var(--danger-color);
    animation: pulse-danger 0.5s infinite;
}

@keyframes pulse-warning {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(255, 165, 2, 0.3);
    }

    50% {
        box-shadow: 0 0 25px rgba(255, 165, 2, 0.6);
    }
}

@keyframes pulse-danger {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(255, 71, 87, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(255, 71, 87, 0.8);
    }
}

/* ===== Crosshair ===== */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 90;
    pointer-events: none;
}

.crosshair-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary-color);
}

/* ===== Camera Indicator ===== */
#camera-indicator {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px 20px;
    z-index: 100;
    pointer-events: none;
}

.camera-icon {
    font-size: 2rem;
    animation: camera-bob 2s ease-in-out infinite;
}

@keyframes camera-bob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* ===== Teleport Marker ===== */
#teleport-marker {
    position: fixed;
    pointer-events: none;
    z-index: 200;
}

.marker-ring {
    width: 60px;
    height: 60px;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: ring-pulse 1s ease-in-out infinite;
}

.marker-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--primary-color);
}

@keyframes ring-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.6;
    }
}

/* ===== Flash Overlay ===== */
#flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease;
}

#flash-overlay.active {
    opacity: 1;
    animation: flash 0.4s ease-out forwards;
}

@keyframes flash {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 50%, #0a1628 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-content h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.loading-content h2 {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 40px;
}

.loading-bar-container {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 20px;
}

.loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 3px;
    transition: width 0.3s ease;
}

#loading-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Screen Overlays ===== */
#start-screen,
#victory-screen,
#timeup-screen,
#results-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

.screen-content {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

.screen-content h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.screen-content h2 {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-bottom: 25px;
}

.screen-content p {
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 15px;
}

.instructions {
    font-size: 1.1rem;
    margin-bottom: 30px;
}

.key {
    display: inline-block;
    background: rgba(0, 212, 170, 0.2);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 0.9rem;
    color: var(--primary-color);
}

.stats {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
}

button {
    background: linear-gradient(135deg, var(--primary-color), #00a385);
    color: var(--secondary-color);
    border: none;
    border-radius: 12px;
    padding: 16px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 20px;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 212, 170, 0.4);
}

button:active {
    transform: translateY(-1px);
}

/* Victory specific */
.victory h1 {
    color: var(--success-color);
}

/* Time up specific */
.timeup h1 {
    color: var(--warning-color);
}

/* ===== Correction Mode HUD ===== */
#correction-hud {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.correction-message {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.9), rgba(255, 71, 87, 0.9));
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    animation: correction-pulse 2s ease-in-out infinite;
}

@keyframes correction-pulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 107, 53, 0.5);
    }

    50% {
        box-shadow: 0 0 40px rgba(255, 107, 53, 0.8);
    }
}

/* ===== Explanation Box ===== */
#explanation-box {
    position: fixed;
    bottom: 180px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    max-width: 500px;
    width: 90%;
}

.explanation-content {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--warning-color);
    border-radius: 12px;
    padding: 20px 25px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.explanation-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.explanation-content p {
    color: var(--text-color);
    font-size: 1.1rem;
    line-height: 1.5;
    margin: 0;
}

/* ===== Results Screen ===== */
#results-content {
    text-align: left;
    margin: 30px 0;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.result-item:last-child {
    border-bottom: none;
}

.result-icon {
    font-size: 1.5rem;
}

.result-found {
    color: var(--success-color);
}

.result-missed {
    color: var(--danger-color);
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #hud {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .hud-item {
        padding: 10px 20px;
        font-size: 1rem;
    }

    #camera-indicator {
        bottom: 20px;
        right: 20px;
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .screen-content h1 {
        font-size: 2rem;
    }
}

/* ===== Menu Screens ===== */
#home-screen,
#pause-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

.menu-screen {
    max-width: 550px;
}

.menu-screen h2 {
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 35px;
}

/* ===== Settings Controls ===== */
.menu-settings {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
    text-align: left;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    color: var(--text-color);
    font-weight: 500;
    margin-bottom: 10px;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Range Slider */
input[type="range"] {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-color);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#hazard-count-value {
    background: var(--primary-color);
    color: var(--secondary-color);
    font-weight: 700;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.1rem;
}

/* Select Dropdown */
select {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
}

select:focus {
    border-color: var(--primary-color);
}

select option {
    background: var(--secondary-color);
    color: var(--text-color);
}

/* Checkbox */
input[type="checkbox"] {
    width: 24px;
    height: 24px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--glass-border);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
}

input[type="checkbox"]:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 14px;
}

.checkbox-label {
    color: var(--text-muted);
}

/* ===== Menu Instructions ===== */
.menu-instructions {
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
}

.menu-instructions p {
    margin-bottom: 8px;
    color: var(--text-color);
}

.menu-instructions p:last-child {
    margin-bottom: 0;
}

/* ===== Button Variants ===== */
.primary-button {
    background: linear-gradient(135deg, var(--primary-color), #00a385);
    color: var(--secondary-color);
    border: none;
    border-radius: 12px;
    padding: 16px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    margin-top: 10px;
}

.secondary-button {
    background: transparent;
    color: var(--text-color);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    margin-top: 10px;
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: none;
    box-shadow: none;
}

.secondary-button.danger {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.secondary-button.danger:hover {
    background: rgba(255, 71, 87, 0.2);
    border-color: var(--danger-color);
}

/* ===== Pause Menu ===== */
.pause-menu {
    max-width: 400px;
}

.pause-menu h1 {
    margin-bottom: 30px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
}