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

:root {
    --pink: #f4a8c8;
    --pink-strong: #e879a8;
    --pink-deep: #d4568a;
    --cherry: #c41e4a;
    --cherry-light: #e03a62;
    --cherry-deep: #9a1538;
    --cherry-glow: rgba(196, 30, 74, 0.35);
    --white: #ffffff;
    --white-soft: rgba(255, 255, 255, 0.85);
    --bg-dark: #1a0f14;
}

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

body {
    font-family: "DM Sans", system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--white);
}

.hidden {
    display: none !important;
}

/* ── Video background ── */
.video-background {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.video-background #youtube-player {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 56.25vw;
    min-height: 100vh;
    min-width: 177.78vh;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.video-background iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.video-background::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(26, 15, 20, 0.35);
    pointer-events: none;
}

/* ── Particles ── */
.particle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity, filter;
}

/* Plain falling stars */
#particles-container.mode-plain .particle.circle {
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 8px #fcf6ba, 0 0 15px #d4af37;
}

#particles-container.mode-plain .particle.star {
    clip-path: polygon(50% 0%, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0% 50%, 39% 35%);
    background: #fcf6ba;
}

/* Shiny / glitter falling stars */
#particles-container.mode-shiny .particle.circle {
    border-radius: 50%;
    background: #ffe4f0;
    box-shadow:
        0 0 4px #ff9ec8,
        0 0 10px #ff6bab,
        0 0 18px rgba(255, 105, 180, 0.7);
}

#particles-container.mode-shiny .particle.star {
    clip-path: polygon(50% 0%, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0% 50%, 39% 35%);
    background: linear-gradient(135deg, #fff 0%, #ffc1dc 40%, #ff6bab 100%);
    box-shadow:
        0 0 6px #ff9ec8,
        0 0 14px rgba(255, 107, 171, 0.85);
}

@keyframes twinkleLevitate {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.5) translateY(-15px);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) translateY(-30px);
    }
}

@keyframes glitterFlash {
    0%, 100% { filter: brightness(1) saturate(1); }
    12% { filter: brightness(2.4) saturate(1.4); }
    24% { filter: brightness(0.6) saturate(1); }
    40% { filter: brightness(1.9) saturate(1.3); }
    55% { filter: brightness(0.8); }
    70% { filter: brightness(2.6) saturate(1.5); }
    85% { filter: brightness(0.9); }
}

@keyframes btnStarFall {
    0% {
        opacity: 0;
        transform: translateY(-120%) scale(0.4) rotate(0deg);
        filter: brightness(0.8);
    }
    15% {
        opacity: 0.95;
        filter: brightness(2);
    }
    40% {
        opacity: 0.55;
        filter: brightness(0.7);
    }
    60% {
        opacity: 0.9;
        filter: brightness(2.2);
    }
    85% {
        opacity: 0.7;
        filter: brightness(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(220%) scale(1) rotate(180deg);
        filter: brightness(0.6);
    }
}

@keyframes friendPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4) rotate(-8deg);
    }
    18% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(4deg);
    }
    82% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(-2deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.85) rotate(6deg);
    }
}

#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* ── Bow border ── */
.bow-border {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.bow {
    position: absolute;
    width: 52px;
    height: auto;
    opacity: 0.92;
    filter: drop-shadow(0 2px 6px rgba(244, 168, 200, 0.3));
}

.bow.bow-strong {
    width: 58px;
    filter: saturate(1.45) brightness(0.95) drop-shadow(0 2px 8px rgba(228, 121, 168, 0.45));
}

.bow.top { top: 8px; }
.bow.bottom { bottom: 8px; }
.bow.left { left: 8px; }
.bow.right { right: 8px; }


/* ── Friends ── */
#friends-layer {
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}

.friend-peek {
    position: absolute;
    width: 72px;
    height: auto;
    opacity: 0;
    filter: drop-shadow(0 4px 14px rgba(244, 168, 200, 0.25));
    animation: friendPop 3.8s ease-in-out forwards;
}

/* ── Main app ── */
.app {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 100vh;
    padding: 72px 24px 88px;
}

.group-upper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-top: 10vh;
}

.group-lower {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 2vh;
}

/* ── Timer ── */
.timer-display {
    text-align: center;
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--white);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.18);
    transition: opacity 0.3s;
}

.timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.timer-display.running {
    opacity: 1;
}

.timer-setup .time-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer-setup label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.timer-setup label span {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 700;
}

.timer-setup input {
    width: 64px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    color: var(--white);
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    padding: 8px 4px;
    outline: none;
    appearance: textfield;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.timer-setup input::-webkit-outer-spin-button,
.timer-setup input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.timer-setup input:focus {
    border-color: var(--white);
}

.timer-setup .colon {
    font-size: 1.5rem;
    color: var(--white);
    font-weight: 700;
    margin-top: 16px;
}

.timer-controls {
    display: flex;
    gap: 12px;
}

.btn {
    font-family: inherit;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    text-transform: lowercase;
    border: none;
    border-radius: 999px;
    padding: 14px 48px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

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

.btn-start {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: linear-gradient(135deg, var(--pink) 0%, var(--pink-strong) 50%, var(--pink-deep) 100%);
    color: var(--white);
    box-shadow: 0 4px 24px rgba(228, 121, 168, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.btn-particles {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.btn-particle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.btn-particle.circle {
    border-radius: 50%;
    background: #ffe4f0;
    box-shadow: 0 0 4px #ff9ec8, 0 0 8px #ff6bab;
}

.btn-particle.star {
    clip-path: polygon(50% 0%, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0% 50%, 39% 35%);
    background: linear-gradient(135deg, #fff 0%, #ffc1dc 45%, #ff6bab 100%);
    box-shadow: 0 0 5px #ff9ec8;
}

.btn-label {
    position: relative;
    z-index: 1;
    font-weight: 700;
}

.btn-start:hover {
    box-shadow: 0 6px 32px rgba(228, 121, 168, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.btn-start::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, transparent 45%, rgba(255, 255, 255, 0.06) 100%);
    pointer-events: none;
    z-index: 0;
}

.btn-start.paused {
    background: linear-gradient(135deg, var(--pink-strong) 0%, var(--pink-deep) 100%);
}

.btn-reset {
    background: transparent;
    color: var(--white);
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 14px 32px;
}

.btn-reset:hover {
    border-color: var(--white);
    color: var(--white);
}

/* ── Bottom controls ── */
.bottom-controls {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-widget {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 6px;
    border-radius: 999px;
    border: 1px solid rgba(244, 168, 200, 0.3);
    background: rgba(26, 15, 20, 0.6);
    backdrop-filter: blur(8px);
    transition: border-color 0.2s, background 0.2s, padding 0.2s;
}

.volume-widget:hover,
.volume-widget:focus-within {
    border-color: var(--pink);
    background: rgba(26, 15, 20, 0.8);
    padding-right: 10px;
}

.volume-toggle {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--pink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.volume-toggle:hover {
    color: var(--white);
}

.volume-slider-wrap {
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: width 0.2s ease, opacity 0.2s ease, margin 0.2s ease;
}

.volume-widget:hover .volume-slider-wrap,
.volume-widget:focus-within .volume-slider-wrap {
    width: 88px;
    opacity: 1;
    margin-left: 2px;
}

.volume-slider-wrap input {
    width: 88px;
    accent-color: var(--pink);
    cursor: pointer;
}

/* ── Settings ── */
.settings {
    position: relative;
}

.settings-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(244, 168, 200, 0.3);
    background: rgba(26, 15, 20, 0.6);
    backdrop-filter: blur(8px);
    color: var(--pink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, background 0.2s;
}

.settings-toggle:hover {
    border-color: var(--pink);
    background: rgba(26, 15, 20, 0.8);
}

.settings-panel {
    position: absolute;
    bottom: 52px;
    right: 0;
    background: rgba(26, 15, 20, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(244, 168, 200, 0.25);
    border-radius: 14px;
    padding: 16px;
    min-width: 200px;
}

.settings-label {
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
}

.bg-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bg-option {
    font-family: inherit;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--white-soft);
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.bg-option:hover {
    background: rgba(244, 168, 200, 0.1);
}

.bg-option.active {
    background: rgba(244, 168, 200, 0.15);
    border-color: rgba(244, 168, 200, 0.4);
    color: var(--white);
}

.bg-option-custom {
    position: relative;
    z-index: 2;
}

/* ── Custom video modal ── */
.custom-video-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(26, 15, 20, 0.6);
    backdrop-filter: blur(6px);
}

.custom-video-dialog {
    position: relative;
    z-index: 101;
    width: min(100%, 420px);
    padding: 24px;
    border-radius: 14px;
    border: 1px solid rgba(244, 168, 200, 0.35);
    background: rgba(26, 15, 20, 0.92);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.custom-video-title {
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 14px;
}

.custom-video-input {
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--white);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.2s;
}

.custom-video-input:focus {
    border-color: var(--pink);
}

.custom-video-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.custom-video-error {
    margin-top: 10px;
    font-size: 0.78rem;
    color: #ff8fab;
}

.custom-video-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.custom-video-submit {
    padding: 12px 36px;
}

@media (max-width: 480px) {
    .bow { width: 36px; }
    .bow.bow-strong { width: 42px; }
    .friend-peek { width: 56px; }
    .bottom-controls { bottom: 16px; right: 16px; }
    .app { padding: 56px 16px 72px; }
}
