:root {
    --game-primary: #c90c0f;
    --game-secondary: #f4c430;
}

body.pg-page {
    margin: 0;
    min-height: 100vh;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: #f8f1e3;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 14% 8%, rgba(244, 167, 185, 0.22), transparent 42%),
        radial-gradient(circle at 88% 10%, rgba(201, 12, 15, 0.2), transparent 46%),
        linear-gradient(180deg, #3d2416 0%, #5a3420 48%, #1a100c 100%);
}

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

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

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

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

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

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

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

.pg-lcd {
    min-width: 4.6rem;
    padding: 0.2rem 0.45rem;
    background: #140c08;
    color: #f5c518;
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    border-radius: 6px;
    box-shadow: inset 0 0 0 2px #7f1d1d, inset 0 8px 16px rgba(0, 0, 0, 0.45);
}

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

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

.pg-races {
    display: grid;
    gap: 0.4rem;
    margin: 0 auto 0.85rem;
}

.pg-race {
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    gap: 0.45rem;
    align-items: center;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fde68a;
}

.pg-race-track {
    height: 0.7rem;
    border-radius: 999px;
    background: #140c08;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(244, 196, 48, 0.25);
}

.pg-race-track i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #c90c0f, #f4c430);
    transition: width 0.35s ease;
}

.pg-race:last-child .pg-race-track i {
    background: linear-gradient(90deg, #7c3aed, #f4a7b9);
}

.pg-status {
    text-align: center;
    min-height: 1.4rem;
    margin: 0 0 0.85rem;
    color: #fde68a;
    font-weight: 600;
}

.pg-table {
    position: relative;
    margin: 0 auto 1rem;
    padding: 1.4rem 1rem 1.6rem;
    min-height: 220px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 20%, rgba(244, 167, 185, 0.16), transparent 55%),
        linear-gradient(180deg, #6b4228, #3d2416);
    border: 4px solid #1a100c;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 16px 32px rgba(0, 0, 0, 0.35);
    perspective: 700px;
}

.pg-table.is-bust {
    box-shadow: inset 0 0 0 4px #c90c0f, 0 16px 32px rgba(0, 0, 0, 0.35);
}

.pg-turn-pot {
    position: absolute;
    top: 0.7rem;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    background: #140c08;
    color: #f5c518;
    border-radius: 10px;
    padding: 0.25rem 0.85rem;
    min-width: 6.5rem;
    box-shadow: inset 0 0 0 2px #7f1d1d;
}

.pg-turn-pot span {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #f4a7b9;
}

.pg-turn-pot strong {
    font-size: 1.55rem;
}

.pg-dice {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.6rem;
    min-height: 150px;
    margin-top: 1.6rem;
}

.pg-die-wrap {
    width: 92px;
    height: 92px;
    perspective: 600px;
}

.pg-die-wrap.is-hidden {
    display: none;
}

.pg-die {
    width: 88px;
    height: 88px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-18deg) rotateY(18deg);
    transition: transform 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pg-die.is-rolling {
    transition: transform 0.62s linear;
}

.pg-face {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: #f7f2e8;
    box-shadow: inset 0 0 0 2px #d6cbb8, 0 0 0 1px #1a100c;
    backface-visibility: hidden;
}

.pg-face-1 { transform: rotateY(0deg) translateZ(44px); }
.pg-face-2 { transform: rotateY(90deg) translateZ(44px); }
.pg-face-3 { transform: rotateX(90deg) translateZ(44px); }
.pg-face-4 { transform: rotateX(-90deg) translateZ(44px); }
.pg-face-5 { transform: rotateY(-90deg) translateZ(44px); }
.pg-face-6 { transform: rotateY(180deg) translateZ(44px); }

.pg-face[data-pips="1"] {
    background-image: radial-gradient(circle at 50% 50%, #1a100c 0 11%, transparent 12%);
}
.pg-face[data-pips="2"] {
    background-image:
        radial-gradient(circle at 28% 28%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 72%, #1a100c 0 10%, transparent 11%);
}
.pg-face[data-pips="3"] {
    background-image:
        radial-gradient(circle at 28% 28%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 50% 50%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 72%, #1a100c 0 10%, transparent 11%);
}
.pg-face[data-pips="4"] {
    background-image:
        radial-gradient(circle at 28% 28%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 28%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 28% 72%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 72%, #1a100c 0 10%, transparent 11%);
}
.pg-face[data-pips="5"] {
    background-image:
        radial-gradient(circle at 28% 28%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 28%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 50% 50%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 28% 72%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 72%, #1a100c 0 10%, transparent 11%);
}
.pg-face[data-pips="6"] {
    background-image:
        radial-gradient(circle at 28% 24%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 28% 50%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 28% 76%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 24%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 50%, #1a100c 0 10%, transparent 11%),
        radial-gradient(circle at 72% 76%, #1a100c 0 10%, transparent 11%);
}

.pg-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.7rem;
}

.pg-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-width: 8.5rem;
    min-height: 48px;
    padding: 0.7rem 1.2rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: 1.05rem;
    cursor: pointer;
}

.pg-action-roll {
    background: #c90c0f;
    color: #fff;
    border: 2px solid #c90c0f;
}

.pg-action-roll:hover:not(:disabled) {
    background: #a00a0c;
    border-color: #a00a0c;
    color: #fff;
}

.pg-action-hold {
    background: #fff;
    color: #c90c0f;
    border: 2px solid #c90c0f;
}

.pg-action-hold:hover:not(:disabled) {
    background: #c90c0f;
    color: #fff;
}

.pg-action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pg-hint {
    text-align: center;
    color: rgba(253, 230, 138, 0.8);
    font-size: 0.88rem;
    margin: 0;
}

.pg-settings-panel__label {
    margin: 0 0 0.45rem;
    color: #1a120c;
    font-weight: 600;
}

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

#settingsModal .difficulty-pill {
    border: 1px solid #fed7aa;
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    background: #fff7ed;
    color: #1a120c !important;
    font-weight: 600;
    cursor: pointer;
}

#settingsModal .difficulty-pill.is-selected {
    background: #c90c0f;
    color: #fff !important;
    border-color: #c90c0f;
}

#settingsModal .pg-settings-panel__note {
    margin: 0.75rem 0 0;
    color: #7f1d1d;
    font-size: 0.9rem;
}

.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;
}

.modal.active {
    display: flex;
}

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

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

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

.modal-header {
    border-bottom: 2px solid #eee;
}

.modal-header h2 {
    margin: 0;
    color: #c90c0f;
    font-size: 1.35rem;
}

.modal-close {
    background: #fff !important;
    border: 2px solid #c90c0f;
    color: #c90c0f !important;
    border-radius: 8px;
    cursor: pointer;
    padding: 0.35rem 0.55rem;
}

.modal-close:hover {
    background: #c90c0f !important;
    color: #fff !important;
}

.modal-body {
    padding: 1.2rem 1.4rem;
}

.modal-footer {
    border-top: 2px solid #eee;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.help-section {
    margin-bottom: 1.1rem;
}

.help-section h3 {
    color: #c90c0f;
    margin: 0 0 0.4rem;
}

.help-section ul {
    margin: 0.3rem 0 0;
    padding-left: 1.2rem;
}

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

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

.stat-value {
    font-size: 1.6rem;
    color: #c90c0f;
    font-weight: 700;
}

.stat-label {
    color: #64748b;
    font-size: 0.85rem;
}

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

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

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

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

.win-stat strong {
    display: block;
    font-size: 1.35rem;
    color: #c90c0f;
}

.win-stat span {
    color: #64748b;
    font-size: 0.82rem;
}

.pg-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;
}

.pg-page .btn-primary {
    background: #c90c0f !important;
    color: #fff !important;
    border-color: #c90c0f;
}

.pg-page .btn-secondary {
    background: #fff !important;
    color: #c90c0f !important;
    border-color: #c90c0f;
}

.pg-page .btn-secondary:hover {
    background: #c90c0f !important;
    color: #fff !important;
}

@media (max-width: 640px) {
    body.pg-page.with-game-header .pg-shell {
        padding-top: 4.75rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .pg-hud {
        max-width: 100%;
    }

    .pg-lcd {
        min-width: 0;
        flex: 1 1 0;
    }

    .pg-die,
    .pg-die-wrap {
        width: 72px;
        height: 72px;
    }

    .pg-die {
        width: 68px;
        height: 68px;
    }

    .pg-face-1 { transform: rotateY(0deg) translateZ(34px); }
    .pg-face-2 { transform: rotateY(90deg) translateZ(34px); }
    .pg-face-3 { transform: rotateX(90deg) translateZ(34px); }
    .pg-face-4 { transform: rotateX(-90deg) translateZ(34px); }
    .pg-face-5 { transform: rotateY(-90deg) translateZ(34px); }
    .pg-face-6 { transform: rotateY(180deg) translateZ(34px); }
}

@media (prefers-reduced-motion: reduce) {
    .pg-die,
    .pg-race-track i {
        transition: none;
    }
}
