:root {
    --bg: #0f2e40;
    --paper: #fffdf5;
    --muted: #666;
    --accent: #235e6e;
    --dice-size: 64px;
    --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
}

/* SCORE SHEET: effetto foglio con tabella disegnata, NESSUNO scroll interno */
.score-sheet {
    width: 100%;
    background: var(--paper);
    border: var(--sheet-border);
    border-radius: 0;
    /* angoli retti */
    padding: 0;
    overflow: visible;
    /* NO scrollbar interna */
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
}

/* ogni riga stile tabella: bordo nero, angoli retti */
.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid #000;
    /* linee orizzontali nette */
    background: transparent;
    cursor: pointer;
    user-select: none;
}

.score-row:first-child {
    border-top: none
}

.score-row--used {
    background: #f0f0f0;
    color: var(--muted);
    cursor: default
}

.score-name {
    color: rgb(10, 28, 39);
    font-size: 0.95rem
}

.score-value {
    min-width: 50px;
    text-align: right;
    font-weight: 700
}

/* preview potenziale (più piccolo) */
.score-preview {
    font-size: 0.78rem;
    color: var(--muted);
    margin-left: 8px
}

.score {
    min-width: 40px;
    text-align: right;
    font-weight: bold;
}

/* potenziale: grigio e corsivo */
.score.potential {
    color: #777;
    font-style: italic;
}

/* convalidato: nero e normale */
.score.confirmed {
    color: #000;
    font-style: normal;
}

/* DICE AREA */
.dice-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px 0
}

.dice-area__row--launched {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    align-items: center;
    justify-items: center;
    padding: 8px;
}

.dice-area__row--held {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    align-items: center;
    justify-items: center;
    padding: 6px;
}

.dice-slot {
    width: var(--dice-size);
    height: var(--dice-size);
    display: flex;
    align-items: center;
    justify-content: center
}

/* dado */
.dice {
    width: 100%;
    height: 100%;
    background: #fff;
    border: 2px solid #000;
    /* bordo netto come foglio */
    border-radius: 6px;
    /* piccolo arrotondamento visivo, se vuoi a 0 cambia */
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    padding: 8px;
    box-shadow: none;
    cursor: pointer;
    touch-action: manipulation;
    /* transition: transform .12s, opacity .12s; */
    transition: transform 0.3s ease;
}

/* pips */
.pip {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #000;
    opacity: 0;
    transform: scale(.85);
    transition: opacity .12s, transform .12s
}

.die-show .pip {
    opacity: 1;
    transform: scale(1)
}

.p1 {
    grid-area: 1/1
}

.p2 {
    grid-area: 1/2
}

.p3 {
    grid-area: 1/3
}

.p4 {
    grid-area: 2/1
}

.p5 {
    grid-area: 2/2
}

.p6 {
    grid-area: 2/3
}

.p7 {
    grid-area: 3/1
}

.p8 {
    grid-area: 3/2
}

.p9 {
    grid-area: 3/3
}

/* quando il dado nello slot è mantenuto, lo nascondiamo ma lasciamo il suo spazio */
.dice.hidden {
    visibility: hidden
}

/* controlli */
.controls {
    display: flex;
    gap: 50px;
    align-items: center;
    padding: 6px;
    justify-content: center;
}

.roll-button {
    background: var(--accent);
    color: #eeeeee;
    border: none;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer
}

.restart-button {
    background: transparent;
    color: var(--clr-chiaro);
    border: 1px solid var(--clr-chiaro);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer
}

/* 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
}


/* piccole regole per schermi stretti */
@media (max-width:420px) {
    :root {
        --dice-size: 40px;
    }

    /* header */
    .app__header {
        padding: 0 10px 0 10px;
    }

    .score-sheet {
        width: 95%;
        margin: 0 10px 0 10px;
    }

    .score-row {
        padding: 5px 10px
    }

    .dice {
        padding: 2px;
        gap: 4px;
    }

    .pip {
        width: 8px;
        height: 8px;
    }

    .dice-area__row {
        padding: 0px;
        margin: 0 20px 0 20px;
    }

    .app {
        gap: 5px
    }
}