:root {
    --game-primary: #c90c0f;
    --game-secondary: #14b8a6;
    --pp-ink: #071816;
    --pp-navy: #102824;
    --pp-teal: #2dd4bf;
    --pp-copper: #d97706;
}

body.pp-page {
    margin: 0;
    min-height: 100vh;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: #f4f7fb;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 12% 8%, rgba(45, 212, 191, 0.16), transparent 42%),
        radial-gradient(circle at 88% 6%, rgba(201, 12, 15, 0.2), transparent 46%),
        linear-gradient(180deg, #071816 0%, #123830 48%, #071816 100%);
}

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

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

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

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

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

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

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

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

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

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

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

.pp-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(45, 212, 191, 0.28);
    background: rgba(7, 24, 22, 0.7);
    color: #f4f7fb !important;
    font-weight: 700;
    cursor: pointer;
}

.pp-tool-btn:hover {
    border-color: #2dd4bf;
    color: #5eead4 !important;
}

.pp-tool-btn.is-on {
    background: #0f766e;
    border-color: #5eead4;
    color: #fff !important;
}

.pp-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

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

.pp-hint {
    text-align: center;
    max-width: 36rem;
    margin: 0.75rem auto 0;
    color: #c5d4de;
    font-size: 0.92rem;
}

.pp-board-wrap {
    display: flex;
    justify-content: center;
    overflow: visible;
    max-width: 100%;
    padding: 0.35rem;
}

.pp-board {
    --pp-cell: min(72px, calc((min(94vw, 560px) - 1.2rem) / var(--pp-size, 6)));
    display: grid;
    grid-template-columns: repeat(var(--pp-size), var(--pp-cell));
    grid-template-rows: repeat(var(--pp-size), var(--pp-cell));
    gap: 0;
    background: #0b1f1c;
    border: 4px solid #071816;
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
    padding: 0.45rem;
    user-select: none;
    touch-action: manipulation;
}

.pp-cell {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background:
        linear-gradient(180deg, #1a2e2b 0%, #122422 100%);
    color: transparent;
    cursor: pointer;
    position: relative;
}

.pp-cell svg {
    display: block;
    width: 100%;
    height: 100%;
}

.pp-cell.is-cursor:not(:disabled) {
    outline: 2px solid #5eead4;
    outline-offset: -2px;
    z-index: 1;
}

.pp-cell.is-hint {
    box-shadow: inset 0 0 0 3px #fbbf24;
    z-index: 2;
}

.pp-cell.is-locked::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 2px;
    background: #fbbf24;
    box-shadow: 0 0 0 1px #7c2d12;
}

.pp-cell:disabled {
    cursor: default;
}

.pp-board.is-won .pp-cell {
    filter: saturate(1.15) brightness(1.05);
}

.pp-result-sheet {
    display: none;
    width: min(640px, calc(100% - 1.5rem));
    margin: 0.85rem auto 0;
    background: #fff;
    color: #1a1a1a;
    border-radius: 1rem;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
    z-index: 40;
}

.pp-result-sheet.active {
    display: block;
    animation: pp-sheet-in 0.4s ease;
}

.pp-result-sheet__inner {
    padding: 1rem 1.15rem 1.1rem;
}

.pp-result-sheet__header h2 {
    margin: 0 0 0.35rem;
    color: #c90c0f;
    font-size: 1.35rem;
}

.pp-result-sheet__actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

@keyframes pp-sheet-in {
    from {
        opacity: 0;
        transform: translateY(1.1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pp-settings-panel__label {
    margin: 0.85rem 0 0.45rem;
    font-weight: 700;
    color: #1a120c;
}

.pp-settings-panel__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

#settingsModal .difficulty-pill {
    border: 1px solid #99f6e4;
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    background: #f0fdfa;
    color: #134e4a !important;
    font-weight: 600;
    cursor: pointer;
}

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

.pp-settings-panel__note,
#settingsModal .pp-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;
}

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

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

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

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

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

    .pp-hud {
        max-width: 100%;
        gap: 0.4rem;
        padding: 0.4rem 0.45rem;
    }

    .pp-lcd {
        min-width: 0;
        flex: 1 1 0;
        font-size: 1rem;
    }

    .pp-toolbar {
        max-width: 100%;
        gap: 0.35rem;
    }

    .pp-tool-btn {
        min-height: 44px;
        padding: 0.45rem 0.6rem;
        color: #f4f7fb !important;
        background: rgba(7, 24, 22, 0.85);
    }

    .pp-board {
        --pp-cell: min(56px, calc((100vw - 2.4rem) / var(--pp-size, 6)));
        padding: 0.3rem;
    }

    .pp-cell {
        min-height: 0;
    }

    .pp-status {
        font-size: 0.88rem;
        padding: 0 0.15rem;
    }

    .modal {
        padding: 0.65rem;
        align-items: flex-end;
    }

    .modal-content {
        max-height: 88vh;
    }

    .pp-result-sheet.active {
        position: sticky;
        bottom: 0.35rem;
        max-height: 28vh;
        overflow-y: auto;
        width: min(100%, calc(100vw - 1rem));
        margin-top: 0.55rem;
        z-index: 30;
    }

    .win-stats {
        gap: 0.35rem;
    }
}
