/* Variabili Colori, Prevenzione Fuori Bordi, Aspetto */ 
:root { 
    --neon-blue: #00f2ff; 
    --neon-pink: #ff0055; 
    --bg-dark: #0a0a0c; 
    --led-green: #39ff14; 
    --grey: #A9A9A9; 
    --phantom-gold: #ffcc00; /* Colore per la fase intermedia */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body { 
    margin: 0; 
    background: var(--bg-dark); 
    color: white; 
    font-family: monospace; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 100vh; 
    overflow: hidden; 
}

/* Interfaccia iniziale */
.panel { width: 95%; max-width: 380px; }
.neon-title { font-size: 1.8rem; text-align: center; margin-bottom: 20px; letter-spacing: 3px; color: #fff; }
.neon-title span { color: var(--neon-pink); text-shadow: 0 0 10px var(--neon-pink), 0 0 20px var(--neon-pink); }
.card { background: #0f0f13; border-radius: 15px; padding: 25px 15px; border: 1px solid #222; display: flex; flex-direction: column; align-items: center; position: relative; width: 100%; min-height: 480px; }

/* Manuale Power Database */
.manual-terminal { border: 1px solid var(--neon-blue); text-align: left !important; padding: 20px; }
.terminal-header { font-size: 0.7rem; color: var(--neon-blue); margin-bottom: 15px; border-bottom: 1px solid #222; padding-bottom: 5px; }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.manual-col h3 { font-size: 0.8rem; margin-bottom: 10px; letter-spacing: 1px; }
.power-item { font-size: 0.65rem; color: #888; margin-bottom: 8px; line-height: 1.2; }
.power-item span { color: #fff; font-weight: bold; display: block; font-size: 0.7rem; }
.blue-text { color: var(--neon-blue); }
.pink-text { color: var(--neon-pink); }
.terminal-footer { font-size: 0.5rem; color: #333; margin-top: 20px; text-align: center; letter-spacing: 2px; }

/* Punteggio */
.match-score { position: absolute; top: 15px; left: 15px; display: flex; align-items: center; background: rgba(255,255,255,0.03); padding: 5px 12px; border-radius: 6px; }
.score-display { display: flex; align-items: center; gap: 8px; }
.score-box { display: flex; flex-direction: column; align-items: center; }
.score-label { font-size: 0.5rem; color: #444; font-weight: bold; text-transform: uppercase; margin-bottom: 2px; }
#score-me, #score-remote { font-size: 1.2rem; font-weight: 900; color: var(--neon-blue); line-height: 1; }
.score-divider { color: #333; margin: 8px 2px 0 2px; font-weight: bold; }

/* Stato e Status Bar */
.led { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #333; transition: 0.3s; cursor: pointer; }
.led-on { background: var(--led-green); box-shadow: 0 0 10px var(--led-green); }
.status-bar { width: 100%; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #222; padding-bottom: 10px; margin-bottom: 5px; }
#status-text { font-size: 0.7rem; color: #444; }

/* Timer */
.timer-container { width: 100%; display: flex; justify-content: center; margin-top: 45px; margin-bottom: 10px; }
#timer-display { font-size: 3.5rem; color: var(--neon-pink); font-weight: bold; text-shadow: 0 0 15px rgba(255, 0, 85, 0.3); }

/* Id Display e Input */
.id-display { font-size: 2.5rem; font-weight: 900; color: var(--neon-pink); letter-spacing: 5px; text-align: center; width: 100%; margin: 0; display: block; }
.btn-copy { margin: 10px auto 20px auto !important; display: table; background: none; border: 1px solid #333; color: #555; font-size: 0.6rem; padding: 5px 12px; border-radius: 4px; cursor: pointer; }
#peer-id-input, #secret-word-input { width: 100%; height: 55px; background: rgba(255,255,255,0.05) !important; border: none !important; border-bottom: 2px solid #333 !important; color: var(--grey) !important; text-align: center; font-size: 1.1rem; border-radius: 0 !important; margin-bottom: 20px !important; transition: 0.3s; }
#peer-id-input:focus { border-bottom-color: var(--neon-blue) !important; }
#secret-word-input:focus { border-bottom-color: var(--neon-pink) !important; }

/* Centratura Schermata Master */
#master-section { display: flex; flex-direction: column; align-items: center; width: 100%; justify-content: center; text-align: center; min-height: 200px; }

/* Barra del Rank */
.rank-container { width: 100%; }
.rank-bar-bg { width: 100%; height: 4px; background: #000; overflow: hidden; }
.rank-bar-fill { height: 100%; width: 0%; transition: width 1.5s ease; }
.rank-label { font-size: 0.6rem; margin-top: 5px; text-align: center; font-weight: bold; margin-bottom: 12px}

/* Bottoni Main */
.btn-main { width: 100%; height: 60px; border-radius: 8px; border: none; font-weight: bold; font-size: 1.1rem; letter-spacing: 2px; text-transform: uppercase; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.blue { background: var(--neon-blue); color: #000; }
.pink { background: var(--neon-pink); color: #fff; margin-bottom: 12px }
.btn-main:active { transform: scale(0.96); }
.btn-reset { margin-top: 20px ; margin-bottom: 5px ; background: transparent; border: none; color: rgba(255, 255, 255, 0.1); font-size: 0.65rem; cursor: pointer; font-family: monospace; transition: 0.3s; letter-spacing: 1px; text-transform: uppercase; }
.btn-reset:hover { color: var(--neon-pink); }

/* Poteri */
.powers-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-bottom: 10px }
.btn-pwr { height: 45px; background: #000; border: 1px solid #222; color: #333; font-size: 0.65rem; border-radius: 8px; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 5px; }
.btn-pwr:not(:disabled) { border-color: var(--neon-blue); color: var(--neon-blue); }
.btn-pwr.master:not(:disabled) { border-color: var(--neon-pink); color: var(--neon-pink); }

/* Effetti Speciali */
.effect-blackout { filter: brightness(0); pointer-events: none; transition: 0.3s; }
.effect-glitch { animation: glitch-anim 0.2s infinite; filter: hue-rotate(90deg); }
.effect-fog { filter: blur(8px); transition: 0.5s; }
.effect-shake { animation: letterShake 0.2s infinite; }

@keyframes glitch-anim { 0% { transform: translate(0); } 20% { transform: translate(-5px, 5px); } 40% { transform: translate(-5px, -5px); } 60% { transform: translate(5px, 5px); } 80% { transform: translate(5px, -5px); } 100% { transform: translate(0); } }
@keyframes letterShake { 0% { transform: translate(0,0); } 50% { transform: translate(1px, -1px); } 100% { transform: translate(0,0); } }

/* Tastiera e Parola */
#keyboard { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; width: 100%; }
.key { aspect-ratio: 1/1; background: #1a1a1f; border: none; border-radius: 6px; color: white; font-weight: bold; cursor: pointer; }
.key.used { opacity: 0.05; pointer-events: none; }
#word-display { display: flex; gap: 6px; min-height: 40px; margin-top: 10px; margin-bottom: 30px}
.letter-slot { width: 22px; border-bottom: 2px solid #333; font-size: 1.8rem; text-align: center; color: var(--neon-blue); font-weight: bold; }

/* Overlays e Rank Up */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.95); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 2000; }
.overlay-card { background: #000; padding: 40px 20px; border: 1px solid #222; border-radius: 20px; text-align: center; width: 90%; max-width: 380px; }

.overlay-rank-up {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); display: flex; align-items: center;
    justify-content: center; z-index: 9999;
}
.rank-up-content {
    background: #000; padding: 40px; text-align: center;
    border-radius: 15px; border: 1px solid white;
    animation: rank-entry 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes rank-entry {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes glitch-fast {
    0% { clip-path: inset(50% 0 30% 0); transform: translate(-5px); }
    20% { clip-path: inset(10% 0 80% 0); transform: translate(5px); }
    100% { clip-path: inset(50% 0 30% 0); transform: translate(-5px); }
}

.win-glow { color: var(--neon-blue) !important; text-shadow: 0 0 15px var(--neon-blue); text-transform: uppercase; }
.lose-glow { color: var(--neon-pink) !important; text-shadow: 0 0 15px var(--neon-pink); text-transform: uppercase; }
.hidden { display: none !important; }
