:root {
    --bg-color: #0d0f1a;
    --neon-blue: #00f3ff;
    --neon-purple: #9d00ff;
    --neon-green: #00ff66;
    --neon-red: #ff0055;
    --neon-orange: #ff7700;
    --neon-yellow: #ffee00;
    --text-primary: #ffffff;
    --text-secondary: #a0a5b5;
    --glass-bg: rgba(20, 25, 40, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(157, 0, 255, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(0, 243, 255, 0.15), transparent 25%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    width: 95vw;
    height: 95vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    height: 10vh;
}

.header-title h1 {
    font-weight: 900;
    font-size: 2.5rem;
    letter-spacing: 4px;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(157, 0, 255, 0.5);
}

.header-stat {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.2rem;
    font-weight: 700;
}

.label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.energy-bar-container {
    width: 200px;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.energy-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-yellow), var(--neon-green));
    box-shadow: 0 0 10px var(--neon-green);
    transition: width 0.3s ease-out, background 0.3s;
}

/* Layout */
.main-content {
    display: flex;
    gap: 20px;
    height: calc(85vh - 20px);
}

.stats-panel {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.log-panel {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
}

.center-panel {
    flex: 2.5;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Stats Bars */
.stat-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.1rem;
}

.progress-bg {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.speed-color {
    background: var(--neon-blue);
    box-shadow: 0 0 10px var(--neon-blue);
}

.endurance-color {
    background: var(--neon-green);
    box-shadow: 0 0 10px var(--neon-green);
}

.strength-color {
    background: var(--neon-red);
    box-shadow: 0 0 10px var(--neon-red);
}

.technique-color {
    background: var(--neon-purple);
    box-shadow: 0 0 10px var(--neon-purple);
}

/* Buttons & Actions */
.actions-panel {
    padding: 30px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.actions-footer {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
}

.action-btn {
    padding: 20px;
    border: none;
    border-radius: 15px;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
    z-index: -1;
}

.action-btn:hover::before {
    transform: translateX(100%);
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.action-btn:active {
    transform: translateY(1px);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.btn-speed:hover {
    border-color: var(--neon-blue);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.btn-endurance:hover {
    border-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.4);
}

.btn-strength:hover {
    border-color: var(--neon-red);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.4);
}

.btn-technique:hover {
    border-color: var(--neon-purple);
    box-shadow: 0 0 15px rgba(157, 0, 255, 0.4);
}

.btn-rest {
    background: rgba(0, 243, 255, 0.1);
    border-color: rgba(0, 243, 255, 0.3);
}

.btn-compete {
    background: rgba(255, 238, 0, 0.1);
    border-color: rgba(255, 238, 0, 0.4);
    color: var(--neon-yellow);
}

.btn-compete:hover {
    box-shadow: 0 0 20px rgba(255, 238, 0, 0.5);
}

/* History Log */
.log-container {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 10px;
}

.log-container::-webkit-scrollbar {
    width: 6px;
}

.log-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.log-entry {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease-in;
    border-left: 3px solid var(--text-secondary);
}

.log-entry.compete {
    border-left-color: var(--neon-yellow);
    background: rgba(255, 238, 0, 0.05);
}

.log-entry.training {
    border-left-color: var(--neon-blue);
}

.log-entry.rest {
    border-left-color: var(--neon-green);
}

.log-entry.warning {
    border-left-color: var(--neon-red);
    color: var(--neon-red);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Visual Scene Frame */
.scene-container {
    height: 35%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#track {
    width: 100%;
    height: 60px;
    position: relative;
    background: #e65c00;
    /* Track color */
    border-top: 2px solid white;
    border-bottom: 2px solid white;
}

.track-lines {
    position: absolute;
    top: 50%;
    width: 100%;
    height: 2px;
    background: repeating-linear-gradient(90deg, transparent, transparent 20px, white 20px, white 40px);
}

#athlete {
    position: absolute;
    top: -20px;
    left: 20px;
    font-size: 4rem;
    z-index: 10;
    transition: transform 0.2s;
}

#action-text-overlay {
    position: absolute;
    font-size: 3rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.1);
    z-index: 5;
    text-transform: uppercase;
    letter-spacing: 10px;
    pointer-events: none;
    transition: all 0.5s;
}

/* Animations for Athlete */
.anim-run {
    animation: sprint 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes sprint {
    0% {
        left: 5%;
        transform: scale(1) rotate(0deg);
    }

    30% {
        transform: scale(1.1) rotate(15deg);
    }

    100% {
        left: 80%;
        transform: scale(1) rotate(0deg);
    }
}

.anim-lift {
    animation: liftWeight 1.5s ease-in-out forwards;
}

@keyframes liftWeight {
    0% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-10px) scale(1.1);
    }

    100% {
        transform: translateY(0) scale(1);
    }
}

.anim-rest {
    animation: sleep 2s ease-in-out infinite alternate;
}

@keyframes sleep {
    0% {
        opacity: 0.8;
        transform: scale(1);
    }

    100% {
        opacity: 0.4;
        transform: scale(0.95);
    }
}

.anim-compete {
    animation: sprintCompete 2s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
}

@keyframes sprintCompete {
    0% {
        left: -10%;
        text-shadow: 0 0 10px white;
    }

    50% {
        left: 45%;
        text-shadow: 0 0 20px var(--neon-yellow);
        transform: scale(1.2);
    }

    100% {
        left: 110%;
        text-shadow: 0 0 5px white;
    }
}

/* Modal */
.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 400px;
    text-align: center;
    padding: 40px;
}

.modal-body {
    margin: 30px 0;
    font-size: 1.2rem;
    line-height: 1.6;
}

.race-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-right: 10px;
}

.race-options::-webkit-scrollbar {
    width: 6px;
}

.race-options::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.race-btn {
    padding: 15px;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
}

.race-btn:hover:not(:disabled) {
    background: rgba(255, 238, 0, 0.1);
}

.btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.cost-ok {
    color: var(--neon-green);
    font-weight: bold;
}

.cost-bad {
    color: var(--neon-red);
    font-weight: bold;
}

/* Sublevel Pop up */
.stat-pop {
    animation: popStat 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popStat {
    0% {
        transform: scale(1);
        color: white;
    }

    50% {
        transform: scale(1.5);
        color: var(--neon-yellow);
    }

    100% {
        transform: scale(1);
        color: var(--text-primary);
    }
}

/* Live Race View */
#live-race-view {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95vw;
    height: 95vh;
    max-width: 1400px;
    background-color: var(--bg-color);
    z-index: 50;
}

.race-lane {
    position: relative;
    height: 45px;
    width: 100%;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
}

.finish-line {
    position: absolute;
    right: 5%;
    top: 0;
    bottom: 0;
    width: 6px;
    background: repeating-linear-gradient(0deg, white, white 10px, black 10px, black 20px);
    z-index: 10;
}

.racer-dot {
    position: absolute;
    left: 0;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 10px white;
    transform: translateX(-50%);
    transition: left 0.1s linear;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    color: black;
    font-weight: bold;
}

/* Effort Visual Effects */
.effort-sprint {
    background: #ff0055 !important;
    box-shadow: 0 0 25px #ff0055, 0 0 10px #ff0055 inset !important;
    animation: fireTrail 0.2s infinite alternate;
}

@keyframes fireTrail {
    0% {
        transform: translateX(-50%) scale(1);
        filter: drop-shadow(-5px 0px 5px #ff7700);
    }

    100% {
        transform: translateX(-50%) scale(1.1);
        filter: drop-shadow(-15px 0px 10px #ff0055);
    }
}

.effort-push {
    background: #ffee00 !important;
    box-shadow: 0 0 15px #ffee00 !important;
}

.effort-relax {
    background: #00f3ff !important;
    box-shadow: 0 0 10px #00f3ff !important;
    opacity: 0.8;
}

.status-danger {
    animation: dangerBlink 0.5s infinite alternate !important;
}

@keyframes dangerBlink {
    0% {
        background: #ff0055;
        box-shadow: 0 0 20px #ff0055;
    }

    100% {
        background: transparent;
        box-shadow: 0 0 0px transparent;
    }
}

.racer-player {
    background: var(--neon-yellow);
    box-shadow: 0 0 15px var(--neon-yellow);
}

.racer-info {
    position: absolute;
    left: 15px;
    /* Stay fixed on the left side of the lane */
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    z-index: 1;
}

.racer-player-info {
    color: var(--neon-yellow);
}

/* Route Mode */
.route-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
    transition: left 0.1s linear, top 0.1s linear;
}

.route-dot-player {
    width: 12px;
    height: 12px;
    background: var(--neon-yellow);
    box-shadow: 0 0 8px var(--neon-yellow);
    z-index: 100;
}

.route-info {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--text-secondary);
    white-space: nowrap;
    pointer-events: none;
}

.route-info-player {
    color: var(--neon-yellow);
    font-weight: bold;
    font-size: 0.8rem;
    top: -18px;
}

/* Scopes / Categorías de Carreras */
.scope-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    display: inline-block;
    vertical-align: middle;
}