/* Pattern Pulse playfield. Matches the poster: navy ground, coral rings, moon discs. */

body.patternpulse-page:not(.game-menu-active)::before {
    background:
        radial-gradient(circle at 50% 46%, transparent 0 150px, rgba(240, 122, 134, 0.28) 151px 158px, transparent 159px 250px, rgba(246, 239, 226, 0.16) 251px 258px, transparent 259px 360px, rgba(231, 168, 90, 0.22) 361px 368px, transparent 369px 480px, rgba(208, 106, 72, 0.18) 481px 488px, transparent 489px),
        radial-gradient(880px 420px at 50% -8%, #31457f 0%, transparent 62%),
        linear-gradient(180deg, #1a274f 0%, #121936 58%, #0e152e 100%);
}

body.patternpulse-page:not(.game-menu-active)::after {
    opacity: 0.2;
}

body.vault-tide.patternpulse-page {
    --game-primary: #f07a86;
    --game-header-title-color: #f07a86;
    --pp-navy: #1a2456;
    --pp-ink: #101735;
    --pp-coral: #f07a86;
    --pp-coral-deep: #d45364;
    --pp-cream: #f6efe2;
    --pp-sand: #e7c9a4;
    --pp-amber: #e7a85a;
    --pp-clay: #d06a48;
}

body.patternpulse-page.with-game-header {
    padding-top: 64px !important;
}

body.vault-tide.patternpulse-page .game-top-bar {
    background: linear-gradient(180deg, rgba(14, 21, 46, 0.94), rgba(14, 21, 46, 0.62)) !important;
    border-bottom: 1px solid rgba(240, 122, 134, 0.32) !important;
    box-shadow: none !important;
}

body.vault-tide.patternpulse-page.with-game-header .game-top-bar h1.game-title-header {
    color: #f07a86 !important;
    -webkit-text-fill-color: #f07a86;
    font-size: 1.15rem !important;
    letter-spacing: 0.16em !important;
    line-height: 1 !important;
    text-shadow: none !important;
}

body.patternpulse-page #game-screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    background: transparent;
    color: var(--pp-cream, #f6efe2);
    min-height: calc(100dvh - 64px);
    overflow-x: hidden;
}

body.patternpulse-page #stage {
    width: min(520px, calc(100% - 24px));
}

body.patternpulse-page #game-screen .vr-num {
    font-family: "Segoe UI", Outfit, system-ui, sans-serif !important;
    font-variant-numeric: tabular-nums lining-nums;
}

.pp-stage {
    position: relative;
    z-index: 1;
    width: 100%;
    margin: 0 auto;
    padding: 2px 0 12px;
}

.pp-hud {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 8px;
}

.pp-pill {
    min-height: 64px;
    padding: 8px 8px 10px;
    border-radius: 16px;
    background: rgba(10, 16, 38, 0.55);
    border: 1px solid rgba(246, 239, 226, 0.16);
    text-align: center;
    box-shadow: inset 0 1px 0 rgba(246, 239, 226, 0.08);
}

.pp-pill > span,
.pp-pill small {
    display: block;
}

.pp-pill > span {
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--pp-sand);
}

.pp-pill strong {
    display: block;
    margin-top: 2px;
    font-size: 1.25rem !important;
    font-weight: 700;
    line-height: 1.1;
    color: var(--pp-cream);
    white-space: nowrap;
}

.pp-of {
    margin-left: 1px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--pp-sand);
}

.pp-pill small {
    margin-top: 2px;
    font-size: 11px;
    color: rgba(231, 201, 164, 0.85);
}

.pp-lives {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.pp-pip {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--pp-coral);
    box-shadow: 0 0 0 3px rgba(240, 122, 134, 0.2);
}

.pp-pip.is-off {
    background: transparent;
    box-shadow: inset 0 0 0 2px rgba(246, 239, 226, 0.72);
}

.pp-kicker {
    margin: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--pp-coral);
}

.pp-lead {
    margin: 4px 0 0;
    text-align: center;
    color: var(--pp-sand);
    font-size: 15px;
}

.pp-orbit {
    position: relative;
    height: 118px;
    margin: 2px 0 0;
    overflow: hidden;
}

.pp-halo {
    position: absolute;
    left: 50%;
    top: 54%;
    width: min(640px, 150%);
    height: auto;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: pp-spin 42s linear infinite;
}

.pp-seq {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pp-term {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1 1 0;
    min-width: 0;
}

.pp-moon {
    width: min(64px, 100%);
    aspect-ratio: 1;
    height: auto;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.32);
}

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

.pp-term .vr-num {
    font-size: clamp(0.95rem, 3.6vw, 1.35rem) !important;
    font-weight: 700;
    line-height: 1;
    color: var(--pp-cream);
    letter-spacing: -0.03em;
}

.pp-term-next .pp-moon {
    background: radial-gradient(circle at 50% 45%, rgba(240, 122, 134, 0.18), rgba(16, 23, 53, 0.2) 62%);
    box-shadow: inset 0 0 0 3px var(--pp-coral), 0 0 18px rgba(240, 122, 134, 0.4);
    animation: pp-throb 1.15s ease-in-out infinite;
}

.pp-term-next .vr-num {
    color: var(--pp-coral);
}

.pp-term-reveal .pp-moon {
    box-shadow: 0 0 0 2px var(--pp-cream), 0 0 18px rgba(246, 239, 226, 0.35);
}

.pp-term-reveal .vr-num {
    color: var(--pp-cream);
}

.pp-metro {
    position: relative;
    width: 108px;
    height: 108px;
    margin: 0 auto 8px;
}

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

.pp-track,
.pp-arc,
.pp-ticks {
    fill: none;
}

.pp-track {
    stroke: rgba(246, 239, 226, 0.16);
    stroke-width: 7;
}

.pp-ticks {
    stroke: rgba(231, 168, 90, 0.55);
    stroke-width: 3;
    stroke-dasharray: 1.5 5.5;
}

.pp-arc {
    stroke: var(--pp-coral);
    stroke-width: 7;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 60px 60px;
    stroke-dasharray: 100;
    stroke-dashoffset: calc(100 * (1 - var(--pp-left, 1)));
    transition: stroke-dashoffset 0.9s linear;
    filter: drop-shadow(0 0 4px rgba(240, 122, 134, 0.45));
}

.pp-metro.is-low .pp-arc {
    stroke: #ffd7a8;
    filter: drop-shadow(0 0 6px rgba(255, 196, 140, 0.7));
}

.pp-metro.is-open .pp-arc {
    stroke: var(--pp-cream);
    filter: none;
}

.pp-entry {
    position: absolute;
    inset: 24px;
    display: grid;
    place-items: center;
    margin: 0;
    border-radius: 50%;
    background: rgba(12, 18, 42, 0.78);
    box-shadow: inset 0 0 0 1px rgba(246, 239, 226, 0.12);
    font-size: 1.85rem !important;
    font-weight: 700;
    color: var(--pp-cream);
    letter-spacing: -0.04em;
}

.pp-entry.is-empty {
    color: rgba(246, 239, 226, 0.32);
}

.pp-entry.is-reveal {
    color: #1a1220;
    background: var(--pp-coral);
}

.pp-pad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: min(360px, 100%);
    margin: 0 auto;
}

.pp-key {
    min-height: 50px;
    border: 0;
    border-radius: 16px;
    background: var(--pp-cream);
    color: var(--pp-navy);
    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 0 #c9b49a;
    touch-action: manipulation;
    user-select: none;
}

.pp-key:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #c9b49a;
}

.pp-key:disabled {
    opacity: 0.4;
    cursor: default;
}

.pp-key-ghost {
    background: transparent;
    color: var(--pp-cream);
    box-shadow: inset 0 0 0 1.5px rgba(246, 239, 226, 0.45);
}

.pp-key-ghost:active:not(:disabled) {
    box-shadow: inset 0 0 0 1.5px rgba(246, 239, 226, 0.45);
}

.pp-key-go {
    grid-column: 1 / -1;
    min-height: 52px;
    background: var(--pp-coral);
    color: #2a1220;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.95rem;
    box-shadow: 0 5px 0 var(--pp-coral-deep);
}

.pp-key-go:active:not(:disabled) {
    box-shadow: 0 2px 0 var(--pp-coral-deep);
}

.pp-key:focus-visible,
.pp-leave:focus-visible,
.pp-switch input:focus-visible + span {
    outline: 3px solid var(--pp-cream);
    outline-offset: 3px;
}

.pp-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.pp-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--pp-cream);
    font-size: 14px;
    cursor: pointer;
}

.pp-switch input {
    appearance: none;
    width: 42px;
    height: 26px;
    margin: 0;
    border-radius: 999px;
    border: 1px solid rgba(246, 239, 226, 0.35);
    background: rgba(10, 16, 38, 0.65);
    position: relative;
    cursor: pointer;
    flex: 0 0 auto;
}

.pp-switch input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--pp-cream);
    transition: transform 0.15s ease;
}

.pp-switch input:checked {
    background: var(--pp-coral);
    border-color: var(--pp-coral);
}

.pp-switch input:checked::after {
    transform: translateX(16px);
    background: #2a1220;
}

.pp-note {
    min-height: 1.4em;
    margin: 0;
    text-align: center;
    color: var(--pp-sand);
    font-size: 15px;
    line-height: 1.4;
}

.pp-leave {
    border: 0;
    background: none;
    color: var(--pp-sand);
    font: inherit;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.pp-stage.is-done .pp-leave,
.pp-finale .pp-key-go {
    width: min(360px, 100%);
    min-height: 52px;
    border-radius: 16px;
    background: var(--pp-coral);
    color: #2a1220;
    text-decoration: none;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 5px 0 var(--pp-coral-deep);
}

.pp-finale {
    min-height: calc(100dvh - 120px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
}

.pp-finale h2 {
    margin: 8px 0 0;
    font-size: clamp(40px, 8vw, 64px);
    line-height: 0.9;
    color: var(--pp-cream);
}

.pp-finale-score {
    margin: 8px 0 0;
    font-size: 4rem !important;
    line-height: 1;
    color: var(--pp-coral);
}

.pp-finale .pp-halo {
    position: relative;
    left: auto;
    top: auto;
    width: min(420px, 100%);
    transform: none;
    margin-bottom: -28px;
    animation: none;
}

body.patternpulse-page .modal-content {
    background: #f6efe2;
    color: #1a2456;
    border-radius: 22px;
    border: 3px solid #f07a86;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

body.patternpulse-page .modal-header h2 {
    margin: 0;
    color: #1a2456;
}

body.patternpulse-page .modal .vr-btn {
    border: 0;
    border-radius: 999px;
    background: #1a2456;
    color: #f6efe2;
    min-height: 40px;
}

body.patternpulse-page .vr-help p {
    line-height: 1.45;
}

body.patternpulse-page .vr-help strong {
    color: #d45364;
}

@keyframes pp-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes pp-throb {
    50% { box-shadow: inset 0 0 0 3px #f07a86, 0 0 26px rgba(240, 122, 134, 0.75); }
}

@media (max-width: 380px) {
    .pp-pad { gap: 8px; }
    .pp-key { min-height: 50px; border-radius: 14px; }
    .pp-orbit { height: 142px; }
    .pp-metro { width: 112px; height: 112px; }
    .pp-entry { font-size: 1.55rem !important; }
}

@media (max-height: 720px) {
    .pp-orbit { height: 132px; }
    .pp-metro { width: 108px; height: 108px; margin-bottom: 8px; }
    .pp-key { min-height: 46px; }
    .pp-hud { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .pp-halo,
    .pp-term-next .pp-moon,
    .pp-metro.is-low .pp-arc {
        animation: none !important;
    }

    .pp-arc,
    .pp-switch input::after,
    .pp-key {
        transition: none !important;
    }
}
