﻿/* public/css/pattern-guessr.css - Premium Pattern Guessr */

/* === THEME VARIABLES ===================================================== */
#pattern-game-container {
    /* Surfaces */
    --pg-surface: var(--_bg-1, #0a0f25);
    --pg-panel: var(--_bg-2, #10162f);
    --pg-card: var(--_card, rgba(255,255,255,0.05));
    /* Text */
    --pg-text-0: var(--_text-0, #ffffff);
    --pg-text-1: var(--_text-1, #d7e1ff);
    --pg-muted: var(--_muted, #9bb0d3);
    /* Accent / brand */
    --pg-accent: var(--_accent, #8a7cff);
    --pg-accent-hover: color-mix(in oklab, var(--pg-accent), black 12%);
    --pg-brand: var(--_brand, #00b4d8);
    --pg-brand-glow: rgba(0, 180, 216, 0.4);
    /* Button tokens */
    --pg-button-top: color-mix(in oklab, var(--pg-brand), white 28%);
    --pg-button-bottom: color-mix(in oklab, var(--pg-brand), black 4%);
    --pg-button-hover-top: color-mix(in oklab, var(--pg-brand), white 40%);
    --pg-button-hover-bottom: color-mix(in oklab, var(--pg-brand), black 12%);
    --pg-button-border: rgba(0, 0, 0, 0.2);
    --pg-button-border-hover: color-mix(in oklab, var(--pg-brand), black 30%);
    --pg-button-shadow: 0 6px 18px rgba(0, 180, 216, 0.25);
    --pg-button-shadow-hover: 0 10px 26px rgba(0, 180, 216, 0.35);
    /* Invite button */
    --pg-invite-top: color-mix(in oklab, var(--pg-accent), white 58%);
    --pg-invite-bottom: color-mix(in oklab, var(--pg-accent), black 8%);
    --pg-invite-hover-top: color-mix(in oklab, var(--pg-accent), white 68%);
    --pg-invite-hover-bottom: color-mix(in oklab, var(--pg-accent), black 18%);
    --pg-invite-border: color-mix(in oklab, var(--pg-accent), black 22%);
    --pg-invite-shadow: 0 12px 30px rgba(138, 124, 255, 0.32);
    /* Frame */
    --pg-border: var(--_border, rgba(92,217,240,0.25));
    --pg-radius-sm: var(--_radius-sm, 10px);
    --pg-radius-md: var(--_radius-md, 14px);
    --pg-radius-lg: var(--_radius-lg, 18px);
    --pg-radius-xl: 24px;
    --pg-shadow: var(--_shadow-soft, 0 10px 30px rgba(0,0,0,0.35));
    --pg-shadow-lg: 0 20px 50px rgba(0,0,0,0.5);
    /* Semantic */
    --pg-success: color-mix(in oklab, #1fc868 82%, black 6%);
    --pg-success-hover: color-mix(in oklab, var(--pg-success), black 18%);
    --pg-danger: color-mix(in oklab, #f23a5a 80%, black 4%);
    --pg-danger-hover: color-mix(in oklab, var(--pg-danger), black 18%);
    /* Sizes */
    --game-size: min(75vmin, 720px);
    --pg-btn-height: 52px;
    --pg-btn-font: 600 1rem/1 'B612 Mono', monospace;
    color-scheme: dark;
}

/* === FONT IMPORT ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=B612+Mono:wght@400;700&display=swap');

/* === GAME CONTAINER ====================================================== */
#pattern-game-container {
    position: fixed;
    top: 3rem;
    left: 0;
    width: 100%;
    height: calc(100vh - 3rem);
    background: 
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0, 180, 216, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 50% at 80% 100%, rgba(138, 124, 255, 0.06) 0%, transparent 50%),
        var(--pg-surface);
    overflow: hidden;
    z-index: 100;
}

/* === START SCREEN ======================================================== */
#start-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--game-size);
    height: var(--game-size);
    background: 
        linear-gradient(180deg, rgba(16, 22, 47, 0.98), rgba(10, 15, 37, 0.99));
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-xl);
    box-shadow: 
        var(--pg-shadow-lg),
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 0 80px rgba(0, 180, 216, 0.1);
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Animated glow effect */
.start-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        conic-gradient(from 0deg at 50% 50%, 
            transparent 0deg, 
            rgba(0, 180, 216, 0.15) 60deg, 
            transparent 120deg,
            rgba(138, 124, 255, 0.1) 180deg,
            transparent 240deg,
            rgba(0, 180, 216, 0.15) 300deg,
            transparent 360deg
        );
    animation: rotate-glow 20s linear infinite;
    pointer-events: none;
    opacity: 0.5;
}

@keyframes rotate-glow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.start-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.start-title {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-family: 'B612 Mono', monospace;
    font-weight: 700;
    color: var(--pg-text-0);
    text-shadow: 0 0 40px var(--pg-brand-glow);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.start-title i[data-lucide] {
    color: var(--pg-brand);
    filter: drop-shadow(0 0 12px var(--pg-brand-glow));
}

.start-subtitle {
    font-size: 0.95rem;
    color: var(--pg-muted);
    font-family: 'B612 Mono', monospace;
    margin: 0;
    letter-spacing: 0.02em;
}

.start-buttons-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.start-top-buttons {
    display: flex;
    gap: 1rem;
}

.start-footer {
    position: absolute;
    bottom: 1rem;
    left: 1.25rem;
    right: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.start-footer .footer-text {
    font-size: 0.72rem;
    color: var(--pg-muted);
    font-family: 'B612 Mono', monospace;
    opacity: 0.7;
}

.start-footer .footer-text a {
    color: var(--pg-text-1);
    text-decoration: none;
    transition: color 0.2s;
}

.start-footer .footer-text a:hover {
    color: var(--pg-brand);
}

/* === PLAY FIELD ========================================================== */
#play-field {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--game-size);
    height: var(--game-size);
    background: 
        linear-gradient(180deg, rgba(16, 22, 47, 0.98), rgba(10, 15, 37, 0.99));
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-xl);
    box-shadow: 
        var(--pg-shadow-lg),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.play-field-glow {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(0, 180, 216, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(138, 124, 255, 0.06) 0%, transparent 40%);
    pointer-events: none;
}

/* Score & Timer Overlays - Premium Glass Style */
.overlay {
    position: absolute;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--pg-radius-md);
    font-family: 'B612 Mono', monospace;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.overlay.score {
    top: 1rem;
    left: 1rem;
}

.overlay.timer {
    top: 1rem;
    right: 1rem;
}

.overlay i[data-lucide] {
    width: 1.1rem;
    height: 1.1rem;
    color: var(--pg-brand);
}

.overlay-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pg-muted);
}

.overlay-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--pg-text-0);
    min-width: 1.5ch;
    text-align: center;
}

.overlay-unit {
    font-size: 0.9rem;
    color: var(--pg-muted);
}

/* Watermark Container */
.watermark-container {
    position: relative;
    width: calc(var(--game-size) - 3rem);
    height: calc(var(--game-size) - 6rem);
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Watermark background - separate from image */
.watermark-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        url("/images/DP_logo_watermark.webp"),
        url("/images/DP_Logo_White.webp");
    background-size: 200px;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.05;
    pointer-events: none;
}

.watermark-container img#game-image {
    position: relative;
    z-index: 1;
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--pg-radius-sm);
}

/* Loader - Premium Spinner */
.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    z-index: 450;
}

.loader::before,
.loader::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
}

.loader::before {
    border-top-color: var(--pg-brand);
    animation: spin 1s linear infinite;
}

.loader::after {
    border-right-color: var(--pg-accent);
    animation: spin 1.5s linear infinite reverse;
    inset: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading Info Box */
.loading-info {
    position: absolute;
    top: calc(50% + 50px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-sm);
    font-size: 0.8rem;
    color: var(--pg-muted);
    z-index: 450;
    white-space: nowrap;
}

.loading-info i[data-lucide] {
    width: 1rem;
    height: 1rem;
    color: var(--pg-brand);
}

/* Choice Buttons Container */
.choices {
    position: absolute;
    bottom: 1.25rem;
    display: flex;
    gap: 1rem;
    z-index: 100;
}

/* === SKIN NAME HINT ====================================================== */
.skin-hint {
    position: absolute;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--pg-radius-md);
    font-family: 'B612 Mono', monospace;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.hint-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pg-muted);
}

.hint-text {
    display: flex;
    gap: 0.05rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.15em;
}

.hint-char {
    display: inline-block;
    min-width: 0.7em;
    text-align: center;
    transition: color 0.2s, text-shadow 0.2s;
}

.hint-char.scrambled {
    color: var(--pg-muted);
    opacity: 0.6;
}

.hint-char.revealed {
    color: var(--pg-brand);
    text-shadow: 0 0 8px var(--pg-brand-glow);
    animation: char-reveal 0.3s ease-out;
}

@keyframes char-reveal {
    0% {
        transform: scale(1.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* === BUTTONS ============================================================= */
#play-btn,
.leaderboard-toggle,
.choice-btn,
.gameover-actions .choice-btn,
.popup-actions .choice-btn,
.gameover-invitation-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: var(--pg-btn-height);
    padding: 0 1.5rem;
    font: var(--pg-btn-font);
    letter-spacing: 0.03em;
    text-decoration: none;
    border-radius: var(--pg-radius-md);
    border: 1px solid var(--pg-button-border);
    background: linear-gradient(180deg, var(--pg-button-top), var(--pg-button-bottom));
    color: #061018;
    box-shadow: var(--pg-button-shadow);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

#play-btn::before,
.leaderboard-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.25s;
}

#play-btn:hover::before,
.leaderboard-toggle:hover::before {
    opacity: 1;
}

#play-btn:hover,
.leaderboard-toggle:hover,
.choice-btn:hover:not(:disabled),
.gameover-actions .choice-btn:hover,
.popup-actions .choice-btn:hover,
.gameover-invitation-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--pg-button-shadow-hover), 0 0 0 4px rgba(0, 180, 216, 0.15);
}

#play-btn:active,
.leaderboard-toggle:active {
    transform: translateY(-1px) scale(0.98);
}

/* Play button pulse animation */
#play-btn {
    font-size: 1.1rem;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: var(--pg-button-shadow); }
    50% { box-shadow: var(--pg-button-shadow-hover), 0 0 30px rgba(0, 180, 216, 0.4); }
}

#play-btn:hover {
    animation: none;
}

/* Steam Login Button */
.steam-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    min-height: var(--pg-btn-height);
    padding: 0 1.5rem;
    font: var(--pg-btn-font);
    background: linear-gradient(180deg, #2d3842, #171d21);
    color: var(--pg-text-0);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--pg-radius-md);
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.steam-login-btn:hover {
    background: linear-gradient(180deg, #3c5566, #1e262c);
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}

/* Logged In User Display */
.logged-in-user {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(31, 200, 104, 0.1);
    border: 1px solid rgba(31, 200, 104, 0.25);
    border-radius: var(--pg-radius-md);
    color: var(--pg-text-1);
    font-family: 'B612 Mono', monospace;
    font-size: 0.9rem;
}

.logged-in-user i[data-lucide] {
    color: var(--pg-success);
    width: 1.1rem;
    height: 1.1rem;
}

.logged-in-user strong {
    color: var(--pg-text-0);
}

/* Success (Has Pattern) Button */
.has-pattern-btn {
    background: linear-gradient(180deg, var(--pg-success), color-mix(in oklab, var(--pg-success) 65%, black));
    color: #fff;
    border: 1px solid color-mix(in oklab, var(--pg-success), black 18%);
    box-shadow: 0 8px 22px rgba(31, 200, 104, 0.3);
}

.has-pattern-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--pg-success-hover), color-mix(in oklab, var(--pg-success) 48%, black));
    box-shadow: 0 10px 26px rgba(31, 200, 104, 0.4), 0 0 0 4px rgba(31, 200, 104, 0.15);
}

/* Danger (No Pattern) Button */
.no-pattern-btn {
    background: linear-gradient(180deg, var(--pg-danger), color-mix(in oklab, var(--pg-danger) 65%, black));
    color: #fff;
    border: 1px solid color-mix(in oklab, var(--pg-danger), black 18%);
    box-shadow: 0 8px 22px rgba(242, 58, 90, 0.3);
}

.no-pattern-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--pg-danger-hover), color-mix(in oklab, var(--pg-danger) 48%, black));
    box-shadow: 0 10px 26px rgba(242, 58, 90, 0.4), 0 0 0 4px rgba(242, 58, 90, 0.15);
}

.choice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* === FLASH EFFECTS ======================================================= */
.flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 400;
    animation: flash-animation 0.5s ease-out;
    border-radius: var(--pg-radius-xl);
}

.flash.correct {
    background: radial-gradient(circle at center, rgba(31, 200, 104, 0.5) 0%, rgba(31, 200, 104, 0.2) 50%, transparent 70%);
}

.flash.incorrect {
    background: radial-gradient(circle at center, rgba(242, 58, 90, 0.5) 0%, rgba(242, 58, 90, 0.2) 50%, transparent 70%);
}

@keyframes flash-animation {
    0% { opacity: 0; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.1); }
}

/* Shake Animation */
#play-field.shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
    0%, 100% { transform: translate(-50%, -50%) translateX(0); }
    10% { transform: translate(-50%, -50%) translateX(-10px) rotate(-1deg); }
    20% { transform: translate(-50%, -50%) translateX(10px) rotate(1deg); }
    30% { transform: translate(-50%, -50%) translateX(-10px) rotate(-1deg); }
    40% { transform: translate(-50%, -50%) translateX(10px) rotate(1deg); }
    50% { transform: translate(-50%, -50%) translateX(-6px) rotate(0); }
    60% { transform: translate(-50%, -50%) translateX(6px) rotate(0); }
    70% { transform: translate(-50%, -50%) translateX(-3px); }
    80% { transform: translate(-50%, -50%) translateX(3px); }
    90% { transform: translate(-50%, -50%) translateX(-1px); }
}

/* === LEAVE OVERLAY ======================================================= */
#leave-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(244, 68, 68, 0.3);
    border-radius: var(--pg-radius-lg);
    font: bold 1.5rem 'B612 Mono', monospace;
    color: #f44;
    animation: pulse 1s infinite;
    z-index: 300;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* === LEADERBOARD ========================================================= */
.leaderboard {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--game-size);
    height: var(--game-size);
    background: 
        linear-gradient(180deg, rgba(16, 22, 47, 0.98), rgba(10, 15, 37, 0.99));
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-xl);
    padding: 1.5rem;
    color: var(--pg-text-1);
    overflow: hidden;
    z-index: 700;
    flex-direction: column;
    box-shadow: var(--pg-shadow-lg);
}

.leaderboard.open {
    display: flex;
}

.leaderboard-close {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pg-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--pg-text-0);
}

.leaderboard h3 {
    margin: 0.5rem 0 1rem;
    font-size: 1.5rem;
    font-family: 'B612 Mono', monospace;
    color: var(--pg-brand);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.table-wrapper {
    flex: 1;
    overflow: auto;
    border-radius: var(--pg-radius-md);
    background: rgba(0, 0, 0, 0.2);
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-family: 'B612 Mono', monospace;
}

.table-wrapper th,
.table-wrapper td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.table-wrapper th {
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.5);
    color: var(--pg-brand);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.table-wrapper tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.table-wrapper tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.table-wrapper td a {
    color: var(--pg-accent);
    text-decoration: none;
    transition: color 0.2s;
}

.table-wrapper td a:hover {
    color: var(--pg-text-0);
}

/* === GAME OVER MODAL ===================================================== */
#game-over {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: 
        radial-gradient(circle at 50% 30%, rgba(138, 124, 255, 0.1) 0%, transparent 50%),
        rgba(10, 15, 37, 0.95);
    backdrop-filter: blur(12px);
    z-index: 600;
}

.gameover-card {
    width: var(--game-size);
    height: var(--game-size);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.75rem;
    padding: 2.5rem 2rem;
    background: 
        linear-gradient(180deg, rgba(20, 26, 50, 0.98), rgba(12, 16, 35, 0.99));
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-xl);
    box-shadow: 
        var(--pg-shadow-lg),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.gameover-heading-wrap {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gameover-heading {
    margin: 0;
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-family: 'B612 Mono', monospace;
    color: var(--pg-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.gameover-subtitle {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--pg-muted);
}

.gameover-stats {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.stat-pill {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--pg-radius-md);
    transition: all 0.25s;
}

.stat-pill:hover {
    transform: translateY(-2px);
    border-color: rgba(138, 124, 255, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.stat-pill i[data-lucide] {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--pg-accent);
}

.stat-pill .pill-label {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--pg-muted);
    font-family: 'B612 Mono', monospace;
}

.stat-pill .pill-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--pg-text-0);
    font-family: 'B612 Mono', monospace;
}

.gameover-invitation-btn {
    width: 100%;
    background: linear-gradient(180deg, var(--pg-invite-top), var(--pg-invite-bottom));
    color: #f5f7ff;
    border: 1px solid var(--pg-invite-border);
    box-shadow: var(--pg-invite-shadow);
}

.gameover-invitation-btn:hover {
    background: linear-gradient(180deg, var(--pg-invite-hover-top), var(--pg-invite-hover-bottom));
    box-shadow: 0 14px 30px rgba(138, 124, 255, 0.4), 0 0 0 4px rgba(138, 124, 255, 0.15);
}

.gameover-footer {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gameover-actions {
    display: flex;
    gap: 0.75rem;
}

.gameover-actions .choice-btn {
    flex: 1;
    min-height: var(--pg-btn-height);
}

.gameover-share {
    width: 100%;
}

/* === SHARE DROPDOWN ====================================================== */
.share-dropdown-container {
    width: 100%;
}

.native-hidden {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.share-select-wrapper {
    position: relative;
    width: 100%;
}

.share-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: var(--pg-btn-height);
    padding: 0 1.25rem;
    background: rgba(0, 0, 0, 0.3);
    color: var(--pg-text-0);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--pg-radius-md);
    cursor: pointer;
    font: var(--pg-btn-font);
    transition: all 0.2s;
}

.share-trigger:hover {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
}

.share-trigger[aria-expanded="true"] {
    border-color: var(--pg-accent);
    box-shadow: 0 0 0 3px rgba(138, 124, 255, 0.2);
}

.share-menu {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0.5rem;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: rgba(16, 22, 47, 0.98);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-md);
    box-shadow: var(--pg-shadow);
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 900;
}

.share-menu.open {
    display: flex;
}

.share-menu li {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: var(--pg-radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'B612 Mono', monospace;
}

.share-menu li:hover {
    background: rgba(255, 255, 255, 0.08);
}

.share-menu li i[data-lucide] {
    width: 1rem;
    height: 1rem;
    color: var(--pg-accent);
}

/* === STEAM POPUP ========================================================= */
.steam-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 650;
    display: none;
}

#steam-popup {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100% - 2rem));
    background: 
        linear-gradient(180deg, rgba(20, 26, 50, 0.98), rgba(12, 16, 35, 0.99));
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-xl);
    padding: 2rem;
    box-shadow: var(--pg-shadow-lg);
    z-index: 660;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.steam-popup-content {
    width: 100%;
    text-align: center;
    position: relative;
    color: var(--pg-text-1);
    font-family: 'B612 Mono', monospace;
    padding-top: 1rem;
}

.popup-close-btn {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pg-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.popup-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--pg-text-0);
}

.steam-popup-content p {
    margin: 1rem 0;
    line-height: 1.6;
    font-size: 0.95rem;
}

.popup-actions {
    width: 100%;
    display: flex;
    gap: 0.75rem;
}

.popup-actions .choice-btn {
    flex: 1;
}

/* === NUMBER ANIMATION ==================================================== */
@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.number-change {
    display: inline-block;
    animation: breathe 0.3s ease;
}

/* === MOBILE RESPONSIVE =================================================== */
@media (max-width: 768px) {
    #pattern-game-container {
        top: 2rem;
        height: calc(100vh - 2rem);
        --game-size: min(90vw, 500px);
        --game-height: min(75vh, 600px);
    }

    #start-screen {
        width: var(--game-size);
        height: var(--game-height);
        padding: 1rem;
    }

    .start-title {
        font-size: 1.5rem;
    }

    .start-subtitle {
        font-size: 0.85rem;
    }

    .start-top-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .start-top-buttons button {
        width: 100%;
    }

    #play-field {
        width: var(--game-size);
        height: var(--game-height);
    }

    .overlay {
        padding: 0.4rem 0.75rem;
    }

    .overlay.score { top: 0.5rem; left: 0.5rem; }
    .overlay.timer { top: 0.5rem; right: 0.5rem; }

    .overlay-value {
        font-size: 1.1rem;
    }

    .choices {
        bottom: 0.75rem;
        gap: 0.5rem;
        width: calc(100% - 1.5rem);
        justify-content: center;
    }

    .skin-hint {
        bottom: 4rem;
        padding: 0.4rem 0.75rem;
    }

    .hint-text {
        font-size: 0.85rem;
    }

    .choice-btn {
        flex: 1;
        min-height: 44px;
        padding: 0 1rem;
        font-size: 0.9rem;
    }

    .leaderboard {
        width: var(--game-size);
        height: var(--game-height);
        padding: 1rem;
    }

    .gameover-card {
        width: var(--game-size);
        height: var(--game-height);
        padding: 1rem 1.25rem;
        gap: 0.75rem;
    }

    .gameover-heading {
        font-size: 1.5rem;
        gap: 0.5rem;
    }

    .gameover-subtitle {
        font-size: 0.8rem;
    }

    .gameover-heading-wrap {
        gap: 0.25rem;
    }

    .gameover-stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .stat-pill {
        padding: 0.5rem;
        gap: 0.25rem;
        flex-direction: row;
        justify-content: center;
    }

    .stat-pill .pill-value {
        font-size: 1.1rem;
    }

    .stat-pill .pill-label {
        font-size: 0.65rem;
    }

    .stat-pill i[data-lucide] {
        width: 1rem;
        height: 1rem;
    }

    .gameover-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .gameover-actions button,
    .gameover-actions a {
        width: 100%;
        min-height: 40px;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .share-dropdown {
        width: 100%;
    }

    .share-dropdown summary {
        min-height: 40px;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .popup-actions {
        flex-direction: column;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    #pattern-game-container {
        --game-size: min(70vw, 500px);
        --game-height: min(85vh, 550px);
    }
}

/* === ACCESSIBILITY ======================================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible states */
button:focus-visible,
a:focus-visible,
.share-trigger:focus-visible {
    outline: 2px solid var(--pg-brand);
    outline-offset: 2px;
}

/* High contrast mode */
@media (forced-colors: active) {
    .overlay,
    .gameover-card,
    #start-screen,
    #play-field,
    .leaderboard {
        border: 2px solid CanvasText;
    }
}

/* === LEFT SKYSCRAPER AD RAIL ============================================= */
.pg-side-rail--left {
    position: fixed;
    top: calc(3rem + 50%);
    top: calc(3rem + (100vh - 3rem) / 2);
    left: calc(50% - (var(--game-size) / 2) - clamp(220px, 18vw, 300px));
    transform: translateY(-50%);
    width: clamp(140px, 16vw, 240px);
    z-index: 560;
    display: block;
    pointer-events: auto;
}

.pg-side-rail--left .dp-slot {
    margin: 0;
    width: 100%;
}

@media (max-width: 1280px) {
    .pg-side-rail--left {
        left: max(16px, calc(50% - (var(--game-size) / 2) - 210px));
        width: 150px;
    }
}

@media (max-width: 1024px) {
    .pg-side-rail--left {
        left: 14px;
        width: 122px;
    }
}

@media (max-width: 768px) {
    .pg-side-rail--left,
    .pg-side-rail--left * {
        display: none !important;
        visibility: hidden !important;
    }
}

/* === AD SPOT ============================================================= */
.promo-spot {
    position: absolute;
    top: 50%;
    right: calc(50% - (var(--game-size) / 2) - clamp(220px, 18vw, 300px));
    transform: translateY(-50%);
    width: clamp(140px, 16vw, 240px);
    aspect-ratio: 3 / 5;
    display: block;
    z-index: 560;
    overflow: hidden;
    line-height: 0;
    border-radius: 0;
    border: 1px solid rgba(0, 180, 216, 0.35);
    background: linear-gradient(165deg, rgba(14, 22, 52, 0.55) 0%, rgba(6, 10, 28, 0.65) 100%);
    box-shadow:
        0 14px 36px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(0, 180, 216, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(14px) saturate(140%) brightness(1.05);
    -webkit-backdrop-filter: blur(14px) saturate(140%) brightness(1.05);
    transition: transform 350ms cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 400ms cubic-bezier(0.23, 1, 0.32, 1),
                border-color 350ms ease;
    cursor: pointer;
}

/* Top glossy edge highlight */
.promo-spot::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background:
        linear-gradient(165deg,
            rgba(138, 124, 255, 0.22) 0%,
            rgba(0, 180, 216, 0.08) 30%,
            transparent 55%),
        linear-gradient(to bottom,
            rgba(255, 255, 255, 0.12) 0%,
            transparent 40%,
            transparent 85%,
            rgba(0, 180, 216, 0.06) 100%);
    mix-blend-mode: screen;
    opacity: 0.7;
    transition: opacity 350ms ease;
}

/* Shine sweep — idle periodic + hover override */
.promo-spot::after {
    content: '';
    position: absolute;
    top: -120%;
    left: -50%;
    width: 44%;
    height: 340%;
    pointer-events: none;
    z-index: 3;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.06) 30%,
        rgba(255, 255, 255, 0.38) 50%,
        rgba(255, 255, 255, 0.06) 70%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(16deg);
    opacity: 0;
    animation: promo-idle-shine 5.5s 2s ease-in-out infinite;
}

.promo-spot:hover {
    transform: translateY(calc(-50% - 6px)) scale(1.03);
    border-color: rgba(0, 200, 240, 0.7);
    box-shadow:
        0 20px 48px rgba(0, 0, 0, 0.5),
        0 0 26px rgba(0, 180, 216, 0.28),
        0 0 60px rgba(138, 124, 255, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.promo-spot:hover::before {
    opacity: 1;
}

.promo-spot:hover::after {
    animation: promo-hover-shine 700ms cubic-bezier(0.22, 0.68, 0, 1) forwards;
}

.promo-spot:active {
    transform: translateY(calc(-50% - 2px)) scale(0.99);
    transition-duration: 80ms;
}

.promo-spot-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 350ms ease;
}

.promo-spot:hover .promo-spot-media {
    filter: brightness(1.08) contrast(1.04);
}

/* Idle: periodic subtle shine sweep every ~5.5s */
@keyframes promo-idle-shine {
    0%, 72%   { opacity: 0;    transform: translateX(-10%) rotate(16deg); }
    78%       { opacity: 0.22; }
    100%      { opacity: 0;    transform: translateX(280%) rotate(16deg); }
}

/* Hover: brighter quicker shine */
@keyframes promo-hover-shine {
    0%   { opacity: 0.9;  transform: translateX(-10%) rotate(16deg); }
    100% { opacity: 0;    transform: translateX(280%) rotate(16deg); }
}

@media (max-width: 1280px) {
    .promo-spot {
        right: max(16px, calc(50% - (var(--game-size) / 2) - 210px));
        width: 150px;
    }
}

@media (max-width: 1024px) {
    .promo-spot {
        right: 14px;
        width: 122px;
    }
}

/* Hide promo spot on mobile as well */
@media (max-width: 768px) {
    .promo-spot,
    .promo-spot * {
        display: none !important;
        visibility: hidden !important;
    }
}

/* === HOW TO PLAY MODAL =================================================== */

/* Open button on start screen footer */
.htp-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--pg-radius-sm);
    color: var(--pg-muted);
    font-family: 'B612 Mono', monospace;
    font-size: 0.72rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.htp-open-btn:hover {
    color: var(--pg-brand);
    border-color: rgba(0, 180, 216, 0.35);
    background: rgba(0, 180, 216, 0.08);
}

.htp-open-btn i[data-lucide] {
    width: 0.85rem;
    height: 0.85rem;
}

/* Overlay wrapper */
.htp-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.htp-overlay.htp-visible {
    pointer-events: auto;
    opacity: 1;
}

/* Backdrop */
.htp-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 4, 15, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Panel */
.how-to-play {
    position: relative;
    width: min(380px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.75rem;
    background: linear-gradient(180deg, rgba(16, 22, 47, 0.98), rgba(10, 15, 37, 0.99));
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-xl);
    box-shadow:
        var(--pg-shadow-lg),
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 0 60px rgba(0, 180, 216, 0.12);
    transform: translateY(12px) scale(0.97);
    transition: transform 0.25s ease;
}

.htp-overlay.htp-visible .how-to-play {
    transform: translateY(0) scale(1);
}

/* Header row */
.htp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.htp-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.1rem;
    font-family: 'B612 Mono', monospace;
    color: var(--pg-brand);
}

.htp-title i[data-lucide] {
    width: 1.2rem;
    height: 1.2rem;
}

/* Close button */
.htp-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--pg-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.htp-close-btn:hover {
    color: var(--pg-danger);
    border-color: rgba(242, 58, 90, 0.4);
    background: rgba(242, 58, 90, 0.1);
}

.htp-close-btn i[data-lucide] {
    width: 1rem;
    height: 1rem;
}

.htp-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.htp-step {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.htp-step-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--pg-button-top), var(--pg-button-bottom));
    color: #061018;
    font-family: 'B612 Mono', monospace;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 50%;
}

.htp-step-content h3 {
    margin: 0 0 0.25rem;
    font-size: 0.9rem;
    font-family: 'B612 Mono', monospace;
    color: var(--pg-text-0);
}

.htp-step-content p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--pg-muted);
    line-height: 1.5;
}

.htp-step-content strong {
    color: var(--pg-text-1);
}

.htp-tip {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.85rem;
    background: rgba(0, 180, 216, 0.08);
    border: 1px solid rgba(0, 180, 216, 0.2);
    border-radius: var(--pg-radius-md);
    font-size: 0.75rem;
    color: var(--pg-text-1);
    line-height: 1.5;
}

.htp-tip i[data-lucide] {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    color: var(--pg-brand);
    margin-top: 0.1rem;
}

.htp-tip strong {
    color: var(--pg-brand);
}

/* === LUCIDE ICON DEFAULTS ================================================ */
#pattern-game-container i[data-lucide] {
    width: 1em;
    height: 1em;
    stroke-width: 2;
    flex-shrink: 0;
    vertical-align: middle;
}
