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

body.lw-page {
    margin: 0;
    min-height: 100vh;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", Georgia, serif;
    color: #f4ead5;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 16% 0%, rgba(244, 196, 48, 0.18), transparent 36%),
        radial-gradient(circle at 88% 8%, rgba(201, 12, 15, 0.22), transparent 40%),
        linear-gradient(180deg, #161226 0%, #241c36 46%, #100d18 100%);
}

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

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

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

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

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

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

.lw-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: 720px;
    margin: 0 auto 0.85rem;
    padding: 0.55rem 0.7rem;
    background: linear-gradient(180deg, #3a2d4e, #1a1424);
    border: 3px solid #120e18;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.lw-lcd {
    min-width: 4.6rem;
    padding: 0.2rem 0.45rem;
    background: #0a1418;
    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);
}

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

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

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

.lw-tool-btn,
.lw-next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(244, 196, 48, 0.28);
    background: rgba(10, 20, 24, 0.75);
    color: #f4ead5 !important;
    font-weight: 700;
    cursor: pointer;
}

.lw-tool-btn:hover,
.lw-next:hover {
    border-color: #f5c518;
    color: #f5c518 !important;
}

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

.lw-next {
    display: flex;
    width: min(720px, 100%);
    margin: 0.9rem auto 0;
    background: #c90c0f !important;
    color: #fff !important;
    border: none;
    font-size: 1.05rem;
}

.lw-next:hover {
    background: #a50a0c !important;
    color: #fff !important;
}

.lw-next[hidden] {
    display: none;
}

.lw-prompt {
    text-align: center;
    font-size: clamp(1.05rem, 3.2vw, 1.4rem);
    font-weight: 800;
    color: #fff8e7;
    margin: 0 auto 0.35rem;
    max-width: 40rem;
    line-height: 1.35;
}

.lw-status {
    text-align: center;
    min-height: 1.45rem;
    margin: 0 auto 0.75rem;
    color: #fde68a;
    font-weight: 700;
    max-width: 40rem;
}

.lw-status.is-good {
    color: #bbf7d0;
}

.lw-status.is-bad {
    color: #fecaca;
}

.lw-board {
    max-width: 720px;
    margin: 0 auto;
}

.lw-pair {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.45rem 0.55rem;
    align-items: center;
}

.lw-rel {
    color: #f4c430;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-align: center;
}

.lw-rel-as {
    grid-column: 1 / -1;
    margin: 0.15rem 0;
}

.lw-matrix {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    max-width: 460px;
    margin: 0 auto;
}

.lw-card {
    background: #fffaf3;
    border: 3px solid #1c1917;
    border-radius: 16px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.35rem 0.15rem;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.lw-card svg {
    width: min(118px, 26vw);
    height: min(118px, 26vw);
}

.lw-card figcaption {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #7c2d12;
    font-weight: 800;
}

.lw-unknown {
    border-style: dashed;
    border-color: #c90c0f;
    background:
        radial-gradient(circle at 50% 40%, rgba(244, 196, 48, 0.35), transparent 60%),
        #fffaf3;
}

.lw-unknown strong {
    font-size: 2.4rem;
    color: #c90c0f;
    line-height: 1;
}

.lw-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    max-width: 720px;
    margin: 1rem auto 0;
}

.lw-options.is-six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lw-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 0;
    padding: 0.35rem 0.3rem 0.25rem;
    border-radius: 14px;
    border: 3px solid #c90c0f;
    background: #fff !important;
    color: #1a1a1a !important;
    font-weight: 800;
    cursor: pointer;
}

.lw-option svg {
    width: min(92px, 24vw);
    height: min(92px, 24vw);
}

.lw-option-key {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: #7f1d1d;
}

.lw-option:hover:not(:disabled) {
    transform: translateY(-2px);
    background: #fff7ed !important;
    color: #1a1a1a !important;
}

.lw-option.is-correct {
    background: #dcfce7 !important;
    box-shadow: 0 0 0 4px #16a34a;
    color: #14532d !important;
}

.lw-option.is-wrong {
    background: #fecaca !important;
    box-shadow: 0 0 0 4px #c90c0f;
    color: #7f1d1d !important;
}

.lw-option:disabled {
    cursor: default;
}

.lw-option.is-hidden {
    visibility: hidden;
}

.lw-hint {
    text-align: center;
    color: #e7d3b0;
    font-size: 0.92rem;
    margin: 0.85rem auto 0;
    max-width: 40rem;
}

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

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

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

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

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

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

.lw-page .btn-primary:hover {
    background: #a50a0c !important;
    color: #fff !important;
}

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

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

@media (min-width: 760px) {
    .lw-options.is-six {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-height: 860px) {
    .lw-card svg,
    .lw-option svg {
        width: 78px;
        height: 78px;
    }

    .lw-prompt {
        margin-bottom: 0.2rem;
    }

    .lw-options {
        margin-top: 0.55rem;
        gap: 0.45rem;
    }
}

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

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

    .lw-card {
        min-height: 92px;
    }

    .lw-card svg,
    .lw-option svg {
        width: 84px;
        height: 84px;
    }

    .lw-rel {
        font-size: 0.82rem;
    }
}
