/* Retro score display. Game controls stay ahead of the history. */
:root {
    --felt: #123c28;
    --felt-dark: #092719;
    --cream: #fff0cc;
    --cream-shade: #f0dfb7;
    --ink: #171910;
    --muted-ink: #514c3a;
    --orange: #b93410;
    --orange-line: #ff7138;
    --table-bg: var(--felt-dark);
    --table-panel: var(--felt);
    --table-header: var(--felt-dark);
    --table-line: #597459;
    --table-divider: #385742;
    --table-text: var(--cream);
    --table-muted: #ecdfbd;
    --table-accent: #ffd39b;
    --table-display: "Bahnschrift Condensed", "Arial Narrow", system-ui, sans-serif;
}

body { margin: 0; background: var(--felt-dark); }
.grid-container {
    max-width: 76rem;
    margin-inline: auto;
    padding: 6px;
    gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
        "brand brand"
        "a1 a1"
        "a4 a6"
        "a5 a5"
        "history history"
        "a7 a9";
    background: radial-gradient(ellipse at top, #1b4c33, var(--felt-dark));
}
.retro-brand {
    grid-area: brand;
    margin: 0 2px 0 40px;
    padding: 3px 0 5px;
    border-bottom: 2px solid var(--orange-line);
    font: italic 850 clamp(1rem, 4vw, 1.5rem)/1.15 var(--table-display);
    text-transform: uppercase;
}
.retro-history {
    grid-area: history;
    text-align: center;
    font: italic 750 .95rem/1.2 var(--table-display);
    text-transform: uppercase;
    margin-top: 5px;
}
.grid-container .item1 { display: grid; padding-top: 0; gap: 3px 0; }
.grid-container .item1 > div { min-height: 0; padding: 0; font-size: .95rem; }
.bos1, .bos2 {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    width: min(100%, 480px);
    height: auto;
    margin: 0 auto;
}
.imgball { width: 78%; max-width: 36px; height: auto; margin: auto; cursor: pointer; }
.imgball.select { border-radius: 50%; outline: 2px solid var(--orange-line); outline-offset: 1px; }
.item6 { display: none; }
.item5 br, .item7 br { display: none; }

.player-card { background: var(--cream); color: var(--ink); border-radius: 9px; }
.player-card .player-heading { padding: 4px; background: var(--cream-shade); color: var(--ink); }
.player-name { font: 850 clamp(1.05rem, 4.5vw, 1.5rem)/1.12 var(--table-display); }
.turn-slot { min-height: 1.25rem; line-height: 1; }
.turn-badge:not([hidden]) {
    padding: .15rem .35rem;
    border: 0;
    border-radius: 3px;
    background: var(--orange);
    color: #fff8e4;
    font: italic 850 .72rem/1.1 var(--table-display);
    animation: none;
}
.turn-badge::before { content: none; }
.grid-container .player-heading:has(.turn-badge:not([hidden])) { box-shadow: inset 0 3px var(--orange); }
.player-stats { padding: 3px 7px 7px; gap: 1px; }
.player-stats > div { font-size: clamp(.8rem, 3.7vw, .96rem); line-height: 1.16; }
.player-stats dt { color: var(--muted-ink); }
.player-stats dd { color: var(--ink); font-size: 1em; font-weight: 800; }
.player-stats .total-score { display: block; text-align: center; margin: 0 0 3px; }
.total-score dt { font-size: .68rem; color: var(--muted-ink); letter-spacing: .05em; }
.total-score dd { font: 900 clamp(2.5rem, 12vw, 4.5rem)/.98 var(--table-display); }
.player-card :focus-visible { outline-color: var(--orange); }

.grid-container .item3 {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: 5px;
    align-items: stretch;
}
.item3 .button {
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding-inline: 4px;
    font-size: clamp(.9rem, 4vw, 1.15rem);
    text-transform: uppercase;
}
.foul-controls {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    background: var(--cream);
    color: var(--ink);
    border-radius: 8px;
}
.foul-count { grid-column: 2; grid-row: 1; font-weight: 800; font-size: .86rem; }
.foul-controls .button {
    background: transparent;
    color: var(--ink);
    border: 0;
    font-size: 1.4rem;
}
#Foul_Min_button { grid-column: 1; grid-row: 1; }
#Foul_Plus_button { grid-column: 3; grid-row: 1; }
.item3 #Change_Turns_Button {
    grid-column: 1 / -1;
    grid-row: 2;
    background: var(--orange);
    border-color: var(--orange-line);
    color: #fff8e4;
}
.item3 #New_Rack_Button { grid-column: 2; grid-row: 1; border-color: var(--cream); }
.foul-controls:has(.hidden) { display: none; }

@media (orientation: landscape) {
    .grid-container .item1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .item1 > div { grid-column: 1 / -1; }
    .bos1, .bos2 { width: 100%; }
    .imgball { max-width: 32px; }
    .player-stats {
        grid-template-columns: minmax(0, .9fr) minmax(0, 1fr);
        gap: 1px 6px;
    }
    .player-stats > div { grid-column: 2; font-size: clamp(.75rem, 2.2vw, 1rem); }
    .player-stats .total-score {
        grid-column: 1;
        grid-row: 1 / span 5;
        align-self: center;
    }
    .total-score dd { font-size: clamp(2.2rem, 8vw, 5.5rem); }
    .grid-container .item3 { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.4fr) minmax(0, 1fr); }
    .item3 #Change_Turns_Button { grid-column: 2; grid-row: 1; }
    .item3 #New_Rack_Button { grid-column: 3; grid-row: 1; }
}

.item3 #Change_Turns_Button {
    min-width: 0;
    min-height: 56px;
    padding: 4px 5px;
    border: 2px solid #ff854f;
    border-radius: 9px;
    background: linear-gradient(#d53c0e, #b62d0b);
    box-shadow: inset 0 -3px rgb(74 18 0 / 28%);
    color: #fff4d9;
    letter-spacing: .025em;
}
.item3 #Change_Turns_Button:active {
    box-shadow: inset 0 2px 4px rgb(74 18 0 / 35%);
}

@media (orientation: landscape) {
    .item3 #Change_Turns_Button {
        min-height: 44px;
    }
}

/* Bold print-inspired lettering and depth on the felt. */
:root {
    --ink: #080808;
    --retro-heavy: "Arial Black", "Segoe UI Black", system-ui, sans-serif;
}
.imgball {
    border-radius: 50%;
    box-shadow: 1px 3px 4px rgb(0 0 0 / 72%);
    filter: drop-shadow(1px 1px 1px rgb(0 0 0 / 35%));
}
.imgball.select {
    box-shadow: 1px 4px 6px rgb(0 0 0 / 78%);
    position: relative;
    z-index: 1;
}
.player-name {
    font-family: var(--retro-heavy);
    font-weight: 950;
    letter-spacing: -.045em;
    text-transform: uppercase;
}
.total-score dd {
    color: var(--ink);
    font: 950 clamp(3rem, 17vw, 6.75rem)/.94 var(--retro-heavy);
    letter-spacing: -.075em;
    -webkit-text-stroke: .025em currentColor;
    font-variant-numeric: proportional-nums;
}
.total-score dd[data-wide-score] { font-size: clamp(1.65rem, 9vw, 4rem); }
.foul-controls .button {
    color: var(--ink);
    font: 950 2rem/1 var(--retro-heavy);
    -webkit-text-stroke: .055em currentColor;
}

@media (orientation: landscape) {
    .total-score dd { font-size: clamp(2.5rem, 8vw, 6.75rem); }
    .total-score dd[data-wide-score] { font-size: clamp(1.5rem, 4.5vw, 4rem); }
}

/* Keep the score dominant and separate the foul controls visually. */
.total-score dt {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.total-score dd { font-size: clamp(3.9rem, 22.8vw, 9rem); }

.item3 {
    --retro-control-size: clamp(.95rem, 3.5vw, 1.65rem);
}
.item3 #Change_Turns_Button,
.item3 #New_Rack_Button,
.item3 .foul-count {
    font: 750 var(--retro-control-size)/1.15 "Bahnschrift Condensed", "Arial Narrow", system-ui, sans-serif;
    -webkit-text-stroke: 0;
}
.item3 .foul-controls .button { font-size: 2rem; }
.foul-count {
    align-self: stretch;
    display: grid;
    grid-auto-flow: column;
    place-content: center;
    gap: .22em;
    border-inline: 1px solid var(--muted-ink);
    margin-block: 6px;
    text-transform: uppercase;
}

@media (orientation: portrait) and (max-width: 360px) {
    .grid-container .item3 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
}

@media (orientation: landscape) {
    .total-score dd { font-size: clamp(2.75rem, 9vw, 7.5rem); }
}


/* Felt texture stays behind the clean cream scorecards. */
.grid-container {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Cpath fill='%23fff' opacity='.13' filter='url(%23grain)' d='M0 0h160v160H0z'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at top, #1b4c33, var(--felt-dark));
}
.player-card { box-shadow: 0 2px 5px rgb(0 0 0 / 35%); }
.turn-badge:not([hidden]) {
    padding-inline: .7rem;
    clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%);
}

@media (orientation: landscape) {
    .player-card .player-heading {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 4px;
    }
    .player-heading .player-name { text-align: left; padding-inline: 4px; }
    .player-heading .turn-slot { min-height: 0; }
    .player-stats {
        grid-template-columns: minmax(0, 1.65fr) minmax(7rem, 1fr);
    }
    .player-stats .total-score {
        align-self: stretch;
        display: grid;
        place-content: center;
        border-inline-end: 1px solid #ad9b77;
        padding-inline-end: 4px;
    }
    .total-score dd { font-size: clamp(3.3rem, 10.2vw, 9rem); }
    .total-score dd[data-wide-score] { font-size: clamp(1.5rem, 4.5vw, 4rem); }
}
