:root {
    --bg: #0f2e40;
    --accent: #235e6e;
    --sheet-border: 2px solid #000;

    --clr-chiaro: #84c1c6;
    --clr-medio: #235e6e;
    --clr-scuro: #0f2e40;
    --clr-scurissimo: rgb(10, 28, 39);
}

/* base */
* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
    background: var(--bg);
    color: #eeeeee;
    -webkit-font-smoothing: antialiased;
    padding: 8px;
    display: flex;
    justify-content: center;
}

.app {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* header */
.app__header {
    display: flex;
    justify-content: space-between;
    align-items: center
}

.app__title {
    font-size: 1.3rem;
    margin: 0
}

.back-button {
    color: var(--clr-chiaro);
    text-decoration: none;
}

.status {
    color: var(--clr-chiaro);
    font-size: 0.95rem
}

/* Mastermind */
.mastermind-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mastermind-board {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    margin: 20px 0;
    background-color: #333;
    border-radius: 10px;
    min-height: 60px;
    width: fit-content;
}

.mastermind-guess-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.mastermind-guess-number {
    width: 35px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2em;
    color: #eee;
    margin-right: 10px;
    flex-shrink: 0;
}

.mastermind-code {
    display: flex;
    gap: 5px;
}

.mastermind-code-peg,
.mastermind-feedback-peg {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

.mastermind-peg-slot {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: #555;
    border: 2px dashed #888;
    cursor: pointer;
    box-sizing: border-box;
}

.mastermind-feedback {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    width: 25px;
    height: 25px;
    flex-shrink: 0;
}

.mastermind-feedback-peg {
    width: 10px;
    height: 10px;
    background-color: #555;
    border: 1px solid #777;
}

.mastermind-rules {
    text-align: center;
    max-width: 400px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #ccc;
    line-height: 1.4;
}

.mastermind-rules .mastermind-feedback-peg {
    display: inline-block;
    vertical-align: middle;
    width: 12px;
    height: 12px;
    border: 1px solid #777;
    margin: 0 2px;
}

/* Colori dei pallini del codice */
.color-red {
    background-color: red;
}

.color-blue {
    background-color: blue;
}

.color-green {
    background-color: green;
}

.color-yellow {
    background-color: yellow;
}

.color-purple {
    background-color: purple;
}

.color-orange {
    background-color: orange;
}

/* Colori dei pallini di feedback */
.mastermind-feedback-peg.color-black {
    background-color: black;
    border-color: #333;
}

.mastermind-feedback-peg.color-white {
    background-color: white;
    border-color: #aaa;
}

/* Area di selezione dei colori */
.mastermind-color-selector {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
    /* Aggiungi un margine anche sotto */
}

.mastermind-color-peg {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    /* Animazione per la selezione */
}

.mastermind-color-peg:hover {
    opacity: 0.8;
}

.mastermind-color-peg.selected {
    border-color: var(--clr-chiaro);
    /* box-shadow: 0 0 8px rgba(255, 255, 255, 0.7); */
    box-shadow: 0 0 15px rgba(132, 193, 198, 0.9);
    /* Effetto luminoso */
}

/* Messaggio di stato */
.mastermind-status {
    margin-top: 20px;
    font-size: 1.3em;
    /* Aumenta la dimensione */
    font-weight: bold;
    text-align: center;
    color: #eee;
    /* Colore chiaro per leggibilità */
    min-height: 2em;
    /* Per evitare salti quando il testo cambia */
}

/* Stili per il pulsante Disabilita */
.mastermind-container .button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Nascondi i pallini originali della selezione colori quando non selezionati */
.mastermind-color-peg:not(.selected) {
    border-color: rgba(255, 255, 255, 0.3);
    /* Bordo più discreto */
}

/* Stili per il codice segreto mostrato a fine gioco */
.secret-code-display {
    display: flex;
    /* Aggiungi questa riga */
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
}

/* Stili bottoni */
.controls {
    display: flex;
    gap: 50px;
    align-items: center;
    padding: 6px;
    justify-content: center;
}

.submit-button {
    width: 110px;
    height: 35px;
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer
}

.restart-button {
    width: 110px;
    height: 35px;
    background: transparent;
    color: var(--clr-chiaro);
    border: 1px solid var(--clr-chiaro);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer
}



/* piccole regole per schermi stretti */
@media (max-width:420px) {

    /* header */
    .app__header {
        padding: 0 10px 0 10px;
    }

    .mastermind-container {
        margin: 0 10px 0 10px;
    }

    .mastermind-rules {
        margin-bottom: 10px;
    }

    .mastermind-color-selector {
        gap: 10px;
        margin-top: 10px;
        margin-bottom: 10px;
    }

    .mastermind-board {
        gap: 10px;
        padding: 10px;
        margin: 10px 0 0 0;
        min-height: 50px;
        min-width: 265px;
    }

    .app {
        gap: 5px
    }
}

/* finestra modale per Ricomincia e Fine partita */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal__content {
    background: var(--accent);
    color: #eeeeee;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    max-width: 300px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.modal__content h2 {
    margin-top: 0;
}

.modal__content button {
    margin: 0.5rem;
}

#modal-buttons button {
    margin: 0.5rem;
    min-width: 50px;
    background: #0f2e40;
    color: var(--clr-chiaro);
    border: 1px solid var(--clr-chiaro);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer
}