:root {
    --bg-color: #1a1a2e;
    --text-color: #ffffff;
    --accent: #e94560; /* Vermell/Rosa (Inici) */
    --mid: #f9a826;    /* Taronja/Groc (Mig - Difícil) */
    --end: #4caf50;    /* Verd (Final) */
    --neutral: #4a4e69; /* Gris blavós (Usuari) */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* Vital per no fer scroll mentre s'arrosseguen nodes al mòbil */
    touch-action: none; 
}

/* Pantalles completes flotants (Menú, Càrrega i Victòria) */
#loader, #menu, #victory-modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    transition: opacity 0.5s;
}

#menu { z-index: 50; }
#victory-modal { z-index: 200; background-color: rgba(26, 26, 46, 0.95); }

#menu h1 { font-size: 3rem; color: var(--accent); margin-bottom: 5px; }
.subtitle { font-size: 1.2rem; margin-bottom: 30px; color: #a0a0b5; }

.botons-nivell {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
    max-width: 300px;
}

.botons-nivell button, #victory-modal button {
    padding: 15px;
    font-size: 18px;
    border-radius: 12px;
    border: none;
    background: var(--neutral);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.botons-nivell button:hover { background: #5c6182; }

/* SVG on es dibuixen els nodes */
#graf {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0; left: 0;
}

/* Interfície inferior durant la partida */
#ui-container {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none; /* Deixa travessar els clics cap al graf per moure nodes darrere la UI */
}

#status-bar, #input-form, #message-box {
    pointer-events: auto; /* Reactiva els clics per la barra d'escriure */
    width: 100%;
    max-width: 500px;
    text-align: center;
    margin-bottom: 10px;
}

#status-bar {
    font-size: 18px;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 20px;
}
.color-start { color: var(--accent); }
.color-mid { color: var(--mid); }
.color-end { color: var(--end); }

#input-form { display: flex; gap: 10px; }

input {
    flex-grow: 1;
    padding: 15px;
    border-radius: 25px;
    border: none;
    outline: none;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.95);
}

#input-form button {
    padding: 0 25px;
    border-radius: 25px;
    background: var(--accent);
}

#message-box {
    height: 20px;
    font-size: 14px;
    color: #ffb8b8;
}

/* Estils de les línies i nodes de D3 */
.node circle {
    stroke: #fff;
    stroke-width: 2px;
}
.node text {
    font-size: 14px;
    font-weight: bold;
    fill: white;
    text-anchor: middle;
    pointer-events: none;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}
.link {
    stroke: rgba(255, 255, 255, 0.4);
}