:root {
    --teal: #3b8583;
    --cream: #efe2b6;
    --ink: #1b1a18;
    --gold: #f2cc4d;
    --red: #cf4136;
    --blue: #2f5ccf;
    --panel: #254c4a;
    --muted: #c7c1a2;
    --shadow: 0 1rem 22px rgba(0, 0, 0, .35);
    --radius: 22px;
}

* {
    box-sizing: border-box;
    user-select:none;
}

html {
    font-size: 10px;
}

html,
body {
    height: 100%;
    touch-action: manipulation;
}

body {
    margin: 0;
    color: var(--cream);
    font: 16px/1.6 ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans";
    background: radial-gradient(1000px 600px at 50% -100px, rgba(0, 0, 0, .35), transparent 60%), radial-gradient(1200px 700px at 50% 120%, rgba(0, 0, 0, .35), transparent 60%), linear-gradient(0deg, rgba(0, 0, 0, .06), rgba(0, 0, 0, .06)), var(--teal)
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: url('data:image/svg+xml;utf8:<svg%20xmlns=%27http://www.w3.org/2000/svg%27%20viewBox=%270%200%20100%20100%27%20preserveAspectRatio=%27none%27><filter%20id=%27n%27><feTurbulence%20type=%27fractalNoise%27%20baseFrequency=%270.8%27%20numOctaves=%272%27%20stitchTiles=%27stitch%27/></filter><rect%20width=%27100%%27%20height=%27100%%27%20filter=%27url(%23n)%27%20opacity=%270.05%27/></svg>');
    background-size: 300px 300px;
    mix-blend-mode: multiply
}

header.appbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in oklab, var(--teal) 70%, black 10%);
    border-bottom: .2rem solid #0003;
    box-shadow: var(--shadow)
}

.shell {
    max-width: 120rem;
    margin: 0 auto;
    padding: 1.2rem 1.6rem;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    height: 100%
}

.brand img {
    height: 4.6rem
}

.brand h1 {
    margin: 0;
    font-size: 2rem;
    text-transform: uppercase;
    color: var(--cream)
}

.actions {
    display: flex;
    gap: .8rem;
    margin-left: auto
}

.icon-btn {
    height: 4.4rem;
    padding: 0 1.4rem;
    border-radius: 1.2rem;
    border: .2rem solid #0008;
    background: var(--panel);
    display: flex;
    align-items: center;
    gap: .8rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    color: var(--cream);
    font-weight: 800;
}

main.grid {
    display: grid;
    gap: 1.4rem;
    padding: 1.4rem;
}

/* @media(min-width:900px) {
    main.grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        grid-template-rows: 1.8fr 1.2fr;
        grid-template-areas: "visitor merged merged home" "blue green gold red";
        align-items: stretch;
    }
} */

@media screen and (max-width:899px) {
    main.grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
        grid-template-rows: min-content max-content min-content;
        grid-template-areas: "visitor visitor home home" "merged merged merged merged" "blue green gold red";
        align-items: stretch;
    }
}

main.grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-rows: min-content max-content min-content;
    grid-template-areas: "visitor visitor home home" "merged merged merged merged" "blue green gold red";
    align-items: stretch;
}

.card {
    background: color-mix(in oklab, var(--panel) 88%, black 12%);
    border: .2rem solid #0008;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: grid;
    grid-template-rows: auto 1fr;
}

.card h3 {
    margin: 0 0 1rem;
    font-size: 2rem;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    align-self: start;
    justify-self: start
}

.visitor {
    grid-area: visitor
}

.inning {
    width: 100%;
}

.home {
    grid-area: home
}

.outs {
    /* grid-area: outs */
}

.gold {
    grid-area: gold
}

.green {
    grid-area: green
}

.blue {
    grid-area: blue
}

.red {
    grid-area: red
}

.bases {
    grid-template-rows: max-content 1fr;
}

.visitor h3 {
    color: #7aa1ff
}

.home h3 {
    color: #ff8a86
}

.score-board {
    display: grid;
    place-items: center;
    padding: 1.5rem;
    height: 100%
}

.num {
    font-size: 15rem;
    font-weight: 900;
    cursor: pointer;
    text-shadow: 0 .6rem 0 #0008;
    user-select: none;
    line-height: 1
}

.visitor .num {
    color: #2f5ccf
}

.home .num {
    color: #cf4136
}

.inning .wrap {
    display: grid;
    grid-template-rows: auto auto;
    justify-items: center;
    gap: 1.5rem;
    height: 100%
}

.inning .big {
    font-size: 9rem;
    font-weight: 900;
    text-shadow: 0 .6rem 0 #0008;
    cursor: pointer;
    user-select: none;
    line-height: 1
}

.half-pill {
    padding: .5rem 1.6rem;
    border-radius: 99rem;
    border: .2rem solid #000;
    background: color-mix(in oklab, #f2cc4d 80%, black 5%);
    color: #2b2b2b;
    font-weight: 900;
    cursor: pointer;
    font-size: 2rem;
}

.die-card .dice {
    width: 14rem;
    height: 14rem;
    border-radius: 2rem;
    border: .2rem solid #0008;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    margin: auto;
    user-select: none;
}

.rolling {
    pointer-events:none;
}

.die-card .dice svg {
    width: 13.2rem;
    height: 13.2rem
}

.die-card.blue .dice {
    background: color-mix(in oklab, #2f5ccf 55%, black 15%)
}

.die-card.red .dice {
    background: color-mix(in oklab, #cf4136 55%, black 15%)
}

.die-card.green .dice {
    background: color-mix(in oklab, #2e6b3a 40%, black 10%)
}

.die-card.gold .dice {
    background: #f2cc4d;
    border-color: #000
}

.gold-text {
    font-size: 4.2rem;
    font-weight: 900
}

.outs .outs-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2.8rem;
    height: 100%
}

body.top .die-card.gold {
    grid-area: green;
}

body.top .die-card.green {
    grid-area: gold;

}

.outs .dot {
    width: 7rem;
    height: 7rem;
    border-radius: 99rem;
    border: .4rem solid #000;
    background: transparent;
    box-shadow: inset 0 -.5rem 0 #0006
}

.outs .dot.on {
    background: #f2cc4d
}

.bases .field {
    position: relative;
    display: grid;
    width: 100%;
    grid-template-columns: repeat(4, 6rem);
    grid-template-rows: repeat(4, 6rem);
    place-items: center;
    gap: 0;
    aspect-ratio: 1/1;
}

.base-btn {
    width: 10rem;
    height: 10rem;
    border: none;
    background: transparent;
    cursor: pointer;
    position: absolute
}


.base-btn svg {
    display: block;
    /* filter: drop-shadow(0 -4px 0 rgba(0, 0, 0, .4)); */
    transition: transform .08s ease;
}

.base-btn .gem {
    stroke: #000;
    stroke-width: 4
}

.base-btn.active svg .gem {
    fill: #f2cc4d
}

.base-1 {
    grid-column: 3 / 5;
    grid-row: 2 / 4;
    place-self: center start;
    margin-left: .3rem;
}

.base-2 {
    grid-column: 2/4;
    grid-row: 1 / 3;
    margin-top: 1rem;
}

.base-3 {
    grid-column: 1 / 3;
    grid-row: 2/4;
    place-self: center end;
    margin-right: .3rem;
}

dialog.modal {
    border: none;
    border-radius: 1.8rem;
    padding: 0;
    width: min(92rem, 96vw);
    background: var(--panel);
    box-shadow: var(--shadow)
}

.modal>header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.4rem;
    border-bottom: .2rem solid #0008
}

.modal>section {
    padding: 1.6rem 1.8rem;
    max-height: 72vh;
    overflow: auto;
    line-height: 1.85
}

.rules-content p {
    margin: .7em 0
}

.merged {
    grid-area: merged;
    display: grid;
    grid-template-rows: auto 1fr;
}

.merged .merged-inner {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2rem;
    align-items: center;
}

.merged-inner>* {
    place-items: center;
}

/* Remove inner card chrome so it looks unified */
.merged .card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0
}

.visitor .num,
.home .num {
    font-size: 14rem;
}


/* Tighter, explicit centering for big scores */
.visitor .score-board,
.home .score-board {
    display: grid;
    place-items: center;
    padding: 0
}

.visitor .num,
.home .num {
    display: block;
    line-height: 1;
    text-align: center;
    margin: 0
}

/* Scale the whole HOME card content (not only the number) */

/* Unified size for VISITOR & HOME numbers */
.visitor .num,
.home .num {
    font-size: 13remů
}

.card.merged .merged-inner {
    transform-origin: center;
    display: grid;
    place-items: start center;
}

.card.merged {
    display: grid;
    overflow: visible;
    height: 100%;
}

.merged .inning .wrap {
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: 0
}

.merged .inning .wrap .topbot {
    font-size: 2.6rem;
}

.merged .inning .wrap .topbot {
    font-size: 2.2rem;
}

.merged .inning .wrap {
    margin-top: -2rem;
}

/* === CUSTOM ALIGNMENT ADJUSTMENTS === */

.merged .inning .wrap {
    margin-top: 0 !important;
    /* remove extra negative margin */
    justify-content: center;
    align-items: flex-start;
}

/* === FINAL ALIGNMENT TWEAKS === */

/* INNING: number + TOP/BOT label shifted into upper half */

.merged .inning .wrap {
    margin-top: 0 !important;
    justify-content: flex-start;
    align-items: center;
}

.merged .inning .wrap .topbot {
    margin-top: .4rem !important;
    /* small spacing below the number */
}

#rulesModal:not([open]) {
    display: none;
    visibility: hidden;
}