body {
    margin-top: 72px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

.puzzle-header {
    text-align: center;
    margin: 32px auto 26px;
    position: relative;
}

.puzzle-header h1 {
    font-size: clamp(1.5rem, 3.6vw, 2rem);
    font-weight: 800;
    color: var(--dark);
    letter-spacing: -0.02em;
    line-height: 1.15;
    display: inline-flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.puzzle-header .puzzle-id {
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--gray);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--light-secondary, #f1f5f9);
    border: 1px solid var(--light-quaternary, #e2e8f0);
    padding: 4px 11px;
    border-radius: 999px;
    transform: translateY(-2px);
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto 24px;
}

/* ── Stats strip ─────────────────────────────────────── */
.puzzle-info {
    display: flex;
    gap: 0;
    margin: 0 auto 20px;
    max-width: 520px;
    width: 100%;
    background: white;
    border: 1px solid var(--light-quaternary);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

.info-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 14px 10px;
    gap: 3px;
    border-right: 1px solid var(--light-quaternary);
}

.info-item:last-child { border-right: none; }

.info-item span {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--dark);
    font-family: 'Orbitron', monospace;
    line-height: 1;
}

.info-item i {
    font-size: 0.85rem;
    color: var(--primary);
}

.info-item label {
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.game-menu {
    flex: 1;    
    gap: 16px;
    display: flex;
    flex-wrap: wrap;
    max-width: 800px;
    align-items: center;
    margin: 0 auto 50px auto;  
    justify-content: center;
    padding: 20px;
}

.game-menu button {
    position: relative;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    min-width: 130px;
    text-align: center;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 
        0 4px 15px rgba(37, 99, 235, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.game-menu button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.game-menu button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(37, 99, 235, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.game-menu button:hover::before {
    left: 100%;
}

.game-menu button:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 8px rgba(37, 99, 235, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.1);
}

.game-menu button:focus {
    outline: none;
    box-shadow: 
        0 4px 15px rgba(37, 99, 235, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 0 0 3px rgba(37, 99, 235, 0.3);
}

.game-menu button:nth-child(1) {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.game-menu button:nth-child(2) {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 
        0 4px 15px rgba(100, 116, 139, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-menu button:nth-child(2):hover {
    box-shadow: 
        0 8px 25px rgba(100, 116, 139, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.game-menu button:nth-child(3) {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 
        0 4px 15px rgba(245, 158, 11, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-menu button:nth-child(3):hover {
    box-shadow: 
        0 8px 25px rgba(245, 158, 11, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.game-menu button:nth-child(4) {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 
        0 4px 15px rgba(16, 185, 129, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-menu button:nth-child(4):hover {
    box-shadow: 
        0 8px 25px rgba(16, 185, 129, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.game-menu button.with-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.game-menu button.with-icon::after {
    content: attr(data-icon);
    font-size: 16px;
    opacity: 0.8;
}

@media screen and (max-width: 768px) {
    .game-menu {
        gap: 12px;
        max-width: 100%;
        padding: 15px;
    }

    .game-menu button {
        min-width: 110px;
        padding: 12px 20px;
        font-size: 14px;
    }
}

@media screen and (max-width: 480px) {
    .game-menu {
        flex-direction: column;
        gap: 10px;
    }

    .game-menu button {
        width: 100%;
        max-width: 200px;
        min-width: unset;
    }
}

.game-menu button.loading {
    pointer-events: none;
    opacity: 0.7;
}

.game-menu button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

.button-container {
    text-align: center;
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    pointer-events: none;
    z-index: 999;
}

.confetti-piece {
    opacity: 1;
    position: absolute;
    will-change: transform;
}

@keyframes rise {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 1;
        transform: translateY(calc(-1 * var(--max-height)));
    }
}

@keyframes fall {
    from {
        opacity: 1;
        transform: translateY(calc(-1 * var(--max-height)));
    }
    to {
        opacity: 0;
        transform: translateY(100vh);
    }
}

.close-btn {
    background: none;
    border: none;
    color: var(--gray-dark);
    font-size: 2rem;
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--accent-red);
}

.overlay {
    display: flex;
    align-items: center;
    justify-content: center;

    position: fixed;
    top: 0;
    left: 0;

    width: 100vw;
    height: 100vh;

    background-color: rgba(0, 0, 0, 0.8);

    z-index: 99;

    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
}

.overlay.active {
    visibility: visible;
    opacity: 1;
}

.alert-win {
    width: 100%;
    padding: 40px;
    max-width: 400px;
    text-align: center;
    border-radius: 15px;
    transform: scale(0.8);
    background-color: #fff;
    transition: transform 0.3s ease-in-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.overlay.active .alert-win {
    transform: scale(1);
}

.alert-win h1 {
    font-size: 2rem;
    color: var(--dark);
    margin-bottom: 10px;
}

.alert-win h2 {
    font-size: 1.2rem;
    color: var(--gray);
    margin-bottom: 30px;
    font-weight: 400;
    line-height: 1.5;
}

.alert-win h2 span {
    color: var(--primary);
    font-weight: 700;
}

.play-again {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.play-again-btn {
    margin: 0;
    border: none;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 11px 24px;
    border-radius: 8px;
    background: var(--primary);
    transition: background 0.2s ease;
    font-family: inherit;
}

.play-again-btn:hover { background: var(--primary-dark); }

.home-btn {
    margin: 0;
    border: 1px solid var(--light-quaternary);
    color: var(--gray-dark);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 11px 24px;
    border-radius: 8px;
    background: var(--light-secondary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.home-btn:hover { background: var(--dark); color: white; border-color: var(--dark); }

.grow-text {
    animation: grow-text 0.3s ease forwards;
}

@keyframes grow-text {
    0% {
      transform: scale(0);
      opacity: 0;
    }
    100% {
      transform: scale(1);
      opacity: 1;
    }
}

.shrink-text {
    animation: shrink-text 0.3s ease forwards;
}

@keyframes shrink-text {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

@media (max-width: 600px) {
    .alert-win {
        max-width: 90%;
        padding: 20px;
    }

    .alert-win h1 {
        font-size: 1.5rem;
    }

    .alert-win h2 {
        font-size: 1.2rem;
    }

    .play-again button {
        width: 100%;
    }
}

.how-to-play-section {
    margin-top: 2rem;
    margin-bottom: 50px;
    background: var(--glass-strong);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    overflow: hidden;
    transition: all 0.4s ease;
    position: relative;
}

.how-to-play-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.6), 
        transparent
    );
}

.how-to-play-section:hover {
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 12px 20px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.how-to-play-toggle {
    width: 100%;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(255, 255, 255, 0.05) 100%
    );
    border: none;
    padding: 1.5rem 2rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.how-to-play-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent
    );
    transition: left 0.5s ease;
}

.how-to-play-toggle:hover::before {
    left: 100%;
}

.how-to-play-toggle:hover {
    background: linear-gradient(135deg, 
        rgba(37, 99, 235, 0.1) 0%, 
        rgba(139, 92, 246, 0.05) 100%
    );
    color: var(--primary);
}

.how-to-play-toggle i:first-child {
    font-size: 1.3rem;
    opacity: 0.8;
}

.how-to-play-toggle i:last-child {
    font-size: 1rem;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.how-to-play-toggle.expanded i:last-child {
    transform: rotate(180deg);
}

.how-to-play-toggle span {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.how-to-play-content {
    padding: 0 2rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg,
        var(--light) 0%,
        rgba(248, 250, 252, 0.95) 100%
    );
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    position: relative;
}

.how-to-play-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 2rem;
    right: 2rem;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(37, 99, 235, 0.2), 
        transparent
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.how-to-play-content.expanded {
    max-height: 800px;
    padding: 2.5rem 2rem;
}

.how-to-play-content.expanded::before {
    opacity: 1;
}

.how-to-play-content h3 {
    color: var(--dark);
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    text-align: center;
    position: relative;
    letter-spacing: 0.5px;
}

.how-to-play-content h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 1px;
}

.how-to-play-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 1.25rem;
}

.how-to-play-content li {
    padding: 1.25rem 1.5rem;
    color: var(--gray-dark);
    line-height: 1.7;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    border: 1px solid rgba(37, 99, 235, 0.1);
    transition: all 0.3s ease;
    position: relative;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.how-to-play-content li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary), var(--primary-light));
    border-radius: 0 2px 2px 0;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.how-to-play-content li:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(37, 99, 235, 0.1),
        0 3px 10px rgba(0, 0, 0, 0.06);
    border-color: rgba(37, 99, 235, 0.2);
}

.how-to-play-content li:hover::before {
    opacity: 1;
    width: 5px;
}

.how-to-play-content li strong {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
    display: block;
    margin-bottom: 0.5rem;
    letter-spacing: 0.3px;
    position: relative;
    padding-left: 1.5rem;
}

.how-to-play-content li strong::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.how-to-play-content li:nth-child(1) strong::before { background: var(--accent-green); box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2); }
.how-to-play-content li:nth-child(2) strong::before { background: var(--accent-cyan); box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2); }
.how-to-play-content li:nth-child(3) strong::before { background: var(--accent-pink); box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.2); }
.how-to-play-content li:nth-child(4) strong::before { background: var(--accent); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
.how-to-play-content li:nth-child(5) strong::before { background: var(--accent-violet); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2); }
.how-to-play-content li:nth-child(6) strong::before { background: var(--accent-red); box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); }

/* Responsive Design */
@media screen and (max-width: 768px) {
    .how-to-play-toggle {
        padding: 1.25rem 1.5rem;
        font-size: 1rem;
        gap: 0.75rem;
    }

    .how-to-play-content.expanded {
        padding: 2rem 1.5rem;
    }

    .how-to-play-content h3 {
        font-size: 1.2rem;
    }

    .how-to-play-content li {
        padding: 1rem 1.25rem;
    }

    .how-to-play-content li strong {
        font-size: 0.95rem;
        padding-left: 1.25rem;
    }
}

@media screen and (max-width: 414px) {
    .puzzle-header h1 {
        font-size: 20px;
    }

    .puzzle-header .puzzle-id {
        font-size: 16px;
    }

    .how-to-play-section {
        margin-bottom: 30px;
        border-radius: 16px;
    }

    .how-to-play-toggle {
        padding: 1rem;
        font-size: 0.95rem;
    }

    .how-to-play-content.expanded {
        padding: 1.5rem 1rem;
    }

    .how-to-play-content ul {
        gap: 1rem;
    }

    .how-to-play-content li {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .how-to-play-content li strong {
        font-size: 0.9rem;
        padding-left: 1rem;
    }
}

/* ============================================================
   PREMIUM PASS — overrides the legacy accordion above into a
   clean "How to Play" pill button + centred modal, plus shared
   level-selector, toast, and a richer win dialog.
   (Later rules win over the earlier same-specificity ones.)
   ============================================================ */

/* How to Play — trigger pill (replaces full-width glass bar) */
.how-to-play-section {
    margin: 0 auto 48px;
    text-align: center;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    overflow: visible;
}
.how-to-play-section::before { display: none; }
.how-to-play-section:hover { transform: none; box-shadow: none; }

.how-to-play-toggle {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.07);
    border: 1px solid rgba(37, 99, 235, 0.16);
    color: var(--primary-dark);
    box-shadow: none;
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.how-to-play-toggle i:first-child {
    font-size: 0.92rem;
    opacity: 1;
    color: var(--primary);
    width: auto;
    height: auto;
    background: none;
    box-shadow: none;
    border-radius: 0;
    transition: transform 0.22s ease;
}
.how-to-play-toggle:hover {
    transform: translateY(-2px);
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.34);
    color: var(--primary-dark);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.14);
}
.how-to-play-toggle:hover i:first-child { transform: scale(1.12); }
.how-to-play-toggle:hover::before { left: -100%; }
.how-to-play-toggle i:last-child { display: none; }

/* How to Play — modal backdrop + card */
.how-to-play-content {
    position: fixed;
    inset: 0;
    max-height: none;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}
.how-to-play-content::before { display: none; }
.how-to-play-content.expanded {
    max-height: none;
    padding: 24px;
    opacity: 1;
    visibility: visible;
}

.htp-card {
    position: relative;
    width: 100%;
    max-width: 540px;
    max-height: 86vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 22px;
    padding: 2.6rem 2rem 2rem;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
    transform: scale(0.92);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease;
}
.how-to-play-content.expanded .htp-card { transform: scale(1); opacity: 1; }

.htp-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--light-secondary, #f1f5f9);
    color: var(--gray-dark, #475569);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
}
.htp-close:hover {
    background: var(--accent-red, #ef4444);
    color: #fff;
    transform: rotate(90deg);
}

body.htp-open { overflow: hidden; }

/* Shared level selector (new games rely on this; legacy per-game
   files still override harmlessly). */
.level-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0 auto 22px;
    max-width: 720px;
    padding: 0 20px;
}
.level-btn {
    padding: 10px 22px;
    border-radius: 12px;
    border: 2px solid var(--light-quaternary);
    background: #fff;
    color: var(--gray-dark);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.3;
    font-family: inherit;
}
.level-btn small { font-size: 0.74rem; color: var(--gray); display: block; }
.level-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.level-btn.active {
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}
.level-btn.active small { color: rgba(255, 255, 255, 0.85); }

/* Richer win dialog */
.alert-win {
    position: relative;
    overflow: hidden;
    transform: scale(0.85);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.alert-win::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), var(--accent-cyan), var(--accent-pink), var(--accent));
}

/* Toasts */
#pnp-toast-host {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}
.pnp-toast {
    pointer-events: auto;
    background: var(--dark, #1e293b);
    color: #fff;
    padding: 13px 20px;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    gap: 9px;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition: all 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-width: 92vw;
}
.pnp-toast.show { opacity: 1; transform: translateY(0) scale(1); }
.pnp-toast.record { background: linear-gradient(135deg, #f59e0b, #d97706); }
.pnp-toast.info { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.pnp-toast a { color: #fff; text-decoration: underline; }
.pnp-toast i { font-size: 1rem; }

@media (max-width: 600px) {
    .htp-card { padding: 2.2rem 1.3rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .htp-card,
    .pnp-toast,
    .alert-win,
    .how-to-play-content { transition: none !important; }
}

/* ============================================================
   HOW TO PLAY — modern modal (2026 pass)
   A clean white sheet with a gradient icon badge in the header
   and soft, card-like instruction rows (no coloured left bars),
   each revealing with a gentle stagger.
   ============================================================ */
.how-to-play-content {
    background: rgba(15, 23, 42, 0.66);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
}

.htp-card {
    max-width: 540px;
    max-height: 86vh;
    padding: 0;
    border-radius: 28px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.4), 0 2px 0 rgba(255, 255, 255, 0.6) inset;
    display: flex;
    flex-direction: column;
}

/* subtle sheet grabber at the very top */
.htp-card::before {
    content: "";
    position: absolute;
    top: 11px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.14);
    z-index: 3;
}

/* Soft-tinted header with a gradient icon badge + divider */
.htp-card h3 {
    margin: 0;
    flex: none;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 30px 60px 20px 26px;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    text-align: left;
    color: var(--dark);
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0));
    border-bottom: 1px solid var(--light-quaternary, #e2e8f0);
}
.htp-card h3::after { display: none; }            /* drop the underline accent */
.htp-card h3::before {
    content: "\f05a";                              /* fa info-circle */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 1rem;
    flex: none;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

.htp-close {
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    background: var(--light-secondary, #f1f5f9);
    color: var(--gray-dark, #475569);
}
.htp-close:hover {
    background: var(--accent-red, #ef4444);
    color: #fff;
    transform: rotate(90deg);
}

/* Instruction list — soft rounded rows, no left colour bar.
   This is the scroll area: header stays pinned, long content scrolls. */
.how-to-play-content ul {
    gap: 10px;
    padding: 18px 20px 22px;
    background: #fff;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.how-to-play-content li {
    padding: 14px 16px;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 14px;
    background: var(--light-secondary, #f8fafc);
    box-shadow: none;
    backdrop-filter: none;
    color: var(--gray-dark);
    line-height: 1.6;
    font-size: 0.94rem;
    text-align: justify;
    opacity: 0;
    transform: translateY(8px);
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.how-to-play-content li::before { display: none; }   /* kill the left colour bar */
.how-to-play-content li:hover {
    background: #fff;
    border-color: var(--light-quaternary, #e2e8f0);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    transform: translateY(0);
}

/* Heading of each row: a small coloured dot + label */
.how-to-play-content li strong {
    padding-left: 1.5rem;
    margin-bottom: 0.3rem;
    color: var(--dark);
    font-size: 0.97rem;
}
.how-to-play-content li strong::before {
    width: 9px;
    height: 9px;
    box-shadow: none;
}

/* Staggered reveal once the modal is open */
.how-to-play-content.expanded li {
    animation: htpRowIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.how-to-play-content.expanded li:nth-child(1) { animation-delay: 0.05s; }
.how-to-play-content.expanded li:nth-child(2) { animation-delay: 0.10s; }
.how-to-play-content.expanded li:nth-child(3) { animation-delay: 0.15s; }
.how-to-play-content.expanded li:nth-child(4) { animation-delay: 0.20s; }
.how-to-play-content.expanded li:nth-child(5) { animation-delay: 0.25s; }
.how-to-play-content.expanded li:nth-child(6) { animation-delay: 0.30s; }

@keyframes htpRowIn {
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .how-to-play-content li { opacity: 1; transform: none; }
    .how-to-play-content.expanded li { animation: none; }
}

/* ── Shared puzzle navigator (Prev / N of 10 / Next) for games with fixed sets ── */
.puzzle-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0 auto 18px;
}
.pnav-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--hairline-strong);
    background: var(--light);
    color: var(--gray-dark);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.pnav-btn:hover { background: var(--dark); border-color: var(--dark); color: #fff; transform: translateY(-1px); }
.pnav-btn:active { transform: scale(0.94); }
.pnav-label { font-weight: 700; color: var(--ink); font-size: 0.98rem; min-width: 118px; text-align: center; }
.pnav-total { color: var(--muted); font-weight: 600; }


/* ============================================================
   Difficulty + puzzle choice now happen in the catalog's setup
   modal (games page). The in-game pickers stay in the DOM so the
   URL applier can drive them, but they are never shown — players
   go back to All Games to pick a new level or puzzle.
   ============================================================ */
.level-selector,
.puzzle-nav {
    display: none !important;
}

/* ── Bottom "How to Play" toggle removed — the rules live behind the
      book chip in the top bar (and open as a modal). The content div
      must stay in the DOM for that modal. ── */
.how-to-play-toggle { display: none !important; }
.how-to-play-section { margin: 0; padding: 0; }

/* ── Meta bar under the game title ───────────────────────────────
      One segmented pill bar: board info (level, puzzle) plus how the
      community and you do on this game. Read-only — selection happens
      on the All Games page. Segments are color-coded by their icon,
      not by loud chip backgrounds. */
.puzzle-meta {
    display: flex;              /* block-level: always on its own line below the title */
    width: fit-content;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
    margin: 14px auto 0;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--light-quaternary, #e2e8f0);
    border-radius: 999px;
    padding: 4px 6px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.pm-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 15px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--gray-dark, #334155);
    position: relative;
    white-space: nowrap;
}

/* hairline divider between segments */
.pm-pill + .pm-pill::before {
    content: '';
    position: absolute;
    left: 0;
    top: 22%;
    bottom: 22%;
    width: 1px;
    background: var(--light-quaternary, #e2e8f0);
}

.pm-pill i {
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.pm-level i { color: var(--primary, #2563eb); background: rgba(37, 99, 235, 0.1); }
.pm-daily i { color: #b45309; background: rgba(245, 158, 11, 0.14); }
.pm-daily strong { color: #b45309; }
.pm-num i { color: #7c3aed; background: rgba(124, 58, 237, 0.1); }
.pm-community i { color: #047857; background: rgba(16, 185, 129, 0.12); }
.pm-best i { color: #b45309; background: rgba(245, 158, 11, 0.14); }

.pm-num { font-family: var(--font-mono, 'JetBrains Mono', monospace); letter-spacing: 0; }
.pm-community strong, .pm-best strong { color: var(--dark, #1e293b); }

@media (max-width: 560px) {
    .puzzle-meta { border-radius: 18px; }
    .pm-pill { padding: 5px 11px; font-size: 0.72rem; }
}