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

body.mm-page {
    margin: 0;
    min-height: 100vh;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: #f8f1e3;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 12% 8%, rgba(201, 12, 15, 0.18), transparent 42%),
        radial-gradient(circle at 88% 10%, rgba(244, 196, 48, 0.14), transparent 46%),
        linear-gradient(180deg, #1a120c 0%, #2a1c14 48%, #120c08 100%);
}

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

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

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

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

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

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

.mm-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: 520px;
    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);
}

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

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

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

.mm-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    margin: 0 auto 0.85rem;
    max-width: 520px;
}

.mm-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(244, 196, 48, 0.28);
    background: rgba(20, 12, 8, 0.75);
    color: #f8f1e3;
    font-weight: 700;
    cursor: pointer;
}

.mm-tool-btn:hover {
    border-color: #f5c518;
    color: #f5c518;
}

.mm-tool-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.mm-status {
    text-align: center;
    min-height: 1.4rem;
    margin: 0 auto 0.75rem;
    color: #fde68a;
    font-weight: 700;
}

.mm-board-wrap {
    display: flex;
    justify-content: center;
    padding: 0.35rem 0.25rem 0.5rem;
}

.mm-board {
    --mm-board-w: min(92vw, 480px);
    width: var(--mm-board-w);
    background: linear-gradient(180deg, #4a2e1c 0%, #2c1a10 100%);
    border: 4px solid #1a100c;
    border-radius: 18px;
    padding: 0.65rem 0.55rem 0.7rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 16px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.mm-secret {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.5rem 0.65rem;
    border-bottom: 2px solid rgba(0, 0, 0, 0.35);
    margin-bottom: 0.2rem;
}

.mm-secret-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #e7d3b0;
}

.mm-secret-pegs,
.mm-row-pegs {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
}

.mm-shield {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
}

.mm-row {
    display: grid;
    grid-template-columns: 1.4rem 1fr auto;
    align-items: center;
    gap: 0.35rem;
    padding: 0.08rem 0.1rem;
    border-radius: 10px;
}

.mm-row.is-current {
    background: rgba(244, 196, 48, 0.12);
    box-shadow: inset 0 0 0 2px rgba(244, 196, 48, 0.35);
}

.mm-row-num {
    font-size: 0.72rem;
    font-weight: 800;
    color: #c4a574;
    text-align: center;
}

.mm-peg,
.mm-hole {
    width: clamp(22px, 5.2vw, 36px);
    height: clamp(22px, 5.2vw, 36px);
    border-radius: 50%;
    border: 0;
    padding: 0;
    cursor: pointer;
    position: relative;
    flex: 0 0 auto;
    box-shadow: inset 0 6px 8px rgba(255, 255, 255, 0.28), inset 0 -4px 6px rgba(0, 0, 0, 0.35), 0 3px 0 rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mm-hole {
    background:
        radial-gradient(circle at 50% 42%, #2a1c14 0 38%, #0a0604 70%);
    box-shadow: inset 0 4px 7px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 255, 255, 0.08);
    border: 2px solid #5a3a24;
    cursor: default;
}

.mm-row.is-current .mm-hole,
.mm-row.is-current .mm-peg {
    cursor: pointer;
}

.mm-row.is-current .mm-hole.is-selected {
    box-shadow: inset 0 0 0 3px #f4c430, inset 0 3px 6px rgba(0, 0, 0, 0.7);
}

.mm-peg.is-white {
    box-shadow: inset 0 6px 8px rgba(255, 255, 255, 0.55), inset 0 -4px 6px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.2), 0 3px 0 rgba(0, 0, 0, 0.25);
}

.mm-peg.is-black {
    box-shadow: inset 0 5px 6px rgba(255, 255, 255, 0.18), inset 0 -4px 6px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.18), 0 3px 0 rgba(0, 0, 0, 0.4);
}

.mm-peg:focus-visible,
.mm-hole:focus-visible,
.mm-swatch:focus-visible,
.mm-submit:focus-visible,
.mm-tool-btn:focus-visible {
    outline: 3px solid #f4c430;
    outline-offset: 3px;
}

.mm-keys {
    display: grid;
    grid-template-columns: repeat(2, 12px);
    gap: 4px;
    padding: 4px;
    background: #1a100c;
    border-radius: 6px;
}

.mm-keys.is-five {
    grid-template-columns: repeat(3, 12px);
}

.mm-key {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3d2a1c;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7);
}

.mm-key.is-black {
    background: #111;
    box-shadow: 0 0 0 1px #000, inset 0 1px 1px rgba(255, 255, 255, 0.12);
}

.mm-key.is-white {
    background: #f4f1e8;
    box-shadow: 0 0 0 1px #3d2a1c;
}

.mm-palette-wrap {
    margin: 0.55rem auto 0;
    max-width: 520px;
    text-align: center;
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: 0.45rem 0.35rem 0.7rem;
    background: linear-gradient(180deg, rgba(18, 12, 8, 0), #120c08 28%);
}

.mm-palette-label {
    margin: 0 0 0.45rem;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #e7d3b0;
    font-weight: 800;
}

.mm-palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.mm-swatch {
    width: clamp(36px, 9vw, 48px);
    height: clamp(36px, 9vw, 48px);
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.35);
    cursor: pointer;
    box-shadow: inset 0 6px 8px rgba(255, 255, 255, 0.3), 0 4px 0 rgba(0, 0, 0, 0.3);
}

.mm-swatch.is-white {
    border-color: #888;
}

.mm-swatch:disabled {
    opacity: 0.4;
    cursor: default;
}

.mm-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 48px;
    padding: 0.7rem 1.4rem;
    border-radius: 999px;
    border: 0;
    background: #c90c0f;
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
}

.mm-submit:hover:not(:disabled) {
    background: #a00a0c;
    color: #fff;
}

.mm-submit:disabled {
    background: #5a3a24;
    color: #c4a574;
    cursor: default;
}

.mm-hint {
    text-align: center;
    color: #e7d3b0;
    font-size: 0.92rem;
    margin: 0.85rem 0 0;
}

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

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

.mm-help-pegs {
    display: flex;
    gap: 0.45rem;
    justify-content: center;
    margin-top: 0.6rem;
}

.mm-help-peg {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    display: inline-block;
}

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

.mm-reveal {
    display: flex;
    justify-content: center;
    gap: 0.45rem;
    margin: 0 0 1rem;
}

.mm-reveal .mm-peg {
    cursor: default;
}

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

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

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

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

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

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

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

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

@media (prefers-reduced-motion: reduce) {
    .mm-peg,
    .mm-swatch {
        transition: none;
    }
}
