/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #05050a;
    font-family: 'Outfit', sans-serif;
    color: #ffffff;
}

/* 3D Game Container */
#game-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    overflow: visible;
    background: #000;
}

/* HUD Overlay */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* HUD Top Header (Mimics image references) */
#hud-top {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 10px 20px;
}

#distance-container {
    font-family: 'Orbitron', monospace;
    font-size: 24px;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    color: #ffffff;
    justify-self: start;
}

#level-container {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    color: #ffffff;
    justify-self: end;
}

/* Reference image: black track with orange filled area and glowing sun indicator */
#progress-bar-container {
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid #111;
    border-radius: 10px;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    overflow: visible;
}

#progress-bar {
    height: 100%;
    width: 30%; /* Dynamic width */
    background: linear-gradient(90deg, #ff4500, #ff8c00);
    border-radius: 7px;
    position: relative;
    transition: width 0.1s linear;
}

#progress-indicator {
    width: 24px;
    height: 24px;
    background: #ffcc00;
    border-radius: 50%;
    position: absolute;
    right: -12px;
    top: -5px;
    box-shadow: 0 0 15px #ffcc00, 0 0 30px #ff8c00;
    border: 2px solid #ffffff;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* Action Prompts (Centered in the upper-middle screen) */
#action-prompt {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 12;
}

.prompt-circle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    animation: prompt-appear 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes prompt-appear {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* JUMP style: green neon */
#prompt-jump {
    border: 5px solid #00ffcc;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.6), inset 0 0 20px rgba(0, 255, 204, 0.3);
}

#prompt-jump .arrow-up {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 25px solid #00ffcc;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 5px #00ffcc);
}

#prompt-jump .prompt-text {
    color: #00ffcc;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(0, 255, 204, 0.8);
}

/* DOWN style: purple/magenta neon */
#prompt-down {
    border: 5px solid #ff00ff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.6), inset 0 0 20px rgba(255, 0, 255, 0.3);
}

#prompt-down .arrow-down {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 25px solid #ff00ff;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 5px #ff00ff);
}

#prompt-down .prompt-text {
    color: #ff00ff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 0, 255, 0.8);
}

/* PUNCH style: red/orange neon */
#prompt-punch {
    border: 5px solid #ff3333;
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.6), inset 0 0 20px rgba(255, 51, 51, 0.3);
}

#prompt-punch .fist-icon {
    font-size: 35px;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 8px rgba(255, 51, 51, 0.8));
    animation: fist-shake 0.5s infinite;
}

#prompt-punch .prompt-text {
    color: #ff3333;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 51, 51, 0.8);
}

@keyframes fist-shake {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.15) rotate(5deg); }
}

/* HUD Bottom Row Layout */
#hud-bottom-row {
    display: flex;
    gap: 15px;
    align-items: center;
    pointer-events: auto;
    align-self: flex-start;
    margin-top: 10px;
    width: 100%;
}

/* Audio & AI Toggle (HUD overlay buttons) */
.audio-hud-btn, .ai-hud-btn {
    padding: 8px 18px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffcc;
    color: #00ffcc;
    border-radius: 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.ai-hud-btn {
    border-color: #ff3333;
    color: #ff3333;
    box-shadow: 0 0 10px rgba(255, 51, 51, 0.2);
}

.audio-hud-btn:hover {
    background: #00ffcc;
    color: #000;
    box-shadow: 0 0 15px #00ffcc;
}

.ai-hud-btn.active {
    border-color: #00ff00;
    color: #00ff00;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.4);
}

.ai-hud-btn:hover {
    transform: translateY(-1px);
}

/* Recording Status Indicator */
#rec-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 900;
    color: #ff3333;
    text-shadow: 0 0 8px #ff3333;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 15px;
    border: 1px solid #ff3333;
    animation: pulse 1s infinite alternate;
}

.rec-dot {
    width: 8px;
    height: 8px;
    background-color: #ff3333;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px #ff3333;
}

/* Settings Box (Start Screen) */
.settings-box {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 0, 255, 0.3);
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 25px;
    text-align: left;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.settings-row {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.settings-row label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Outfit', sans-serif;
    color: #e0e0f0;
}

.settings-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #ff00ff;
}

.settings-row input[type="number"] {
    width: 60px;
    background: #000;
    border: 1px solid #ff00ff;
    border-radius: 4px;
    color: #00ffcc;
    padding: 4px 8px;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    text-align: center;
    margin-left: 10px;
}

/* On-Screen Mobile Touch Controls */
#touch-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    pointer-events: auto;
    padding-bottom: 10px;
}

.ctrl-btn {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #00ffcc;
    color: #00ffcc;
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
    transition: all 0.1s ease;
    touch-action: manipulation;
}

#ctrl-left, #ctrl-right {
    width: 70px;
    height: 70px;
    font-size: 28px;
}

#ctrl-middle-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 180px;
}

#ctrl-middle-btns .ctrl-btn {
    font-size: 14px;
    padding: 10px 0;
    width: 100%;
}

.ctrl-btn:active {
    background: #00ffcc;
    color: #000000;
    box-shadow: 0 0 20px #00ffcc;
    transform: scale(0.95);
}

/* Screen Layouts (Start / Game Over Overlay) */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(5, 5, 20, 0.85) 0%, rgba(2, 2, 5, 0.98) 100%);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    padding-bottom: 5vh;
    overflow-y: auto;
    transition: opacity 0.5s ease;
}

.screen-content {
    text-align: center;
    max-width: 800px;
    width: 90%;
    padding: 30px;
    background: rgba(10, 10, 25, 0.6);
    border: 2px solid #ff00ff;
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.3), inset 0 0 20px rgba(255, 0, 255, 0.1);
    animation: panel-glow 4s infinite alternate;
}

@keyframes panel-glow {
    0% { border-color: #ff00ff; box-shadow: 0 0 25px rgba(255, 0, 255, 0.3); }
    50% { border-color: #00ffcc; box-shadow: 0 0 35px rgba(0, 255, 204, 0.4); }
    100% { border-color: #ff00ff; box-shadow: 0 0 25px rgba(255, 0, 255, 0.3); }
}

/* Glitch Title Text Effect */
h1.glitch {
    font-family: 'Orbitron', sans-serif;
    font-size: 52px;
    font-weight: 900;
    letter-spacing: 4px;
    color: #ffffff;
    position: relative;
    text-shadow: 0px 0px 15px rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
}

h1.glitch::before, h1.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

h1.glitch::before {
    left: 2px;
    text-shadow: -2px 0 #ff00ff;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

h1.glitch::after {
    left: -2px;
    text-shadow: -2px 0 #00ffcc, 0 2px #00ffcc;
    clip: rect(85px, 450px, 140px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(31px, 9999px, 94px, 0); }
    10% { clip: rect(112px, 9999px, 76px, 0); }
    20% { clip: rect(85px, 9999px, 5px, 0); }
    30% { clip: rect(27px, 9999px, 115px, 0); }
    40% { clip: rect(73px, 9999px, 29px, 0); }
    50% { clip: rect(120px, 9999px, 105px, 0); }
    60% { clip: rect(44px, 9999px, 88px, 0); }
    70% { clip: rect(98px, 9999px, 13px, 0); }
    80% { clip: rect(3px, 9999px, 147px, 0); }
    90% { clip: rect(61px, 9999px, 55px, 0); }
    100% { clip: rect(135px, 9999px, 19px, 0); }
}

@keyframes glitch-anim2 {
    0% { clip: rect(76px, 9999px, 116px, 0); }
    11% { clip: rect(2px, 9999px, 83px, 0); }
    22% { clip: rect(139px, 9999px, 4px, 0); }
    33% { clip: rect(57px, 9999px, 98px, 0); }
    44% { clip: rect(110px, 9999px, 42px, 0); }
    55% { clip: rect(24px, 9999px, 130px, 0); }
    66% { clip: rect(89px, 9999px, 17px, 0); }
    77% { clip: rect(13px, 9999px, 103px, 0); }
    88% { clip: rect(144px, 9999px, 71px, 0); }
    100% { clip: rect(68px, 9999px, 122px, 0); }
}

.subtitle {
    font-size: 16px;
    color: #a0a0c0;
    margin-bottom: 30px;
    letter-spacing: 1px;
}

/* Instructions Box */
.instructions-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 255, 204, 0.2);
    border-radius: 10px;
    padding: 20px;
    text-align: left;
    margin-bottom: 35px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.instructions-box h3 {
    font-family: 'Orbitron', sans-serif;
    color: #00ffcc;
    font-size: 18px;
    margin-bottom: 12px;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.4);
}

.instructions-box ul {
    list-style: none;
}

.instructions-box li {
    font-size: 14px;
    margin-bottom: 10px;
    color: #e0e0f0;
    display: flex;
    align-items: center;
}

.key {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    color: #00ffcc;
    margin-right: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    min-width: 32px;
    text-align: center;
}

/* Glow Buttons */
.glow-button {
    background: transparent;
    border: 3px solid #ff00ff;
    color: #ff00ff;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 900;
    padding: 15px 40px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
    transition: all 0.3s ease;
    letter-spacing: 2px;
}

.glow-button:hover {
    background: #ff00ff;
    color: #000000;
    box-shadow: 0 0 30px #ff00ff;
    transform: translateY(-2px);
}

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

/* Game Over Styling */
.game-over-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 60px;
    font-weight: 900;
    color: #ff3333;
    text-shadow: 0 0 20px #ff3333;
    margin-bottom: 10px;
    letter-spacing: 6px;
    animation: red-flicker 1.5s infinite;
}

@keyframes red-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; text-shadow: 0 0 20px #ff3333; }
    20%, 24%, 55% { opacity: 0.8; text-shadow: none; }
}

.summary-text {
    font-size: 18px;
    color: #a0a0c0;
    margin-bottom: 30px;
}

/* Stats Box */
.stats-box {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 51, 51, 0.3);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 35px;
    text-align: left;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span {
    font-size: 16px;
    color: #c0c0d0;
}

.stat-highlight {
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    color: #00ffcc !important;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.5);
}

#btn-restart {
    border-color: #00ffcc;
    color: #00ffcc;
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.3);
}

#btn-restart:hover {
    background: #00ffcc;
    color: #000000;
    box-shadow: 0 0 30px #00ffcc;
}

/* Custom select styling */
.custom-select {
    background: #000000;
    border: 1px solid #ff00ff;
    color: #00ffcc;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    font-weight: bold;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(255, 0, 255, 0.2);
    outline: none;
    margin-left: 10px;
}
.custom-select:focus {
    box-shadow: 0 0 10px #ff00ff;
    border-color: #00ffcc;
}

/* Media Queries for Desktop / Touch Controls layout */
@media(min-width: 769px) {
    #touch-controls {
        display: none !important; /* Hide touch buttons on desktop */
    }
}

@media(max-width: 768px) {
    h1.glitch {
        font-size: 36px;
    }
    .game-over-title {
        font-size: 40px;
    }
    #hud-top {
        grid-template-columns: 1fr 1.5fr 1fr;
    }
    #distance-container, #level-val {
        font-size: 18px;
    }
    .prompt-circle {
        width: 100px;
        height: 100px;
    }
    #prompt-jump .prompt-text, #prompt-down .prompt-text, #prompt-punch .prompt-text {
        font-size: 14px;
    }
    #prompt-punch .fist-icon {
        font-size: 28px;
    }
}

#prep-screen { background: transparent !important; backdrop-filter: none !important; }
#prep-screen .screen-content { margin-top: 250px; background: rgba(10, 10, 25, 0.85); }
