:root {
    --bg-image: none;
    --bg-fallback: #0a0a0a;
    --glass-bg: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.25);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.78);
    --shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
}

.background {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background: var(--bg-fallback);
    background-image: var(--bg-image), var(--bg-fallback);
    background-size: cover;
    background-position: center;
}

.bg-video {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    /* contain: видео показывается целиком в своём соотношении сторон.
       Области вне видео (сверху/снизу для 16:9 на портретном экране)
       прозрачны — через них виден градиент фона. */
    object-fit: cover;
    display: block;
}

/* Десктоп / ландшафт: видео поворачиваем на 90° и растягиваем покрыть экран.
   w=100vh, h=100vw → после поворота визуальный размер = 100vw × 100vh. */
@media (orientation: landscape) {
    .bg-video {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        width: 100vh;
        height: 100vw;
        object-fit: cover;
        transform: translate(-50%, -50%) rotate(90deg);
    }
}

.background::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.45) 100%);
    pointer-events: none;
}

@keyframes bgShift {
    0%   { transform: scale(1)    translate(0, 0); filter: hue-rotate(0deg); }
    100% { transform: scale(1.08) translate(-1%, -1%); filter: hue-rotate(15deg); }
}

.card {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 56px 64px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    text-align: center;
    max-width: 760px;
    width: 100%;
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.card.fade-out .timer,
.card.fade-out .subtitle {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.subtitle {
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 300;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 36px;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 90px;
}

.digits {
    display: flex;
    gap: 4px;
    font-variant-numeric: tabular-nums;
}

.digit {
    position: relative;
    display: inline-block;
    font-size: clamp(48px, 8vw, 88px);
    font-weight: 700;
    line-height: 1;
    min-width: 0.65em;
    height: 1em;
    text-align: center;
    overflow: hidden;
    vertical-align: top;
    perspective: 420px;
    transform-style: preserve-3d;
}

.digit > span {
    position: absolute;
    inset: 0;
    display: block;
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    backface-visibility: hidden;
    transform-origin: 50% 50%;
    will-change: transform;
}

.digit > .digit-current { transform: translateY(0); }
.digit > .digit-next    { transform: translateY(100%); opacity: 0; }

.digit.flipping > .digit-current {
    animation: rollOut var(--flip-duration, 0.58s) cubic-bezier(0.35, 0, 0.2, 1) forwards;
}
.digit.flipping > .digit-next {
    animation: rollIn var(--flip-duration, 0.58s) cubic-bezier(0.35, 0, 0.2, 1) forwards;
}

@keyframes rollOut {
    0%   { transform: translateY(0) rotateX(0deg) scale(1); opacity: 1; filter: brightness(1); }
    100% { transform: translateY(-110%) rotateX(70deg) scale(0.98); opacity: 0; filter: brightness(0.65); }
}
@keyframes rollIn {
    0%   { transform: translateY(110%) rotateX(-70deg) scale(0.98); opacity: 0; filter: brightness(0.65); }
    42%  { opacity: 0; }
    50%  { opacity: 0.88; }
    100% { transform: translateY(0) rotateX(0deg) scale(1); opacity: 1; filter: brightness(1); }
}

.label {
    font-size: clamp(10px, 1.4vw, 13px);
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.separator {
    font-size: clamp(40px, 7vw, 72px);
    font-weight: 300;
    line-height: 1;
    opacity: 0.5;
    margin-bottom: 28px;
    align-self: center;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 0.9; }
}

.greeting {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
    transition: opacity 1.2s ease 0.4s, transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s;
}

.greeting.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.greeting h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 500;
    font-size: clamp(36px, 6vw, 64px);
    line-height: 1.15;
    margin-bottom: 24px;
    text-shadow: 0 6px 30px rgba(0, 0, 0, 0.3);
}

.greeting .name {
    font-weight: 700;
    background: linear-gradient(135deg, #fff6d5 0%, #ffd1ec 50%, #c4a7ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.3em;
}

.greeting .wish {
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.notify-btn {
    margin-top: 36px;
    padding: 12px 28px;
    font-family: inherit;
    font-size: clamp(13px, 1.6vw, 15px);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.3s ease;
}

.notify-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

.notify-btn:active {
    transform: scale(0.97);
}

.notify-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.card.fade-out .notify-btn {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 640px) {
    .card {
        padding: 36px 20px;
        border-radius: 22px;
    }

    .timer {
        gap: 2px;
    }

    .unit {
        min-width: 60px;
        gap: 8px;
    }

    .separator {
        margin-bottom: 22px;
    }

    .digits {
        gap: 2px;
    }
}

@media (max-width: 380px) {
    .timer {
        flex-wrap: wrap;
        gap: 12px;
    }
    .separator {
        display: none;
    }
    .unit {
        flex: 1 1 40%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .background,
    .separator,
    .digit.flipping > .digit-current,
    .digit.flipping > .digit-next {
        animation: none;
    }
}
