/* ==========================================================================
   VAPOR I NOTES — Pressió al Pentagrama
   Estètica Steampunk: bronze, coure, llautó, vapor
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bronze-fosc: #3a2418;
    --bronze: #6b4423;
    --bronze-clar: #a87242;
    --coure: #b87333;
    --coure-clar: #d4944a;
    --llauto: #e3b04b;
    --llauto-clar: #f5d76e;
    --daurat: #c9a227;
    --metall-fosc: #1a1410;
    --metall: #2d2018;
    --metall-clar: #4a3828;
    --rovell: #8b3a1f;
    --vermell-alarma: #c0392b;
    --verd-encert: #4caf50;
    --vapor: rgba(255, 255, 255, 0.18);
    --ombra-profunda: 0 8px 24px rgba(0, 0, 0, 0.7);
    --ombra-relleu: inset 0 2px 4px rgba(255, 220, 150, 0.25),
                    inset 0 -3px 6px rgba(0, 0, 0, 0.4);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: var(--llauto-clar);
    background: var(--metall-fosc);
    user-select: none;
}

/* ==========================================================================
   FONS GENERAL: METALL FOSC AMB REBLONS
   ========================================================================== */
body {
    background:
        radial-gradient(circle at 20% 30%, rgba(184, 115, 51, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(184, 115, 51, 0.06) 0%, transparent 40%),
        repeating-linear-gradient(
            45deg,
            #1a1410 0px,
            #1a1410 2px,
            #221a14 2px,
            #221a14 4px
        ),
        linear-gradient(135deg, #2d2018 0%, #1a1410 100%);
}

/* Reblons (rivets) - patró repetit */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 30px 30px, rgba(160, 100, 40, 0.5) 2px, transparent 4px),
        radial-gradient(circle at 30px 30px, rgba(0, 0, 0, 0.6) 1px, transparent 2px);
    background-size: 80px 80px;
    background-position: 0 0, 1px 1px;
    pointer-events: none;
    opacity: 0.4;
    z-index: 0;
}

/* ==========================================================================
   GESTIÓ DE PANTALLES
   ========================================================================== */
.pantalla {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1;
    overflow: hidden;
}

.pantalla.activa {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: fadeInPantalla 0.5s ease-out;
}

@keyframes fadeInPantalla {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   PANTALLA 1: LANDING
   ========================================================================== */
#pantalla-landing {
    background:
        radial-gradient(ellipse at center, rgba(184, 115, 51, 0.12) 0%, transparent 60%);
}

.contingut-landing {
    text-align: center;
    z-index: 10;
    padding: 40px;
}

.titol-principal {
    font-size: clamp(2.8rem, 11vmin, 7rem);
    font-weight: 900;
    letter-spacing: clamp(2px, 0.5vmin, 4px);
    margin-bottom: 10px;
    text-shadow:
        2px 2px 0 #000,
        4px 4px 0 var(--bronze-fosc),
        0 0 40px rgba(212, 148, 74, 0.4);
    line-height: 1;
    font-family: 'Georgia', serif;
}

.titol-vapor, .titol-notes {
    background: linear-gradient(180deg,
        var(--llauto-clar) 0%,
        var(--llauto) 30%,
        var(--coure) 60%,
        var(--bronze) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.titol-i {
    color: var(--coure-clar);
    font-size: 0.7em;
    margin: 0 20px;
    vertical-align: middle;
    text-shadow: 0 0 20px var(--coure);
    -webkit-text-fill-color: var(--coure-clar);
}

.subtitol {
    font-size: clamp(0.9rem, 2.2vmin, 1.5rem);
    color: var(--coure-clar);
    letter-spacing: clamp(3px, 1vmin, 8px);
    margin-bottom: clamp(25px, 6vmin, 60px);
    text-shadow: 1px 1px 2px #000;
}

.botons-landing {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2.5vmin, 25px);
    align-items: center;
    margin-bottom: clamp(25px, 6vmin, 60px);
}

.peu-pagina {
    color: var(--bronze-clar);
    font-style: italic;
    font-size: 0.95rem;
    opacity: 0.7;
}

/* Engranatges decoratius */
.engranatge {
    position: absolute;
    color: var(--bronze);
    opacity: 0.18;
    text-shadow: 0 0 30px var(--coure);
    pointer-events: none;
    z-index: 1;
}

.engranatge-1 {
    font-size: 22rem;
    top: -8%;
    left: -5%;
    animation: girar 20s linear infinite;
}
.engranatge-2 {
    font-size: 18rem;
    bottom: -6%;
    right: -4%;
    animation: girar-invers 25s linear infinite;
}
.engranatge-3 {
    font-size: 14rem;
    top: 5%;
    right: 8%;
    animation: girar 30s linear infinite;
}
.engranatge-4 {
    font-size: 12rem;
    bottom: 8%;
    left: 6%;
    animation: girar-invers 18s linear infinite;
}

@keyframes girar {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes girar-invers {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

/* Vapor animat */
.vapor {
    position: absolute;
    bottom: -100px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--vapor) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: pujar-vapor 8s ease-in infinite;
}
.vapor-1 { left: 10%; animation-delay: 0s; }
.vapor-2 { left: 50%; animation-delay: 3s; }
.vapor-3 { left: 80%; animation-delay: 5s; }

@keyframes pujar-vapor {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }
    20% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-110vh) scale(2);
        opacity: 0;
    }
}

/* ==========================================================================
   BOTONS DE LLAUTÓ
   ========================================================================== */
.boto-llauto {
    position: relative;
    padding: 16px 36px;
    font-family: 'Georgia', serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--metall-fosc);
    text-transform: uppercase;
    background: linear-gradient(180deg,
        var(--llauto-clar) 0%,
        var(--llauto) 40%,
        var(--coure) 80%,
        var(--bronze) 100%);
    border: 3px solid var(--bronze-fosc);
    border-radius: 14px;
    cursor: pointer;
    text-shadow: 1px 1px 0 rgba(255, 220, 150, 0.4);
    box-shadow:
        var(--ombra-relleu),
        0 6px 0 var(--bronze-fosc),
        0 8px 16px rgba(0, 0, 0, 0.6);
    transition: all 0.1s ease;
    overflow: hidden;
    z-index: 10;
}

.boto-llauto::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 8px;
    right: 8px;
    height: 30%;
    background: linear-gradient(180deg, rgba(255, 240, 200, 0.5) 0%, transparent 100%);
    border-radius: 8px 8px 50% 50%;
    pointer-events: none;
}

.boto-llauto:hover {
    transform: translateY(-2px);
    box-shadow:
        var(--ombra-relleu),
        0 8px 0 var(--bronze-fosc),
        0 12px 24px rgba(0, 0, 0, 0.7),
        0 0 30px rgba(212, 148, 74, 0.4);
}

.boto-llauto:active {
    transform: translateY(6px);
    box-shadow:
        var(--ombra-relleu),
        0 0 0 var(--bronze-fosc),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

.boto-gran {
    padding: clamp(12px, 2.5vmin, 22px) clamp(28px, 6vmin, 60px);
    font-size: clamp(1rem, 2.2vmin, 1.5rem);
    min-width: min(380px, 80vw);
}

.boto-petit {
    padding: 8px 18px;
    font-size: 0.9rem;
}

.boto-perill {
    background: linear-gradient(180deg, #d97256 0%, #a13b22 50%, #6b1f0f 100%);
    color: #fff5e6;
    border-color: #3a0f08;
    text-shadow: 1px 1px 2px #000;
    box-shadow:
        var(--ombra-relleu),
        0 6px 0 #3a0f08,
        0 8px 16px rgba(0, 0, 0, 0.6);
}

.boto-perill:active {
    box-shadow:
        var(--ombra-relleu),
        0 0 0 #3a0f08,
        0 2px 4px rgba(0, 0, 0, 0.5);
}

.boto-destacat {
    background: linear-gradient(180deg, #f5d76e 0%, #c9a227 40%, #8b6914 100%);
    box-shadow:
        var(--ombra-relleu),
        0 6px 0 #5a4408,
        0 0 30px rgba(245, 215, 110, 0.6);
}

.boto-llauto .icona {
    margin-right: 10px;
    font-size: 1.3em;
}

/* ==========================================================================
   PANTALLA 2: TUTORIAL
   ========================================================================== */
.marc-tutorial {
    background:
        linear-gradient(135deg, var(--metall-clar) 0%, var(--metall) 100%);
    border: 4px solid var(--bronze);
    border-radius: 20px;
    padding: clamp(20px, 3vmin, 40px) clamp(25px, 5vmin, 60px);
    max-width: min(800px, 92vw);
    width: 92%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow:
        var(--ombra-relleu),
        var(--ombra-profunda),
        0 0 60px rgba(184, 115, 51, 0.2);
    z-index: 10;
}

.titol-secundari {
    font-size: clamp(1.4rem, 4vmin, 2.5rem);
    color: var(--llauto-clar);
    text-align: center;
    margin-bottom: clamp(15px, 2.5vmin, 30px);
    letter-spacing: clamp(1px, 0.4vmin, 3px);
    text-shadow: 2px 2px 0 #000, 0 0 20px var(--coure);
}

.passos-tutorial {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2vmin, 22px);
    margin-bottom: clamp(18px, 3vmin, 35px);
}

.pas {
    display: flex;
    align-items: flex-start;
    gap: clamp(12px, 2.5vmin, 22px);
    background: rgba(0, 0, 0, 0.3);
    padding: clamp(10px, 2vmin, 20px);
    border-radius: 12px;
    border-left: 5px solid var(--coure);
}

.numero-pas {
    flex: 0 0 clamp(40px, 7vmin, 60px);
    height: clamp(40px, 7vmin, 60px);
    background: radial-gradient(circle at 30% 30%,
        var(--llauto-clar) 0%,
        var(--coure) 60%,
        var(--bronze) 100%);
    border: 3px solid var(--bronze-fosc);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 3vmin, 1.8rem);
    font-weight: 900;
    color: var(--metall-fosc);
    box-shadow:
        var(--ombra-relleu),
        0 4px 8px rgba(0, 0, 0, 0.5);
}

.text-pas h3 {
    color: var(--llauto-clar);
    margin-bottom: 6px;
    letter-spacing: 1.5px;
    text-shadow: 1px 1px 0 #000;
    font-size: clamp(0.95rem, 2.2vmin, 1.2rem);
}

.text-pas p {
    color: var(--bronze-clar);
    line-height: 1.4;
    font-size: clamp(0.8rem, 1.7vmin, 1rem);
}

#pantalla-tutorial .boto-llauto {
    display: block;
    margin: 0 auto;
}

/* ==========================================================================
   PANTALLA 3: NIVELLS
   ========================================================================== */
.marc-nivells {
    background: linear-gradient(135deg, var(--metall-clar) 0%, var(--metall) 100%);
    border: 4px solid var(--bronze);
    border-radius: 20px;
    padding: clamp(20px, 3vmin, 40px) clamp(25px, 5vmin, 60px);
    max-width: min(900px, 95vw);
    width: 95%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow:
        var(--ombra-relleu),
        var(--ombra-profunda);
    z-index: 10;
}

.instruccio-nivells {
    text-align: center;
    color: var(--bronze-clar);
    margin-bottom: clamp(15px, 3vmin, 30px);
    font-style: italic;
    font-size: clamp(0.85rem, 1.8vmin, 1.1rem);
}

.graella-nivells {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(8px, 1.5vmin, 15px);
    margin-bottom: clamp(15px, 3vmin, 30px);
}

.casella-nivell {
    aspect-ratio: 1;
    background: radial-gradient(circle at 30% 30%,
        var(--llauto-clar) 0%,
        var(--coure) 50%,
        var(--bronze) 100%);
    border: 3px solid var(--bronze-fosc);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--metall-fosc);
    font-size: clamp(1rem, 2.5vmin, 1.8rem);
    font-weight: 900;
    box-shadow:
        var(--ombra-relleu),
        0 4px 0 var(--bronze-fosc),
        0 6px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.15s;
    position: relative;
}

.casella-nivell:hover:not(.bloquejat) {
    transform: translateY(-3px);
    box-shadow:
        var(--ombra-relleu),
        0 7px 0 var(--bronze-fosc),
        0 10px 20px rgba(0, 0, 0, 0.5),
        0 0 25px rgba(245, 215, 110, 0.5);
}

.casella-nivell:active:not(.bloquejat) {
    transform: translateY(2px);
    box-shadow:
        var(--ombra-relleu),
        0 2px 0 var(--bronze-fosc),
        0 4px 6px rgba(0, 0, 0, 0.5);
}

.casella-nivell.bloquejat {
    background: linear-gradient(135deg, #2a201a 0%, #1a1410 100%);
    color: #5a4528;
    cursor: not-allowed;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.6);
    border-color: #1a1410;
}

.casella-nivell.bloquejat::after {
    content: '🔒';
    font-size: 2rem;
    position: absolute;
}

.casella-nivell.bloquejat .num-nivell,
.casella-nivell.bloquejat .estrelles {
    display: none;
}

.casella-nivell.completat {
    background: radial-gradient(circle at 30% 30%, #ffe066 0%, #c9a227 50%, #8b6914 100%);
}

.num-nivell {
    line-height: 1;
}

.estrelles {
    font-size: 0.7rem;
    color: var(--metall-fosc);
    margin-top: 4px;
    letter-spacing: 2px;
}

.botons-nivells {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

/* ==========================================================================
   PANTALLA 4: JOC — LAYOUT REACTIU
   ========================================================================== */
#pantalla-joc {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: clamp(6px, 1.2vh, 16px);
    gap: clamp(6px, 1.2vh, 14px);
}

/* HUD SUPERIOR */
.hud-superior {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(8px, 1.5vw, 20px);
    padding: clamp(6px, 1.2vh, 14px) clamp(10px, 2vw, 24px);
    background:
        linear-gradient(180deg,
            var(--metall-clar) 0%,
            var(--metall) 50%,
            var(--metall-fosc) 100%);
    border: 3px solid var(--bronze);
    border-radius: 14px;
    box-shadow:
        var(--ombra-relleu),
        0 6px 16px rgba(0, 0, 0, 0.6);
    z-index: 10;
    flex-wrap: wrap;
}

.hud-bloc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: clamp(70px, 10vw, 110px);
}

.etiqueta-hud {
    font-size: clamp(0.6rem, 1.1vh, 0.75rem);
    color: var(--bronze-clar);
    letter-spacing: clamp(1px, 0.3vw, 2px);
    text-transform: uppercase;
    white-space: nowrap;
}

.valor-hud {
    font-size: clamp(1rem, 2.6vh, 1.8rem);
    font-weight: 900;
    color: var(--llauto-clar);
    text-shadow: 1px 1px 0 #000, 0 0 10px var(--coure);
    line-height: 1;
}

.vides {
    display: flex;
    gap: 4px;
    font-size: clamp(0.95rem, 2.2vh, 1.6rem);
    filter: drop-shadow(0 0 6px rgba(192, 57, 43, 0.6));
}

.vida.gastada {
    filter: grayscale(100%) brightness(0.3);
}

/* MANÒMETRE */
.manometre {
    position: absolute;
    top: clamp(80px, 12vh, 120px);
    right: clamp(10px, 2vw, 40px);
    width: clamp(70px, 11vh, 110px);
    z-index: 10;
    text-align: center;
    pointer-events: none;
}

.cara-manometre {
    width: clamp(70px, 11vh, 110px);
    height: clamp(70px, 11vh, 110px);
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 30%, #f5e6c8 0%, #d4c4a0 40%, #8b7355 100%);
    border: 6px solid var(--bronze-fosc);
    position: relative;
    box-shadow:
        inset 0 4px 8px rgba(0, 0, 0, 0.4),
        var(--ombra-relleu),
        0 6px 12px rgba(0, 0, 0, 0.6);
}

.cara-manometre::before {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background:
        conic-gradient(
            from 225deg,
            #4caf50 0deg,
            #ffeb3b 80deg,
            #ff9800 130deg,
            #c0392b 180deg,
            transparent 180deg
        );
    opacity: 0.35;
}

.agulla {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 38%;
    background: linear-gradient(180deg, #1a1410 0%, var(--rovell) 100%);
    transform-origin: 50% 100%;
    transform: translate(-50%, -100%) rotate(-90deg);
    transition: transform 0.5s cubic-bezier(0.4, 1.5, 0.6, 1);
    border-radius: 2px;
    z-index: 2;
}

.centre-manometre {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: radial-gradient(circle at 30% 30%, #c9a227 0%, var(--bronze-fosc) 100%);
    border-radius: 50%;
    z-index: 3;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

.etiqueta-manometre {
    display: block;
    margin-top: 6px;
    color: var(--llauto-clar);
    font-size: 0.85rem;
    letter-spacing: 3px;
    text-shadow: 1px 1px 0 #000;
}

/* ZONA PENTAGRAMA — flex grow, ocupa l'espai disponible */
.zona-pentagrama {
    position: relative;
    width: min(95%, 1200px);
    margin: 0 auto;
    flex: 1 1 0;
    min-height: 180px;
    max-height: 60vh;
    background:
        linear-gradient(135deg,
            rgba(45, 32, 24, 0.7) 0%,
            rgba(26, 20, 16, 0.7) 100%);
    border: 4px solid var(--bronze);
    border-radius: 16px;
    box-shadow:
        var(--ombra-relleu),
        var(--ombra-profunda);
    padding: clamp(25px, 5vh, 45px) clamp(40px, 6vw, 80px) clamp(25px, 5vh, 45px) clamp(70px, 10vw, 130px);
    z-index: 5;
    overflow: visible;
}

.clau-sol {
    position: absolute;
    left: clamp(10px, 1.5vw, 30px);
    top: 50%;
    transform: translateY(-50%);
    font-size: clamp(5rem, 28vh, 14rem);
    line-height: 1;
    color: var(--llauto);
    text-shadow:
        0 0 20px var(--coure),
        2px 2px 0 #000;
    pointer-events: none;
    font-family: 'Georgia', serif;
}

.canonades {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.canonada {
    height: clamp(8px, 1.6vh, 14px);
    background:
        linear-gradient(180deg,
            #f5d76e 0%,
            #c9a227 25%,
            var(--coure) 50%,
            var(--bronze) 75%,
            #5a3a1a 100%);
    border-top: 1px solid #fff5d6;
    border-bottom: 1px solid #1a1004;
    border-radius: 4px;
    box-shadow:
        inset 0 2px 4px rgba(255, 240, 180, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.5),
        0 4px 8px rgba(0, 0, 0, 0.4);
    position: relative;
}

/* Reblons en les canonades */
.canonada::before, .canonada::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff5d6 0%, var(--bronze-fosc) 100%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.canonada::before { left: 6px; }
.canonada::after { right: 6px; }

/* ZONA DE FUITES (SVG/divs) */
.zona-fuites {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 6;
}

/* FUITA DE VAPOR */
.fuita {
    position: absolute;
    width: clamp(44px, 7vh, 60px);
    height: clamp(44px, 7vh, 60px);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: aparicio-fuita 0.3s ease-out;
}

@keyframes aparicio-fuita {
    from {
        transform: translate(-50%, -50%) scale(0.2);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Cap de la nota (vàlvula brillant) */
.fuita .nota-cap {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 22px;
    background: radial-gradient(circle at 30% 30%, #fff8dc 0%, var(--llauto) 30%, var(--coure) 60%, var(--bronze-fosc) 100%);
    border: 2px solid var(--bronze-fosc);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotate(-20deg);
    box-shadow:
        inset -3px -3px 6px rgba(0, 0, 0, 0.4),
        inset 2px 2px 4px rgba(255, 240, 180, 0.6),
        0 0 12px rgba(245, 215, 110, 0.7),
        0 0 25px rgba(212, 148, 74, 0.5);
    z-index: 3;
}

.fuita .nota-pal {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.5px;
    height: 36px;
    background: linear-gradient(180deg, var(--llauto) 0%, var(--bronze) 100%);
    transform: translate(8px, -36px);
    z-index: 2;
}

/* Anell temporitzador */
.fuita .anell-temps {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    z-index: 1;
}

.fuita .anell-temps svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.fuita .anell-temps circle {
    fill: none;
    stroke-width: 4;
}

.fuita .anell-fons {
    stroke: rgba(0, 0, 0, 0.5);
}

.fuita .anell-progres {
    stroke: #ffeb3b;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
    filter: drop-shadow(0 0 4px currentColor);
}

.fuita.urgent .anell-progres {
    stroke: var(--vermell-alarma);
    animation: pulsacio-urgent 0.4s ease-in-out infinite alternate;
}

@keyframes pulsacio-urgent {
    from { filter: drop-shadow(0 0 4px var(--vermell-alarma)); }
    to { filter: drop-shadow(0 0 12px var(--vermell-alarma)); }
}

/* Vapor sortint de la fuita */
.fuita .vapor-fuita {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 30px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
    border-radius: 50%;
    animation: pujar-vapor-fuita 1.5s ease-out infinite;
}

@keyframes pujar-vapor-fuita {
    0% { transform: translate(-50%, 0) scale(0.5); opacity: 0.8; }
    100% { transform: translate(-50%, -40px) scale(1.5); opacity: 0; }
}

/* Animació encert / error */
.fuita.encert {
    animation: explota-encert 0.5s forwards;
}
.fuita.error {
    animation: explota-error 0.6s forwards;
}

@keyframes explota-encert {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% {
        transform: translate(-50%, -50%) scale(1.4);
        filter: brightness(2) drop-shadow(0 0 30px var(--verd-encert));
    }
    100% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
}

@keyframes explota-error {
    0% { transform: translate(-50%, -50%) scale(1); }
    20% { transform: translate(-50%, -50%) scale(1.6); filter: brightness(1.5) hue-rotate(0deg); }
    40% { transform: translate(-50%, -50%) scale(1.5); filter: brightness(1.5) hue-rotate(-30deg); }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
        filter: brightness(0.5) hue-rotate(-60deg);
    }
}

/* Línies addicionals (ledger lines) */
.linia-addicional {
    position: absolute;
    height: 4px;
    width: 50px;
    background: linear-gradient(180deg, #c9a227 0%, var(--coure) 50%, #5a3a1a 100%);
    border-radius: 2px;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

/* TAULER COMANDAMENT */
.tauler-comandament {
    width: min(95%, 1200px);
    margin: 0 auto;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    gap: clamp(6px, 1.5vw, 20px);
    padding: clamp(10px, 2vh, 22px) clamp(12px, 2vw, 25px);
    background:
        linear-gradient(180deg,
            var(--metall-clar) 0%,
            var(--metall) 60%,
            var(--metall-fosc) 100%);
    border: 4px solid var(--bronze);
    border-radius: 16px;
    box-shadow:
        var(--ombra-relleu),
        0 8px 20px rgba(0, 0, 0, 0.7);
    z-index: 10;
    flex-wrap: nowrap;
}

.valvula {
    width: clamp(48px, 10vh, 90px);
    height: clamp(48px, 10vh, 90px);
    flex-shrink: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
        var(--llauto-clar) 0%,
        var(--coure) 40%,
        var(--bronze) 80%,
        var(--bronze-fosc) 100%);
    border: 4px solid var(--bronze-fosc);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--metall-fosc);
    font-family: 'Georgia', serif;
    font-weight: 900;
    box-shadow:
        var(--ombra-relleu),
        0 6px 0 var(--bronze-fosc),
        0 8px 16px rgba(0, 0, 0, 0.6),
        inset 0 0 10px rgba(255, 220, 150, 0.3);
    transition: all 0.08s ease;
    position: relative;
    overflow: hidden;
}

.valvula::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 18px;
    width: 30%;
    height: 25%;
    background: radial-gradient(ellipse, rgba(255, 240, 200, 0.6) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.valvula:hover {
    transform: translateY(-2px);
    box-shadow:
        var(--ombra-relleu),
        0 8px 0 var(--bronze-fosc),
        0 12px 20px rgba(0, 0, 0, 0.7),
        0 0 25px rgba(245, 215, 110, 0.6);
}

.valvula:active, .valvula.premuda {
    transform: translateY(6px);
    box-shadow:
        var(--ombra-relleu),
        0 0 0 var(--bronze-fosc),
        0 2px 4px rgba(0, 0, 0, 0.5),
        inset 0 4px 12px rgba(0, 0, 0, 0.5);
}

.valvula.encert-flash {
    animation: flash-encert 0.4s;
}
.valvula.error-flash {
    animation: flash-error 0.4s;
}

@keyframes flash-encert {
    0%, 100% { background: radial-gradient(circle at 30% 30%, var(--llauto-clar) 0%, var(--coure) 40%, var(--bronze) 80%, var(--bronze-fosc) 100%); }
    50% {
        background: radial-gradient(circle at 30% 30%, #ccffcc 0%, var(--verd-encert) 60%, #1b5e20 100%);
        box-shadow: 0 0 30px var(--verd-encert);
    }
}

@keyframes flash-error {
    0%, 100% { background: radial-gradient(circle at 30% 30%, var(--llauto-clar) 0%, var(--coure) 40%, var(--bronze) 80%, var(--bronze-fosc) 100%); }
    50% {
        background: radial-gradient(circle at 30% 30%, #ffcccc 0%, var(--vermell-alarma) 60%, #4a0e08 100%);
        box-shadow: 0 0 30px var(--vermell-alarma);
    }
}

.nom-nota {
    font-size: clamp(0.8rem, 2.2vh, 1.4rem);
    line-height: 1;
    text-shadow: 1px 1px 0 rgba(255, 220, 150, 0.4);
}

.tecla-nota {
    font-size: clamp(0.55rem, 1.1vh, 0.7rem);
    margin-top: 4px;
    color: var(--bronze-fosc);
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 1px;
}

/* VAPOR DE FONS */
.vapor-fons {
    position: fixed;
    bottom: -50px;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    border-radius: 50%;
    pointer-events: none;
    animation: pujar-vapor 12s ease-in infinite;
    z-index: 1;
}
.vapor-fons-1 { left: 5%; animation-delay: 0s; }
.vapor-fons-2 { right: 5%; animation-delay: 6s; }

/* OVERLAY ALARMA */
.overlay-alarma {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(192, 57, 43, 0.4) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s;
    z-index: 50;
}

.overlay-alarma.activa-1 { opacity: 0.3; }
.overlay-alarma.activa-2 { opacity: 0.5; }
.overlay-alarma.activa-3 { opacity: 0.75; }

.overlay-alarma.flash {
    animation: flash-alarma 0.4s;
}

@keyframes flash-alarma {
    0%, 100% { opacity: var(--opacitat-base, 0); }
    50% {
        opacity: 1;
        background: radial-gradient(ellipse at center, rgba(192, 57, 43, 0.6) 0%, rgba(192, 57, 43, 0.9) 100%);
    }
}

/* Vibració de pantalla */
.pantalla.vibrar {
    animation: vibrar 0.4s;
}

@keyframes vibrar {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-8px, 2px); }
    20%, 40%, 60%, 80% { transform: translate(8px, -2px); }
}

/* ==========================================================================
   MODAL FINAL DE NIVELL
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-overlay.activa {
    display: flex;
    animation: fadeInPantalla 0.4s;
}

.modal-contingut {
    background: linear-gradient(135deg, var(--metall-clar) 0%, var(--metall) 100%);
    border: 5px solid var(--bronze);
    border-radius: 20px;
    padding: clamp(20px, 4vmin, 40px) clamp(25px, 6vmin, 60px);
    max-width: min(600px, 92vw);
    width: 92%;
    max-height: 92vh;
    overflow-y: auto;
    text-align: center;
    box-shadow:
        var(--ombra-relleu),
        0 0 80px rgba(245, 215, 110, 0.4);
}

.modal-cos {
    margin: clamp(15px, 3vmin, 30px) 0;
    font-size: clamp(0.95rem, 2.2vmin, 1.3rem);
    line-height: 1.8;
}

.modal-linia {
    color: var(--bronze-clar);
}

.modal-linia span {
    color: var(--llauto-clar);
    font-weight: 900;
    text-shadow: 0 0 8px var(--coure);
}

.modal-botons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Modal mode "fracàs" */
.modal-overlay.fracas .modal-contingut {
    border-color: var(--vermell-alarma);
    box-shadow:
        var(--ombra-relleu),
        0 0 80px rgba(192, 57, 43, 0.6);
}

.modal-overlay.fracas .titol-secundari {
    color: #ff6b5e;
    text-shadow: 2px 2px 0 #000, 0 0 20px var(--vermell-alarma);
}

/* ==========================================================================
   RESPONSIVE — la majoria d'escalat ja es fa via clamp().
   Aquí només els canvis estructurals (layout) que no es poden fer amb clamp.
   ========================================================================== */
@media (max-width: 900px) {
    .manometre { display: none; }
    .graella-nivells { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 600px) {
    .pas { flex-direction: column; align-items: center; text-align: center; }
    .tecla-nota { display: none; }
    .graella-nivells { grid-template-columns: repeat(3, 1fr); }
    .hud-bloc { min-width: 60px; }
}

/* Pantalla molt baixa (apaisat de mòbil): més compacte vertical */
@media (max-height: 500px) {
    .manometre { display: none; }
    .clau-sol { font-size: clamp(3rem, 50vh, 9rem); }
    .zona-pentagrama { padding: 20px 50px 20px 70px; min-height: 130px; }
    .hud-bloc { gap: 0; }
}
