/* ============================================================ */
/* EL SÓNAR — Estètica CRT / Fòsfor Verd / Submarí              */
/* ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&display=swap');

:root {
    --fosfor: #39ff14;
    --fosfor-mid: #1ec40a;
    --fosfor-fosc: #0f7a06;
    --fosfor-tenue: #0a3a04;
    --negre: #000000;
    --negre-panel: #020a02;
    --ambar: #ffaa00;
    --ambar-fosc: #8a5c00;
    --roig-alarma: #ff2b2b;
    --roig-fosc: #800f0f;
    --blau-aigua: #0088cc;
    --bloquejat: #444;
}

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

html, body {
    height: 100%;
    background: #000;
    color: var(--fosfor);
    font-family: 'VT323', 'Share Tech Mono', monospace;
    overflow: hidden;
    user-select: none;
}

button { font-family: inherit; }

/* ---------- FRAME CRT ---------- */
.crt-frame {
    position: relative;
    width: 100%;
    height: 100vh;
    background: radial-gradient(ellipse at center, #041a05 0%, #000 75%);
    padding: 14px;
    overflow: hidden;
}

.crt-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.85) 100%);
    pointer-events: none;
    z-index: 50;
}

.scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0,0,0,0) 0px,
        rgba(0,0,0,0) 2px,
        rgba(0,0,0,0.18) 3px,
        rgba(0,0,0,0) 4px
    );
    pointer-events: none;
    z-index: 40;
    mix-blend-mode: multiply;
}

.crt-flicker {
    position: absolute;
    inset: 0;
    background: rgba(57, 255, 20, 0.02);
    pointer-events: none;
    z-index: 45;
    animation: flicker 4s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 0.55; }
    52%      { opacity: 0.15; }
    54%      { opacity: 0.5; }
}

/* ---------- PANTALLES (contenidor base) ---------- */
.pantalla {
    position: absolute;
    inset: 14px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 1100px;
    margin: 0 auto;
}

.ocult { display: none !important; }

/* ========================================================== */
/* PANTALLA 1 · LANDING                                       */
/* ========================================================== */
#pantalla-landing {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    max-width: 640px;
    width: 100%;
}

.radar-hero {
    width: 180px;
    height: 180px;
    position: relative;
    margin-bottom: 8px;
}

.radar-disc {
    position: relative;
    width: 100%;
    height: 100%;
    border: 2px solid var(--fosfor-fosc);
    border-radius: 50%;
    background:
        radial-gradient(circle at center, rgba(57,255,20,0.08) 0%, rgba(57,255,20,0) 70%),
        radial-gradient(circle at center, #041a05 0%, #000 80%);
    box-shadow:
        0 0 30px rgba(57,255,20,0.4),
        inset 0 0 30px rgba(57,255,20,0.15);
    overflow: hidden;
}

.radar-rings::before,
.radar-rings::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    border: 1px solid var(--fosfor-fosc);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.5;
}
.radar-rings::before { width: 60%; height: 60%; }
.radar-rings::after  { width: 30%; height: 30%; }

.radar-crosshair::before,
.radar-crosshair::after {
    content: '';
    position: absolute;
    background: var(--fosfor-fosc);
    opacity: 0.4;
}
.radar-crosshair::before { top: 0; bottom: 0; left: 50%; width: 1px; }
.radar-crosshair::after  { left: 0; right: 0; top: 50%; height: 1px; }

.radar-sweep {
    position: absolute;
    top: 0; left: 50%;
    width: 50%;
    height: 50%;
    transform-origin: 0% 100%;
    background: conic-gradient(
        from -90deg,
        rgba(57,255,20,0.55) 0deg,
        rgba(57,255,20,0) 60deg
    );
    animation: sweep-rot 3s linear infinite;
}

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

.radar-blip {
    position: absolute;
    width: 7px;
    height: 7px;
    background: var(--fosfor);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--fosfor);
    animation: blip-fade 3s linear infinite;
}
.radar-blip.b1 { top: 22%; left: 64%; animation-delay: 0.4s; }
.radar-blip.b2 { top: 58%; left: 28%; animation-delay: 1.2s; }
.radar-blip.b3 { top: 40%; left: 78%; animation-delay: 2.1s; }

@keyframes blip-fade {
    0%, 10%  { opacity: 1; transform: scale(1.2); }
    40%, 100% { opacity: 0; transform: scale(1); }
}

.titol-principal {
    font-size: 3.6rem;
    letter-spacing: 10px;
    text-shadow:
        0 0 10px var(--fosfor),
        0 0 22px var(--fosfor),
        0 0 40px var(--fosfor-fosc);
    animation: glow-pulse 2.2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { text-shadow: 0 0 8px var(--fosfor), 0 0 16px var(--fosfor); }
    50%      { text-shadow: 0 0 14px var(--fosfor), 0 0 28px var(--fosfor), 0 0 40px var(--fosfor-fosc); }
}

.subtitol {
    font-size: 1rem;
    letter-spacing: 5px;
    color: var(--fosfor-fosc);
    opacity: 0.85;
}

.descripcio {
    font-size: 1.05rem;
    letter-spacing: 1px;
    opacity: 0.7;
    margin-top: -6px;
}

/* ---------- Menú principal ---------- */
.menu-principal {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-menu {
    min-width: 220px;
    background: linear-gradient(180deg, rgba(4, 40, 4, 0.7) 0%, rgba(2, 14, 2, 0.9) 100%);
    color: var(--fosfor);
    border: 2px solid var(--fosfor-fosc);
    padding: 18px 26px;
    cursor: pointer;
    text-align: left;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 14px;
    align-items: center;
    box-shadow:
        0 0 18px rgba(57, 255, 20, 0.25),
        inset 0 0 14px rgba(57, 255, 20, 0.08);
    transition: all 0.15s ease-out;
}

.btn-menu .ico {
    grid-row: 1 / 3;
    font-size: 2.4rem;
    color: var(--fosfor);
    text-shadow: 0 0 10px var(--fosfor);
}

.btn-menu .text {
    font-size: 1.6rem;
    letter-spacing: 4px;
    text-shadow: 0 0 6px var(--fosfor);
}

.btn-menu .sub {
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: var(--fosfor-fosc);
}

.btn-menu:hover {
    border-color: var(--fosfor);
    transform: translateY(-2px);
    box-shadow:
        0 0 26px rgba(57, 255, 20, 0.6),
        inset 0 0 18px rgba(57, 255, 20, 0.18);
}

.btn-menu.btn-primari {
    border-color: var(--fosfor);
    background: linear-gradient(180deg, rgba(20, 90, 20, 0.7) 0%, rgba(8, 40, 8, 0.9) 100%);
}

.btn-menu.btn-primari .text { color: #fff; }

.landing-footer {
    margin-top: 20px;
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: var(--fosfor-fosc);
    display: flex;
    gap: 10px;
    align-items: center;
}

.status-led {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--fosfor);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--fosfor);
    animation: led-blink 1.2s infinite;
}

@keyframes led-blink {
    0%, 49%, 100% { opacity: 1; }
    50%, 99%      { opacity: 0.25; }
}

.sep { opacity: 0.5; }

/* ========================================================== */
/* CAP DE PANTALLA (comú nivells + tutorial + joc)            */
/* ========================================================== */
.cap-pantalla {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid var(--fosfor-fosc);
    background: rgba(0, 20, 0, 0.55);
    padding: 10px 16px;
    box-shadow:
        0 0 14px rgba(57, 255, 20, 0.3),
        inset 0 0 14px rgba(57, 255, 20, 0.06);
    gap: 12px;
}

.cap-titol { text-align: center; flex: 1; }
.cap-titol h2 {
    font-size: 1.6rem;
    letter-spacing: 5px;
    text-shadow: 0 0 8px var(--fosfor);
}
.subtitol-cap {
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: var(--fosfor-fosc);
}

.btn-tornar {
    font-family: 'VT323', monospace;
    font-size: 1rem;
    letter-spacing: 2px;
    background: transparent;
    color: var(--fosfor);
    border: 1px solid var(--fosfor-fosc);
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.12s;
}

.btn-tornar:hover {
    background: var(--fosfor-fosc);
    color: #000;
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}

.btn-tornar.petit {
    padding: 6px 10px;
    font-size: 1.2rem;
}

.hud-panel.compact {
    padding: 4px 10px;
    min-width: 80px;
}

/* ========================================================== */
/* PANTALLA 2 · SELECTOR DE NIVELLS                           */
/* ========================================================== */
.nivells-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    flex: 1;
    align-content: start;
    padding: 4px;
    overflow-y: auto;
}

.nivell-card {
    position: relative;
    border: 2px solid var(--fosfor-fosc);
    background: linear-gradient(180deg, rgba(4, 30, 4, 0.7) 0%, rgba(1, 10, 1, 0.9) 100%);
    padding: 18px 16px;
    cursor: pointer;
    transition: all 0.15s;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.15);
}

.nivell-card:hover:not(.bloquejat) {
    border-color: var(--fosfor);
    transform: translateY(-3px);
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.5);
}

.nivell-card .num {
    font-size: 2.6rem;
    letter-spacing: 2px;
    color: var(--fosfor);
    text-shadow: 0 0 10px var(--fosfor);
    line-height: 1;
}

.nivell-card h3 {
    font-size: 1.25rem;
    letter-spacing: 3px;
    text-shadow: 0 0 6px var(--fosfor);
}

.nivell-card .desc {
    font-size: 0.95rem;
    color: var(--fosfor-mid);
    flex: 1;
    line-height: 1.3;
}

.nivell-card .stats {
    font-size: 0.8rem;
    letter-spacing: 1px;
    color: var(--fosfor-fosc);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nivell-card .badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.75rem;
    letter-spacing: 1px;
    padding: 3px 8px;
    border: 1px solid currentColor;
    border-radius: 2px;
}

.nivell-card.superat      { border-color: var(--fosfor); }
.nivell-card.superat .badge { color: var(--fosfor); background: rgba(57,255,20,0.12); }
.nivell-card.superat::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(57,255,20,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.nivell-card.disponible .badge { color: var(--ambar); background: rgba(255,170,0,0.12); }

.nivell-card.bloquejat {
    border-color: var(--bloquejat);
    background: linear-gradient(180deg, rgba(20,20,20,0.6) 0%, rgba(5,5,5,0.85) 100%);
    cursor: not-allowed;
    opacity: 0.75;
}
.nivell-card.bloquejat .num,
.nivell-card.bloquejat h3,
.nivell-card.bloquejat .desc,
.nivell-card.bloquejat .stats { color: #666; text-shadow: none; }
.nivell-card.bloquejat .badge { color: #888; background: rgba(100,100,100,0.15); }

.nivell-card.bonus {
    border-color: var(--ambar);
    background: linear-gradient(180deg, rgba(80, 50, 0, 0.4) 0%, rgba(20, 10, 0, 0.85) 100%);
}
.nivell-card.bonus.superat, .nivell-card.bonus.disponible {
    box-shadow: 0 0 18px rgba(255, 170, 0, 0.35);
}
.nivell-card.bonus .num,
.nivell-card.bonus h3 {
    color: var(--ambar);
    text-shadow: 0 0 8px var(--ambar);
}

.nivell-card .rec-nivell {
    font-size: 0.78rem;
    color: var(--ambar);
    margin-top: 2px;
}

.nivells-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-top: 1px solid var(--fosfor-fosc);
    font-size: 0.85rem;
    color: var(--fosfor-fosc);
    letter-spacing: 1px;
}

.btn-reset {
    background: transparent;
    color: var(--roig-alarma);
    border: 1px solid var(--roig-fosc);
    padding: 4px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    letter-spacing: 2px;
}
.btn-reset:hover { background: rgba(255,43,43,0.15); }

/* ========================================================== */
/* PANTALLA 3 · TUTORIAL                                      */
/* ========================================================== */
.tutorial-tauler {
    position: relative;
    flex: 1;
    min-height: 260px;
    border: 2px solid var(--fosfor-fosc);
    background: #000;
    box-shadow:
        0 0 20px rgba(57, 255, 20, 0.35),
        inset 0 0 30px rgba(57, 255, 20, 0.1);
    overflow: hidden;
}

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

#tutorial-spotlight {
    position: absolute;
    border: 2px solid var(--ambar);
    box-shadow: 0 0 20px var(--ambar), inset 0 0 10px var(--ambar);
    border-radius: 50%;
    pointer-events: none;
    animation: spotlight-pulse 1.2s ease-in-out infinite;
    z-index: 5;
}

@keyframes spotlight-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.15); opacity: 0.6; }
}

.tutorial-dialeg {
    border: 2px solid var(--fosfor-fosc);
    background: rgba(0, 20, 0, 0.6);
    padding: 14px 18px;
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.25);
    position: relative;
}

.progres-barra {
    height: 4px;
    background: rgba(57,255,20,0.15);
    border: 1px solid var(--fosfor-fosc);
    margin-bottom: 10px;
    overflow: hidden;
}
.progres-fill {
    height: 100%;
    width: 0%;
    background: var(--fosfor);
    box-shadow: 0 0 8px var(--fosfor);
    transition: width 0.4s ease-out;
}

#tutorial-text {
    font-size: 1.15rem;
    line-height: 1.5;
    min-height: 3em;
    letter-spacing: 0.5px;
}
#tutorial-text b { color: var(--fosfor); text-shadow: 0 0 6px var(--fosfor); }
#tutorial-text i { color: var(--ambar); font-style: normal; }

.tutorial-accions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.btn-tut {
    font-family: 'VT323', monospace;
    font-size: 1rem;
    letter-spacing: 2px;
    background: transparent;
    color: var(--fosfor);
    border: 1px solid var(--fosfor-fosc);
    padding: 8px 18px;
    cursor: pointer;
    transition: all 0.12s;
}
.btn-tut:hover:not(:disabled) {
    background: var(--fosfor-fosc);
    color: #000;
    box-shadow: 0 0 12px rgba(57,255,20,0.5);
}
.btn-tut:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-tut.btn-primari {
    background: var(--fosfor-fosc);
    color: #000;
    border-color: var(--fosfor);
    font-weight: bold;
}
.btn-tut.btn-primari:hover { background: var(--fosfor); box-shadow: 0 0 16px var(--fosfor); }

/* ========================================================== */
/* PANTALLA 4 · JOC                                           */
/* ========================================================== */
#pantalla-joc {
    gap: 10px;
}

#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid var(--fosfor-fosc);
    background: rgba(0, 20, 0, 0.6);
    padding: 8px 14px;
    border-radius: 4px;
    gap: 12px;
    box-shadow:
        0 0 14px rgba(57, 255, 20, 0.35),
        inset 0 0 18px rgba(57, 255, 20, 0.08);
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-left h3 {
    font-size: 1.3rem;
    letter-spacing: 4px;
    text-shadow: 0 0 6px var(--fosfor);
}

.subtitol-hud {
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--fosfor-fosc);
}

.hud-right {
    display: flex;
    gap: 8px;
}

.hud-panel {
    border: 1px solid var(--fosfor-fosc);
    padding: 5px 10px;
    min-width: 90px;
    text-align: center;
    background: rgba(0, 30, 0, 0.5);
    box-shadow: inset 0 0 6px rgba(57, 255, 20, 0.15);
}
.hud-panel .label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--fosfor-fosc);
}
.hud-panel .value {
    display: block;
    font-size: 1.2rem;
    color: var(--fosfor);
    text-shadow: 0 0 6px var(--fosfor);
    font-family: 'Share Tech Mono', monospace;
}

/* ---------- Tauler canvas ---------- */
#tauler-central {
    position: relative;
    flex: 1;
    min-height: 260px;
    border: 2px solid var(--fosfor-fosc);
    background: #000;
    box-shadow:
        0 0 22px rgba(57, 255, 20, 0.4),
        inset 0 0 40px rgba(57, 255, 20, 0.12);
    overflow: hidden;
    border-radius: 6px;
}

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

.canvas-overlay {
    position: absolute;
    top: 8px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: var(--fosfor);
    text-shadow: 0 0 6px var(--fosfor);
    pointer-events: none;
}

.radar-tag { animation: blink 1.2s infinite; }
@keyframes blink {
    0%, 49%, 100% { opacity: 1; }
    50%, 99%      { opacity: 0.3; }
}

/* Missatge flotant de nivell */
#missatge-nivell {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 30;
    pointer-events: none;
    animation: msg-fade 2.2s ease-out forwards;
}
#missatge-nivell h2 {
    font-size: 2.8rem;
    letter-spacing: 7px;
    text-shadow: 0 0 12px var(--fosfor), 0 0 24px var(--fosfor);
}
#missatge-nivell p {
    font-size: 1.1rem;
    letter-spacing: 2px;
    opacity: 0.85;
    margin-top: 4px;
}
@keyframes msg-fade {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- Notificació narrativa flotant ---------- */
#notificacio-joc {
    position: absolute;
    top: 36px;
    left: 50%;
    transform: translateX(-50%) scale(0.7);
    padding: 10px 28px;
    border: 2px solid var(--fosfor);
    background: rgba(0, 20, 0, 0.85);
    font-size: 1.35rem;
    letter-spacing: 4px;
    z-index: 25;
    pointer-events: none;
    opacity: 0;
    color: var(--fosfor);
    text-shadow: 0 0 10px currentColor;
    font-family: 'VT323', monospace;
    white-space: nowrap;
}
#notificacio-joc.alarma {
    border-color: var(--roig-alarma);
    background: rgba(50, 0, 0, 0.88);
    color: var(--roig-alarma);
    box-shadow: 0 0 20px rgba(255, 43, 43, 0.6);
}
#notificacio-joc.encert {
    border-color: var(--fosfor);
    color: var(--fosfor);
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
}
#notificacio-joc.ambar {
    border-color: var(--ambar);
    color: var(--ambar);
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.5);
}
#notificacio-joc.activa {
    animation: notif-pop 1.4s ease-out forwards;
}
@keyframes notif-pop {
    0%   { transform: translateX(-50%) scale(0.6); opacity: 0; }
    14%  { transform: translateX(-50%) scale(1.12); opacity: 1; }
    22%  { transform: translateX(-50%) scale(1); }
    80%  { transform: translateX(-50%) scale(1); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); opacity: 0; }
}

/* ========================================================== */
/* TECLAT DE NOTES (compartit joc + tutorial)                 */
/* ========================================================== */
.teclat-notes {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.tecla-nota {
    background: linear-gradient(180deg, #022f02 0%, #010d01 100%);
    color: var(--fosfor);
    border: 2px solid var(--fosfor-fosc);
    border-radius: 6px;
    padding: 14px 6px;
    cursor: pointer;
    text-shadow: 0 0 6px var(--fosfor);
    box-shadow:
        0 0 10px rgba(57, 255, 20, 0.3),
        inset 0 -4px 0 rgba(0, 0, 0, 0.5),
        inset 0 0 14px rgba(57, 255, 20, 0.1);
    transition: all 0.08s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.tecla-nota .nom {
    font-size: 1.7rem;
    letter-spacing: 2px;
    font-weight: bold;
}
.tecla-nota .tecla {
    font-size: 0.7rem;
    color: var(--fosfor-fosc);
    border: 1px solid var(--fosfor-fosc);
    padding: 1px 5px;
    border-radius: 2px;
    opacity: 0.85;
}
.tecla-nota:hover {
    background: linear-gradient(180deg, #044404 0%, #021402 100%);
    box-shadow:
        0 0 18px rgba(57, 255, 20, 0.6),
        inset 0 0 14px rgba(57, 255, 20, 0.2);
}
.tecla-nota:active,
.tecla-nota.premuda {
    transform: translateY(3px);
    background: #0a6a0a;
    box-shadow:
        0 0 24px rgba(57, 255, 20, 0.9),
        inset 0 0 18px rgba(57, 255, 20, 0.4);
}
.tecla-nota.destacada {
    border-color: var(--ambar);
    box-shadow: 0 0 20px var(--ambar), inset 0 0 14px rgba(255,170,0,0.3);
    animation: tecla-destac 0.8s ease-in-out infinite;
}
@keyframes tecla-destac {
    0%, 100% { box-shadow: 0 0 20px var(--ambar), inset 0 0 14px rgba(255,170,0,0.3); }
    50%      { box-shadow: 0 0 30px var(--ambar), inset 0 0 20px rgba(255,170,0,0.55); }
}

/* ========================================================== */
/* MODALS                                                     */
/* ========================================================== */
.modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 10, 0, 0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(2px);
}

.modal-box {
    border: 2px solid var(--fosfor);
    background: rgba(0, 20, 0, 0.9);
    padding: 30px 40px;
    text-align: center;
    max-width: 540px;
    width: 90%;
    box-shadow:
        0 0 30px rgba(57, 255, 20, 0.6),
        inset 0 0 20px rgba(57, 255, 20, 0.12);
    animation: modal-in 0.35s ease-out;
}

@keyframes modal-in {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.modal-box.alarma {
    border-color: var(--roig-alarma);
    box-shadow: 0 0 30px rgba(255, 43, 43, 0.6), inset 0 0 20px rgba(255, 43, 43, 0.15);
}
.modal-box.alarma h2 {
    color: var(--roig-alarma);
    text-shadow: 0 0 10px var(--roig-alarma);
}

.modal-box h2 {
    font-size: 2rem;
    letter-spacing: 5px;
    margin-bottom: 14px;
    text-shadow: 0 0 10px var(--fosfor), 0 0 20px var(--fosfor);
}

.stats-final {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 18px 0;
}
.stats-final > div {
    border: 1px solid var(--fosfor-fosc);
    padding: 10px 20px;
    background: rgba(0,30,0,0.5);
}
.stats-final .label {
    display: block;
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--fosfor-fosc);
}
.stats-final .value {
    display: block;
    font-size: 1.8rem;
    color: var(--ambar);
    text-shadow: 0 0 10px var(--ambar);
    font-family: 'Share Tech Mono', monospace;
}

.record-msg {
    font-size: 1.2rem;
    color: var(--ambar);
    margin-bottom: 10px;
    letter-spacing: 3px;
    animation: record-blink 0.6s infinite;
}
@keyframes record-blink {
    0%, 100% { opacity: 1; text-shadow: 0 0 12px var(--ambar); }
    50%      { opacity: 0.4; }
}

.desbloquejat {
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--fosfor);
    margin-bottom: 14px;
    animation: record-blink 0.9s infinite;
}

.modal-accions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn-accio {
    font-family: 'VT323', monospace;
    font-size: 1.15rem;
    letter-spacing: 3px;
    background: var(--fosfor-fosc);
    color: #000;
    border: 2px solid var(--fosfor);
    padding: 10px 22px;
    cursor: pointer;
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.5);
    transition: all 0.1s ease-out;
    font-weight: bold;
}

.btn-accio:hover {
    background: var(--fosfor);
    box-shadow: 0 0 24px rgba(57, 255, 20, 0.9);
    transform: scale(1.04);
}

.btn-accio.secundari {
    background: transparent;
    color: var(--fosfor);
    border-color: var(--fosfor-fosc);
    box-shadow: none;
}
.btn-accio.secundari:hover {
    background: rgba(57,255,20,0.12);
    box-shadow: 0 0 12px rgba(57,255,20,0.4);
}

/* ========================================================== */
/* MODE CLAU DE FA (estètica vermella)                        */
/* ========================================================== */
body.mode-fa {
    --fosfor: #ff3333;
    --fosfor-mid: #d42424;
    --fosfor-fosc: #990000;
    --fosfor-tenue: #330000;
}
body.mode-fa .crt-frame {
    background: radial-gradient(ellipse at center, #1a0000 0%, #000 75%);
}
body.mode-fa #tauler-central {
    box-shadow:
        0 0 24px rgba(255, 51, 51, 0.6),
        inset 0 0 40px rgba(255, 51, 51, 0.15);
}

/* ========================================================== */
/* ANIMACIONS UTILITÀRIES                                     */
/* ========================================================== */
.shake { animation: shake 0.35s; }
@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    20%      { transform: translate(-6px, 3px); }
    40%      { transform: translate(5px, -4px); }
    60%      { transform: translate(-4px, -3px); }
    80%      { transform: translate(3px, 4px); }
}

/* ========================================================== */
/* RESPONSIVE                                                 */
/* ========================================================== */
@media (max-width: 760px) {
    .titol-principal { font-size: 2.4rem; letter-spacing: 5px; }
    .btn-menu { min-width: 180px; padding: 14px 18px; }
    #hud { flex-direction: column; align-items: stretch; gap: 8px; }
    .hud-right { flex-wrap: wrap; justify-content: center; }
    .hud-left h3 { font-size: 1rem; letter-spacing: 2px; }
    .tecla-nota .nom { font-size: 1.1rem; }
    .tecla-nota { padding: 10px 4px; }
    .cap-titol h2 { font-size: 1.1rem; letter-spacing: 3px; }
    .nivells-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .stats-final { flex-direction: column; gap: 10px; }
}
