/* ========================================
   Reset di base
   ========================================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: black;

    /* Centra l'area di gioco nella finestra */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

/* Contenitore che racchiude canvas, HUD e schermate sovrapposte.
   `position: relative` serve da riferimento per gli elementi assoluti.
   Nessun line-height qui: verrebbe ereditato da menu e schede. */
#areaGioco {
    position: relative;
}

/* Font del gioco, usato da HUD, menu e testi */
#hud,
#menu,
#displayText,
#loadingScreen,
canvas {
    font-family: 'Bitcount Prop Double Ink', sans-serif;
}

/* ========================================
   Canvas
   ========================================== */
canvas {
    display: block;
}

/* ========================================
   HUD
   ========================================== */
#hud {
    position: absolute;
    display: flex;
    width: 100%;
    align-items: center;
    padding: 20px;
    z-index: 10;
}

/* Metà HUD di un giocatore (vita, stamina e ultimate) */
.hud-lato {
    position: relative;
    flex: 1;            /* si divide lo spazio disponibile con l'altra metà */
    min-width: 0;
    height: 44px;       /* 20 vita + 8 ultimate + margini */
}

.hud-lato.sinistra {
    display: flex;
    justify-content: flex-end;
    border-top: 4px solid black;
    border-left: 4px solid black;
    border-bottom: 4px solid black;
}

.hud-lato.destra {
    border-top: 4px solid black;
    border-right: 4px solid black;
    border-bottom: 4px solid black;
}

/* Striscia rossa di fondo: si vede quando la vita scende */
.barra-fondo {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    background-color: red;
    height: 20px;
}

/* Fondo della barra ultimate, sotto la stamina */
.barra-fondo-ultimate {
    top: 24px;
    height: 10px;
    background-color: #111111;
    border-top: 1px solid #000000;
}

/* Riempimento sovrapposto: la larghezza in % è impostata da index.js */
.barra-valore {
    position: absolute;
    width: 100%;
}

#player-health {
    background: #595818;
    right: 0;
    top: 0;
    height: 20px;
}

#player-stamina {
    background: #482D20;
    right: 0;
    top: 14px;
    height: 6px;
}

#player-ultimate {
    background: #e7c34a;
    right: 0;
    top: 27px;
    height: 6px;
    width: 0%;
}

#enemy-health {
    background: blue;
    left: 0;
    right: 0;
    top: 0;
    height: 20px;
}

#enemy-stamina {
    background: turquoise;
    left: 0;
    right: 0;
    top: 14px;
    height: 6px;
}

#enemy-ultimate {
    background: #e7a23a;
    left: 0;
    right: 0;
    top: 27px;
    height: 6px;
    width: 0%;
}

/* Timer centrale */
#timer {
    background-color: black;
    height: 50px;
    width: 100px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid black;
    font-size: 35px;
    color: white;
}

/* ========================================
   Testo di fine partita
   ========================================== */
#displayText {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    color: aliceblue;
    font-size: 50px;
    z-index: 20;
    text-align: center;
}

/* ========================================
   Schermate sovrapposte (caricamento e menu)
   ========================================== */
/* La visibilità è gestita da js/Stato.js tramite display */
.schermata {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: black;
    z-index: 40;
}

/* ========================================
   Schermata di caricamento
   ========================================== */
#loadingScreen {
    gap: 24px;
}

/* Logo del gioco, usato sia nel caricamento sia nel menu */
.logo {
    width: 180px;
    height: auto;
}

#loadingTesto {
    font-size: 30px;
    color: #888888;
}

/* ========================================
   Menu
   ========================================== */
#menuLogo {
    width: 200px;
    height: auto;
    margin-bottom: 12px;
}

#menuTitolo {
    font-size: 42px;
    color: white;
    margin-bottom: 36px;
    letter-spacing: 3px;
    text-align: center;
    max-width: 1400px;
    line-height: 1.2;
}

#menuVoci {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

/* Singola voce di menu */
.voce {
    font-size: 40px;
    color: #777777;
    user-select: none;
}

/* Voce evidenziata dalla tastiera */
.voce.selezionata {
    color: white;
}

/* Voce non ancora disponibile: mostrata ma non selezionabile */
.voce.wip {
    color: #444444;
}

.etichetta-wip {
    font-size: 18px;
    color: #aa8800;
    margin-left: 14px;
    vertical-align: middle;
}

/* ========================================
   Selezione del personaggio
   ========================================== */
#selezione {
    gap: 14px;
    padding: 20px;
    overflow: hidden;
}

#selezioneTitolo {
    font-size: 34px;
    color: white;
    letter-spacing: 3px;
}

/* Schede dei due giocatori, a sinistra e a destra */
#selezioneInfo {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 20px;
}

.info-lato {
    flex: 1;
    min-height: 78px;
    padding: 8px 14px;
    border: 3px solid transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#infoP1 {
    border-color: #4a7dff;
}

#infoP2 {
    border-color: #ff7a4a;
    text-align: right;
}

.info-nome {
    font-size: 26px;
    color: white;
}

.info-ok {
    font-size: 16px;
    color: #7dff7d;
    margin-left: 12px;
    vertical-align: middle;
}

.info-archetipo {
    font-size: 18px;
    color: #999999;
}

.info-stat {
    font-size: 16px;
    color: #cccccc;
}

.info-ultimate {
    font-size: 14px;
    color: #e7c34a;
    margin-top: 4px;
}

/* Griglia dei personaggi */
#selezioneGriglia {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 1400px;
}

.cella {
    width: 132px;
    padding: 6px;
    border: 3px solid #333333;
    background-color: #0d0d0d;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* Cursore del giocatore 1 */
.cella.p1 {
    border-color: #4a7dff;
    background-color: #101a33;
}

/* Cursore del giocatore 2 */
.cella.p2 {
    border-color: #ff7a4a;
    background-color: #331a10;
}

/* Entrambi i cursori sulla stessa cella */
.cella.p1.p2 {
    border-color: #b06aff;
    background-color: #1f1033;
}

/* Scelta confermata */
.cella.confermato {
    box-shadow: inset 0 0 14px rgba(255, 255, 255, 0.75);
}

/* Ritratto: mostra solo il personaggio, ritagliato dal foglio di idle */
.ritratto {
    width: 110px;
    height: 110px;
    background-repeat: no-repeat;
}

.cella-nome {
    font-size: 14px;
    color: #dddddd;
    text-align: center;
}

#selezioneIstruzioni {
    font-size: 16px;
    color: #888888;
    text-align: center;
}

/* ========================================
   Report bug (tasto R)
   ========================================== */
.report-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.82);
    z-index: 60;
    padding: 24px;
}

.report-overlay.aperto {
    display: flex;
}

.report-pannello {
    width: min(760px, 96vw);
    background-color: #0d0d12;
    border: 2px solid #ff4d4d;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 0 30px rgba(255, 77, 77, 0.25);
}

.report-titolo {
    font-size: 30px;
    color: #ff6b6b;
    letter-spacing: 2px;
}

.report-istruzioni {
    font-size: 15px;
    color: #999999;
    line-height: 1.4;
}

#reportTesto {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    background-color: #050508;
    color: #eeeeee;
    border: 1px solid #333333;
    border-radius: 6px;
    padding: 12px;
    font-family: inherit;
    font-size: 16px;
    box-sizing: border-box;
}

#reportTesto:focus {
    outline: 2px solid #ff4d4d;
}

.report-riga {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.report-bottone {
    background-color: #ff4d4d;
    color: #050508;
    border: 0;
    border-radius: 4px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
}

.report-bottone:hover {
    background-color: #ff7373;
}

.report-bottone.secondario {
    background-color: #333333;
    color: #dddddd;
}

.report-bottone.secondario:hover {
    background-color: #444444;
}

.report-stato {
    font-size: 14px;
    color: #9adf9a;
    min-height: 20px;
}

/* ========================================
   Menu di pausa
   ========================================== */
/* Sopra la partita: sfondo semitrasparente invece che nero pieno */
#menu.pausa {
    background-color: rgba(0, 0, 0, 0.82);
}

#menu.pausa #menuLogo {
    display: none;
}

#menu.pausa #menuTitolo {
    margin-bottom: 24px;
}

/* Pulsante report bug nell'angolo del menu di pausa */
#pausaReport {
    display: none;
    position: absolute;
    right: 22px;
    bottom: 22px;
    background-color: #1a1a1a;
    color: #ff8a8a;
    border: 1px solid #ff4d4d;
    border-radius: 4px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 15px;
    letter-spacing: 1px;
    cursor: pointer;
}

#menu.pausa #pausaReport {
    display: block;
}

#pausaReport:hover {
    background-color: #ff4d4d;
    color: #050508;
}

/* ========================================
   VS ONLINE
   ========================================== */
/* Pannello per digitare il codice della stanza */
.online-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 60;
}

.online-pannello {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 460px;
    padding: 28px 34px;
    text-align: center;
    background-color: #0c0c0c;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
}

.online-titolo {
    font-size: 28px;
    letter-spacing: 2px;
    color: white;
}

.online-stato {
    font-size: 16px;
    line-height: 1.4;
    color: #b8b8b8;
}

.online-campo {
    width: 240px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 42px;
    letter-spacing: 14px;
    text-align: center;
    text-transform: uppercase;
    color: white;
    background-color: #050508;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    outline: none;
}

.online-campo:focus {
    border-color: #7dff7d;
}

.online-riga {
    display: flex;
    gap: 14px;
}

.online-bottone {
    padding: 10px 22px;
    font-family: inherit;
    font-size: 18px;
    letter-spacing: 1px;
    color: #050508;
    background-color: #7dff7d;
    border: 1px solid #7dff7d;
    border-radius: 4px;
    cursor: pointer;
}

.online-bottone.secondario {
    color: #b8b8b8;
    background-color: transparent;
    border-color: #3a3a3a;
}

/* Codice della stanza e stato della connessione */
.online-badge {
    display: none;
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    font-size: 16px;
    letter-spacing: 1px;
    color: #7dff7d;
    background-color: rgba(0, 0, 0, 0.75);
    border: 1px solid #2f2f2f;
    border-radius: 4px;
    z-index: 70;
    pointer-events: none;
}

/* ========================================
   Comandi touch (telefono e tablet)
   ========================================== */
/* Livello trasparente sopra il canvas: le zone attive riattivano i tocchi,
   il centro resta libero per non coprire il combattimento. */
.comandi-touch {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 16px 18px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    z-index: 35;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    pointer-events: none;
}

.comandi-touch > * {
    pointer-events: auto;
}

.zona-leva {
    display: flex;
    align-items: center;
}

/* Leva virtuale: il pomello si trascina, la base resta ferma */
.leva-touch {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 136px;
    height: 136px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.45));
    touch-action: none;
}

.leva-touch.attiva {
    border-color: #7dff7d;
    background: radial-gradient(circle, rgba(125, 255, 125, 0.18), rgba(0, 0, 0, 0.45));
}

.leva-pomello {
    width: 58px;
    height: 58px;
    border: 2px solid rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    pointer-events: none;
}

.zona-tasti {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.riga-tasti {
    display: flex;
    align-items: flex-end;
    gap: 14px;
}

/* Sigla del giocatore: compare solo con due gruppi sullo stesso schermo */
.etichetta-giocatore {
    font-size: 12px;
    letter-spacing: 2px;
    color: #9a9a9a;
}

.tasto-touch {
    width: 76px;
    height: 76px;
    font-family: inherit;
    font-size: 15px;
    letter-spacing: 1px;
    color: white;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    touch-action: none;
}

.tasto-touch.attacco {
    color: #ffb3a1;
    border-color: #ff6b4a;
}

.tasto-touch.parata {
    color: #c3d6ff;
    border-color: #8ab4ff;
}

.tasto-touch.ultimate {
    width: 68px;
    height: 68px;
    font-size: 13px;
    color: #ffe9a1;
    border-color: #ffd34d;
}

.tasto-touch.premuto {
    color: white;
    background: rgba(255, 255, 255, 0.25);
}

/* Due giocatori sullo stesso schermo: comandi più compatti per stare in due */
.comandi-touch.due-giocatori .leva-touch {
    width: 108px;
    height: 108px;
}

.comandi-touch.due-giocatori .leva-pomello {
    width: 46px;
    height: 46px;
}

.comandi-touch.due-giocatori .riga-tasti {
    gap: 8px;
}

.comandi-touch.due-giocatori .tasto-touch {
    width: 58px;
    height: 58px;
    font-size: 12px;
}

/* Telefono in verticale: invito a ruotarlo */
.comandi-touch.verticale::before {
    content: 'Gira il telefono in orizzontale per giocare meglio';
    position: absolute;
    top: -34px;
    left: 0;
    right: 0;
    font-size: 13px;
    text-align: center;
    color: #b8b8b8;
    pointer-events: none;
}

/* Schermi stretti (telefono): comandi più piccoli e, con due giocatori,
   due file per non farli uscire dallo schermo */
@media (max-width: 700px) {
    .comandi-touch {
        padding: 8px 10px 12px;
    }

    .leva-touch {
        width: 112px;
        height: 112px;
    }

    .leva-pomello {
        width: 48px;
        height: 48px;
    }

    .riga-tasti {
        gap: 10px;
    }

    .tasto-touch {
        width: 64px;
        height: 64px;
        font-size: 13px;
    }

    .tasto-touch.ultimate {
        width: 56px;
        height: 56px;
        font-size: 11px;
    }

    .comandi-touch.due-giocatori {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .comandi-touch.due-giocatori .leva-touch {
        width: 84px;
        height: 84px;
    }

    .comandi-touch.due-giocatori .leva-pomello {
        width: 36px;
        height: 36px;
    }

    .comandi-touch.due-giocatori .tasto-touch {
        width: 48px;
        height: 48px;
        font-size: 10px;
    }

    .comandi-touch.due-giocatori .riga-tasti {
        gap: 6px;
    }
}

/* ========================================
   Keybinds
   ========================================== */
#keybinds {
    gap: 14px;
}

#keybindsTitolo {
    font-size: 40px;
    letter-spacing: 4px;
    color: white;
}

#keybindsElenco {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 460px;
    max-height: 66vh;
    overflow-y: auto;
    padding-right: 8px;
}

.keybinds-gruppo {
    margin: 10px 0 2px;
    font-size: 16px;
    letter-spacing: 2px;
    color: #7dff7d;
}

.keybinds-riga {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    padding: 6px 12px;
    font-size: 20px;
    color: #9a9a9a;
    border: 1px solid transparent;
    border-radius: 4px;
}

.keybinds-riga.selezionata {
    color: white;
    background-color: rgba(255, 255, 255, 0.06);
    border-color: #3a3a3a;
}

.keybinds-riga.in-ascolto {
    color: #ffd34d;
    border-color: #ffd34d;
}

.keybinds-tasto {
    min-width: 200px;
    text-align: right;
    color: inherit;
}

.keybinds-stato {
    max-width: 560px;
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
    color: #b8b8b8;
}

/* ========================================
   Suggerimento sotto le voci di menu
   ========================================== */
.menu-suggerimento {
    margin-top: 26px;
    font-size: 15px;
    letter-spacing: 1px;
    color: #777777;
    text-align: center;
}

/* Scheda dell'avversario in VS ONLINE */
.info-nome.avversario {
    color: #ff7a4a;
}

/* ========================================
   Schermi stretti (telefono in verticale, tablet piccoli)
   ========================================== */
@media (max-width: 820px), (max-height: 620px) {
    #menuLogo {
        width: 116px;
        margin-bottom: 8px;
    }

    #menuTitolo {
        margin-bottom: 16px;
        font-size: 24px;
        letter-spacing: 2px;
    }

    #menuVoci {
        gap: 10px;
    }

    .voce {
        font-size: 24px;
    }

    .menu-suggerimento {
        margin-top: 14px;
        font-size: 12px;
    }

    #pausaReport {
        right: 10px;
        bottom: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }

    /* Selezione: schede compatte e griglia che può scorrere */
    #selezione {
        gap: 8px;
        padding: 10px;
        overflow-y: auto;
        justify-content: flex-start;
    }

    #selezioneTitolo {
        font-size: 20px;
        letter-spacing: 2px;
    }

    #selezioneInfo {
        gap: 8px;
        flex-wrap: wrap;
    }

    .info-lato {
        min-height: 0;
        padding: 4px 8px;
        border-width: 2px;
    }

    .info-nome {
        font-size: 15px;
    }

    .info-ok {
        margin-left: 6px;
        font-size: 11px;
    }

    .info-archetipo,
    .info-stat {
        font-size: 11px;
    }

    .info-ultimate {
        display: none;
    }

    #selezioneGriglia {
        gap: 6px;
    }

    .cella {
        width: 80px;
        padding: 4px;
        border-width: 2px;
        gap: 3px;
    }

    .cella-nome {
        font-size: 10px;
    }

    #selezioneIstruzioni {
        font-size: 11px;
        line-height: 1.4;
    }

    /* Keybinds: righe più strette */
    #keybindsTitolo {
        font-size: 24px;
        letter-spacing: 2px;
    }

    #keybindsElenco {
        min-width: 0;
        width: 92%;
        max-height: 70vh;
    }

    .keybinds-riga {
        padding: 4px 8px;
        gap: 12px;
        font-size: 15px;
    }

    .keybinds-tasto {
        min-width: 120px;
    }

    .keybinds-stato {
        font-size: 12px;
        padding: 0 12px;
    }

    /* Pannelli di online, report e stanza */
    .online-pannello,
    .report-pannello {
        width: 92%;
        max-width: 420px;
        padding: 18px;
    }

    .online-titolo {
        font-size: 22px;
    }

    .online-campo {
        width: 190px;
        font-size: 32px;
        letter-spacing: 10px;
    }

    #reportTesto {
        min-height: 90px;
    }
}

/* ========================================
   Pulsanti della selezione su telefono
   ========================================== */
.selezione-comandi {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    padding: 4px 8px;
}

.gruppo-selezione {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gruppo-nome {
    font-size: 14px;
    letter-spacing: 1px;
    color: #9a9a9a;
}

.tasto-selezione {
    min-width: 52px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 16px;
    color: white;
    background-color: rgba(0, 0, 0, 0.55);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    touch-action: manipulation;
}

.tasto-selezione.conferma {
    font-size: 14px;
    color: #7dff7d;
    border-color: #7dff7d;
}

.tasto-selezione:active {
    background-color: rgba(255, 255, 255, 0.22);
}
