:root {
    --felt: #1f7a4d;
    --felt-dark: #17603c;
    --edge: #0e4429;
    --gold: #f0b429;
    --ink: #12301f;
    --cream: #f6f3e7;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--edge);
    color: var(--cream);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

.table {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 16px;
    background: radial-gradient(ellipse at 50% 35%, var(--felt) 0%, var(--felt-dark) 55%, var(--edge) 100%);
}

.scores {
    display: flex;
    gap: 10px;
    width: min(560px, 100%);
}
.player {
    flex: 1;
    background: rgba(0, 0, 0, .22);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 10px 14px;
    text-align: center;
    transition: border-color .2s, background .2s;
}
.player.active {
    border-color: var(--gold);
    background: rgba(0, 0, 0, .34);
}
.player .name {
    font-size: 13px;
    letter-spacing: .1em;
    text-transform: uppercase;
    opacity: .8;
}
.player .score {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.turn {
    font-size: 15px;
    letter-spacing: .04em;
    opacity: .95;
}
.turn strong {
    color: var(--gold);
    font-size: 20px;
    font-variant-numeric: tabular-nums;
}

.tray {
    width: min(560px, 100%);
    min-height: 190px;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: rgba(0, 0, 0, .18);
    border-radius: 16px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .07);
}
.tray-hint {
    margin: 0;
    opacity: .6;
    font-size: 15px;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.die {
    width: 62px;
    height: 62px;
    padding: 9px;
    display: grid;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    gap: 3px;
    background: var(--cream);
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 0 #c9c3ad, 0 6px 10px rgba(0, 0, 0, .3);
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, opacity .2s;
}
.die:not(:disabled):hover { transform: translateY(-3px); }
.die:disabled { cursor: default; }
.die.selected {
    background: #fff6cf;
    box-shadow: 0 0 0 3px var(--gold), 0 4px 0 #c9a13a, 0 6px 10px rgba(0, 0, 0, .3);
    transform: translateY(-4px);
}
.die.kept {
    opacity: .55;
    transform: scale(.86);
    box-shadow: 0 2px 0 #c9c3ad;
}
.pip {
    background: var(--ink);
    border-radius: 50%;
    align-self: center;
    justify-self: center;
    width: 11px;
    height: 11px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
button.action {
    font: inherit;
    font-weight: 600;
    font-size: 16px;
    padding: 12px 22px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: var(--gold);
    color: #3a2a05;
    box-shadow: 0 3px 0 #c08d1c;
    transition: transform .1s, opacity .2s;
}
button.action.ghost {
    background: rgba(255, 255, 255, .14);
    color: var(--cream);
    box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
button.action:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
button.action:disabled { opacity: .38; cursor: default; }

.message {
    min-height: 22px;
    font-size: 15px;
    text-align: center;
    opacity: .92;
}

dialog#rules {
    max-width: 460px;
    width: calc(100% - 32px);
    border: none;
    border-radius: 14px;
    padding: 22px 24px;
    background: var(--cream);
    color: var(--ink);
    line-height: 1.6;
}
dialog#rules::backdrop { background: rgba(0, 0, 0, .55); }
dialog#rules h2 { margin: 0 0 10px; font-size: 20px; }
dialog#rules table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; }
dialog#rules td { padding: 3px 0; font-size: 15px; }
dialog#rules td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
dialog#rules p { font-size: 15px; margin: 8px 0; }

@media (max-width: 420px) {
    .die { width: 52px; height: 52px; padding: 7px; }
    .pip { width: 9px; height: 9px; }
    .player .score { font-size: 25px; }
}
