body.be-page {
    display: block;
    min-height: 100vh;
    margin: 0;
    background: #1a100c;
    color: #f4efe4;
    font-family: "Segoe UI", system-ui, sans-serif;
    perspective: none;
    justify-content: stretch;
    align-items: stretch;
}

/* Steampunk menu title — brass face, copper depth */
.game-menu-screen.beetle-menu .game-menu-hero h1 {
    font-family: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #ffe8c4;
    -webkit-text-stroke: 0.5px #8a2a18;
    text-shadow:
        0 1px 0 #e0b050,
        0 2px 0 #c4482a,
        0 3px 0 #9a2e1a,
        0 4px 0 #6e1810,
        0 12px 28px rgba(0, 0, 0, 0.55);
}

.game-menu-screen.beetle-menu .game-menu-hero__icon {
    background: linear-gradient(145deg, #e85a3c 0%, #c4191c 48%, #6e0f12 100%);
    border: 1px solid #e0b050;
    color: #ffe8c4;
    box-shadow:
        0 10px 24px rgba(196, 25, 28, 0.35),
        inset 0 1px 0 rgba(255, 232, 196, 0.25);
}

.game-menu-screen.beetle-menu .game-menu-hero__subtitle {
    color: #e8bc60;
}

.game-menu-screen.beetle-menu .game-menu-badge {
    background: rgba(232, 188, 96, 0.12);
    border-color: rgba(232, 188, 96, 0.35);
    color: #e8bc60;
}

.be-page .btn-primary:disabled {
    background: #9d090c !important;
    color: #fff !important;
    opacity: 0.7;
    cursor: default;
}

.be-shell {
    max-width: 920px;
    margin: 0 auto;
    padding: 1rem 1rem 2.5rem;
}

.be-hud,
.be-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.be-lcd,
.be-chip {
    background: #120c0a;
    border: 1px solid #b06a24;
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    color: #e8bc60;
    font-weight: 700;
}

.be-lcd span {
    display: block;
    color: #b06a24;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.be-layout {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 0.9rem;
    align-items: start;
}

.be-bugs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
}

.be-bugs.is-solo {
    grid-template-columns: 1fr;
}

.be-card {
    background: #f7f3e8;
    color: #1a1208;
    border-radius: 16px;
    padding: 0.75rem 0.8rem 0.9rem;
}

.be-card h2 {
    margin: 0 0 0.2rem;
    font-size: 1rem;
    color: #c90c0f;
}

.be-card p {
    margin: 0 0 0.35rem;
    font-weight: 700;
}

.be-bug {
    background: #0a0605;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(176, 106, 36, 0.35);
}

.be-stack {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
}

.be-stack .be-part {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.be-stack .be-empty {
    opacity: 0.9;
}

.be-part.is-fresh {
    animation: be-pop 0.45s ease;
}

@keyframes be-pop {
    0% { filter: brightness(2.1); }
    100% { filter: brightness(1); }
}

.be-chart {
    display: grid;
    gap: 0.35rem;
}

.be-chart div {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    background: #0e241c;
    color: #f4efe4;
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
    font-size: 0.88rem;
}

.be-chart strong {
    color: #f4c430;
}

.be-dice.dice-area {
    margin: 0.4rem 0 0.6rem;
    min-height: 7.2rem;
    gap: 1.2rem;
}

.be-page .be-dice .dice-container {
    width: 104px;
    height: 104px;
    margin: 0;
    perspective: 640px;
}

.be-page .be-dice .dice {
    --die-size: 104px;
    width: 104px;
    height: 104px;
}

.be-dice.is-choosing .dice.is-pickable {
    cursor: pointer;
}

.be-dice.is-choosing .dice-container:has(.dice.is-pickable) {
    cursor: pointer;
    border-radius: 16px;
    outline: 2px solid transparent;
    transition: outline-color 0.15s ease, transform 0.15s ease;
}

.be-dice.is-choosing .dice-container:has(.dice.is-useful) {
    outline-color: #e8bc60;
}

.be-dice.is-choosing .dice-container:has(.dice.is-pickable):hover,
.be-dice.is-choosing .dice-container:has(.dice.is-pickable):focus-within {
    outline-color: #c4191c;
    transform: translateY(-2px);
}

.be-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.be-status {
    min-height: 1.4rem;
    margin: 0.4rem 0 0;
    color: #d7c7a1;
    font-weight: 600;
}

.be-note {
    margin: 0.8rem 0 0;
    color: #d7c7a1;
}

.be-settings-note {
    margin: 0.75rem 0 0;
    color: #5c3b12;
}

.difficulty-pill {
    padding: 0.45rem 0.75rem;
    min-height: 44px;
    border-radius: 999px;
    border: 2px solid #c90c0f;
    background: #fff !important;
    color: #c90c0f !important;
    font-weight: 700;
    cursor: pointer;
}

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

.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,
.win-stat span {
    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;
}

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

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

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

.be-page .btn-secondary:hover,
.be-page .btn-primary:hover {
    background: #9d090c !important;
    color: #fff !important;
    border-color: #9d090c;
}

@media (max-width: 760px) {
    .be-layout,
    .be-bugs {
        grid-template-columns: 1fr;
    }

    body.be-page.with-game-header .be-shell {
        padding-top: 4.6rem;
    }
}

/* Victory scurrying beetles */
.be-scurry {
    position: fixed;
    inset: 0;
    z-index: 12050;
    pointer-events: none;
    overflow: hidden;
    display: none;
}

.be-scurry.is-active {
    display: block;
}

.be-scurry-bug {
    position: absolute;
    left: var(--be-shift, 0);
    top: var(--be-shift, 0);
    width: var(--be-size, 72px);
    height: var(--be-size, 72px);
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
    will-change: transform, opacity;
    animation-name: var(--be-anim, be-scurry-e);
    animation-duration: var(--be-dur, 4.2s);
    animation-delay: var(--be-delay, 0s);
    animation-timing-function: linear;
    animation-fill-mode: both;
}

.be-scurry-rig {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    animation: be-scurry-bob var(--be-gait, 0.2s) ease-in-out infinite;
}

.be-scurry-torso,
.be-scurry-leg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.be-scurry-leg-a {
    animation: be-walk-a var(--be-gait, 0.2s) ease-in-out infinite;
}

.be-scurry-leg-b {
    animation: be-walk-b var(--be-gait, 0.2s) ease-in-out infinite;
}

@keyframes be-walk-a {
    0% { transform: rotate(-16deg); }
    50% { transform: rotate(16deg); }
    100% { transform: rotate(-16deg); }
}

@keyframes be-walk-b {
    0% { transform: rotate(16deg); }
    50% { transform: rotate(-16deg); }
    100% { transform: rotate(16deg); }
}

@keyframes be-scurry-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4%); }
}

@keyframes be-scurry-e {
    0% { opacity: 0; transform: translate(-18vw, var(--be-lane, 40vh)) rotate(88deg) scale(0.85); }
    8% { opacity: 1; }
    20% { transform: translate(18vw, calc(var(--be-lane, 40vh) + 12px)) rotate(96deg) scale(1); }
    45% { transform: translate(48vw, calc(var(--be-lane, 40vh) - 10px)) rotate(86deg); }
    70% { transform: translate(78vw, calc(var(--be-lane, 40vh) + 14px)) rotate(94deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(118vw, var(--be-lane, 40vh)) rotate(90deg) scale(0.9); }
}

@keyframes be-scurry-w {
    0% { opacity: 0; transform: translate(118vw, var(--be-lane, 40vh)) rotate(-88deg) scale(0.85); }
    8% { opacity: 1; }
    25% { transform: translate(72vw, calc(var(--be-lane, 40vh) - 14px)) rotate(-96deg) scale(1); }
    55% { transform: translate(38vw, calc(var(--be-lane, 40vh) + 10px)) rotate(-84deg); }
    80% { transform: translate(10vw, calc(var(--be-lane, 40vh) - 8px)) rotate(-92deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(-18vw, var(--be-lane, 40vh)) rotate(-90deg) scale(0.9); }
}

@keyframes be-scurry-s {
    0% { opacity: 0; transform: translate(var(--be-lane, 40vw), -18vh) rotate(178deg) scale(0.85); }
    8% { opacity: 1; }
    30% { transform: translate(calc(var(--be-lane, 40vw) + 14px), 28vh) rotate(188deg) scale(1); }
    60% { transform: translate(calc(var(--be-lane, 40vw) - 12px), 58vh) rotate(174deg); }
    85% { transform: translate(calc(var(--be-lane, 40vw) + 8px), 88vh) rotate(182deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--be-lane, 40vw), 118vh) rotate(180deg) scale(0.9); }
}

@keyframes be-scurry-n {
    0% { opacity: 0; transform: translate(var(--be-lane, 40vw), 118vh) rotate(2deg) scale(0.85); }
    8% { opacity: 1; }
    28% { transform: translate(calc(var(--be-lane, 40vw) - 12px), 78vh) rotate(-8deg) scale(1); }
    55% { transform: translate(calc(var(--be-lane, 40vw) + 14px), 42vh) rotate(6deg); }
    82% { transform: translate(calc(var(--be-lane, 40vw) - 8px), 12vh) rotate(-4deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--be-lane, 40vw), -18vh) rotate(0deg) scale(0.9); }
}

@keyframes be-scurry-se {
    0% { opacity: 0; transform: translate(-16vw, -16vh) rotate(128deg) scale(0.85); }
    8% { opacity: 1; }
    40% { transform: translate(42vw, 38vh) rotate(140deg) scale(1); }
    70% { transform: translate(78vw, 72vh) rotate(122deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(118vw, 118vh) rotate(135deg) scale(0.9); }
}

@keyframes be-scurry-nw {
    0% { opacity: 0; transform: translate(118vw, 118vh) rotate(-48deg) scale(0.85); }
    8% { opacity: 1; }
    35% { transform: translate(68vw, 68vh) rotate(-58deg) scale(1); }
    65% { transform: translate(28vw, 28vh) rotate(-38deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(-18vw, -18vh) rotate(-45deg) scale(0.9); }
}

@keyframes be-scurry-ne {
    0% { opacity: 0; transform: translate(-16vw, 118vh) rotate(48deg) scale(0.85); }
    8% { opacity: 1; }
    40% { transform: translate(42vw, 58vh) rotate(38deg) scale(1); }
    70% { transform: translate(78vw, 22vh) rotate(56deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(118vw, -18vh) rotate(45deg) scale(0.9); }
}

@keyframes be-scurry-sw {
    0% { opacity: 0; transform: translate(118vw, -16vh) rotate(-128deg) scale(0.85); }
    8% { opacity: 1; }
    40% { transform: translate(58vw, 42vh) rotate(-140deg) scale(1); }
    70% { transform: translate(22vw, 78vh) rotate(-118deg); }
    92% { opacity: 1; }
    100% { opacity: 0; transform: translate(-18vw, 118vh) rotate(-135deg) scale(0.9); }
}

@media (prefers-reduced-motion: reduce) {
    .be-scurry { display: none !important; }
}
