/* ------------------------------------- */
/* ARENA COMUNE: SINGLEPLAYER E MULTIPLAYER */
/* ------------------------------------- */

#singleplayerStart,
#multiplayerStart {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(100vw, 56.25dvh);
    height: 100dvh;
    overflow: hidden;
}

#backgroundSingleplayer,
#multiplayerBackground {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    image-rendering: pixelated;
}

#enemySprite,
#playerSprite,
#multiplayerEnemySprite,
#multiplayerPlayerSprite {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    height: auto;
    z-index: 2;
    image-rendering: pixelated;
}

#enemySprite,
#multiplayerEnemySprite {
    top: 25%;
    width: 42%;
}

#playerSprite,
#multiplayerPlayerSprite {
    bottom: 5%;
    width: 60%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* ------------------------------------- */
/* CSS DEL SINGLEPLAYER */
/* ------------------------------------- */

#throwButton {
    position: absolute;
    bottom: 3%;
    right: 5%;

    width: 90px;
    height: 90px;

    border-radius: 50%;
    border: 5px solid black;

    background-color: #b94f19;
    color: white;

    font-family: "Press Start 2P";
    font-size: 10px;

    z-index: 3;
    cursor: pointer;
}

#shitSprite {
    position: absolute;
    width: 60px;
    height: auto;
    rotate: 270;

    left: 0;
    top: 0;

    transform: translate(-50%, -50%);
    transform-origin: center;

    z-index: 3;
    image-rendering: pixelated;
    display: none;
    pointer-events: none;
}

#shitSplatSprite {
    position: absolute;
    width: 90px;
    height: auto;

    display: none;

    transform: translate(-50%, -50%);
    z-index: 4;
    image-rendering: pixelated;
    pointer-events: none;
}

#throwCounter {
    position: absolute;
    top: 3%;
    right: 5%;

    padding: 10px;
    background-color: rgb(128, 66, 66);
    color: white;

    border: 3px solid black;
    border-radius: 5px;

    font-size: 12px;
    z-index: 5;
}
/* ------------------------------------- */
/* CSS DELLA LOBBY */
/* ------------------------------------- */

#roomsContainer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 15px;

    width: 90%;
    max-width: 800px;

    margin: 20px auto;
}

.roomTitle {
    
    font-size: 16px;
    text-align: center;
    line-height: 1.5;
    color: lightgreen;
}

.roomPlayers {
    
    font-size: 12px;
    text-align: center;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.roomButton:hover:not(:disabled) {
    background-color: #946020;
}

.roomButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.room {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;

    width: 100%;
    padding: 3px;

    cursor: pointer;
}

.roomButton {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    gap: 10px;

    width: 100%;
    min-width: 0;
    min-height: 100px;

    padding: 15px;
    box-sizing: border-box;

    background-color: #704619;
    color: white;

    border: 3px solid black;

    font-family: "Press Start 2P", cursive;

    cursor: pointer;
}

@media (max-width: 600px) {

    #roomsContainer {
        width: 95%;
        gap: 8px;
        margin: 15px auto;
    }

    .roomButton {
        min-height: 85px;
        padding: 8px;
        gap: 8px;
    }

    .roomTitle {
        font-size: 12px;
    }

    .roomPlayers {
        font-size: 8px;
    }
}

#multiplayerLobby {
    width: 100%;
    min-height: 100dvh;

    box-sizing: border-box;
    padding: 15px;

    text-align: center;
    height: 100dvh;
    overflow-y: auto;
}

.roomCharacters {
    color: gold;
    font-size: 11px;
    text-align: right;
}

@media (max-width: 600px) {
    .roomCharacters {
        font-size: 9px;
    }
}
/* ------------------------------------- */
/* CSS DELLA WAITING ROOM */
/* ------------------------------------- */

#roomName {
    font-size: 40px;
}

#multiplayerWaiting {
    display: flex;
    flex-direction: row;
    align-items: center;

    gap: 30px;
}

#backToLobby {
    margin-top: 20px;
}

#waitingPlayer,
#waitingEnemy {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    flex: 1;
    min-width: 0;
    min-height: 120px;
    gap: 10px;
}

#playerIconImg,
#enemyIconImg {
    width: 320px;
    height: 320px;
    border-radius: 10px;
    border-color: black;
    border-style: solid;
    object-fit: contain;
    image-rendering: pixelated;
}

#playerWaitingName,
#enemyWaitingName {
    font-size: 20px;
    text-align: center;
    line-height: 1.8;
    margin: 0;
}

@media (max-width: 600px) {
    #playerIconImg,
    #enemyIconImg {
        width: 50px;
        height: 50px;
    }

    #playerWaitingName,
    #enemyWaitingName {
        font-size: 9px;
    }
}
/* ------------------------------------- */
/* CSS DEL MULTIPLAYER: COMANDI E HUD */
/* ------------------------------------- */

#multiplayerActions {
    position: absolute;
    bottom: 3%;
    left: 3%;
    width: 30%;

    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;

    z-index: 3;
}

/* I tre pulsanti delle mosse */
#attackButton,
#defendButton,
#reloadButton {
    box-sizing: border-box;
    width: 100%;
    aspect-ratio: 1 / 1;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 4px;
    background-color: #b94f19;
    border: 3px solid black;
    border-radius: 5px;
    cursor: pointer;
}

/* Attacco e difesa sulla prima riga */
#attackButton {
    grid-column: 1 / 3;
}

#defendButton {
    grid-column: 3 / 5;
}

/* Ricarica al centro della seconda riga */
#reloadButton {
    grid-column: 2 / 4;
}

/* Immagini tutte della stessa dimensione */
#attackImg,
#defendImg,
#loadImg {
    display: block;
    width: 65%;
    height: 65%;
    object-fit: contain;
    image-rendering: pixelated;
}

/* PRONTO occupa l'intera terza riga */
#readyButton {
    grid-column: 1 / 5;

    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    aspect-ratio: auto;

    padding: 10px 4px;

    font-family: "Press Start 2P", cursive;
    font-size: clamp(7px, 2vw, 10px);
    overflow-wrap: anywhere;
    line-height: 1.5;

    background-color: #b94f19;
    color: white;
    border: 3px solid black;
    border-radius: 5px;
    cursor: pointer;
}

#multiplayerActions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#multiplayerActions button.selectedAction {
    background-color: #87af4c;
    border-color: #1d5c20;
}

@media (max-width: 600px), (max-height: 760px) {
    #multiplayerActions {
        gap: 4px;
    }

    #multiplayerActions button {
        border-width: 2px;
    }

    #readyButton {
        min-height: 32px;
        font-size: 7px;
    }
}

#enemyHud,
#playerHud {
    position: absolute;
    right: 3%;
    z-index: 5;

    display: flex;
    flex-direction: column;
    gap: 6px;

    box-sizing: border-box;
    max-width: 43%;
    padding: 10px;

    background-color: rgb(128, 66, 66);
    border: 3px solid black;
    border-radius: 5px;
}

#enemyHud {
    top: 3%;
}

#playerHud {
    bottom: 3%;
}

#playerHp,
#playerAmmo {
    display: flex;
    justify-content: center;
    align-items: center;
}

#playerAmmo {
    color: white;
    text-align: center;
}

.hudIcon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 1;
    min-width: 0;
}

#disconnectPopup {
    position: fixed;
    inset: 0;
    z-index: 1000;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 20px;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.8);
}

#disconnectPopupContent {
    width: 100%;
    max-width: 420px;
    box-sizing: border-box;

    padding: 25px 20px;
    text-align: center;

    background-color: #704619;
    border: 5px solid black;
    border-radius: 6px;

    color: white;
    font-family: "Press Start 2P", cursive;
}

#disconnectPopupContent h2 {
    font-size: 15px;
    color: #ffce54;
    line-height: 1.8;
}

#disconnectPopupContent p {
    font-size: 10px;
    line-height: 2;
    margin: 20px 0;
}

#disconnectOkButton {
    padding: 12px 32px;

    background-color: #b94f19;
    border: 3px solid black;
    border-radius: 4px;

    color: white;
    font-family: "Press Start 2P", cursive;
    font-size: 12px;
    cursor: pointer;
}

#disconnectOkButton:hover {
    background-color: #e46a2f;
}

.gameResultPopup {
    position: fixed;
    inset: 0;
    z-index: 1000;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 20px;
    box-sizing: border-box;

    background-color: rgba(0, 0, 0, 0.85);
}

.gameResultContent {
    width: 100%;
    max-width: 420px;

    box-sizing: border-box;
    padding: 25px 20px;

    text-align: center;

    background-color: #704619;
    border: 5px solid black;
    border-radius: 6px;

    color: white;
    font-family: "Press Start 2P", cursive;
}

.gameResultContent h2 {
    font-size: 18px;
    color: gold;
    line-height: 1.8;
}

.gameResultContent p {
    font-size: 10px;
    line-height: 2;
}

.gameResultContent button {
    padding: 12px 30px;
    margin-top: 15px;

    background-color: #b94f19;
    border: 3px solid black;
    border-radius: 5px;

    color: white;
    font-family: "Press Start 2P", cursive;
    cursor: pointer;
}