/* =========================================
   CONFIGURACIÓ I VARIABLES
   ========================================= */
:root {
    --glow-blue: #00ccff;
    --imperial-red: #ff0055;
    --bg-black: #000810;
    --panel-bg: rgba(0, 15, 25, 0.9);
    --font-terminal: 'Courier New', Courier, monospace;
}

* { box-sizing: border-box; }

.ocult { display: none !important; }

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column; /* Posem la barra superior a dalt i el joc a sota */
    background-color: var(--bg-black);
    overflow: hidden; /* Prohibit l'scroll general de la pàgina */
}

/* =========================================
   PANTALLA DE LOGIN
   ========================================= */
/* =========================================
   CONTENIDOR PARE (CENTRAT TOTAL)
   ========================================= */
.full-screen-overlay {
    display: flex;
    justify-content: center; /* Centrat horitzontal */
    align-items: center;     /* Centrat vertical */
    height: 100vh;           /* Tota l'alçada de la finestra */
    width: 100vw;            /* Tota l'amplada de la finestra */
    background: radial-gradient(circle, #001a2a 0%, #000 100%);
    position: fixed;         /* Perquè res el mogui */
    top: 0;
    left: 0;
    z-index: 9999;
}

/* =========================================
   CAIXA DE LOGIN (AMPLADA CONTROLADA)
   ========================================= */
.login-box {
    width: 90%;              /* Ocupa el 90% en pantalles petites */
    max-width: 550px;        /* Però mai més de 550px (amplada ideal) */
    text-align: center;
    padding: 30px 40px;
    border: 1px solid var(--glow-blue);
    background: rgba(0, 8, 15, 0.95);
    box-shadow: 0 0 50px rgba(0, 204, 255, 0.2);
    border-radius: 10px;
    
    /* Efecte de vora extra estil "scanner" */
    outline: 1px solid rgba(0, 204, 255, 0.1);
    outline-offset: 10px;
}

/* El títol principal STAR WARS */
.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 4em;
    margin: 0;
    color: #fff;
    letter-spacing: 12px;
    text-shadow: 
        0 0 10px #fff,
        0 0 20px var(--glow-blue),
        0 0 40px var(--glow-blue);
    line-height: 1;
}

/* El subtítol CHALLENGE */
.sub-logo {
    font-family: 'Orbitron', sans-serif;
    font-weight: 400;
    font-size: 1.2em;
    color: var(--glow-blue);
    letter-spacing: 8px;
    margin-bottom: 40px;
    margin-top: 10px;
    opacity: 0.8;
}

/* El missatge de sistema bloquejat */
.blink {
    font-family: 'Space Mono', monospace;
    font-size: 0.9em;
    letter-spacing: 2px;
    color: var(--imperial-red);
    margin-bottom: 30px;
    text-transform: uppercase;
}

/* El botó de Google estil Imperial */
.btn-imperial {
    font-family: 'Orbitron', sans-serif;
    background: transparent;
    border: 1px solid var(--glow-blue);
    color: var(--glow-blue);
    padding: 18px 40px;
    font-size: 0.9em;
    font-weight: 900;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.btn-imperial:hover {
    background: var(--glow-blue);
    color: #000;
    box-shadow: 0 0 30px var(--glow-blue);
    transform: translateY(-2px);
}
.login-box::before, .login-box::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--glow-blue);
}

.login-box::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.login-box::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

/* =========================================
   NAV: SYSTEM MONITOR (BARRA SUPERIOR)
   ========================================= */
/* 2. Donar aire a la barra d'info superior */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    background: rgba(0, 20, 35, 0.95);
    border-bottom: 2px solid var(--glow-blue);
    height: 90px; /* Una mica més d'alçada perquè no estigui tot premsat */
    flex-shrink: 0; /* Que no s'enculli */
}

.stat-row { font-family: var(--font-terminal); font-size: 0.85em; margin-bottom: 4px; }
.label { color: #666; }
.val { color: var(--glow-blue); font-weight: bold; }
.val.online { color: #00ff88; text-shadow: 0 0 5px #00ff88; }

/* REACTOR CORE (VIDES) */
.reactor-core { text-align: center; width: 150px; }
.reactor-label { font-size: 0.6em; color: var(--glow-blue); letter-spacing: 2px; }
.heart-container { position: relative; display: inline-block; margin: 5px 0; }
.heart-svg { width: 40px; fill: var(--imperial-red); filter: drop-shadow(0 0 5px var(--imperial-red)); }
.vides {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -40%);
    font-weight: bold; font-size: 1.2em; color: #fff;
}
.vitality-bar { width: 100%; height: 4px; background: #222; margin-top: 5px; }
.vitality-bar .fill { height: 100%; background: var(--imperial-red); width: 100%; transition: 0.5s; }

.btn-eject {
    background: var(--imperial-red);
    border: none; color: #fff; font-size: 0.7em;
    padding: 2px 6px; cursor: pointer; margin-left: 10px;
}

/* =========================================
   LAYOUT PRINCIPAL
   ========================================= */
/* =========================================
   TITOL SUPERIOR (GAME-HEADER)
   ========================================= */
.game-header {
    padding: 15px 40px; /* Augmentem el padding lateral */
    text-align: center; /* Centrem el text de l'Holocró */
    flex-shrink: 0;
}

#title {
    font-family: 'Orbitron', sans-serif; /* Usant la font xula de login */
    font-weight: 900;
    font-size: 1.4em;
    letter-spacing: 5px;
    color: var(--glow-blue);
    text-shadow: 0 0 15px rgba(0, 204, 255, 0.6);
    margin: 0 auto;
    display: inline-block;
}

/* 4. El Layout de joc ha d'ocupar la resta de la pantalla */
#main-game-layout {
    display: flex;
    flex: 1; /* Ocupa tot l'espai vertical restant */
    padding: 0 20px 20px 20px;
    gap: 20px;
    overflow: hidden; /* El layout en si no fa scroll... */
}

#panel-left { flex: 2; display: flex; flex-direction: column; }
#main-game-layout .panel-right {
    flex: 0 0 350px; /* Li donem un ample fix de 350px */
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%; /* Ocupa tota l'alçada del main-game-layout */
    font-family: var(--font-terminal);
}

/* =========================================
   VISIBILITAT DEL PANELL DRET
   ========================================= */

/* Títols de les seccions (DATA RECURSOS i CONSOLA) */
.panel-right h3 {
    color: var(--glow-blue);
    font-family: var(--font-terminal);
    font-size: 1em;
    margin-top: 0;
    margin-bottom: 10px;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(0, 204, 255, 0.5);
}

/* Instruccions i textos petits */
.panel-right .small-text, 
.panel-right .instruction {
    color: #a0d8ff; /* Blauet clar molt llegible */
    font-size: 0.85em;
    line-height: 1.4;
    margin-bottom: 10px;
}

/* El text del botó d'esquema */
.esquema-icon-btn span {
    color: #fff; /* Text blanc pur per contrastar */
    font-family: var(--font-terminal);
    text-transform: uppercase;
}

/* Icona de l'esquema (assegurem que brilli) */
.icon-holo svg {
    filter: drop-shadow(0 0 5px var(--glow-blue));
    color: var(--glow-blue);
}

/* =========================================
   PROGRESS & MISSION
   ========================================= */
/* =========================================
   BARRA DE PROGRÈS (TEXT LLEGIBLE)
   ========================================= */
.progress-container {
    width: 100%;
    background: rgba(0, 20, 30, 0.8); /* Fons molt fosc per contrastar */
    height: 30px;
    border: 1px solid var(--glow-blue);
    position: relative;
    margin-bottom: 20px;
    box-shadow: 0 0 10px rgba(0, 204, 255, 0.1);
    border-radius: 2px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #004466, var(--glow-blue));
    width: 0%; /* Es controla per JS */
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 15px rgba(0, 204, 255, 0.4);
}

.progress-text {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* Millora de visibilitat */
    font-family: 'Space Mono', 'Courier New', monospace;
    font-size: 0.85em;
    font-weight: bold;
    color: #fff; /* Blanc pur per màxima visibilitat */
    text-transform: uppercase;
    letter-spacing: 2px;
    
    /* Ombra negra al voltant de les lletres (text-outline) */
    /* Això fa que es llegeixi bé tant sobre el blau com sobre el fons fosc */
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         0 0 8px var(--glow-blue); 
    
    pointer-events: none; /* Perquè no interfereixi amb el ratolí */
    z-index: 2;
}

#progress-percent {
    margin-left: 8px;
    color: #fff;
    text-decoration: underline;
}

/* 5. El quadre de missió SÍ que pot fer scroll si el text és llarg */
.mission-wrapper {
    background: var(--panel-bg);
    border: 1px solid rgba(0, 204, 255, 0.2);
    padding: 25px;
    flex: 1; 
    overflow-y: auto; /* NOMÉS aquí apareixerà la barra d'scroll si cal */
    display: flex;
    flex-direction: column;
}

/* Personalització de la barra d'scroll perquè sembli de Star Wars */
.mission-wrapper::-webkit-scrollbar {
    width: 6px;
}
.mission-wrapper::-webkit-scrollbar-thumb {
    background: var(--glow-blue);
    border-radius: 10px;
}
.mission-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.status-blink { color: var(--imperial-red); font-size: 0.7em; animation: blinker 1s infinite; }
.glow-line { border: 0; height: 1px; background: linear-gradient(90deg, var(--glow-blue), transparent); margin: 15px 0; }

/* =========================================
   CAPÇALERA DE LA MISSIÓ (PANEL ESQUERRE)
   ========================================= */

.mission-header {
    padding: 10px 20px; /* Afegim padding lateral per separar-ho de les vores */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Títol de la missió (H2) */
.mission-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8em;
    color: #fff;
    margin: 0;
    padding-left: 20px; /* El separem de l'esquerra */
    text-shadow: 0 0 10px var(--glow-blue);
    letter-spacing: 2px;
}

/* Text de la transmissió pampalluguejant */
.status-blink {
    font-family: 'Space Mono', monospace;
    font-size: 0.8em;
    font-weight: bold;
    color: var(--imperial-red);
    text-transform: uppercase;
    letter-spacing: 3px;
    padding-left: 20px; /* També el separem de l'esquerra */
    
    /* Animació de pampallugueig */
    animation: alert-blink 1s steps(2) infinite;
}

/* Definició de l'animació tipus 'alarma' */
@keyframes alert-blink {
    0% { opacity: 1; text-shadow: 0 0 10px var(--imperial-red); }
    100% { opacity: 0.2; text-shadow: none; }
}

/* =========================================
   ESTIL DE LLETRA "HOLOGRÀFICA"
   ========================================= */

#descripcio {
    line-height: 1.6;
    font-size: 1.05em;
    text-shadow: 0 0 5px rgba(0, 204, 255, 0.3); /* Brillantor suau */
    padding: 0 40px 20px 40px; /* Mateix marge de 40px que la capçalera */
    font-family: 'Space Mono', monospace;
    color: #c0eaff;
    line-height: 1.7;
}

/* Títols dins de les instruccions (Ex: TRANSMISSIÓ REBUDA) */
#descripcio h3 {
    font-family: 'Courier New', Courier, monospace;
    color: var(--glow-blue);
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(0, 204, 255, 0.2);
    display: inline-block;
    margin-bottom: 15px;
    text-shadow: 0 0 10px var(--glow-blue);
}

/* Ressaltat de paraules clau (Ex: el nom d'un planeta o color d'ulls) */
#descripcio b, #descripcio strong {
    color: var(--glow-blue);
    font-weight: bold;
    background: rgba(0, 204, 255, 0.1);
    padding: 0 4px;
    border-radius: 2px;
}

/* Efecte de sacsejada per a la missió */
.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Flaix vermell a tota la pantalla */
.error-glitch {
    background-color: rgba(255, 0, 85, 0.15) !important;
    transition: background-color 0.1s;
}

/* Millora del cursor a la descripció */
#descripcio::after {
    content: "|";
    color: var(--glow-blue);
    animation: blink 0.8s infinite;
}

@keyframes blink { 50% { opacity: 0; } }

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* =========================================
   CARDS DRETES I ESQUEMA
   ========================================= */
.card {
    background: rgba(0, 10, 20, 0.95); /* Quasi opac per llegir millor */
    border: 1px solid rgba(0, 204, 255, 0.3);
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.esquema-icon-btn {
    display: flex; align-items: center; gap: 15px;
    padding: 15px; border: 1px dashed var(--glow-blue);
    cursor: pointer; transition: 0.3s;
}
.esquema-icon-btn:hover { background: rgba(0, 204, 255, 0.1); }
.icon-holo svg { width: 30px; color: var(--glow-blue); }
.esquema-icon-btn span { font-size: 0.8em; text-transform: uppercase; font-weight: bold; }

/* CONSOLA D'ENTRADA */
.box-dades { flex: 0; } /* El quadre de l'esquema ocupa el que necessita */
.box-solucio { flex: 0; } /* El quadre de la resposta també */

/* =========================================
   CENTRAT DEL BOTÓ D'ACCIONAL
   ========================================= */

.box-solucio {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centra els elements fills horitzontalment */
    text-align: center;
}

.btn-action {
    display: block;
    margin: 20px auto 0 auto; /* El 'auto' als costats el centra manualment */
    width: 80%; /* No cal que ocupi el 100%, així queda més elegant */
    max-width: 250px; /* Evitem que es faci massa gran en pantalles amples */
    background: var(--glow-blue);
    color: #000;
    border: none;
    padding: 12px 24px;
    font-weight: 900;
    font-family: var(--font-terminal);
    cursor: pointer;
    text-transform: uppercase;
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0% 100%); /* Tall estil Star Wars */
    transition: all 0.3s ease;
}

.btn-action:hover {
    box-shadow: 0 0 20px var(--glow-blue);
    transform: scale(1.05);
    background: #fff;
}
/* L'input on escriuen la resposta */
#resultat {
    width: 100%;
    background: rgba(0, 30, 50, 0.5); /* Fons blau fosc semitransparent */
    border: 1px solid var(--glow-blue);
    padding: 12px;
    color: #fff; /* Lletra blanca quan escriuen */
    font-family: var(--font-terminal);
    font-size: 1.1em;
    outline: none;
    box-shadow: inset 0 0 10px rgba(0, 204, 255, 0.2);
    text-align: center; /* El text de la resposta sortirà des del mig */
}

/* Color del text de fons (placeholder) */
#resultat::placeholder {
    color: rgba(0, 204, 255, 0.5); /* Blauet tènue */
    font-style: italic;
}


/* =========================================
   MODAL ESQUEMA
   ========================================= */
.modal-esquema {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
}
.modal-contingut { max-width: 90%; max-height: 90%; border: 1px solid var(--glow-blue); }
.tancar-modal {
    position: absolute; top: 20px; right: 40px; font-size: 40px;
    color: var(--glow-blue); cursor: pointer;
}

/* =========================================
   REACTOR CORE: EL COR BLAU BATEGANT
   ========================================= */
.reactor-core { 
    text-align: center; 
    width: 150px; 
    display: flex;
    flex-direction: column;
    align-items: center;
}

.reactor-label { 
    font-size: 0.6em; 
    color: var(--glow-blue); 
    letter-spacing: 2px;
    margin-bottom: 5px;
    text-shadow: 0 0 5px var(--glow-blue);
}

.heart-container { 
    position: relative; 
    display: inline-block; 
}

.heart-svg { 
    width: 45px; 
    fill: rgba(0, 204, 255, 0.2); /* Fons del cor suau */
    stroke: var(--glow-blue);
    stroke-width: 1px;
    filter: drop-shadow(0 0 8px var(--glow-blue));
    /* Animació de batec */
    animation: pulse-blue 1.5s ease-in-out infinite;
}

.vides {
    position: absolute; 
    top: 50%; 
    left: 50%;
    transform: translate(-50%, -45%);
    font-weight: bold; 
    font-size: 1.3em; 
    color: #fff;
    font-family: var(--font-terminal);
    text-shadow: 0 0 10px var(--glow-blue);
}

/* Animació del batec */
@keyframes pulse-blue {
    0% { transform: scale(1); filter: drop-shadow(0 0 5px var(--glow-blue)); opacity: 0.8; }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 15px var(--glow-blue)); opacity: 1; }
    100% { transform: scale(1); filter: drop-shadow(0 0 5px var(--glow-blue)); opacity: 0.8; }
}

/* La barra de sota el cor també en blau */
.vitality-bar { 
    width: 80px; 
    height: 3px; 
    background: rgba(0, 204, 255, 0.1); 
    margin-top: 8px;
    border-radius: 2px;
}

.vitality-bar .fill { 
    height: 100%; 
    background: var(--glow-blue); 
    width: 100%; 
    box-shadow: 0 0 10px var(--glow-blue);
    transition: width 0.5s ease; 
}

.halls-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #222;
}

#leaderboard th {
    font-family: 'Orbitron';
    font-size: 0.7em;
    text-transform: uppercase;
}

#leaderboard-body tr:hover {
    background: rgba(0, 204, 255, 0.1);
}

/* Això farà que el SweetAlert usi la lletra de la teva terminal */
.swal-text-custom {
    font-family: 'Space Mono', 'Courier New', monospace !important;
    border: 1px solid #00ccff !important; /* Marc blau opcional */
}


/* Correcció de visibilitat: sobre la capa de login */
/* =========================================
   PERSONALITZACIÓ SWEETALERT STAR WARS
   ========================================= */

/* Contenidor principal (Z-index per sobre del login) */
.swal2-container {
    z-index: 1000000 !important;
}

/* FORÇAR EL FONS NEGRE I EL TEXT BLANC A L'ALERTA */
body .swal2-popup.swal-starwars-popup {
    background: #000810 !important; /* El teu color de fons */
    background-color: #000810 !important;
    border: 2px solid var(--glow-blue) !important;
    color: #ffffff !important;
}

/* Forçar el color del text del contingut */
body .swal-starwars-popup .swal2-html-container,
body .swal-starwars-popup .swal2-content {
    color: #ffffff !important;
}

/* Forçar el títol en cian */
body .swal-starwars-popup .swal2-title {
    color: var(--glow-blue) !important;
}

/* Variant per a errors (Imperi) */
body .swal-starwars-popup.swal-starwars-error {
    border-color: var(--imperial-red) !important;
}

body .swal-starwars-popup.swal-starwars-error .swal2-title {
    color: var(--imperial-red) !important;
}

.blink-animation {
    animation: alert-blink 1s infinite;
}

@keyframes alert-blink {
    0% { opacity: 1; }
    50% { opacity: 0.4; transform: scale(1.05); }
    100% { opacity: 1; }
}

/* Estil per al grup d'input del repte */
.login-box .input-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-box label {
    display: block;
    color: var(--glow-blue);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.login-box input[type="text"] {
    width: 100%;
    background: rgba(0, 204, 255, 0.05);
    border: 1px solid rgba(0, 204, 255, 0.3);
    color: white;
    padding: 12px;
    font-family: 'Share Tech Mono', monospace;
    transition: all 0.3s ease;
    outline: none;
}

.login-box input[type="text"]:focus {
    border-color: var(--glow-blue);
    box-shadow: 0 0 10px rgba(0, 204, 255, 0.2);
    background: rgba(0, 204, 255, 0.1);
}

/* Contenidor principal de les instruccions */
.instruccions-sql {
    font-family: 'Share Tech Mono', 'Courier New', monospace; /* Forçem la font de terminal */
    color: #00f2ff; /* El color cian de la teva interfície */
    margin-top: 30px;
    padding: 20px;
    border: 1px solid rgba(0, 242, 255, 0.3);
    background: rgba(0, 0, 0, 0.5); /* Fons fosc per contrastar */
    border-radius: 5px;
    text-align: center;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.1);
}

/* El text de les instruccions (ara ja no serà fosc) */
.instruccions-sql p {
    color: #00f2ff; 
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 15px;
    text-shadow: 0 0 5px rgba(0, 242, 255, 0.5); /* Efecte de brillantor */
}

/* Títol de l'alerta en groc/taronja per contrastar */
.alert-icon {
    font-family: 'Orbitron', sans-serif;
    color: #ffcc00;
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
}

/* Botó de descàrrega estilitzat com els teus botons */
.btn-download {
    display: inline-block;
    font-family: 'Orbitron', sans-serif;
    background: transparent;
    color: #00f2ff;
    border: 2px solid #00f2ff;
    padding: 10px 20px;
    text-decoration: none;
    text-transform: uppercase;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-download:hover {
    background: #00f2ff;
    color: #000;
    box-shadow: 0 0 20px #00f2ff;
}