/* =========================================================
   CONFIGURACIÓN GENERAL
========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #08030c;
    --dark: #120510;
    --red: #ff2a2a;
    --orange: #ff6a00;
    --yellow: #ffc400;
    --pink: #ff008c;
    --purple: #8b00ff;
    --white: #ffffff;
    --gray: #b8adb9;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: white;
    font-family: "Rajdhani", sans-serif;
}

button {
    font-family: inherit;
}


/* =========================================================
   PANTALLAS
========================================================= */

.screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}


/* =========================================================
   PORTADA ACADÉMICA
========================================================= */

.academic-cover {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 80%,
        rgba(255, 48, 0, 0.25),
        transparent 35%),
        linear-gradient(
            135deg,
            #050207,
            #16030e,
            #08030d
        );
}

.cover-background {
    position: absolute;
    inset: 0;

    background-image:
        radial-gradient(
            circle at 20% 30%,
            rgba(255, 0, 102, 0.12),
            transparent 25%
        ),
        radial-gradient(
            circle at 80% 60%,
            rgba(255, 76, 0, 0.15),
            transparent 30%
        );

    animation: backgroundPulse 5s ease-in-out infinite;
}

.cover-content {
    position: relative;
    z-index: 5;

    width: min(850px, 92%);

    text-align: center;

    padding: 40px;

    border: 1px solid rgba(255, 83, 32, 0.25);

    border-radius: 30px;

    background:
        linear-gradient(
            145deg,
            rgba(255,255,255,0.06),
            rgba(255,255,255,0.015)
        );

    backdrop-filter: blur(18px);

    box-shadow:
        0 0 60px rgba(255, 30, 0, 0.08),
        inset 0 0 40px rgba(255,255,255,0.02);
}

.school-badge {
    width: 75px;
    height: 75px;

    margin: 0 auto 20px;

    display: flex;
    justify-content: center;
    align-items: center;

    border-radius: 50%;

    font-size: 38px;

    background:
        linear-gradient(
            145deg,
            rgba(255, 45, 0, 0.25),
            rgba(255, 0, 132, 0.15)
        );

    border: 1px solid rgba(255, 72, 30, 0.5);

    box-shadow:
        0 0 30px rgba(255, 55, 0, 0.25);

    animation: floating 3s ease-in-out infinite;
}

.cover-label {
    font-size: 14px;
    letter-spacing: 5px;
    color: #ff714d;
    font-weight: 700;
}

.cover-content h1 {
    margin: 12px 0;

    font-family: "Orbitron", sans-serif;

    font-size: clamp(42px, 8vw, 78px);

    line-height: 0.95;

    letter-spacing: 4px;

    text-shadow:
        0 0 15px rgba(255, 60, 0, 0.5),
        0 0 40px rgba(255, 0, 100, 0.2);
}

.cover-content h1 span {
    background:
        linear-gradient(
            90deg,
            #ff2d00,
            #ff7a00,
            #ff008c
        );

    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cover-line {
    width: 180px;
    height: 2px;

    margin: 20px auto 30px;

    background:
        linear-gradient(
            90deg,
            transparent,
            #ff4b18,
            #ff008c,
            transparent
        );
}

.student-info {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 14px;

    margin: 0 auto 30px;

    max-width: 650px;
}

.info-item {
    padding: 15px;

    border-radius: 12px;

    background: rgba(255,255,255,0.035);

    border: 1px solid rgba(255,255,255,0.07);

    transition: 0.3s;
}

.info-item:hover {
    transform: translateY(-3px);

    border-color: rgba(255,80,30,0.35);

    background: rgba(255,60,20,0.06);
}

.info-title {
    display: block;

    font-family: "Orbitron", sans-serif;

    font-size: 10px;

    letter-spacing: 2px;

    color: #ff643d;

    margin-bottom: 5px;
}

.info-item strong {
    font-size: 17px;
    color: #fff;
}


/* =========================================================
   BOTONES
========================================================= */

.main-button {
    position: relative;

    border: none;

    padding: 16px 42px;

    min-width: 210px;

    border-radius: 12px;

    cursor: pointer;

    color: white;

    font-family: "Orbitron", sans-serif;

    font-size: 15px;

    font-weight: 700;

    letter-spacing: 2px;

    background:
        linear-gradient(
            90deg,
            #ff2700,
            #ff6500,
            #ff008c
        );

    box-shadow:
        0 0 20px rgba(255, 47, 0, 0.35);

    transition: 0.3s;
}

.main-button span {
    margin-right: 15px;
}

.main-button:hover {
    transform: translateY(-4px) scale(1.02);

    box-shadow:
        0 0 30px rgba(255, 57, 0, 0.65);
}

.main-button:active {
    transform: scale(0.97);
}

.secondary-button {
    margin-top: 12px;

    padding: 12px 25px;

    background: transparent;

    color: #aaa;

    border: 1px solid rgba(255,255,255,0.15);

    border-radius: 10px;

    cursor: pointer;

    transition: 0.3s;
}

.secondary-button:hover {
    color: white;

    border-color: rgba(255,80,40,0.5);
}


/* =========================================================
   MENÚ DEL JUEGO
========================================================= */

#gameMenu {
    overflow-y: auto;

    background:
        radial-gradient(
            circle at 50% 20%,
            rgba(255, 60, 0, 0.12),
            transparent 35%
        ),
        #08030c;
}

.menu-content {
    position: relative;

    z-index: 2;

    width: min(900px, 94%);

    margin: auto;

    padding: 45px 20px;

    text-align: center;
}

.game-subtitle {
    color: #ff673d;

    font-family: "Orbitron", sans-serif;

    font-size: 12px;

    letter-spacing: 5px;
}

.menu-content h2 {
    margin: 10px 0;

    font-family: "Orbitron", sans-serif;

    font-size: clamp(38px, 7vw, 65px);

    letter-spacing: 3px;
}

.menu-content h2 span {
    color: #ff4b19;

    text-shadow:
        0 0 20px rgba(255,70,0,0.5);
}

.menu-description {
    color: #aaa;

    margin-bottom: 30px;

    font-size: 17px;
}


/* =========================================================
   SELECCIONES
========================================================= */

.selection-section {
    margin: 25px 0;
}

.selection-section h3 {
    font-family: "Orbitron", sans-serif;

    font-size: 13px;

    letter-spacing: 2px;

    color: #ddd;

    margin-bottom: 15px;
}

.avatar-grid {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 14px;
}

.avatar-card,
.difficulty-card {
    border: 1px solid rgba(255,255,255,0.1);

    background:
        rgba(255,255,255,0.035);

    color: white;

    border-radius: 16px;

    cursor: pointer;

    transition: 0.3s;
}

.avatar-card {
    padding: 18px 10px;
}

.avatar-card:hover,
.difficulty-card:hover {
    transform: translateY(-5px);

    border-color: rgba(255,78,35,0.6);

    background: rgba(255,60,20,0.08);
}

.avatar-card.selected,
.difficulty-card.selected {
    border-color: #ff4b20;

    background:
        linear-gradient(
            145deg,
            rgba(255,60,0,0.14),
            rgba(255,0,120,0.08)
        );

    box-shadow:
        0 0 25px rgba(255,50,0,0.15);
}

.avatar-icon {
    font-size: 55px;

    margin-bottom: 8px;

    filter:
        drop-shadow(
            0 0 10px rgba(255,80,0,0.3)
        );
}

.avatar-card span {
    display: block;

    font-family: "Orbitron", sans-serif;

    font-size: 12px;

    font-weight: 700;
}

.avatar-card small {
    color: #999;

    font-size: 13px;
}

.difficulty-grid {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 14px;
}

.difficulty-card {
    padding: 18px;
}

.difficulty-icon {
    display: block;

    font-size: 30px;

    margin-bottom: 7px;
}

.difficulty-card strong {
    display: block;

    font-family: "Orbitron", sans-serif;

    font-size: 12px;

    margin-bottom: 6px;
}

.difficulty-card small {
    color: #999;

    line-height: 1.3;
}

.play-button {
    margin-top: 15px;
}


/* =========================================================
   CANVAS
========================================================= */

#gameScreen {
    background: #07030a;
}

#gameCanvas {
    position: absolute;

    inset: 0;

    width: 100%;

    height: 100%;

    display: block;
}


/* =========================================================
   HUD
========================================================= */

#hud {
    position: absolute;

    top: 20px;

    left: 50%;

    transform: translateX(-50%);

    display: flex;

    gap: 10px;

    z-index: 10;
}

.hud-box {
    min-width: 100px;

    display: flex;

    align-items: center;

    gap: 9px;

    padding: 9px 14px;

    border-radius: 10px;

    background:
        rgba(10, 5, 14, 0.75);

    border: 1px solid rgba(255,100,60,0.2);

    backdrop-filter: blur(8px);
}

.hud-box > span {
    font-size: 20px;
}

.hud-box small {
    display: block;

    color: #999;

    font-size: 9px;

    letter-spacing: 1px;
}

.hud-box strong {
    font-family: "Orbitron", sans-serif;

    font-size: 14px;
}


/* =========================================================
   NIVEL
========================================================= */

.level-message {
    position: absolute;

    top: 45%;

    left: 50%;

    transform: translate(-50%, -50%);

    z-index: 20;

    text-align: center;

    animation: levelAppear 1.5s ease forwards;

    pointer-events: none;
}

.level-message span {
    display: block;

    font-family: "Orbitron", sans-serif;

    color: #ff673d;

    letter-spacing: 5px;
}

.level-message strong {
    display: block;

    font-family: "Orbitron", sans-serif;

    font-size: 80px;

    color: white;

    text-shadow:
        0 0 30px #ff4500;
}


/* =========================================================
   GAME OVER
========================================================= */

.overlay {
    position: absolute;

    inset: 0;

    z-index: 50;

    display: flex;

    justify-content: center;

    align-items: center;

    background:
        rgba(4, 1, 7, 0.78);

    backdrop-filter: blur(8px);
}

.game-over-card {
    width: min(450px, 90%);

    padding: 35px;

    text-align: center;

    border-radius: 22px;

    background:
        linear-gradient(
            145deg,
            #160812,
            #09040c
        );

    border: 1px solid rgba(255,70,30,0.3);

    box-shadow:
        0 0 60px rgba(255,40,0,0.15);
}

.game-over-icon {
    font-size: 50px;

    margin-bottom: 10px;
}

.game-over-card p {
    color: #ff653c;

    font-family: "Orbitron", sans-serif;

    font-size: 11px;

    letter-spacing: 3px;
}

.game-over-card h2 {
    font-family: "Orbitron", sans-serif;

    font-size: 42px;

    margin: 8px 0 20px;

    color: #fff;
}

.final-stats {
    display: flex;

    justify-content: center;

    gap: 50px;

    margin-bottom: 25px;
}

.final-stats span {
    display: block;

    color: #888;

    font-size: 10px;

    letter-spacing: 2px;
}

.final-stats strong {
    font-family: "Orbitron", sans-serif;

    font-size: 25px;

    color: #ff602e;
}


/* =========================================================
   CONTROLES TÁCTILES
========================================================= */

#touchControls {
    position: absolute;

    bottom: 20px;

    left: 50%;

    transform: translateX(-50%);

    z-index: 20;

    display: none;

    gap: 15px;
}

#touchControls button {
    width: 65px;

    height: 65px;

    border-radius: 50%;

    border: 1px solid rgba(255,100,60,0.3);

    background: rgba(10,5,15,0.7);

    color: white;

    font-size: 25px;
}


/* =========================================================
   ANIMACIONES
========================================================= */

@keyframes floating {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes backgroundPulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

@keyframes levelAppear {

    0% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(0.5);
    }

    25% {
        opacity: 1;

        transform:
            translate(-50%, -50%)
            scale(1.1);
    }

    75% {
        opacity: 1;
    }

    100% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(1.3);
    }
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 700px) {

    .cover-content {
        padding: 25px 15px;
    }

    .student-info {
        grid-template-columns: 1fr;
    }

    .avatar-grid,
    .difficulty-grid {
        grid-template-columns: 1fr;
    }

    .avatar-card {
        display: flex;

        align-items: center;

        gap: 15px;

        text-align: left;
    }

    .avatar-icon {
        margin: 0;
        font-size: 40px;
    }

    #hud {
        width: 95%;

        justify-content: center;

        flex-wrap: wrap;

        top: 10px;
    }

    .hud-box {
        min-width: 75px;

        padding: 7px 9px;
    }

    #touchControls {
        display: flex;
    }

}

@media (hover: none) {

    #touchControls {
        display: flex;
    }

}