:root {
    --game-primary: #1e4d36;
    --game-secondary: #d4a017;
    --stb-wood: #5c3a22;
    --stb-wood-dark: #2a1810;
    --stb-felt: #1a3d2b;
    --stb-cream: #f4ead5;
    --stb-ink: #1a1510;
}

body.stb-page {
    margin: 0;
    min-height: 100vh;
    display: block;
    align-items: stretch;
    justify-content: stretch;
    perspective: none;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", Georgia, serif;
    color: var(--stb-cream);
    background:
        radial-gradient(circle at 14% 10%, rgba(212, 160, 23, 0.16), transparent 42%),
        radial-gradient(circle at 88% 8%, rgba(30, 77, 54, 0.35), transparent 46%),
        linear-gradient(180deg, #2a1810 0%, #1a3d2b 48%, #120c08 100%);
}

body.stb-page.game-menu-active {
    overflow-y: auto;
    overflow-x: hidden;
}

body.stb-page.game-menu-active #game-header {
    display: none !important;
}

/* No daily challenge — hide the shared streak nudge. */
body.stb-page .game-menu-nudge-overlay {
    display: none !important;
}

.stb-page .game-screen {
    display: none;
    min-height: 100vh;
}

.stb-page .game-screen.active {
    display: block;
}

body.stb-page.with-game-header .stb-shell {
    padding-top: 5.5rem;
}

.stb-shell {
    max-width: min(920px, 96vw);
    margin: 0 auto;
    padding: 1.1rem 0.75rem 2.5rem;
}

.stb-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 auto 0.85rem;
    padding: 0.55rem 0.7rem;
    background: linear-gradient(180deg, #6b4423, #3d2314);
    border: 3px solid #1a120c;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.stb-lcd {
    min-width: 6.2rem;
    padding: 0.2rem 0.45rem;
    background: #140414;
    color: #f5c518;
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    border-radius: 6px;
    box-shadow: inset 0 0 0 2px #1e4d36, inset 0 8px 16px rgba(0, 0, 0, 0.45);
}

.stb-lcd span {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #86efac;
}

.stb-chip {
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fde68a;
    font-weight: 700;
}

.stb-chip.is-busy {
    background: #1e4d36;
    color: #fff;
}

.stb-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    margin: 0 auto 0.85rem;
}

.stb-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(212, 160, 23, 0.4);
    background: rgba(26, 18, 12, 0.85);
    color: #f8fafc;
    font-weight: 700;
    cursor: pointer;
}

.stb-tool-btn:hover {
    border-color: #d4a017;
    color: #fde68a;
    background: rgba(26, 18, 12, 0.95);
}

.stb-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.stb-scores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin: 0 auto 0.9rem;
}

.stb-score-card {
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(212, 160, 23, 0.22);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    text-align: center;
}

.stb-score-card.is-active {
    border-color: #d4a017;
    box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.25);
}

.stb-score-card strong {
    display: block;
    font-size: 1.35rem;
    color: #fde68a;
}

.stb-score-card span {
    color: #d9f99d;
    font-size: 0.82rem;
}

.stb-box {
    margin: 0 auto;
    width: min(92vw, 720px);
    padding: 0.85rem 0.85rem 1.1rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 38%),
        linear-gradient(180deg, #7a4a28, #4a2c18 58%, #3d2314);
    border: 8px solid #2a1810;
    border-radius: 18px 18px 22px 22px;
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.stb-tiles {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 0.28rem;
    perspective: 900px;
    margin-bottom: 0.85rem;
}

.stb-tile {
    position: relative;
    height: clamp(3.4rem, 9vw, 5.2rem);
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transform-style: preserve-3d;
}

.stb-tile:disabled {
    cursor: default;
}

.stb-tile-inner {
    display: block;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: 50% 100%;
    transition: transform 0.55s cubic-bezier(0.4, 0.05, 0.2, 1);
}

.stb-tile.is-shut .stb-tile-inner {
    transform: rotateX(-102deg);
}

.stb-tile-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 6px 6px 3px 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
    font-size: clamp(1.05rem, 3vw, 1.55rem);
    color: #2a1810;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 42%),
        linear-gradient(180deg, #efe3c6, #d9c49a);
    border: 2px solid #3d2314;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 8px rgba(0, 0, 0, 0.25);
}

.stb-tile-face--down {
    transform: rotateX(180deg);
    background: #4a3220;
    color: transparent;
    border-color: #2a1810;
}

.stb-tile.is-legal:not(.is-shut) .stb-tile-face--up {
    box-shadow: 0 0 0 2px #d4a017, inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.stb-tile.is-selected:not(.is-shut) .stb-tile-face--up {
    background: linear-gradient(180deg, #fde68a, #d4a017);
    color: #1a1510;
}

.stb-felt {
    min-height: 13.5rem;
    padding: 1rem 0.75rem 1.1rem;
    border-radius: 10px;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.06), transparent 42%),
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.04) 0 2px, transparent 2px 4px),
        linear-gradient(180deg, #24563a, #143326);
    border: 3px solid #0f241a;
    box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.35);
}

.stb-page .stb-felt .dice-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.1rem;
    min-height: 7.2rem;
    margin: 0 0 0.75rem;
}

.stb-page .stb-felt .dice-container {
    width: 100px;
    height: 100px;
    margin: 0;
}

.stb-page .stb-felt .dice,
.stb-page .stb-felt .dice .face {
    width: 100px;
    height: 100px;
}

.stb-page .stb-felt .dice .front { transform: translateZ(50px); }
.stb-page .stb-felt .dice .right { transform: rotateY(90deg) translateZ(50px); }
.stb-page .stb-felt .dice .top { transform: rotateX(90deg) translateZ(50px); }
.stb-page .stb-felt .dice .bottom { transform: rotateX(-90deg) translateZ(50px); }
.stb-page .stb-felt .dice .left { transform: rotateY(-90deg) translateZ(50px); }
.stb-page .stb-felt .dice .back { transform: translateZ(-50px) rotateY(180deg); }

.stb-page .stb-felt .dice .dot {
    width: 15px;
    height: 15px;
}

.stb-page .stb-felt .dice .right,
.stb-page .stb-felt .dice .bottom {
    gap: 10px;
    padding: 15px;
}

.stb-page .stb-felt .dice .top,
.stb-page .stb-felt .dice .left {
    gap: 7.5px;
    padding: 12.5px;
}

.stb-page .stb-felt .dice .back {
    gap: 10px;
    padding: 15px;
}

.stb-roll-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.stb-roll-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.05rem;
    border-radius: 999px;
    border: 2px solid #3d2314;
    background: #d4a017;
    color: #1a1510;
    font-weight: 800;
    cursor: pointer;
}

.stb-roll-btn:hover:not(:disabled) {
    background: #f5c518;
    color: #1a1510;
}

.stb-roll-btn.secondary {
    background: #f4ead5;
    color: #1e4d36;
    border-color: #1e4d36;
}

.stb-roll-btn.secondary:hover:not(:disabled) {
    background: #1e4d36;
    color: #fff;
}

.stb-roll-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.stb-one-die-hint {
    width: 100%;
    margin: 0.35rem 0 0;
    text-align: center;
    color: #d9f99d;
    font-size: 0.92rem;
    font-weight: 600;
}

.stb-one-die-hint[hidden] {
    display: none !important;
}

.stb-hint {
    margin: 0.85rem 0 0;
    text-align: center;
    color: #fde68a;
    font-size: 0.95rem;
}

.stb-settings-panel {
    margin-top: 0.4rem;
    padding: 0.9rem 1rem;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(212, 160, 23, 0.22);
    border-radius: 12px;
}

.stb-settings-panel__title {
    font-weight: 700;
    margin-bottom: 0.55rem;
    color: #f5c518;
}

.stb-settings-panel__label {
    margin: 0.35rem 0 0.4rem;
    font-weight: 600;
}

.stb-settings-panel__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.stb-page .difficulty-pill {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    font-weight: 600;
    cursor: pointer;
}

.stb-page .difficulty-pill:hover {
    border-color: #d4a017;
    color: #fde68a;
    background: rgba(30, 77, 54, 0.45);
}

.stb-page .difficulty-pill.is-selected {
    background: #d4a017;
    color: #1a1510;
    border-color: #d4a017;
}

.stb-page .modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 12000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.stb-page .modal.active {
    display: flex;
}

.stb-page .party-overlay {
    z-index: 13000;
}

.stb-page .modal-content {
    background: #fff;
    color: #1a1a1a;
    border-radius: 1rem;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.stb-page .modal-large { max-width: 760px; }

.stb-page .modal-header,
.stb-page .modal-footer {
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.stb-page .modal-header { border-bottom: 2px solid #eee; }
.stb-page .modal-header h2 { margin: 0; color: #1e4d36; font-size: 1.35rem; }

.stb-page .modal-close {
    background: #fff;
    border: 2px solid #1e4d36;
    color: #1e4d36;
    border-radius: 8px;
    cursor: pointer;
    padding: 0.35rem 0.55rem;
}

.stb-page .modal-close:hover {
    background: #1e4d36;
    color: #fff;
}

.stb-page .modal-body { padding: 1.2rem 1.4rem; }
.stb-page .modal-footer { border-top: 2px solid #eee; justify-content: flex-end; }

.stb-page .help-section { margin-bottom: 1.1rem; }
.stb-page .help-section h3 { color: #1e4d36; margin: 0 0 0.4rem; }
.stb-page .help-section ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

.stb-page .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stb-page .stat-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.85rem;
    text-align: center;
}

.stb-page .stat-value { font-size: 1.6rem; color: #1e4d36; font-weight: 700; }
.stb-page .stat-label { color: #64748b; font-size: 0.85rem; }

.stb-page .win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    text-align: center;
}

.stb-page .win-stat strong { display: block; font-size: 1.35rem; color: #1e4d36; }
.stb-page .win-stat span { color: #64748b; font-size: 0.82rem; }

.stb-page .result-message { font-size: 1.05rem; margin: 0 0 1rem; }

.stb-page .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 0.55rem;
    border: 2px solid transparent;
    font-weight: 700;
    cursor: pointer;
}

.stb-page .btn-primary {
    background: #1e4d36;
    color: #fff;
}

.stb-page .btn-primary:hover {
    background: #163b29;
    color: #fff;
}

.stb-page .btn-secondary {
    background: #fff;
    color: #1e4d36;
    border-color: #1e4d36;
}

.stb-page .btn-secondary:hover {
    background: #1e4d36;
    color: #fff;
}

.stb-page .difficulty-stats {
    display: grid;
    gap: 0.45rem;
}

.stb-page .difficulty-stats div {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0.6rem;
    background: #f8fafc;
    border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
    .stb-tile-inner {
        transition: none;
    }
}

@media (max-width: 640px) {
    .stb-tool-btn span { display: none; }
    .stb-lcd { min-width: 4.6rem; font-size: 1rem; }
    .stb-page .stb-felt .dice-container,
    .stb-page .stb-felt .dice,
    .stb-page .stb-felt .dice .face {
        width: 78px;
        height: 78px;
    }
    .stb-page .stb-felt .dice .front { transform: translateZ(39px); }
    .stb-page .stb-felt .dice .right { transform: rotateY(90deg) translateZ(39px); }
    .stb-page .stb-felt .dice .top { transform: rotateX(90deg) translateZ(39px); }
    .stb-page .stb-felt .dice .bottom { transform: rotateX(-90deg) translateZ(39px); }
    .stb-page .stb-felt .dice .left { transform: rotateY(-90deg) translateZ(39px); }
    .stb-page .stb-felt .dice .back { transform: translateZ(-39px) rotateY(180deg); }
    .stb-page .stb-felt .dice .dot { width: 12px; height: 12px; }
}

#settingsModal .stb-settings-panel__title {
    color: #1e4d36;
}
#settingsModal .stb-settings-panel__label {
    color: #1a1a1a;
}
#settingsModal .difficulty-pill {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}
#settingsModal .difficulty-pill:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #1e4d36;
}
#settingsModal .difficulty-pill.is-selected {
    background: #1e4d36;
    color: #fff;
    border-color: #1e4d36;
}
