/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

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

/* Interfaz Gráfica (HUD) */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Deja pasar clicks al canvas */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    padding: 20px;
}

#messages-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(460px, calc(100vw - 380px));
    max-width: 460px;
    z-index: 20;
}

.penalty-total-row {
    border-top: 1px solid rgba(248, 113, 113, 0.4);
    color: #fecaca;
}

#score-container {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid #333;
}

.good { color: #4ade80; }
.bad { color: #f87171; }

#messages-container {
    background: rgba(0, 0, 0, 0.7);
    color: #fbbf24;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1.2rem;
    max-width: 40%;
    text-align: center;
    border: 2px solid #fbbf24;
    transition: opacity 0.3s;
}

.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 20px;
}

.dashboard {
    position: relative;
    flex: 0 0 auto;
    background:
        radial-gradient(ellipse at 18% 0%, rgba(56, 189, 248, 0.2), transparent 55%),
        linear-gradient(145deg, rgba(34, 51, 72, 0.94), rgba(8, 18, 34, 0.97));
    border: 1px solid rgba(82, 205, 255, 0.62);
    border-radius: 16px;
    padding: 14px;
    color: white;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    grid-template-areas:
        "analog gear"
        "indicators indicators";
    align-items: center;
    gap: 8px 10px;
    width: min(300px, calc(100vw - 40px));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 0 18px rgba(56, 189, 248, 0.13);
    backdrop-filter: blur(8px);
}

.dashboard::before {
    content: "VELOX  •  DRIVE";
    position: absolute;
    top: -9px;
    left: 16px;
    padding: 3px 8px;
    border: 1px solid rgba(91, 210, 255, 0.55);
    border-radius: 999px;
    background: #10233a;
    color: #b6ecff;
    font: 700 8px/1.2 "Segoe UI", sans-serif;
    letter-spacing: 0.12em;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.22);
}

.analog-dashboard {
    grid-area: analog;
    display: flex;
    gap: 10px;
    align-items: center;
}

.speedometer-analog {
    width: 116px;
    height: 116px;
    flex: 0 0 auto;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 7px rgba(56, 189, 248, 0.2));
}

.steering-wheel-ui {
    width: 88px;
    height: 88px;
    flex: 0 0 auto;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.16));
}

.speedometer-analog svg, .steering-wheel-ui svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

#speed-needle {
    transition: transform 0.1s ease-out;
}

#visual-wheel {
    transition: transform 0.1s ease-out;
}

.gear-indicator {
    grid-area: gear;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(250, 204, 21, 0.55);
    border-radius: 10px;
    font-size: 1.25rem;
    font-weight: bold;
    color: #facc15;
    background: rgba(0,0,0,0.5);
}

.indicators {
    grid-area: indicators;
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 0;
}

.indicator {
    opacity: 0.2;
    font-size: 1.5rem;
    transition: opacity 0.2s;
}

.indicator.active {
    opacity: 1;
    text-shadow: 0 0 10px #facc15;
}

#minimap-container {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(198, 225, 233, 0.68);
    background: linear-gradient(145deg, #6b777d, #172329 58%, #52636a);
    box-shadow: 0 8px 20px rgba(0,0,0,0.68), inset 0 0 0 3px rgba(8, 17, 22, 0.8), inset 0 0 16px rgba(155, 210, 225, 0.18);
}

#minimap-canvas {
    width: 100%;
    height: 100%;
    filter: saturate(0.9) contrast(1.08);
}

.environment-button,
.control-overlay-button {
    position: fixed;
    right: 12px;
    z-index: 21;
    padding: 8px 12px;
    border: 1px solid rgba(191, 219, 254, 0.65);
    border-radius: 9px;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.88);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.38);
    font: 600 12px/1.2 "Segoe UI", sans-serif;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.environment-button {
    top: 58px;
}

.control-overlay-button {
    top: 100px;
}

.radio-overlay-button {
    top: 142px;
}

.environment-button:hover,
.control-overlay-button:hover,
.control-overlay-button.active {
    border-color: #7dd3fc;
    background: rgba(8, 47, 73, 0.94);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.28);
}

@media (max-width: 520px) {
    #tiempo-restante-container {
        top: 82px;
        left: 8px;
        padding: 7px 9px;
        font-size: 0.85rem;
    }

    #messages-container {
        top: 138px;
        width: calc(100vw - 24px);
        max-width: none;
        font-size: 0.9rem;
        padding: 7px 10px;
    }

    .environment-button,
    .control-overlay-button {
        right: 8px;
        padding: 7px 9px;
        font-size: 11px;
    }

    .environment-button {
        top: 54px;
    }

    .control-overlay-button {
        top: 128px;
    }

    .radio-overlay-button {
        top: 166px;
    }
}

/* Controles Móviles */
#mobile-controls {
    display: none; /* Oculto en PC por defecto */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 180px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    padding: 0 40px 20px 40px;
    pointer-events: none; /* Deja pasar a través del fondo */
    justify-content: space-between;
    align-items: flex-end;
    z-index: 50;
}

#mobile-controls button {
    pointer-events: auto; /* Solo los botones reciben eventos */
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: bold;
    border-radius: 50%;
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#mobile-controls button:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

.mobile-group-left, .mobile-group-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    pointer-events: auto; /* Asegurar que los contenedores permitan eventos */
}

.mobile-signals {
    display: flex;
    gap: 10px;
}

.btn-small {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
}

.btn-gear {
    background: rgba(0,0,0,0.6);
    border: 2px solid #facc15;
    color: #facc15;
    border-radius: 12px;
    padding: 8px 15px;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    width: auto;
    height: auto;
    transition: all 0.2s;
}

.btn-gear.reverse {
    background: #ef4444;
    border-color: #fff;
    color: #fff;
}

.pedal-pair {
    display: flex;
    align-items: flex-end;
    gap: 20px;
}

.pedal-brake {
    width: 100px;
    height: 60px;
    background: linear-gradient(to bottom, #444, #222);
    border: 3px solid #666;
    border-radius: 8px;
    box-shadow: 0 4px 0 #000, inset 0 0 10px rgba(239, 68, 68, 0.2);
}

.pedal-brake:active {
    transform: translateY(4px);
    box-shadow: none;
    border-color: #ef4444;
}

.pedal-accel {
    width: 60px;
    height: 120px;
    background: linear-gradient(to bottom, #444, #222);
    border: 3px solid #666;
    border-radius: 8px;
    box-shadow: 0 4px 0 #000, inset 0 0 10px rgba(34, 197, 94, 0.2);
}

.pedal-accel:active {
    transform: translateY(4px);
    box-shadow: none;
    border-color: #22c55e;
}

.steer-controls button {
    width: 80px;
    height: 80px;
    font-size: 2rem;
}

/* Media Query para activar controles en móviles */
@media (max-width: 768px) {
    #mobile-controls {
        display: flex;
    }
    
    .bottom-bar {
        justify-content: flex-end; /* Solo el minimapa abajo */
        padding-bottom: 120px;
    }

    .dashboard {
        position: absolute;
        top: 80px; /* Debajo de la top-bar */
        left: 50%;
        transform: translateX(-50%);
        background: none;
        border: none;
        box-shadow: none;
        padding: 0;
        min-width: auto;
        width: auto;
        max-width: calc(100vw - 24px);
        grid-template-columns: 1fr;
        grid-template-areas:
            "analog"
            "indicators"
            "gear";
        gap: 5px;
    }

    .analog-dashboard {
        flex-direction: column;
        gap: 5px;
    }

    .steering-wheel-ui {
        display: none; /* En móvil no necesitamos el volante visual arriba */
    }

    .speedometer-analog {
        width: 120px;
        height: 120px;
    }

    .gear-indicator {
        background: rgba(0,0,0,0.7);
        border-color: #facc15;
    }

    #messages-container {
        font-size: 0.9rem;
        max-width: 80%;
    }
}

/* --- OVERLAYS (Inicio y Game Over) --- */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: auto; /* Bloquea el resto de clics */
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: #1e293b;
    border: 2px solid #475569;
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    color: white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.modal h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #38bdf8;
}

.modal h1.text-red {
    color: #ef4444;
}

.instructions {
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.instructions h3 {
    color: #facc15;
    margin-bottom: 10px;
    margin-top: 15px;
}

.instructions h3:first-child {
    margin-top: 0;
}

.instructions ul {
    list-style-position: inside;
    margin-bottom: 15px;
    line-height: 1.6;
}

.instructions p {
    line-height: 1.6;
    margin-bottom: 5px;
}

.final-score {
    font-size: 1.5rem;
    margin: 20px 0;
    color: #cbd5e1;
}

#final-score-value {
    font-weight: bold;
    color: #4ade80;
}

.btn-primary {
    background: #3b82f6;
    border: none;
    color: white;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    height: auto;
    backdrop-filter: none;
}

.btn-primary:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.btn-primary:active {
    background: #1d4ed8;
    transform: scale(0.95);
}

/* ── Pantalla de Resumen ──────────────────────────────────────────── */
.summary-modal {
    max-width: 860px;
    width: 95%;
    max-height: 92vh;
    overflow-y: auto;
    text-align: left;
    padding: 30px 36px;
}

.summary-modal h1 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 6px;
}

.reason-text {
    text-align: center;
    color: #f87171;
    font-size: 1.1rem;
    margin-bottom: 18px;
}

.summary-header {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 22px;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 16px;
}

 [data-session-type="practical-driving"] .summary-quiz-metrics {
    display: none;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 110px;
}

.stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: bold;
    color: #e2e8f0;
}

.score-value   { color: #38bdf8; }
.rating-value  { font-size: 1.3rem; }

.summary-tables {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 24px;
}

.summary-section h3 {
    font-size: 1rem;
    color: #cbd5e1;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #334155;
}

.table-scroll {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #334155;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.summary-table thead {
    background: #0f172a;
}

.summary-table th {
    padding: 8px 12px;
    text-align: left;
    color: #94a3b8;
    font-weight: 600;
    white-space: nowrap;
}

.summary-table tbody tr:nth-child(odd)  { background: rgba(30,41,59,0.8); }
.summary-table tbody tr:nth-child(even) { background: rgba(15,23,42,0.8); }
.summary-table tbody tr:hover           { background: rgba(56,189,248,0.07); }

.summary-table td {
    padding: 7px 12px;
    vertical-align: top;
    color: #cbd5e1;
    line-height: 1.4;
}

.rule-id      { color: #94a3b8; font-family: monospace; white-space: nowrap; }
.penalty-cell { color: #f87171; white-space: nowrap; font-weight: 600; }
.reward-cell  { color: #4ade80; white-space: nowrap; font-weight: 600; }
.ordinance-cell {
    color: #7dd3fc;
    font-size: 0.78rem;
    max-width: 280px;
}

.summary-modal .btn-primary {
    display: block;
    margin: 0 auto;
    width: 100%;
    max-width: 320px;
}

/* --- OPCIONES Y BOTONES EXTRA --- */
.start-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
}

#start-screen .modal {
    position: relative;
    padding-top: 58px;
}

#start-screen #btn-language {
    position: absolute;
    top: 14px;
    right: 14px;
    left: auto;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 76px;
    padding: 6px 11px;
    border: 1px solid rgba(212, 175, 55, 0.55);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    color: #ffe9a3;
    font: 700 0.78rem 'Rajdhani', sans-serif;
    letter-spacing: 0.04em;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

#start-screen #btn-language:hover {
    border-color: #f2cd69;
    background: rgba(212, 175, 55, 0.18);
}

#start-screen #btn-language:focus-visible {
    outline: 2px solid #f2cd69;
    outline-offset: 2px;
}

.btn-secondary {
    background: rgba(71, 85, 105, 0.8);
    border: 2px solid #475569;
    color: white;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(100, 116, 139, 0.9);
    border-color: #64748b;
}

/* Modal de Opciones */
#options-modal {
    z-index: 1100;
}

.options-modal-content {
    max-width: 500px;
    text-align: left;
}

/* --- VELOX Glassmorphic welcome and authentication screen --- */
#start-screen {
    overflow-y: auto;
    padding: 18px;
    background: rgba(7, 10, 18, 0.58);
}

#start-screen::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: url('models/fondo.png') center/cover no-repeat;
}

#start-screen > .auth-panel {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    max-width: 520px;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    padding: 28px 34px 20px;
    border: 2px solid #D4AF37;
    border-radius: 16px;
    background: linear-gradient(180deg, #131B2E 0%, #0B111E 100%);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.35), 0 20px 40px rgba(0, 0, 0, 0.9);
    text-align: left;
    scrollbar-color: rgba(212, 175, 55, 0.45) transparent;
    scrollbar-width: thin;
}

#start-screen .auth-brand {
    text-align: center;
    padding: 0 0 18px;
}

#start-screen .auth-logo {
    display: block;
    width: 112px;
    height: 74px;
    object-fit: contain;
    margin: 0 auto 8px;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.75)) drop-shadow(0 0 22px rgba(65, 156, 255, 0.5));
}

#start-screen .auth-brand h1 {
    margin: 0;
    color: #f5f7fb;
    font-family: 'Orbitron', 'Arial Black', sans-serif;
    font-size: clamp(1.2rem, 4vw, 1.65rem);
    font-weight: 800;
    letter-spacing: 0.07em;
    line-height: 1.3;
}

#start-screen .auth-brand h1 span {
    background: linear-gradient(110deg, #fff0b9 8%, #d4af37 52%, #fff0b9 92%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

#start-screen .auth-subtitle {
    margin: 7px 0 0;
    color: #E2E8F0;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#start-screen .admin-access {
    position: absolute;
    top: 14px;
    left: 14px;
    right: auto;
    padding: 7px 10px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #e8dfc2;
    font: 600 0.76rem 'Rajdhani', sans-serif;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.2s, border-color 0.2s;
}

#start-screen .admin-access:hover {
    border-color: rgba(212, 175, 55, 0.75);
    background: rgba(212, 175, 55, 0.12);
}

#start-screen .auth-tabs,
#start-screen .payment-toggle {
    display: flex;
    gap: 5px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(4, 9, 18, 0.62);
}

#start-screen .auth-tabs {
    margin-bottom: 17px;
}

#start-screen .auth-tab,
#start-screen .payment-method {
    flex: 1;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #9ba6b9;
    font: 700 0.82rem 'Rajdhani', sans-serif;
    letter-spacing: 0.07em;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

#start-screen .auth-tab.active,
#start-screen .payment-method.active {
    border-color: rgba(255, 226, 139, .62);
    background: linear-gradient(110deg, rgba(255, 243, 197, .2), rgba(222, 177, 57, .3));
    color: #ffe9a3;
    box-shadow: inset 0 1px 0 rgba(255, 248, 218, .16), 0 2px 10px rgba(212, 175, 55, .1);
}

#start-screen .auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#start-screen .auth-form label {
    color: #E2E8F0;
    font: 600 0.85rem 'Rajdhani', sans-serif;
    letter-spacing: 0.035em;
}

#start-screen .auth-form input:not([type="checkbox"]) {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid rgba(155, 171, 197, 0.22);
    border-radius: 7px;
    outline: none;
    background: rgba(4, 10, 20, 0.72);
    color: #E2E8F0;
    font: 500 0.9rem 'Rajdhani', sans-serif;
    user-select: text;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#start-screen .password-input-wrap {
    position: relative;
}

#start-screen .password-input-wrap input {
    padding-right: 44px;
}

#start-screen .password-visibility-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    transform: translateY(-50%);
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #E2E8F0;
    font-size: 15px;
    cursor: pointer;
}

#start-screen .password-visibility-toggle:focus-visible {
    outline: 2px solid rgba(212, 175, 55, 0.8);
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

#start-screen .auth-form input::placeholder {
    color: #aeb9ca;
}

#start-screen .auth-form input:focus {
    border-color: rgba(242, 205, 105, .9);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, .14);
}

#start-screen .remember-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 3px 0 5px;
    color: #aeb8c9 !important;
}

#start-screen .remember-option input {
    accent-color: #d4af37;
}

#start-screen .prototype-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

#start-screen .prototype-btn {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.82rem;
    line-height: 1.2;
    border-radius: 8px;
}

#start-screen .auth-form-actions {
    display: flex;
    gap: 10px;
}

#start-screen .auth-submit {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 239, 177, .9);
    border-radius: 8px;
    background: linear-gradient(110deg, #fff5cb 0%, #f1d477 30%, #d4af37 65%, #b48827 100%);
    color: #17140b;
    font: 800 0.88rem 'Orbitron', sans-serif;
    letter-spacing: 0.035em;
    cursor: pointer;
    box-shadow: 0 7px 20px rgba(212, 175, 55, .3), inset 0 1px 0 rgba(255, 255, 255, .52);
    transition: filter 0.2s, transform 0.2s;
}

#start-screen .auth-submit:hover {
    filter: brightness(1.08) saturate(1.08);
    transform: translateY(-1px);
    box-shadow: 0 9px 24px rgba(212, 175, 55, .4), inset 0 1px 0 rgba(255, 255, 255, .62);
}

#start-screen .auth-options {
    flex: 0 0 auto;
    padding: 9px 13px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.07);
    font: 700 0.8rem 'Rajdhani', sans-serif;
}

#start-screen .auth-demo-account,
#start-screen .admin-demo-hint {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 13px 0 0;
    padding: 11px 13px;
    border: 1px solid rgba(212, 175, 55, .24);
    border-radius: 9px;
    background: rgba(255, 255, 255, .055);
    color: #d5deeb;
    font: 500 .8rem 'Rajdhani', sans-serif;
    text-align: left;
}

#start-screen .auth-demo-account strong,
#start-screen .admin-demo-hint strong {
    margin-bottom: 2px;
    color: #ffe9a3;
    font-size: .86rem;
}

#start-screen .auth-demo-account code,
#start-screen .admin-demo-hint code {
    color: #fff3c7;
    font: 600 .8rem Consolas, monospace;
    overflow-wrap: anywhere;
}

#start-screen .registration-form {
    gap: 11px;
}

#start-screen .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
}

#start-screen .form-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
}

#start-screen .form-field select {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid rgba(155, 171, 197, 0.22);
    border-radius: 7px;
    outline: none;
    background: rgba(4, 10, 20, 0.72);
    color: #E2E8F0;
    font: 500 0.9rem 'Rajdhani', sans-serif;
}

#start-screen .form-field select:focus {
    border-color: rgba(242, 205, 105, .9);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, .1);
}

#start-screen .document-input-wrap {
    display: flex;
    gap: 6px;
}

#start-screen .document-input-wrap input {
    min-width: 0;
}

#start-screen .document-check-digit {
    flex: 0 0 auto;
    padding: 0 9px;
    border: 1px solid rgba(212, 175, 55, .42);
    border-radius: 7px;
    background: rgba(212, 175, 55, .1);
    color: #f0dfab;
    font: 600 .76rem 'Rajdhani', sans-serif;
    cursor: pointer;
    transition: background .2s, border-color .2s;
}

#start-screen .document-check-digit:hover {
    border-color: rgba(242, 205, 105, .8);
    background: rgba(212, 175, 55, .18);
}

#start-screen .document-input-help {
    color: #aeb9ca;
    font: 500 .74rem 'Rajdhani', sans-serif;
}

#start-screen .full-width {
    grid-column: 1 / -1;
}

#start-screen .payment-fieldset {
    min-width: 0;
    padding: 10px 12px 12px;
    border: 1px solid rgba(212, 175, 55, 0.27);
    border-radius: 9px;
}

#start-screen .payment-fieldset legend {
    padding: 0 6px;
    color: #e9d99d;
    font: 600 0.86rem 'Rajdhani', sans-serif;
}

#start-screen .payment-toggle {
    margin-bottom: 10px;
}

#start-screen .payment-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#start-screen .payment-grid {
    margin-top: 3px;
}

#start-screen .token-input {
    font-family: Consolas, monospace !important;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

#start-screen .admin-view h2 {
    margin: 4px 0 5px;
    color: #fff0b9;
    font: 700 1.14rem 'Orbitron', sans-serif;
    text-align: center;
}

#start-screen .admin-note {
    color: #E2E8F0;
    font: 500 0.84rem 'Rajdhani', sans-serif;
    text-align: center;
}

#start-screen .admin-note {
    margin: 0 0 17px;
}

#start-screen .back-to-students {
    align-self: center;
    margin-top: 6px;
    border: 0;
    background: none;
    color: #e8d58e;
    font: 600 0.9rem 'Rajdhani', sans-serif;
    cursor: pointer;
}

#start-screen .inspector-test-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 14px 0 8px;
    padding: 14px;
    border: 1px solid rgba(212, 175, 55, 0.24);
    border-radius: 10px;
    background: rgba(4, 10, 20, 0.48);
}

#start-screen .inspector-test-section h3 {
    color: #fff0b9;
    font: 700 0.9rem 'Rajdhani', sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#start-screen .inspector-test-section label {
    color: #E2E8F0;
    font: 600 0.85rem 'Rajdhani', sans-serif;
}

#start-screen .inspector-test-section input {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid rgba(155, 171, 197, 0.22);
    border-radius: 7px;
    outline: none;
    background: rgba(4, 10, 20, 0.72);
    color: #E2E8F0;
    font: 500 0.9rem 'Rajdhani', sans-serif;
    user-select: text;
}

#start-screen .inspector-test-section input:focus {
    border-color: rgba(212, 175, 55, 0.8);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

#start-screen .auth-message {
    min-height: 18px;
    margin: 10px 0 0;
    color: #b8d7c3;
    font: 600 0.82rem 'Rajdhani', sans-serif;
    text-align: center;
}

#start-screen .auth-message.error {
    color: #ff9a9a;
}

#start-screen .auth-legal {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    color: #E2E8F0;
    font: 500 0.74rem 'Rajdhani', sans-serif;
    letter-spacing: 0.025em;
    text-align: center;
}

#start-screen [hidden] {
    display: none !important;
}

@media (max-width: 520px) {
    #start-screen {
        padding: 10px;
        align-items: flex-start;
    }

    #start-screen > .auth-panel {
        max-height: calc(100vh - 20px);
        margin: auto 0;
        padding: 24px 18px 16px;
    }

    #start-screen .auth-logo {
        width: 90px;
        height: 60px;
    }

    #start-screen .auth-brand {
        padding-top: 10px;
        padding-bottom: 14px;
    }

    #start-screen .form-grid {
        grid-template-columns: 1fr;
    }

    #start-screen .full-width {
        grid-column: auto;
    }

    #start-screen .prototype-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

#start-screen .prototype-btn {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.82rem;
    line-height: 1.2;
    border-radius: 8px;
}

#start-screen .auth-form-actions {
        flex-direction: column;
    }

    #start-screen .auth-options {
        min-height: 40px;
    }

    #start-screen .auth-legal {
        font-size: 0.68rem;
    }
}

.role-dashboard {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    overflow: hidden;
    background:
        radial-gradient(ellipse at 88% 7%, rgba(76, 151, 235, .12), transparent 36%),
        linear-gradient(135deg, #f1f7ff 0%, #f5f7fb 52%, #f2f5fa 100%);
    color: #263445;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.role-dashboard.hidden {
    display: none;
}

.dashboard-sidebar {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 22px 14px;
    border-right: 1px solid #b9d6e8;
    background: linear-gradient(180deg, #d9edfb 0%, #c5e1f2 100%);
    box-shadow: 5px 0 22px rgba(32, 54, 83, .025);
}

.dashboard-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 4px;
    color: #263f54;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: .025em;
    text-decoration: none;
}

.dashboard-logo-image {
    display: block;
    width: 46px;
    height: 36px;
    padding: 3px;
    border: 1px solid #e7ebf2;
    border-radius: 9px;
    background: #fff;
    object-fit: contain;
}

.dashboard-logo-wordmark {
    line-height: 1;
}

.sidebar-section-label {
    margin: 14px 0 -12px;
    padding: 0 8px;
    color: #607b91;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
}

.dashboard-nav {
    display: grid;
    gap: 7px;
}

.dashboard-nav[hidden],
.dashboard-page[hidden] {
    display: none !important;
}

.dashboard-nav-item,
.dashboard-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #405c72;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.dashboard-nav-item:hover,
.dashboard-logout:hover {
    background: #e4f2fb;
    color: #214e6e;
}

.dashboard-nav-item.active {
    background: #a9cfe9;
    color: #164d73;
    font-weight: 700;
    box-shadow: inset 3px 0 #347faf;
}

.dashboard-logout {
    width: auto;
    margin-top: auto;
    color: #315d7a;
    font-weight: 600;
}

.dashboard-logout:hover {
    background: #e4f2fb;
    color: #214e6e;
}

.dashboard-main {
    min-width: 0;
    overflow-y: auto;
}

.dashboard-topbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 58px;
    padding: 14px 30px;
    border-bottom: 1px solid #dfeaf8;
    background: rgba(255,255,255,.96);
    box-shadow: 0 3px 12px rgba(32, 54, 83, .025);
    color: #526174;
    font-size: 13px;
}

.dashboard-topbar small {
    margin-left: 9px;
    color: #99a2af;
}

.dashboard-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px clamp(20px, 3.2vw, 52px) 42px;
}

.inspector-hero,
.student-hero {
    margin: 0 0 22px;
    padding: 21px 24px 18px;
    border: 1px solid #d9e9fb;
    border-left: 4px solid #78aeea;
    border-radius: 15px;
    background: linear-gradient(112deg, #eaf4ff 0%, #f2f8ff 54%, rgba(255, 255, 255, .92) 100%);
    box-shadow: 0 8px 24px rgba(58, 112, 174, .055);
}

.inspector-hero .dashboard-eyebrow,
.student-hero .dashboard-eyebrow {
    margin-top: 0;
}

.inspector-hero .dashboard-subtitle,
.student-hero .dashboard-subtitle {
    margin-bottom: 0;
}

.dashboard-eyebrow {
    margin-bottom: 8px;
    color: #2864d7;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .08em;
}

.dashboard-page h1 {
    margin: 0;
    color: #253347;
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 650;
    letter-spacing: -.025em;
}

.dashboard-subtitle {
    margin: 8px 0 24px;
    color: #7d8998;
    font-size: 14px;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 20px 0 22px;
}

#inspector-home .dashboard-stats {
    margin: 0 0 18px;
}

.dashboard-stat {
    display: grid;
    gap: 8px;
    padding: 20px;
    border: 1px solid #dce8f6;
    border-top: 3px solid #a9ccef;
    border-radius: 14px;
    background: linear-gradient(160deg, #fff 45%, #f6faff 100%);
    box-shadow: 0 7px 20px rgba(49, 91, 139, .055);
    transition: transform .18s ease, box-shadow .18s ease;
}

.dashboard-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 9px 24px rgba(32, 54, 83, .08);
}

.dashboard-stat span,
.dashboard-stat small {
    color: #8490a0;
    font-size: 12px;
}

.dashboard-stat strong {
    color: #23466f;
    font-size: 26px;
    font-weight: 600;
}

.dashboard-actions,
.dashboard-heading-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 22px 0;
}

.dashboard-primary-action,
.dashboard-secondary-action {
    min-height: 40px;
    padding: 10px 16px;
    border: 1px solid #2864d7;
    border-radius: 8px;
    background: #2864d7;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.inspector-reports {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 22px 0;
    padding: 17px 20px;
    border: 1px solid #d7e7f8;
    border-radius: 13px;
    background: linear-gradient(105deg, #eaf4ff 0%, #f4f9ff 66%, #fff 100%);
}

.student-reports {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 22px 0;
    padding: 17px 20px;
    border: 1px solid #d7e7f8;
    border-radius: 13px;
    background: linear-gradient(105deg, #eaf4ff 0%, #f4f9ff 66%, #fff 100%);
}

.student-reports h2 {
    margin: 0 0 5px;
    color: #2e5278;
    font-size: 15px;
}

.student-reports p {
    margin: 0;
    color: #71859d;
    font-size: 12px;
}

.student-reports .report-actions {
    flex-shrink: 0;
    margin: 0;
}

.inspector-reports h2 {
    margin: 0 0 5px;
    color: #2e5278;
    font-size: 15px;
}

.inspector-reports p {
    margin: 0;
    color: #71859d;
    font-size: 12px;
}

.inspector-reports .report-actions {
    flex-shrink: 0;
    margin: 0;
}

.student-reports .dashboard-secondary-action {
    border-color: #bcd4f0;
    background: #fff;
    color: #315e8d;
}

.student-reports .dashboard-secondary-action:hover {
    border-color: #8eb6e5;
    background: #f7fbff;
    color: #245b9a;
}

.inspector-reports .dashboard-secondary-action,
.dashboard-page .report-actions .dashboard-secondary-action {
    border-color: #bcd4f0;
    background: #fff;
    color: #315e8d;
}

.inspector-reports .dashboard-secondary-action:hover,
.dashboard-page .report-actions .dashboard-secondary-action:hover {
    border-color: #8eb6e5;
    background: #f7fbff;
    color: #245b9a;
}

.dashboard-primary-action:hover {
    transform: translateY(-1px);
    border-color: #1f55c2;
    background: #1f55c2;
    box-shadow: 0 5px 14px rgba(40, 100, 215, .2);
}

.dashboard-secondary-action {
    border-color: #dce3ed;
    background: #fff;
    color: #3e526d;
}

.dashboard-secondary-action:hover {
    border-color: #b9c9e2;
    background: #f8faff;
    color: #285db8;
}

.dashboard-nav-item:focus-visible,
.dashboard-logout:focus-visible,
.dashboard-primary-action:focus-visible,
.dashboard-secondary-action:focus-visible,
.dashboard-logo:focus-visible {
    outline: 3px solid rgba(40, 100, 215, .35);
    outline-offset: 2px;
}

.dashboard-page h2 {
    margin: 24px 0 12px;
    color: #334258;
    font-size: 17px;
    font-weight: 650;
}

.dashboard-heading-row {
    justify-content: space-between;
}

.dashboard-heading-row h2 {
    margin: 0;
}

.dashboard-table-wrap {
    overflow-x: auto;
    border: 1px solid #e4e8ef;
    border-radius: 10px;
    background: #fff;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    color: #536174;
    font-size: 12px;
}

.dashboard-table th,
.dashboard-table td {
    padding: 13px 15px;
    border-bottom: 1px solid #edf0f4;
    text-align: left;
    white-space: nowrap;
}

.dashboard-table th {
    background: #fafbfd;
    color: #8994a2;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.dashboard-table tr:last-child td {
    border-bottom: 0;
}

.result-passed {
    color: #23885c !important;
    font-weight: 700;
}

.result-failed {
    color: #bc5959 !important;
    font-weight: 700;
}

.dashboard-empty {
    padding: 18px;
    color: #8a95a5;
    font-size: 13px;
}

.dashboard-search-label {
    display: block;
    margin: 18px 0 6px;
    color: #677588;
    font-size: 12px;
}

.dashboard-search {
    width: min(420px, 100%);
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #dce3ed;
    border-radius: 8px;
    background: #fff;
    color: #263445;
    font-size: 13px;
}

.inspector-test-section {
    display: grid;
    max-width: 560px;
    gap: 9px;
    margin: 24px 0;
    padding: 22px;
    border: 1px solid #d7e6f6;
    border-radius: 14px;
    background: linear-gradient(145deg, #fff 0%, #f1f7ff 100%);
    box-shadow: 0 7px 22px rgba(49, 91, 139, .055);
}

.inspector-test-section h2 {
    margin: 0 0 2px;
}

.inspector-test-section label {
    color: #657387;
    font-size: 12px;
    font-weight: 600;
}

.optional-field {
    color: #98a3b2;
    font-weight: 400;
}

.inspector-test-section input,
.inspector-test-section select {
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid #dce3ed;
    border-radius: 8px;
    color: #263445;
    font-size: 13px;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.inspector-test-section input:focus,
.inspector-test-section select:focus,
.dashboard-search:focus {
    border-color: #6e9bea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(40, 100, 215, .12);
}

.inspector-test-section p {
    margin: 0;
    color: #8490a0;
    font-size: 11px;
}

.access-code-output {
    min-height: 24px;
    color: #285db8;
    font: 700 1rem monospace;
    overflow-wrap: anywhere;
}

.registration-note {
    color: #96a2b1;
    font: 500 .82rem 'Rajdhani', sans-serif;
}

@media (max-width: 760px) {
    .role-dashboard {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .dashboard-sidebar {
        align-items: center;
        padding: 14px 6px;
    }

    .dashboard-logo {
        font-size: 0;
    }

    .dashboard-logo-image {
        width: 42px;
        height: 34px;
        padding: 2px;
    }

    .sidebar-section-label,
    .dashboard-nav-item span,
    .dashboard-logout {
        font-size: 0;
    }

    .dashboard-nav-item {
        justify-content: center;
        padding: 12px 8px;
        font-size: 16px;
    }

    .dashboard-content {
        padding: 22px 14px;
    }

    .inspector-hero,
    .student-hero {
        padding: 18px 16px;
    }

    .inspector-reports,
    .student-reports {
        align-items: flex-start;
        flex-direction: column;
    }

    .inspector-reports .report-actions,
    .student-reports .report-actions {
        width: 100%;
    }

    .inspector-reports .dashboard-secondary-action,
    .student-reports .dashboard-secondary-action {
        flex: 1 1 160px;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .dashboard-stat {
        padding: 13px;
    }
}

/* Forzar visibilidad del botón VR de Three.js */
#VRButton {
    background: rgba(255, 0, 153, 0.2) !important;
    border: 2px solid #ff0099 !important;
    color: white !important;
    font-weight: bold !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    box-shadow: 0 0 15px rgba(255, 0, 153, 0.5) !important;
    transition: all 0.3s ease !important;
    z-index: 10 !important;
    bottom: 30px !important;
}

body.game-over-open #VRButton {
    display: none !important;
}

#VRButton:hover {
    background: rgba(255, 0, 153, 0.5) !important;
    transform: scale(1.1) !important;
}

.options-modal-content h2 {
    margin-bottom: 20px;
    color: #facc15;
    text-align: center;
}

.option-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-group label {
    font-weight: bold;
    color: #94a3b8;
    font-size: 0.9rem;
}

.option-group select, .option-group input[type="text"], .option-group input[type="number"] {
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    padding: 10px;
    border-radius: 4px;
    width: 100%;
}

.radio-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.or-text {
    text-align: center;
    font-size: 0.8rem;
    color: #64748b;
}

.config-inputs {
    display: flex;
    gap: 15px;
}

.input-item {
    flex: 1;
}

.input-item span {
    font-size: 0.8rem;
    color: #64748b;
    display: block;
    margin-bottom: 4px;
}

.modal-footer {
    margin-top: 30px;
}

/* --- RADIO OVERLAY (Estilo GTA Vice City) --- */
#radio-overlay {
    position: absolute;
    top: 15%;
    right: 5%;
    pointer-events: none;
    z-index: 500;
    transition: opacity 0.5s, transform 0.5s;
    opacity: 0;
    transform: translateX(50px);
}

#radio-overlay:not(.hidden) {
    opacity: 1;
    transform: translateX(0);
}

#radio-name {
    font-family: 'Arial Black', sans-serif; /* Aproximación a Pricedown si no está cargada */
    font-size: 3rem;
    font-weight: 900;
    color: #ff66cc; /* Rosa Vice City */
    text-transform: uppercase;
    font-style: italic;
    text-shadow: 
        3px 3px 0 #000,
        -1px -1px 0 #000,  
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
    letter-spacing: -2px;
}

 .summary-math-block {
            background: rgba(0,0,0,0.3);
            border-radius: 10px;
            padding: 12px 16px;
            margin: 12px 0;
            border: 1px solid rgba(255,255,255,0.1);
        }
        .summary-resultado-grande {
            text-align: center;
            margin-bottom: 8px;
        }
        .resultado-texto {
            font-size: 1.6rem;
            font-weight: bold;
            letter-spacing: 2px;
        }
        /* M06 — caja ID intento */
        .summary-intento-box {
            font-size: 0.75rem;
            color: #aaa;
            margin-top: 10px;
            padding: 6px 10px;
            background: rgba(0,0,0,0.2);
            border-radius: 6px;
            line-height: 1.8;
        }
        .intento-id-valor {
            font-family: monospace;
            color: #facc15;
            font-size: 0.75rem;
        }
        /* M04 — tiempo restante en HUD */
        #tiempo-restante-container {
            position: fixed;
            top: 88px;
            left: 20px;
            z-index: 22;
            display: flex;
            align-items: center;
            gap: 4px;
            font-size: 1rem;
            padding: 10px 14px;
            border: 1px solid rgba(250, 204, 21, 0.45);
            border-radius: 8px;
            background: rgba(0, 0, 0, 0.7);
            color: #facc15;
            font-weight: 600;
        }