/* ====== ОСНОВНЫЕ НАСТРОЙКИ ====== */
@font-face {
    font-family: 'SiteTitle';
    /* файл первым: на телефонах local('Segoe Print') часто подставляет другой cursive */
    src: url('fonts/segoepr.ttf?v=20260715d3') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SiteTitle';
    src: url('fonts/segoeprb.ttf?v=20260715d3') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* ===== Brand palette (only these + ok/err/paper) ===== */
    /* P8/N4 — теплее бордо, меньше «фиолетового неона»; откат: #160a0f / #2a141c / #4a1828 */
    --bg: #14090c;
    --bg-mid: #2b1218;
    --bg-login: #4c1524;
    --pink: #ff6b9d;
    --pink-deep: #e8437a;
    --pink-soft: #ffd1e0;
    /* GOLD_TRIAL_A — soft champagne; откат: --gold: #ffd700; (было B: #F3D9A8) */
    --gold: #F0C97A;
    --white: #ffffff;

    /* Semantic (games / form errors) */
    --ok: #2ed573;
    --err: #ff4757;

    /* PAPER_TRIAL — новый фон письма; откат: #fff8f0 + ink #2d1b2e */
    --paper: #fff0f5;
    --paper-ink: #2d1b2e;

    /* Derived surfaces (from palette only) */
    --glass: rgba(255, 255, 255, 0.065);
    --glass-border: rgba(255, 107, 157, 0.18);
    --glass-strong: rgba(255, 255, 255, 0.09);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    --shadow-soft: 0 6px 24px rgba(0, 0, 0, 0.14);
    --shadow-glow: 0 0 22px rgba(255, 107, 157, 0.05);
    --focus-ring: 0 0 0 3px rgba(255, 107, 157, 0.45);

    /* Layout */
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --radius-pill: 999px;
    /* 8px grid */
    --space-1: 8px;
    --space-2: 12px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;
    /* семантический ритм секций */
    --section-pad-x: var(--space-3);
    --section-pad-top-extra: var(--space-5);
    --section-pad-bottom: var(--space-6);
    --title-mb: var(--space-5);
    --title-rule-mt: var(--space-2);
    --stack-xs: var(--space-1);
    --stack-sm: var(--space-2);
    --stack-md: var(--space-3);
    --stack-lg: var(--space-4);
    --stack-xl: var(--space-5);
    --card-pad-y: var(--space-4);
    --card-pad-x: var(--space-3);
    --nav-h: 56px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    /* Compat aliases (old names → new) */
    --pink-light: var(--pink-soft);
    --pink-dark: var(--pink-deep);
    --dark: var(--bg-mid);
    --bg-deep: var(--bg);
    --purple: var(--pink);
    --gold-soft: var(--gold);
    --light: var(--white);
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 0;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* цвет «под» статус-баром и home-индикатором на iPhone */
    background-color: var(--bg);
    overscroll-behavior-y: none;
}

html.on-login {
    background-color: var(--bg-login);
}

body {
    /* Montserrat → похожие системные, если Google не подгрузился */
    font-family: 'Montserrat', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    /* solid color = низ/верх iPhone; gradient = основной фон */
    background-color: var(--bg);
    background-image: linear-gradient(135deg, var(--bg) 0%, var(--bg-mid) 50%, var(--bg) 100%);
    color: var(--white);
    min-height: 100vh;
    min-height: 100svh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overscroll-behavior-y: none;
}

body.is-scroll-locked {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

::selection {
    background: rgba(255, 107, 157, 0.45);
    color: var(--white);
}

/* авторизация: низ/верх телефона бордово-фиолетовые */
body.on-login {
    background-color: var(--bg-login);
    background-image: linear-gradient(135deg, var(--bg-mid) 0%, var(--bg-login) 50%, var(--bg-mid) 100%);
}

/* мягкая «сцена» вокруг контента — не ломает fixed-навбар */
#mainSite::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 90% 55% at 50% -8%, rgba(255, 107, 157, 0.09), transparent 58%),
        radial-gradient(ellipse 55% 40% at 100% 90%, rgba(232, 67, 122, 0.06), transparent 55%),
        radial-gradient(ellipse 45% 35% at 0% 75%, rgba(255, 215, 0, 0.03), transparent 50%);
}

#mainSite .section {
    z-index: 1;
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ====== ЧАСТИЦЫ ФОН ====== */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    font-size: 20px;
    animation: floatUp linear infinite;
    opacity: 0.22;
    filter: drop-shadow(0 0 6px rgba(255, 107, 157, 0.2));
}

@keyframes floatUp {
    0% { transform: translateY(100svh) rotate(0deg); opacity: 0; }
    12% { opacity: 0.22; }
    88% { opacity: 0.22; }
    100% { transform: translateY(-10svh) rotate(360deg); opacity: 0; }
}

/* ====== СТРАНИЦА ВХОДА ====== */
#loginScreen {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100svh;
    padding: max(20px, var(--safe-top)) max(20px, var(--safe-right)) max(20px, var(--safe-bottom)) max(20px, var(--safe-left));
    background: linear-gradient(135deg, var(--bg-mid) 0%, var(--bg-login) 50%, var(--bg-mid) 100%);
    position: relative;
    overflow: hidden;
}

#loginScreen.active {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 3000;
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
    transition:
        opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.75s ease;
}

#loginScreen.active.is-leaving {
    opacity: 0;
    transform: scale(1.04);
    filter: blur(6px);
    pointer-events: none;
}

#loginScreen::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(255,107,157,0.12) 0%, transparent 50%);
    animation: pulseBg 4s ease-in-out infinite;
}

#loginScreen::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 45% at 50% 100%, rgba(255, 215, 0, 0.07), transparent 55%),
        radial-gradient(ellipse 50% 40% at 0% 0%, rgba(255, 107, 157, 0.1), transparent 50%);
}

@keyframes pulseBg {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
}

.login-container {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(28px) saturate(1.2);
    -webkit-backdrop-filter: blur(28px) saturate(1.2);
    border: 1px solid rgba(255,107,157,0.28);
    border-radius: var(--radius-lg);
    padding:
        clamp(28px, 5vw, 48px)
        clamp(20px, 4vw, 40px)
        clamp(16px, 3vw, 24px);
    text-align: center;
    max-width: 420px;
    width: min(92vw, 420px);
    position: relative;
    z-index: 1;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(255, 215, 0, 0.06) inset,
        0 0 48px rgba(255, 107, 157, 0.12);
    box-sizing: border-box;
    overflow: hidden;
}

.login-container.shake {
    animation: loginShake 0.48s ease;
}

@keyframes loginShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.date-input-wrap {
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--stack-lg);
    overflow: hidden;
}

.login-hearts {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 44px;
    margin-bottom: var(--stack-sm);
    line-height: 1;
}

.login-hearts span {
    display: inline-block;
    animation: heartBeat 4s ease-in-out infinite;
    will-change: transform;
    filter: drop-shadow(0 0 10px rgba(255, 107, 157, 0.35));
}

.login-hearts span:nth-child(2) { animation-delay: 0.4s; }
.login-hearts span:nth-child(3) { animation-delay: 0.8s; }

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.login-container h1 {
    font-family: 'SiteTitle', cursive;
    font-size: 42px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--gold);
    margin-bottom: var(--stack-xs);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.32);
}

.login-subtitle {
    color: var(--pink-light);
    display: block;
    width: 100%;
    margin: 0 0 var(--stack-lg);
    font-size: clamp(13px, 3.4vw, 15px);
    line-height: 1.45;
    letter-spacing: 0;
    text-align: center;
    text-wrap: balance;
}

#dateInput {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 14px 14px;
    border: 1.5px solid rgba(255,107,157,0.35);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.09);
    color: var(--white);
    font-size: 16px; /* 16px — без автозума iOS */
    font-family: 'Montserrat', sans-serif;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    margin-bottom: 0;
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
}

#dateInput:focus,
#dateInput:focus-visible {
    outline: none;
    border-color: rgba(255, 107, 157, 0.55);
    background: rgba(255, 255, 255, 0.11);
    /* без глобального --focus-ring и без неонового glow */
    box-shadow: none;
}

#dateInput::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.btn {
    background: linear-gradient(145deg, var(--pink) 0%, var(--pink) 45%, var(--pink-dark) 100%);
    color: var(--white);
    border: none;
    padding: 14px 36px;
    border-radius: var(--radius-pill);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s var(--ease-out), box-shadow 0.3s ease, filter 0.3s ease;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 24px rgba(232, 67, 122, 0.28);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 45%);
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 32px rgba(255, 107, 157, 0.45);
        filter: brightness(1.04);
    }
}

.btn:active {
    transform: translateY(0);
}

/* слот всегда в потоке; текст чуть ниже, высота карточки та же */
#loginError {
    color: var(--err);
    margin-top: 12px;
    margin-bottom: -6px; /* компенсация роста — подложка не меняется */
    height: 1.25em;
    min-height: 1.25em;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

#loginError.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ====== НАВИГАЦИЯ ====== */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding-top: var(--safe-top);
    background: rgba(26, 10, 30, 0.78);
    backdrop-filter: blur(22px) saturate(1.25);
    -webkit-backdrop-filter: blur(22px) saturate(1.25);
    z-index: 2500;
    border-bottom: 1px solid rgba(255, 107, 157, 0.12);
    /* всегда относительно экрана, не родителя */
    transform: translateZ(0);
    transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

#navbar.is-scrolled {
    background: rgba(26, 10, 30, 0.94);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
    border-bottom-color: rgba(255, 107, 157, 0.2);
}

body.on-login #navbar {
    visibility: hidden;
    pointer-events: none;
}

.nav-toggle {
    display: none;
}

/* Планшеты: горизонтальное меню ломается → бургер до 900px */
@media (max-width: 900px) {
    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 12px;
        padding: 10px 16px;
        padding-left: calc(16px + var(--safe-left));
        padding-right: calc(16px + var(--safe-right));
        min-height: 48px;
        border: none;
        background: transparent;
        color: var(--gold);
        font-family: inherit;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    #navbar {
        border-radius: 0 0 var(--radius) var(--radius);
    }

    #navbar .nav-menu {
        display: none;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 6px;
        padding: 4px 14px 16px;
        padding-left: calc(14px + var(--safe-left));
        padding-right: calc(14px + var(--safe-right));
        justify-content: flex-start;
    }

    #navbar.nav-open .nav-menu {
        display: flex;
    }

    #navbar .nav-menu li {
        width: 100%;
    }

    #navbar .nav-menu li a {
        display: flex;
        align-items: center;
        width: 100%;
        font-size: 15px;
        padding: 12px 18px;
        min-height: 48px;
        border-radius: var(--radius-pill);
    }

    .nav-toggle-label {
        flex: 1;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-toggle-icon {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 22px;
        flex-shrink: 0;
    }

    .nav-toggle-icon span {
        display: block;
        height: 2px;
        width: 100%;
        background: var(--pink-light);
        border-radius: 2px;
        transition: transform 0.25s, opacity 0.25s;
    }

    #navbar.nav-open .nav-toggle-icon span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    #navbar.nav-open .nav-toggle-icon span:nth-child(2) {
        opacity: 0;
    }

    #navbar.nav-open .nav-toggle-icon span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
}

#navbar ul,
.nav-menu {
    display: flex;
    justify-content: center;
    list-style: none;
    padding: 12px 16px;
    gap: 8px;
    flex-wrap: nowrap;
    margin: 0;
}

#navbar ul li a {
    color: var(--pink-light);
    text-decoration: none;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

#navbar ul li a.active {
    background: rgba(255, 107, 157, 0.18);
    border-color: rgba(255, 107, 157, 0.24);
    color: var(--gold);
    box-shadow: none;
    /* та же высота ряда, что у обычных пунктов */
    padding: 8px 18px;
    min-height: 0;
}

@media (hover: hover) and (pointer: fine) {
    #navbar ul li a:hover {
        background: rgba(255, 107, 157, 0.18);
        border-color: rgba(255, 107, 157, 0.2);
        color: var(--gold);
    }
}

/* ====== СЕКЦИИ ====== */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

#mainSite.screen.active {
    display: block;
    opacity: 0;
}

#mainSite.screen.active.is-revealed {
    opacity: 1;
    /* только opacity — transform ломает position:fixed у навбара */
    transition: opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

/* только счётчик мягко поднимается — не весь сайт (иначе дергает секции) */
#mainSite.is-revealed #counter.section {
    animation: contentRise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes contentRise {
    from { opacity: 0.75; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    #loginScreen.active,
    #loginScreen.active.is-leaving,
    #mainSite.screen.active,
    #mainSite.screen.active.is-revealed {
        transition: none !important;
        filter: none !important;
        transform: none !important;
    }

    #mainSite.is-revealed #counter.section {
        animation: none !important;
    }
}

.section {
    /* svh стабильнее; lvh — чтобы следующая секция не выглядывала на телефоне */
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100lvh;
    padding:
        calc(var(--nav-h) + var(--safe-top) + var(--section-pad-top-extra))
        max(var(--section-pad-x), var(--safe-right))
        calc(var(--section-pad-bottom) + var(--safe-bottom))
        max(var(--section-pad-x), var(--safe-left));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    scroll-margin-top: 0;
}

.section-title {
    font-family: 'SiteTitle', 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
    font-size: clamp(30px, 5.5vw, 40px);
    font-weight: 700;
    line-height: 1.2;
    color: var(--gold);
    text-align: center;
    margin-bottom: var(--title-mb);
    padding: 0 var(--stack-xs);
    /* мягче неон — тёплый акцент без «геймерского» glow */
    text-shadow: 0 1px 10px rgba(255, 215, 0, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.section-title::after {
    content: '';
    display: block;
    width: min(42%, 7.5em);
    max-width: 220px;
    height: 2px;
    margin: var(--title-rule-mt) auto 0;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--pink), var(--gold), var(--pink), transparent);
    box-shadow: 0 0 6px rgba(255, 107, 157, 0.12);
}

/* ====== СЧЁТЧИК ====== */
.counter-container {
    text-align: center;
}

.counter-grid {
    display: grid;
    /* minmax(0,1fr) — колонки не раздуваются из‑за ширины цифр */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--stack-md);
    max-width: 600px;
    width: 100%;
    margin: 0 auto var(--stack-lg);
}

.counter-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: var(--card-pad-y) var(--stack-sm);
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background 0.3s var(--ease-out), transform 0.3s var(--ease-out), box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

@media (hover: hover) and (pointer: fine) {
    .counter-item:hover {
        background: var(--glass-strong);
        border-color: rgba(255, 107, 157, 0.32);
        transform: translateY(-4px);
        box-shadow: var(--shadow-soft), var(--shadow-glow);
    }
}

.counter-number {
    display: block;
    width: 100%;
    font-size: 48px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
    text-align: center;
    background: linear-gradient(135deg, var(--pink), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: var(--stack-xs);
    /* резерв под 3 цифры (дни), чтобы подложка не прыгала */
    min-height: 1.05em;
}

.counter-label {
    font-size: 14px;
    color: var(--pink-light);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.counter-extra {
    margin-top: var(--stack-lg);
    color: var(--pink-light);
    font-size: 16px;
    line-height: 1.85;
    letter-spacing: 0.01em;
}

.counter-extra span {
    color: var(--gold);
    font-weight: 600;
    text-shadow: 0 1px 8px rgba(255, 215, 0, 0.12);
}

/* Стрелка "листай вниз" */
.scroll-hint {
    margin-top: var(--space-6);
    text-align: center;
    animation: fadeInUp 0.6s ease-out 1s both;
}

.scroll-arrow {
    display: block;
    font-size: 36px;
    color: var(--gold);
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.12));
}

.scroll-hint p {
    color: var(--pink-light);
    font-size: 14px;
    margin-top: var(--space-2);
    letter-spacing: 2px;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

/* ====== ТАЙМЛАЙН ====== */
.timeline {
    position: relative;
    /* wide: больше воздуха карточкам (раньше 700 → ~320px сторона) */
    max-width: 1040px;
    width: 100%;
    padding: var(--stack-md) 0;
    overflow: visible;
}

/*
  Линия без JS:
  1) .timeline-track::before — через все события
  2) .timeline-end-stem — от последнего события до точки
  3) .timeline-end-tip — точка на верхнем борте «Спасибо»
  Дальше линии нет.
*/
.timeline-track {
    position: relative;
}

.timeline-track::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(
        to bottom,
        var(--pink) 0%,
        var(--pink-deep) 55%,
        var(--gold) 100%
    );
    transform: translateX(-50%);
    z-index: 0;
    pointer-events: none;
}

.timeline-end-block {
    /* мостик до финала длиннее обычного зазора — финал ниже */
    --end-gap: 104px;
    --end-overlap: 40px;
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    /* чуть шире обычных карточек, но без огромного разлёта */
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 0 0 var(--stack-xl);
    box-sizing: border-box;
}

/* последняя карточка событий — без нижнего отступа (иначе дырка в линии) */
.timeline-track .timeline-item:last-child {
    margin-bottom: 0;
}

/* продолжение линии: перекрывает стык + доходит до точки */
.timeline-end-stem {
    position: absolute;
    left: 50%;
    top: calc(-1 * var(--end-overlap));
    width: 2px;
    height: calc(var(--end-overlap) + var(--end-gap));
    transform: translateX(-50%);
    background: linear-gradient(to bottom, var(--gold), var(--gold));
    z-index: 2;
    pointer-events: none;
}

.timeline-end-tip {
    position: absolute;
    left: 50%;
    top: var(--end-gap);
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--gold);
    transform: translate(-50%, -50%);
    box-shadow:
        0 0 0 3px rgba(20, 9, 12, 0.98),
        0 0 8px rgba(255, 215, 0, 0.18);
    z-index: 4;
    pointer-events: none;
}

.timeline-end-block .timeline-end-card.timeline-content {
    width: 100%;
    max-width: none;
    margin: var(--end-gap) 0 0;
    text-align: center;
    position: relative;
    z-index: 1;
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-radius: var(--radius);
    /* тот же glass, что у остальных карточек таймлайна */
    background: var(--glass);
    border: 1px solid rgba(255, 215, 0, 0.55);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-sizing: border-box;
    transform: none;
}

.timeline-end-block .timeline-end-card h3 {
    font-family: 'SiteTitle', cursive;
    font-size: clamp(26px, 3.2vw, 34px);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 var(--stack-sm);
    color: var(--gold);
    text-shadow: 0 1px 8px rgba(255, 215, 0, 0.1);
}

.timeline-end-block .timeline-end-card > p {
    font-size: 15px;
    line-height: 1.6;
    margin: 0 auto var(--stack-md);
    max-width: 32em;
    color: var(--pink-light);
    text-wrap: balance;
}

.timeline-end-btn {
    min-width: 160px;
    padding: 12px 30px;
    font-size: 15px;
}

@media (max-width: 768px) {
    .timeline-track::before {
        left: 20px;
    }

    .timeline-end-block {
        --end-gap: 110px;
        width: 100%;
        margin: 0;
        justify-content: flex-start;
        padding-left: 0;
        padding-right: 0;
    }

    .timeline-end-stem,
    .timeline-end-tip {
        left: 20px;
    }

    .timeline-end-block .timeline-end-card.timeline-content {
        width: 100%;
        max-width: none;
        padding: var(--stack-lg) var(--stack-md) var(--stack-md);
    }

    .timeline-end-block .timeline-end-card h3 {
        font-size: 26px;
    }
}

.timeline-item {
    position: relative;
    margin-bottom: var(--space-6);
    width: 100%;
    display: flex;
    justify-content: flex-start;
    padding-left: calc(50% + 32px);
}

.timeline-item:nth-child(even) {
    justify-content: flex-end;
    padding-left: 0;
    padding-right: calc(50% + 32px);
}

.timeline-dot {
    position: absolute;
    left: 50%;
    top: var(--stack-md);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--pink), var(--pink-dark));
    border: 3px solid var(--bg-mid);
    transform: translateX(-50%);
    z-index: 2;
    box-shadow:
        0 0 0 3px rgba(255, 107, 157, 0.1),
        0 0 14px rgba(255, 107, 157, 0.28);
}

.timeline-content {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: var(--card-pad-y) 20px;
    /* все карточки одного размера */
    width: 100%;
    max-width: 400px;
    transition: background 0.3s var(--ease-out), transform 0.3s var(--ease-out), box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@media (hover: hover) and (pointer: fine) {
    .timeline-content:hover {
        background: var(--glass-strong);
        border-color: rgba(255, 107, 157, 0.3);
        transform: translateY(-3px);
        box-shadow: var(--shadow-soft), var(--shadow-glow);
    }
}

.timeline-content h3 {
    color: var(--gold);
    font-size: 18px;
    margin-bottom: var(--stack-xs);
    letter-spacing: 0.02em;
}

.timeline-content .timeline-date {
    display: inline-block;
    background: rgba(255,107,157,0.15);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    color: var(--pink-light);
    margin-bottom: var(--stack-sm);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.timeline-content p {
    color: var(--pink-light);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: var(--stack-sm);
}

/* Спойлер в таймлайне */
.timeline-spoiler {
    margin-top: var(--stack-sm);
    border-top: 1px solid rgba(255,107,157,0.15);
    padding-top: var(--stack-sm);
}

.spoiler-btn {
    background: rgba(255,107,157,0.12);
    border: 1px solid rgba(255,107,157,0.2);
    color: var(--gold);
    padding: 10px 16px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
    font-family: 'Montserrat', sans-serif;
    width: 100%;
    text-align: center;
    font-weight: 600;
    white-space: normal;
    line-height: 1.35;
    min-height: 44px;
}

@media (hover: hover) and (pointer: fine) {
    .spoiler-btn:hover {
        background: rgba(255,107,157,0.25);
    }
}

.spoiler-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
    opacity: 0;
}

.spoiler-content.open {
    max-height: 800px;
    opacity: 1;
    margin-top: var(--stack-sm);
}

.spoiler-content p {
    font-size: 12px;
    margin-bottom: var(--stack-xs);
    color: var(--pink-light);
}

.spoiler-content .timeline-photo {
    max-height: 300px;
}

@media (max-width: 480px) {
    .spoiler-content .timeline-photo { max-height: 220px; }
}

@media (max-width: 360px) {
    .spoiler-content .timeline-photo { max-height: 180px; }
}

.timeline-photo-placeholder {
    background: rgba(255,255,255,0.05);
    border: 2px dashed rgba(255,107,157,0.3);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    color: var(--pink-light);
    font-size: 13px;
    cursor: pointer;
}

/* Фото в таймлайне — с сохранением пропорций */
.timeline-photo {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: contain;
    border-radius: 12px;
    display: block;
    margin-inline: auto;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
    filter: brightness(1.07) contrast(1.04);
}

@media (max-width: 480px) {
    .timeline-photo { max-height: 350px; }
}

@media (max-width: 360px) {
    .timeline-photo { max-height: 250px; }
}

/* Видео в таймлайне */
.timeline-video-wrap {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(145deg, var(--bg-mid) 0%, var(--bg-mid) 55%, var(--bg-login) 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 107, 157, 0.15);
}

.timeline-video {
    width: auto;
    max-width: 100%;
    max-height: 500px;
    height: auto;
    border-radius: 12px;
    display: block;
    background: transparent;
    outline: none;
    vertical-align: middle;
}

@media (max-width: 480px) {
    .timeline-video { max-height: 350px; }
}

@media (max-width: 360px) {
    .timeline-video { max-height: 250px; }
}

/* Live Photo (как на айфоне) */
.live-photo-wrapper {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    /* скролл разрешён; блокируется только после long-press */
    touch-action: pan-y;
}
.live-photo-wrapper.live-holding {
    touch-action: none;
}

.live-photo-img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: contain;
    border-radius: 12px;
    display: block;
    background: rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.live-photo-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: contain;
    /* без чёрного фона — пока грузится, видно фото снизу */
    background: transparent;
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-out;
}

.live-photo-video.active {
    opacity: 1;
    pointer-events: auto;
}

.live-photo-icon {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 18px;
    height: 18px;
    opacity: 0.9;
    pointer-events: none;
    z-index: 4;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
    transition: opacity 0.15s ease-out;
}

.live-photo-icon.dimmed {
    opacity: 0.2;
}

@media (max-width: 480px) {
    .live-photo-img { max-height: 350px; }
    .live-photo-icon { width: 16px; height: 16px; top: 6px; left: 6px; }
}

/* Видео как гифка + кнопка звука */
.gif-video-wrapper {
    position: relative;
    display: block;
}

.gif-video {
    display: block;
    width: 100%;
    max-height: 500px;
    border-radius: 12px;
    background: #000; /* video player chrome */
    outline: none;
}

.sound-toggle {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    border: none;
    color: var(--white);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    z-index: 5;
}

.sound-toggle:hover {
    background: rgba(0,0,0,0.8);
    transform: scale(1.1);
}

/* ====== ГАЛЕРЕЯ ====== */
.gallery-container {
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.gallery-viewer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--stack-md);
}

.gallery-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--white);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s var(--ease-out), box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
    .gallery-btn:hover {
        background: var(--pink);
        border-color: transparent;
        transform: scale(1.08);
        box-shadow: 0 8px 20px rgba(255, 107, 157, 0.35);
    }
}

.photo-display {
    flex: 1;
    max-width: 350px;
}

/* ПК: +25% как у таймлайн/Live (max-height 500 vs прежние ~400) — телефон не трогаем */
@media (min-width: 769px) {
    .gallery-container {
        max-width: 625px;
    }

    .photo-display {
        max-width: 438px;
    }

    .gallery-btn {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }
}

.polaroid {
    background: var(--white);
    padding: var(--stack-sm) var(--stack-sm) var(--stack-md); /* рамка без резерва под пустую подпись */
    border-radius: var(--radius-sm);
    box-shadow:
        var(--shadow),
        0 0 0 1px rgba(45, 27, 46, 0.06);
    transform: rotate(-2deg);
    transition: transform 0.35s var(--ease-out), box-shadow 0.35s ease;
}

.polaroid.has-caption {
    padding-bottom: var(--space-5); /* фиксированный слот подписи — без прыжка высоты */
}

@media (hover: hover) and (pointer: fine) {
    .polaroid:hover {
        transform: rotate(0deg) scale(1.02);
    }
}

/* Анимация перелистывания галереи */
.polaroid.switching {
    opacity: 0;
    transform: rotate(-2deg) translateY(10px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.polaroid-img {
    background: linear-gradient(135deg, var(--bg-mid), var(--bg-login));
    border-radius: 4px;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Фото в галерее — обрезаем без растягивания */
.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.polaroid-caption {
    color: var(--dark);
    font-family: 'SiteTitle', 'Segoe Print', cursive;
    font-size: 18px;
    font-weight: 700;
    margin-top: var(--stack-sm);
    text-align: center;
}

.polaroid-caption:empty {
    display: none;
    margin: 0;
}

.gallery-hint {
    color: var(--pink-light);
    font-size: 12px;
    margin-top: var(--stack-md);
    opacity: 0.6;
}

.gallery-dots {
    display: flex;
    justify-content: center;
    gap: var(--stack-xs);
    margin-top: var(--stack-lg);
}

.gallery-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    cursor: pointer;
    transition: transform 0.25s, background 0.25s;
    position: relative;
}

.gallery-dot::before {
    content: '';
    position: absolute;
    inset: -14px;
}

.live-hint {
    color: var(--pink-light);
    font-size: 12px;
    margin-top: var(--stack-sm);
    text-align: center;
    opacity: 0.8;
    line-height: 1.4;
}

.gallery-dot.active {
    background: var(--pink);
    transform: scale(1.3);
}

/* ====== ПИСЬМО ====== */
.letter-container {
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.letter-envelope {
    display: block;
    width: 100%;
    border: none;
    font: inherit;
    color: inherit;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(145deg, var(--pink) 0%, var(--pink) 40%, var(--pink-dark) 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-5);
    cursor: pointer;
    transition: transform 0.4s var(--ease-out), box-shadow 0.4s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(232, 67, 122, 0.35);
}

.letter-envelope::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.1) 0%, transparent 50%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translate(-30%, -30%); }
    50% { transform: translate(30%, 30%); }
}

@media (hover: hover) and (pointer: fine) {
    .letter-envelope:hover {
        transform: scale(1.02) translateY(-2px);
        box-shadow: 0 20px 48px rgba(255, 107, 157, 0.45);
    }
}

.envelope-icon {
    font-size: 64px;
    display: block;
    margin-bottom: var(--stack-md);
    position: relative;
    z-index: 1;
}

.envelope-front {
    display: block;
    position: relative;
    z-index: 1;
}

.envelope-front .envelope-label,
.envelope-front p {
    font-size: 18px;
    font-weight: 600;
    position: relative;
    z-index: 1;
    display: block;
}

.letter-content {
    /* PAPER_TRIAL — откат: linear-gradient cream #fff8f0 */
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-4);
    position: relative;
    animation: fadeInUp 0.6s var(--ease-out);
    box-shadow: var(--shadow), 0 0 0 1px rgba(255, 107, 157, 0.12);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.letter-text {
    color: var(--paper-ink);
    font-size: 16px;
    line-height: 1.8;
    text-align: left;
    min-height: 100px;
    white-space: pre-wrap;
    font-family: 'Montserrat', 'Segoe UI', Roboto, Arial, sans-serif;
}

.letter-text::after {
    content: '|';
    animation: blink 0.8s infinite;
    color: var(--pink);
}

.letter-text.done::after {
    content: none;
    animation: none;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ====== ИГРЫ ====== */
.games-container {
    /* ритм карточек: одна шкала отступов, без «прыжков» при win-состояниях */
    --gc-gap: 24px;
    --gc-pad-y: 22px;
    --gc-pad-x: 20px;
    --gc-title-mb: 6px;
    --gc-desc-mb: 12px;
    --gc-stats-mb: 12px;
    --gc-footer-mt: 36px; /* запас под win-текст над кнопкой (absolute) */
    --gc-footer-h: 48px;
    --gc-play-h: 320px; /* Memory ↔ Catch */
    --gc-pair2-min: 452px; /* Пазл ↔ Дата: высота play-колонки */
    --gc-tray-h: 124px; /* лоток пазла / даты — одна высота, без прыжка */

    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gc-gap);
    max-width: 900px;
    width: 100%;
    align-items: stretch;
    /* GAMES_CLIP: overflow:hidden — иначе iOS Safari при скролле «протекает» слоями соседних карт */
    overflow: hidden;
    padding-bottom: 10px; /* тени нижних кнопок */
}

.game-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--gc-pad-y) var(--gc-pad-x);
    text-align: center;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
    /* GAMES_CLIP: clip paint — фикс iOS ghosting соседних карт при скролле */
    overflow: hidden;
    contain: paint;
    width: 100%;
    max-width: 100%;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s var(--ease-out);
    isolation: isolate;
}

@media (hover: hover) and (pointer: fine) {
    .game-card:hover {
        border-color: rgba(255, 107, 157, 0.3);
        box-shadow: var(--shadow-soft), var(--shadow-glow);
    }
}

.game-card h3 {
    color: var(--gold);
    font-size: 20px;
    margin: 0 0 var(--gc-title-mb);
    flex-shrink: 0;
    line-height: 1.25;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 6px rgba(255, 215, 0, 0.08);
}

.game-card > p {
    color: var(--pink-light);
    font-size: 13px;
    line-height: 1.4;
    margin: 0 0 var(--gc-desc-mb);
    flex-shrink: 0;
    min-height: 1.4em;
}

/* Общая структура тела игры */
.game-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.game-stats {
    flex-shrink: 0;
    margin: 0 0 var(--gc-stats-mb);
    min-height: 1.35em;
    color: var(--pink-light);
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
}

.game-stats span {
    color: var(--gold);
    font-weight: 600;
}

.game-play {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* Memory: слот футера фиксирован; win-текст над кнопкой — карточка не растёт */
.game-footer {
    position: relative;
    flex-shrink: 0;
    height: var(--gc-footer-h);
    min-height: var(--gc-footer-h);
    margin-top: var(--gc-footer-mt);
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: visible;
}

.game-footer-msg,
.game-footer-btn {
    margin: 0;
    max-width: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.game-footer-msg:not(.visible),
.game-footer-btn:not(.visible) {
    display: none;
}

.game-footer-msg {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    width: 100%;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--gold);
    text-align: center;
    padding: 0 var(--space-1);
    box-sizing: border-box;
}

.game-footer-msg.visible {
    display: block;
    opacity: 1;
}

.game-footer-btn.visible {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    pointer-events: auto;
}

.game-footer-btn {
    white-space: nowrap;
}

/* Единый размер кнопок во всех играх */
.btn.game-action-btn {
    --game-btn-pad-y: 10px;
    --game-btn-pad-x: 18px;
    --game-btn-font: 14px;
    --game-btn-min-h: 42px;
    --game-btn-min-w: 180px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--game-btn-pad-y) var(--game-btn-pad-x) !important;
    font-size: var(--game-btn-font) !important;
    min-height: var(--game-btn-min-h) !important;
    min-width: var(--game-btn-min-w);
    width: auto;
    max-width: 100%;
    line-height: 1.2;
    white-space: nowrap;
    box-sizing: border-box;
    letter-spacing: 0;
}

.compact-game-area {
    --play-height: var(--gc-play-h, 320px);
    height: var(--play-height);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 3D flip: clip внутри карточки (overflow:visible на play давал iOS bleed) */
#memoryGame > .game-play {
    overflow: hidden;
}
#memoryGame .compact-game-area {
    overflow: hidden;
}

/* Игра Memory: карты с переворотом */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-width: 320px;
    width: 100%;
    margin: 0 auto;
    perspective: 1000px;
    overflow: hidden;
}

.memory-card {
    aspect-ratio: 1;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.memory-card.matched {
    animation: matchPulse 0.5s ease;
    pointer-events: none;
}

.memory-card.matched .card-back,
.memory-card.matched .card-front {
    /* тихое «готово» — не спорит с открытыми */
    opacity: 0.64;
    border-color: rgba(240, 201, 122, 0.35);
    box-shadow: inset 0 0 0 1.5px rgba(240, 201, 122, 0.4);
}

@keyframes matchPulse {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.04); }
    100% { transform: rotateY(180deg) scale(1); }
}

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

/*
  MEMORY_HIERARCHY — закрыто → открыто → пара
  Откат к previous MEMORY_CARD_TRIAL: см. git history / mem1
*/
.card-back {
    /* чуть светлее glass, чтобы сетка не тонула в карточке */
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.06) 0%, transparent 42%),
        linear-gradient(135deg, #32161e 0%, var(--bg-login) 42%, #241018 100%);
    border: 2px solid rgba(255, 107, 157, 0.44);
    position: relative;
    overflow: hidden;
}

.card-back::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1.5px solid rgba(255, 107, 157, 0.2);
    border-radius: 6px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 107, 157, 0.1) 0%, transparent 52%),
        radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
}

/* ❤ на рубашке — тихий маркер, не конкурирует с CTA */
.card-back::after {
    content: '❤';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: rgba(255, 107, 157, 0.26);
    text-shadow: 0 0 6px rgba(255, 107, 157, 0.12);
}

/* Лицо — награда: champagne рамка + розовый glow */
.card-front {
    background:
        linear-gradient(145deg, rgba(255, 107, 157, 0.14) 0%, transparent 50%),
        linear-gradient(145deg, #3a1a24 0%, var(--bg-login) 48%, #2c141c 100%);
    border: 2px solid rgba(240, 201, 122, 0.58);
    transform: rotateY(180deg);
    box-shadow:
        inset 0 0 20px rgba(255, 107, 157, 0.28),
        0 0 12px rgba(240, 201, 122, 0.12);
}

.card-icon {
    font-size: 32px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}


.game-score {
    color: var(--pink-light);
    font-size: 14px;
    margin-bottom: 10px;
}

.win-message {
    color: var(--gold);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px 0;
    min-height: 24px;
    line-height: 1.3;
    animation: fadeInUp 0.5s ease-out;
}

.btn.small {
    padding: 10px 24px;
    font-size: 13px;
}

/* Адаптивность для Memory */
@media (max-width: 480px) {
    .memory-grid {
        gap: 8px;
        max-width: 280px;
    }
    .compact-game-area {
        --play-height: 280px;
    }
    .card-back::after { font-size: 18px; }
    .card-icon { font-size: 26px; }
}

@media (max-width: 360px) {
    .memory-grid {
        gap: 6px;
        max-width: 240px;
    }
    .compact-game-area {
        --play-height: 240px;
    }
    .card-back::after { font-size: 14px; }
    .card-icon { font-size: 20px; }
}

/* Игра: Викторина */
.quiz-progress {
    color: var(--pink-light);
    font-size: 14px;
    margin-bottom: 15px;
}

.quiz-question {
    color: var(--white);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.4;
}

.quiz-answers {
    display: grid;
    gap: 10px;
    margin-bottom: 15px;
}

.quiz-answer {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,107,157,0.2);
    border-radius: 10px;
    padding: 12px 20px;
    color: var(--white);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Montserrat', sans-serif;
}

.quiz-answer:hover {
    background: rgba(255,107,157,0.2);
    transform: translateX(5px);
}

.quiz-answer.correct {
    background: rgba(46,213,115,0.3);
    border-color: var(--ok);
    color: var(--ok);
}

.quiz-answer.wrong {
    background: rgba(255,71,87,0.3);
    border-color: var(--err);
    color: var(--err);
}

/* ====== ФУТЕР ====== */
footer {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    border-top: 1px solid rgba(255,107,157,0.1);
}

.footer-hearts {
    font-size: 32px;
    margin-bottom: var(--stack-sm);
    line-height: 1;
}

footer p {
    color: var(--pink-light);
    font-size: 14px;
    margin-bottom: var(--stack-xs);
    line-height: 1.45;
}

.heart-red {
    color: var(--pink);
}

.footer-small {
    font-size: 12px;
    opacity: 0.88;
    color: var(--pink-soft);
    margin-bottom: 0;
}

/* Игра: Лови сердечки */
.catch-body {
    min-height: 0;
}
.catch-play {
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    align-items: stretch;
    justify-content: stretch;
    margin-bottom: 0;
    overflow: hidden;
}
.catch-area {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: var(--gc-play-h, 320px);
    background: rgba(0,0,0,0.15);
    border-radius: 12px;
    overflow: hidden;
    cursor: default;
    --play-height: 400px;
    box-sizing: border-box;
}
.catch-area:has(.catch-heart) {
    overflow: hidden;
    contain: paint;
}
.catch-overlay {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 16px;
    background: rgba(20, 9, 12, 0.62);
    pointer-events: none;
}
.catch-overlay.visible {
    display: flex;
    pointer-events: auto;
}
.catch-end-message {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--err);
}
.catch-heart {
    position: absolute;
    width: 72px;
    height: 72px;
    margin-left: -36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    animation: heartFall linear forwards;
    pointer-events: auto;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
@keyframes heartFall {
    0% { transform: translateY(-40px) rotate(0deg); opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateY(var(--play-height, 400px)) rotate(360deg); opacity: 0; }
}

/* Старт «Лови» — только позиция; анимация/hover как у .game-action-btn */
.catch-start-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

@media (hover: hover) and (pointer: fine) {
    .btn.game-action-btn.catch-start-btn:hover {
        transform: translate(-50%, calc(-50% - 2px));
    }
}

.btn.game-action-btn.catch-start-btn:active {
    transform: translate(-50%, -50%);
}

/* Пазл / Дата: одна min-высота play — пара ровная; контент по центру */
.puzzle-play,
.date-play {
    justify-content: center;
    flex: 1 1 auto;
    min-height: var(--gc-pair2-min, 452px);
    gap: 14px;
    box-sizing: border-box;
}

/* Игра: Пазл — квадратная обрезка + фокус как в галерее */
.puzzle-play {
    overflow: hidden;
}
.puzzle-canvas {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    aspect-ratio: 1 / 1;
}
.puzzle-slot {
    position: relative;
    min-width: 0;
    min-height: 0;
    border: 2px dashed rgba(255,107,157,0.25);
    border-radius: 6px;
    background: rgba(0,0,0,0.15);
    overflow: hidden;
    transition: background 0.2s;
}
.puzzle-slot.drag-over {
    border-color: var(--gold);
    background: rgba(255,215,0,0.08);
}
.puzzle-slot.filled {
    border-style: solid;
    border-color: rgba(255,107,157,0.2);
}
.puzzle-slot-tile {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 4px;
}
/* Полный квадратный кадр cover, сдвинутый к нужному кусочку */
.puzzle-tile-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 300%;
    height: 300%;
    pointer-events: none;
    background-repeat: no-repeat;
    background-size: cover; /* обрезает, не растягивает */
    background-position: 50% 50%;
}
.puzzle-tray {
    --piece-size: 48px;
    --piece-gap: 6px;
    --tray-h: var(--gc-tray-h, 124px);
    position: relative;
    width: 100%;
    height: var(--tray-h);
    min-height: var(--tray-h);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
}
.puzzle-pieces {
    /* 5+4: две компактные строки, последняя по центру */
    width: 100%;
    max-width: calc(var(--piece-size) * 5 + var(--piece-gap) * 4);
    display: flex;
    flex-wrap: wrap;
    gap: var(--piece-gap);
    justify-content: center;
    align-content: center;
    align-items: center;
    margin: 0 auto;
}
.puzzle-done {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 4px 8px;
    overflow: visible;
    box-sizing: border-box;
}
.puzzle-done p {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--gold);
}
.puzzle-tray.done {
    height: var(--tray-h);
    min-height: var(--tray-h);
}
.puzzle-tray.done .puzzle-pieces {
    display: none;
}
.puzzle-tray.done .puzzle-done {
    display: flex;
}
.puzzle-done .btn.game-action-btn {
    --game-btn-pad-y: 7px;
    --game-btn-pad-x: 14px;
    --game-btn-font: 12px;
    --game-btn-min-h: 36px;
    --game-btn-min-w: 150px;
}
.puzzle-piece {
    position: relative;
    width: var(--piece-size);
    height: var(--piece-size);
    flex: 0 0 var(--piece-size);
    border-radius: 6px;
    cursor: grab;
    border: 2px solid rgba(255,107,157,0.2);
    transition: transform 0.15s, opacity 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    overflow: hidden;
}
.puzzle-piece:active {
    cursor: grabbing;
    transform: scale(1.08);
}
.puzzle-piece.dragging {
    opacity: 0.35;
}
.puzzle-piece.placed {
    display: none;
}
.puzzle-touch-clone {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.9;
    margin: 0;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
/* Игра: Угадай дату — вертикальное фото */
.date-play {
    padding: 0;
    overflow: hidden;
}
.date-photo-wrap {
    width: 100%;
    max-width: 230px;
    margin: 0 auto;
    border: 2px solid rgba(255,107,157,0.15);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 3/4;
    background: rgba(0,0,0,0.12);
    flex-shrink: 0;
}
.date-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.date-tray {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    /* выше лотка пазла (текст + кнопка влезают); высота пары = Дата */
    --date-tray-h: var(--gc-tray-h, 124px);
    height: var(--date-tray-h);
    min-height: var(--date-tray-h);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
}
.date-answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    height: 100%;
    width: 100%;
}
.date-feedback {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    text-align: center;
    z-index: 2;
    text-shadow: 0 1px 8px rgba(0,0,0,0.55);
}
.date-feedback.visible {
    opacity: 1;
}
.date-tray:has(.date-feedback.visible) .date-answers {
    opacity: 0.2;
}
.date-done {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 4px 8px;
    overflow: visible;
    box-sizing: border-box;
}
.date-done p {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--gold);
}
.date-tray.done {
    height: var(--date-tray-h);
    min-height: var(--date-tray-h);
}
.date-tray.done .date-answers,
.date-tray.done .date-feedback {
    display: none;
}
.date-tray.done .date-done {
    display: flex;
}
.date-done .btn.game-action-btn {
    --game-btn-pad-y: 7px;
    --game-btn-pad-x: 14px;
    --game-btn-font: 12px;
    --game-btn-min-h: 36px;
    --game-btn-min-w: 150px;
}
/* DATE_BTN_TRIAL — кнопки как .btn; откат: glass chips (rgba white 0.08 + radius 10px) */
.date-answer {
    background: linear-gradient(145deg, var(--pink) 0%, var(--pink) 45%, var(--pink-dark) 100%);
    border: none;
    border-radius: var(--radius-pill);
    padding: 10px 14px;
    color: var(--white);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s var(--ease-out), box-shadow 0.3s ease, filter 0.3s ease;
    font-family: 'Montserrat', 'Segoe UI', Roboto, Arial, sans-serif;
    box-shadow: 0 6px 18px rgba(232, 67, 122, 0.28);
    line-height: 1.2;
}
@media (hover: hover) and (pointer: fine) {
    .date-answer:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 26px rgba(255, 107, 157, 0.42);
        filter: brightness(1.04);
    }
}
.date-answer.correct {
    background: linear-gradient(145deg, #3ddc84 0%, var(--ok) 100%);
    color: var(--white);
    box-shadow: 0 6px 18px rgba(46, 213, 115, 0.35);
}
.date-answer.wrong {
    background: linear-gradient(145deg, #ff6b7a 0%, var(--err) 100%);
    color: var(--white);
    box-shadow: 0 6px 18px rgba(255, 71, 87, 0.35);
}

/* ====== МОБИЛЬНАЯ ОПТИМИЗАЦИЯ ====== */
@media (max-width: 768px) {
    :root {
        --nav-h: 52px;
        --title-mb: var(--space-4);
        --section-pad-top-extra: var(--space-3);
        --section-pad-bottom: var(--space-5);
        --card-pad-y: var(--space-3);
        --card-pad-x: var(--space-3);
    }

    /* короткие экраны-секции: контент по центру, без «хвоста» следующей */
    #counter.section,
    #letter.section,
    #gallery.section {
        justify-content: center;
        min-height: 100svh;
        min-height: 100lvh;
        /* симметричные отступы — оптический центр ниже навбара */
        padding-top: calc(var(--nav-h) + var(--safe-top) + var(--stack-sm));
        padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--stack-sm));
    }

    #counter .scroll-hint {
        position: absolute;
        left: 0;
        right: 0;
        /* safe-area + запас под нижнюю панель Safari на iPhone */
        bottom: calc(56px + var(--safe-bottom));
        margin-top: 0;
        padding: 0 var(--stack-sm);
        pointer-events: none;
        z-index: 2;
    }

    #counter .scroll-arrow {
        font-size: 28px;
    }

    #counter .scroll-hint p {
        font-size: 13px;
        margin-top: 6px;
        letter-spacing: 1.5px;
    }

    #letter.section {
        /* чуть ниже геометрического центра */
        padding-top: calc(var(--nav-h) + var(--safe-top) + 8vh);
        padding-bottom: calc(var(--stack-lg) + var(--safe-bottom) + 2vh);
    }

    .counter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--stack-sm);
    }

    .counter-number {
        font-size: 36px;
    }

    .section-title {
        font-size: 34px;
    }

    .login-container h1 {
        font-size: 38px;
    }

    .timeline-item {
        margin-bottom: var(--space-5);
        padding-left: 50px !important;
        padding-right: 0 !important;
    }

    .timeline-dot {
        left: 20px;
    }

    .timeline-content {
        max-width: 100%;
        padding: var(--card-pad-y) var(--card-pad-x);
    }

    .games-container {
        grid-template-columns: 1fr;
        gap: var(--space-4);
        max-width: 100%;
        /* в 1 колонке не растягиваем play под «пару» */
        --gc-pair2-min: 0;
        --gc-pad-y: 18px;
        --gc-pad-x: 16px;
        --gc-footer-mt: 32px;
        --gc-gap: var(--space-4);
    }

    .game-card {
        min-height: 0;
        width: 100%;
        padding: var(--gc-pad-y) var(--gc-pad-x);
    }

    .puzzle-play,
    .date-play {
        min-height: 0;
    }

    /* мобильное меню — кнопка + вертикальный список */
    #navbar {
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 12px;
        padding: 10px 16px;
        padding-left: calc(16px + var(--safe-left));
        padding-right: calc(16px + var(--safe-right));
        min-height: 48px;
        border: none;
        background: transparent;
        color: var(--gold);
        font-family: inherit;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-toggle-label {
        flex: 1;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-toggle-icon {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 22px;
        flex-shrink: 0;
    }

    .nav-toggle-icon span {
        display: block;
        height: 2px;
        width: 100%;
        background: var(--pink-light);
        border-radius: 2px;
        transition: transform 0.25s, opacity 0.25s;
    }

    #navbar.nav-open .nav-toggle-icon span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    #navbar.nav-open .nav-toggle-icon span:nth-child(2) {
        opacity: 0;
    }

    #navbar.nav-open .nav-toggle-icon span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    #navbar .nav-menu {
        display: none;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 6px;
        padding: 4px 14px 16px;
        padding-left: calc(14px + var(--safe-left));
        padding-right: calc(14px + var(--safe-right));
        overflow: visible;
        justify-content: flex-start;
    }

    #navbar.nav-open .nav-menu {
        display: flex;
    }

    #navbar .nav-menu li {
        width: 100%;
    }

    #navbar .nav-menu li a {
        display: flex;
        align-items: center;
        width: 100%;
        font-size: 15px;
        padding: 12px 18px;
        min-height: 48px;
        height: 48px;
        box-sizing: border-box;
        border-radius: 50px;
        white-space: nowrap;
    }

    #navbar .nav-menu li a.active {
        padding: 12px 18px;
        min-height: 48px;
        height: 48px;
    }

    .login-container {
        padding: var(--space-5) var(--stack-lg) var(--stack-md);
        width: min(92vw, 420px);
    }

    #dateInput {
        padding: 14px 10px;
        font-size: 16px;
    }

    .gallery-viewer {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: var(--stack-md) var(--space-6);
        width: 100%;
    }

    .photo-display {
        flex: 0 0 100%;
        order: 1;
        max-width: min(350px, 100%);
        width: 100%;
    }

    #prevPhoto {
        order: 2;
    }

    #nextPhoto {
        order: 3;
    }

    .gallery-btn {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    .polaroid {
        transform: none;
        max-width: 100%;
        margin: 0 auto;
    }

    .gallery-dots {
        margin-top: var(--stack-md);
    }

    .btn,
    .btn.small {
        min-height: 44px;
        touch-action: manipulation;
    }

    .btn.game-action-btn {
        --game-btn-pad-y: 9px;
        --game-btn-pad-x: 16px;
        --game-btn-font: 13px;
        --game-btn-min-h: 40px;
        --game-btn-min-w: 168px;
    }

    .spoiler-btn {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 13px;
    }

    .date-answer {
        min-height: 48px;
        font-size: 14px;
        padding: 12px 10px;
    }

    .catch-heart {
        width: 80px;
        height: 80px;
        margin-left: -40px;
        font-size: 32px;
    }

    .catch-area {
        min-height: var(--gc-play-h, 280px);
    }

    .game-card {
        padding: var(--gc-pad-y, 18px) var(--gc-pad-x, 16px);
    }

    .games-container {
        overflow: hidden;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        gap: var(--space-5);
        padding-bottom: var(--stack-sm);
        --gc-play-h: 280px;
        --gc-gap: var(--space-5);
    }

    footer {
        padding-bottom: calc(var(--space-5) + var(--safe-bottom));
    }
}

@media (max-width: 480px) {
    :root {
        --title-mb: 28px;
        --section-pad-x: 14px;
        --section-pad-top-extra: 20px;
        --section-pad-bottom: 28px;
        --card-pad-y: var(--space-3);
    }

    .counter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--stack-xs);
        width: 100%;
    }

    .counter-number {
        font-size: 28px;
    }

    .counter-item {
        padding: var(--stack-md) var(--stack-xs);
    }

    .section {
        padding:
            calc(var(--nav-h) + var(--safe-top) + var(--section-pad-top-extra))
            max(var(--section-pad-x), var(--safe-right))
            calc(var(--section-pad-bottom) + var(--safe-bottom))
            max(var(--section-pad-x), var(--safe-left));
        justify-content: flex-start;
    }

    #counter.section,
    #letter.section,
    #gallery.section {
        justify-content: center;
        min-height: 100svh;
        min-height: 100lvh;
        padding-left: max(var(--section-pad-x), var(--safe-left));
        padding-right: max(var(--section-pad-x), var(--safe-right));
        padding-top: calc(var(--nav-h) + var(--safe-top) + var(--stack-sm));
        padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--stack-sm));
    }

    #letter.section {
        padding-top: calc(var(--nav-h) + var(--safe-top) + 10vh);
        padding-bottom: calc(var(--stack-lg) + var(--safe-bottom) + 2vh);
    }

    #counter .scroll-hint {
        bottom: calc(64px + var(--safe-bottom));
    }

    #counter .scroll-arrow {
        font-size: 26px;
    }

    #counter .scroll-hint p {
        font-size: 12px;
    }

    .section-title {
        font-size: 32px;
    }

    .login-container h1 {
        font-size: 36px;
    }

    .nav-toggle {
        padding: 8px 14px;
        padding-left: calc(14px + var(--safe-left));
        padding-right: calc(14px + var(--safe-right));
        min-height: 46px;
        font-size: 14px;
    }

    #navbar .nav-menu li a {
        font-size: 14px;
        padding: 11px 14px;
        min-height: 46px;
    }

    .letter-text {
        font-size: 15px;
        line-height: 1.65;
    }

    .letter-content {
        padding: var(--stack-lg) var(--stack-md);
        width: 100%;
    }

    .letter-envelope {
        width: 100%;
        padding: var(--space-5) var(--stack-lg);
    }

    .polaroid-img {
        font-size: 40px;
    }

    .timeline {
        width: 100%;
        padding: var(--stack-sm) 0;
    }

    .timeline-item {
        margin-bottom: var(--space-4);
    }

    .timeline-content {
        padding: 14px var(--stack-md);
    }

    .timeline-content h3 {
        font-size: 16px;
    }

    .timeline-content p {
        font-size: 13px;
    }

    .scroll-arrow {
        font-size: 40px;
    }

    .scroll-hint {
        margin-top: var(--space-6);
    }

    .scroll-hint p {
        font-size: 13px;
        letter-spacing: 2px;
    }

    .game-card {
        padding: var(--gc-pad-y, 18px) var(--gc-pad-x, 16px);
    }

    .game-card h3 {
        font-size: 17px;
    }

    .btn.game-action-btn {
        --game-btn-pad-y: 8px;
        --game-btn-pad-x: 14px;
        --game-btn-font: 13px;
        --game-btn-min-h: 38px;
        --game-btn-min-w: 156px;
    }

    .game-stats {
        font-size: 12px;
    }

    .compact-game-area {
        --play-height: 280px;
    }

    .memory-grid {
        gap: 8px;
        max-width: min(280px, 100%);
    }

    .puzzle-canvas {
        max-width: min(260px, 78vw);
    }

    .puzzle-tray {
        --piece-size: 46px;
        --piece-gap: 5px;
    }

    .date-photo-wrap {
        max-width: min(210px, 58vw);
    }

    .date-tray {
        max-width: 100%;
        height: var(--date-tray-h, var(--gc-tray-h, 124px));
        min-height: var(--date-tray-h, var(--gc-tray-h, 124px));
    }

    .date-answers {
        height: 100%;
        gap: 8px;
    }

    .login-container {
        padding: var(--space-5) var(--stack-md) var(--stack-sm);
        width: min(94vw, 420px);
    }

    .login-container h1 {
        font-size: 34px;
    }

    #dateInput {
        padding: 12px 8px;
    }

    .login-hearts {
        font-size: 36px;
    }

    .login-subtitle {
        font-size: clamp(12px, 3.2vw, 14px);
        margin-bottom: var(--stack-lg);
        white-space: normal;
    }

    .btn {
        padding: 12px 28px;
        font-size: 15px;
        width: auto;
        max-width: 100%;
    }

    #loginBtn {
        width: 100%;
    }

    .gallery-dots {
        gap: 10px;
        flex-wrap: wrap;
    }

    .gallery-dot {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 360px) {
    .counter-number {
        font-size: 22px;
    }

    .counter-item {
        padding: 10px 5px;
    }

    .counter-label {
        font-size: 11px;
        letter-spacing: 1px;
    }

    .section-title {
        font-size: 30px;
    }

    .timeline-content {
        padding: 12px;
    }

    .timeline-content h3 {
        font-size: 14px;
    }

    .timeline-content p {
        font-size: 12px;
    }

    .letter-text {
        font-size: 14px;
    }

    .letter-content {
        padding: var(--stack-lg) 14px;
    }

    .login-container h1 {
        font-size: 32px;
    }

    .envelope-icon {
        font-size: 48px;
    }

    .envelope-front .envelope-label,
    .envelope-front p {
        font-size: 15px;
    }

    .games-container {
        --gc-pad-y: 14px;
        --gc-pad-x: 12px;
    }

    .game-card {
        padding: var(--gc-pad-y) var(--gc-pad-x);
    }

    .puzzle-canvas {
        max-width: min(220px, 76vw);
    }

    .puzzle-tray {
        --piece-size: 42px;
        --piece-gap: 5px;
    }

    .date-photo-wrap {
        max-width: min(170px, 55vw);
    }

    .catch-heart {
        width: 76px;
        height: 76px;
        margin-left: -38px;
    }

    .btn.game-action-btn {
        --game-btn-pad-y: 7px;
        --game-btn-pad-x: 12px;
        --game-btn-font: 12px;
        --game-btn-min-h: 36px;
        --game-btn-min-w: 148px;
    }
}

/* АЛЬБОМНАЯ ОРИЕНТАЦИЯ — телефон/короткий экран (P1 + P9) */
@media (max-height: 500px) and (orientation: landscape) {
    .section {
        padding: calc(var(--nav-h) + var(--safe-top) + 12px) 20px calc(16px + var(--safe-bottom));
        min-height: auto;
        justify-content: flex-start;
    }

    #counter.section,
    #letter.section,
    #gallery.section {
        min-height: auto;
        justify-content: flex-start;
        padding-top: calc(var(--nav-h) + var(--safe-top) + 10px);
        padding-bottom: calc(12px + var(--safe-bottom));
    }

    #counter .scroll-hint {
        position: static;
        margin-top: 12px;
        bottom: auto;
    }

    .section-title {
        font-size: clamp(22px, 4vw, 28px);
        margin-bottom: var(--stack-md);
    }

    .counter-grid {
        max-width: 420px;
        gap: var(--stack-xs);
        margin-bottom: var(--stack-sm);
    }

    .counter-item {
        padding: var(--stack-xs) 6px;
    }

    .counter-number {
        font-size: 22px;
    }

    .counter-label {
        font-size: 10px;
    }

    .login-container {
        padding: 20px 28px;
        max-height: min(90svh, 100%);
        overflow-y: auto;
    }

    /* P1 + P9 + N3: компактные игры в landscape */
    .games-container {
        grid-template-columns: 1fr !important;
        gap: 10px;
        max-width: 480px;
        margin: 0 auto;
        padding-bottom: 4px;
        --gc-pair2-min: 0;
        --gc-pad-y: 10px;
        --gc-pad-x: 12px;
        --gc-footer-mt: 20px;
        --gc-footer-h: 40px;
        --gc-tray-h: 84px;
        --gc-play-h: 168px;
    }

    .catch-area {
        min-height: var(--gc-play-h, 140px);
    }

    .game-card {
        min-height: 0;
        height: auto;
        padding: var(--gc-pad-y) var(--gc-pad-x);
    }

    .game-card h3 {
        font-size: 15px;
        margin-bottom: 4px;
    }

    .game-card > p {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .game-stats {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .game-footer {
        margin-top: var(--gc-footer-mt);
        height: var(--gc-footer-h);
        min-height: var(--gc-footer-h);
        padding-bottom: 0;
    }

    .puzzle-play,
    .date-play {
        min-height: 0;
        gap: 8px;
    }

    .compact-game-area {
        --play-height: 168px;
    }

    .memory-grid {
        gap: 5px;
        max-width: min(220px, 100%);
    }

    .puzzle-canvas {
        max-width: min(160px, 42vw);
        gap: 2px;
    }

    .puzzle-tray {
        --piece-size: 36px;
        --piece-gap: 4px;
    }

    .date-photo-wrap {
        max-width: min(120px, 28vw);
    }

    .date-tray {
        height: var(--gc-tray-h, 84px);
        min-height: var(--gc-tray-h, 84px);
    }

    .date-answers {
        height: 100%;
        gap: 6px;
    }

    .date-answer {
        font-size: 11px;
        padding: 6px 8px;
        min-height: 0;
    }

    .btn.game-action-btn {
        --game-btn-pad-y: 6px;
        --game-btn-pad-x: 12px;
        --game-btn-font: 12px;
        --game-btn-min-h: 34px;
        --game-btn-min-w: 140px;
    }
}

