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

body.lz-page {
    margin: 0;
    min-height: 100vh;
    background: #140f08;
    color: #f6edd8;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

body.lz-page.game-menu-active {
    overflow-x: hidden;
    overflow-y: auto;
    background:
        radial-gradient(circle at 18% 0%, rgba(214, 222, 167, 0.2), transparent 42%),
        linear-gradient(180deg, #2a220f 0%, #141006 70%);
}

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

body.lz-page.lz-playing {
    overflow: hidden;
    height: 100%;
}

.lz-page .game-screen {
    display: none;
}

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

.lz-stage {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    background: #100e08;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

.lz-view {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.lz-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at center, transparent 42%, rgba(12, 9, 4, 0.55) 100%),
        linear-gradient(180deg, rgba(255, 244, 210, 0.05), transparent 18%, transparent 78%, rgba(0, 0, 0, 0.28));
}

.lz-crosshair {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.lz-crosshair::before,
.lz-crosshair::after {
    content: "";
    position: absolute;
    background: rgba(20, 14, 6, 0.85);
    box-shadow: 0 0 0 1px rgba(246, 236, 196, 0.85);
}

.lz-crosshair::before {
    left: 8px;
    top: 2px;
    width: 2px;
    height: 14px;
}

.lz-crosshair::after {
    left: 2px;
    top: 8px;
    width: 14px;
    height: 2px;
}

.lz-hud {
    position: absolute;
    top: 0.7rem;
    left: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    z-index: 3;
    pointer-events: none;
}

.lz-hud span {
    background: rgba(18, 14, 8, 0.78);
    color: #f6edd4;
    border: 1px solid rgba(246, 237, 212, 0.28);
    border-radius: 6px;
    padding: 0.28rem 0.55rem;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
}

.lz-minimap {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    width: 132px;
    height: 132px;
    border: 1px solid rgba(246, 237, 212, 0.35);
    border-radius: 8px;
    background: rgba(12, 10, 6, 0.72);
    z-index: 3;
    pointer-events: none;
}

body.lz-no-map .lz-minimap {
    display: none;
}

@media (max-width: 700px) {
    .lz-hud {
        max-width: calc(100% - 6.2rem);
    }

    .lz-minimap {
        top: 2.8rem;
        width: 84px;
        height: 84px;
    }
}

.lz-prompt,
.lz-toast,
.lz-fadehint {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    color: #f8f1dc;
    background: rgba(18, 14, 8, 0.78);
    border: 1px solid rgba(246, 237, 212, 0.28);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-size: 0.92rem;
    text-align: center;
    max-width: calc(100% - 2rem);
}

.lz-prompt { bottom: 1.3rem; }
.lz-toast { top: 3.2rem; }
.lz-fadehint {
    bottom: 4.2rem;
    transition: opacity 0.6s ease;
}

.lz-fadehint.lz-gone {
    opacity: 0;
}

.lz-prompt[hidden],
.lz-toast[hidden],
.lz-fadehint[hidden] {
    display: none !important;
}

.lz-puzzle,
.lz-win {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -48%);
    width: min(440px, calc(100% - 1.25rem));
    max-height: calc(100% - 1.25rem);
    overflow: auto;
    z-index: 6;
    background: #e7e6c2;
    color: #24180c;
    border: 1px solid #c3cb6e;
    border-radius: 4px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    padding: 1rem 1.05rem 0.95rem;
}

.lz-puzzle[hidden],
.lz-win[hidden] {
    display: none !important;
}

.lz-kicker {
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #7a5a28;
    font-weight: 700;
}

.lz-puzzle h2,
.lz-win h2 {
    margin: 0.35rem 0 0.75rem;
    font-size: 1.28rem;
    line-height: 1.35;
    color: #24180c;
    font-weight: 700;
}

.lz-answer {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.55rem;
    font-weight: 700;
    text-align: center;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 2px solid #6e5428;
    background: #fffaf0;
    color: #24180c;
    margin-bottom: 0.7rem;
}

.lz-answer:focus {
    outline: 3px solid #9f1d18;
    outline-offset: 1px;
}

.lz-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.7rem;
}

.lz-key,
.lz-text-btn,
.lz-submit {
    min-height: 46px;
    border-radius: 8px;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
}

.lz-key {
    background: #2c2418;
    color: #f6edd4;
    border: 0;
}

.lz-space {
    grid-column: 1 / -1;
}

.lz-code-order[hidden] {
    display: none;
}

.lz-code-order {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.15rem 0.25rem;
    margin: 0 0 0.85rem;
    padding: 0.35rem 0.45rem;
    background: #d6dea7;
    border: 2px solid #24180c;
    border-radius: 8px;
}

.lz-code-sketch {
    width: 52px;
    height: 52px;
    display: block;
    background: transparent;
}

.lz-code-sep {
    width: 22px;
    height: 34px;
    display: block;
    background: transparent;
}

.lz-key:hover,
.lz-key:focus-visible {
    background: #433628;
    color: #fff8e6;
}

.lz-puzzle-actions,
.lz-win-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.lz-text-btn,
.lz-submit {
    flex: 1 1 120px;
    border: 0;
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
}

.lz-text-btn {
    background: #fffaf0;
    color: #24180c;
    border: 2px solid #24180c;
}

.lz-text-btn:hover,
.lz-text-btn:focus-visible {
    background: #24180c;
    color: #f6edd4;
}

.lz-submit {
    background: #9f1d18;
    color: #ffffff;
}

.lz-submit:hover,
.lz-submit:focus-visible {
    background: #7e1511;
    color: #ffffff;
}

.lz-hint-line,
.lz-msg {
    min-height: 1.2rem;
    margin: 0.55rem 0 0;
    color: #5c4520;
    font-size: 0.92rem;
}

.lz-msg {
    color: #9f1d18;
    font-weight: 700;
}

.lz-puzzle.lz-shake {
    animation: lz-shake 0.28s linear;
}

@keyframes lz-shake {
    0%, 100% { transform: translate(-50%, -48%); }
    25% { transform: translate(calc(-50% - 7px), -48%); }
    75% { transform: translate(calc(-50% + 7px), -48%); }
}

.lz-touch {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0.75rem 0.85rem max(0.85rem, env(safe-area-inset-bottom));
    pointer-events: none;
}

body.lz-coarse .lz-touch {
    display: flex;
}

body.lz-coarse .lz-prompt {
    bottom: 8.2rem;
}

body.lz-coarse .lz-fadehint {
    bottom: 11rem;
}

.lz-stick {
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: rgba(18, 14, 8, 0.4);
    border: 2px solid rgba(244, 226, 176, 0.7);
    position: relative;
    pointer-events: auto;
}

.lz-knob {
    position: absolute;
    width: 48px;
    height: 48px;
    left: 50%;
    top: 50%;
    margin: -24px 0 0 -24px;
    border-radius: 50%;
    background: #f3e2b0;
    border: 2px solid #24180c;
}

.lz-door-btn {
    pointer-events: auto;
    min-width: 108px;
    min-height: 56px;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    background: #f3e2b0;
    color: #24180c;
    border: 2px solid #24180c;
    font-weight: 800;
    font-size: 1rem;
}

.lz-door-btn:hover,
.lz-door-btn:focus-visible {
    background: #fff6d8;
    color: #24180c;
}

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

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

.lz-page .modal-content {
    width: min(640px, 100%);
    max-height: min(86vh, 760px);
    overflow: auto;
    background: #f7f0df;
    color: #24180c;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

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

.lz-page .modal-header {
    border-bottom: 1px solid #d6dea7;
}

.lz-page .modal-header h2 {
    margin: 0;
    color: #9f1d18;
    font-size: 1.3rem;
}

.lz-page .modal-close {
    background: #fffaf0;
    color: #24180c;
    border: 2px solid #24180c;
    border-radius: 8px;
    min-width: 40px;
    min-height: 40px;
    cursor: pointer;
    font-size: 1.1rem;
}

.lz-page .modal-close:hover,
.lz-page .modal-close:focus-visible {
    background: #24180c;
    color: #f6edd4;
}

.lz-page .modal-body {
    padding: 1rem 1.15rem 1.15rem;
    line-height: 1.5;
}

.lz-page .modal-body p,
.lz-page .modal-body li {
    color: #24180c;
}

.lz-page .modal-footer {
    border-top: 1px solid #d6dea7;
    justify-content: flex-end;
}

.lz-page .btn {
    min-height: 44px;
    border-radius: 8px;
    border: 0;
    padding: 0.55rem 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.lz-page .btn-primary {
    background: #9f1d18;
    color: #ffffff;
}

.lz-page .btn-primary:hover,
.lz-page .btn-primary:focus-visible {
    background: #7e1511;
    color: #ffffff;
}

.lz-page .btn-secondary {
    background: #4a3c28;
    color: #ffffff;
}

.lz-page .btn-secondary:hover,
.lz-page .btn-secondary:focus-visible {
    background: #2e2618;
    color: #ffffff;
}

.lz-diff {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.lz-page .difficulty-pill {
    background: #fffaf0;
    color: #24180c;
    border: 2px solid #9f1d18;
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.lz-page .difficulty-pill.active,
.lz-page .difficulty-pill:hover,
.lz-page .difficulty-pill:focus-visible {
    background: #9f1d18;
    color: #ffffff;
}

.lz-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.8rem 0 0;
    color: #24180c;
    font-weight: 600;
}

.lz-check input {
    width: 1.1rem;
    height: 1.1rem;
}

.lz-range {
    width: 100%;
    accent-color: #9f1d18;
}

.lz-note {
    color: #5c4520;
    font-size: 0.92rem;
}

.lz-stats-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.lz-stats-list li {
    background: #fffaf0;
    border: 1px solid #d6dea7;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
}

.lz-stats-list strong {
    display: block;
    font-size: 1.2rem;
    color: #24180c;
}

.lz-help-list {
    margin: 0.4rem 0 0;
    padding-left: 1.15rem;
}

.lz-ending {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: #000;
    opacity: 0;
}

.lz-ending[hidden] {
    display: none !important;
}

.lz-ending.is-in {
    opacity: 1;
    transition: opacity 1.2s ease;
}

.lz-ending-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    display: block;
}

.lz-ending.is-photo .lz-ending-photo {
    animation: lz-flicker 1.45s linear forwards;
}

@keyframes lz-flicker {
    0%, 13.9% { opacity: 0; }
    14%, 27.9% { opacity: 1; }
    28%, 47.9% { opacity: 0; }
    48%, 65.9% { opacity: 1; }
    66%, 85.9% { opacity: 0; }
    86%, 100% { opacity: 1; }
}

.lz-ending .lz-win {
    top: auto;
    bottom: 1.15rem;
    transform: translateX(-50%);
    width: min(520px, calc(100% - 1.5rem));
    background: rgba(16, 12, 8, 0.9);
    color: #f6edd4;
    border: 1px solid rgba(214, 222, 167, 0.5);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    opacity: 0;
}

.lz-ending.is-result .lz-win {
    opacity: 1;
    transition: opacity 0.7s ease;
}

.lz-ending .lz-kicker {
    color: #d6dea7;
}

.lz-ending .lz-win h2,
.lz-ending .lz-win p {
    color: #f6edd4;
}

.lz-ending .lz-text-btn {
    background: #2c2418;
    color: #f6edd4;
    border: 2px solid #d6dea7;
}

.lz-ending .lz-text-btn:hover,
.lz-ending .lz-text-btn:focus-visible {
    background: #d6dea7;
    color: #24180c !important;
}

.lz-ending .lz-submit {
    background: #C90C0F;
    color: #fff;
}

.lz-ending .lz-submit:hover,
.lz-ending .lz-submit:focus-visible {
    background: #9a0a0c;
    color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    .lz-puzzle.lz-shake {
        animation: none;
    }

    .lz-ending,
    .lz-ending-photo,
    .lz-ending .lz-win {
        transition: none;
    }

    .lz-ending.is-photo .lz-ending-photo {
        animation: none;
        opacity: 1;
    }
}
