:root {
    --night: #0b0d2a;
    --dusk: #241046;
    --ink: #fdf4ea;
    --muted: #bdb8da;
    --gold: #ffc857;
    --rose: #ff6b8a;
    --sky: #7fd6ff;
    --panel: rgba(22, 20, 60, .72);
    --line: rgba(255, 255, 255, .14);
    --display: 'Bricolage Grotesque', system-ui, sans-serif;
    --body: 'Figtree', system-ui, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    background: var(--night);
}

body {
    margin: 0;
    min-height: 100dvh;
    color: var(--ink);
    font-family: var(--body);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

[hidden],
.hidden {
    display: none !important;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 3px solid var(--sky);
    outline-offset: 3px;
}

#bgCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
}

#floatingEmojis {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}

.floating-emoji {
    position: absolute;
    bottom: -3rem;
    will-change: transform;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0);
        opacity: 0;
    }

    10% {
        opacity: .9;
    }

    100% {
        transform: translateY(-115vh) rotate(25deg);
        opacity: 0;
    }
}

.pill {
    padding: .55rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .08);
    transition: background .15s, transform .15s;
}

    .pill:hover {
        background: rgba(255, 255, 255, .16);
    }

    .pill:active {
        transform: scale(.97);
    }

    .pill:disabled {
        opacity: .5;
        cursor: not-allowed;
    }

    .pill.primary {
        background: var(--gold);
        border-color: var(--gold);
        color: #1b1230;
        font-weight: 600;
    }

        .pill.primary:hover {
            background: #ffd779;
        }

    .pill.danger {
        border-color: rgba(255, 107, 138, .6);
        color: var(--rose);
    }

    .pill.big {
        padding: 1rem 2rem;
        font-size: 1.15rem;
    }

.link-btn {
    background: none;
    border: 0;
    color: var(--muted);
    text-decoration: underline;
    padding: .5rem;
}

.gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
    background: rgba(8, 9, 30, .84);
    backdrop-filter: blur(8px);
    transition: opacity .4s;
}

    .gate.leaving {
        opacity: 0;
        pointer-events: none;
    }

    .gate h2 {
        margin: 0;
        max-width: 18ch;
        font: 800 clamp(1.9rem, 6vw, 3.2rem)/1.05 var(--display);
        text-wrap: balance;
    }

.lead {
    margin: 0 0 .5rem;
    color: var(--muted);
    font-size: clamp(1rem, 2.6vw, 1.25rem);
}

#mainContent {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: clamp(1.5rem, 5vw, 4rem) 1rem 8rem;
    text-align: center;
}

.birthday-name {
    margin: 0;
    font-family: var(--display);
    font-weight: 800;
    font-size: clamp(2.6rem, 10vw, 7rem);
    line-height: .98;
    letter-spacing: -.03em;
    text-wrap: balance;
}

.name-text {
    color: var(--gold);
}

#countdownDisplay {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(.5rem, 2vw, 1.25rem);
    max-width: 44rem;
    margin: clamp(3.5rem, 8vw, 5rem) auto 1.5rem;
}

.time-block {
    position: relative;
    padding: clamp(1rem, 3vw, 1.75rem) .5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    backdrop-filter: blur(10px);
}

.time-value {
    display: block;
    font: 800 clamp(2.2rem, 8vw, 4.5rem)/1 var(--display);
    font-variant-numeric: tabular-nums;
    color: var(--gold);
}

.time-label {
    display: block;
    margin-top: .5rem;
    color: var(--muted);
    font-size: .95rem;
}

.tick {
    animation: tick .35s ease-out;
}

@keyframes tick {
    from {
        transform: translateY(-8px);
        opacity: .3;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

.time-block.seconds::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -1.2rem;
    width: .45rem;
    height: 1.2rem;
    transform: translateX(-50%);
    border-radius: .2rem .2rem 0 0;
    background: repeating-linear-gradient(135deg, #fff 0 .3rem, var(--rose) .3rem .6rem);
}

.time-block.seconds::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -2.45rem;
    width: .8rem;
    height: 1.25rem;
    transform: translateX(-50%);
    transform-origin: 50% 100%;
    border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
    background: radial-gradient(circle at 50% 70%, #fff6c9 0 25%, var(--gold) 55%, var(--rose) 100%);
    box-shadow: 0 0 1.3rem .35rem rgba(255, 200, 87, .55);
    animation: flicker 1.1s ease-in-out infinite alternate;
}

@keyframes flicker {
    from {
        transform: translateX(-50%) scale(1, 1) rotate(-3deg);
    }

    to {
        transform: translateX(-50%) scale(.92, 1.12) rotate(3deg);
    }
}

.target-date {
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.celebration-title {
    margin: 0 auto;
    max-width: 18ch;
    font: 800 clamp(2rem, 7vw, 4.5rem)/1.05 var(--display);
    text-wrap: balance;
}

.cake-anim {
    margin: 1rem 0;
    font-size: clamp(4rem, 14vw, 8rem);
    animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
    50% {
        transform: translateY(-12px) rotate(-3deg);
    }
}

.subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 1.2rem;
}

.voice-badge {
    margin-top: 1.25rem;
    padding: .7rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--gold);
    background: rgba(255, 200, 87, .12);
    color: var(--gold);
}

#celebrationSection.revealed {
    animation: rise .8s cubic-bezier(.2, .8, .2, 1);
}

@keyframes rise {
    from {
        transform: translateY(24px) scale(.96);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

#musicPlayer {
    position: fixed;
    left: 50%;
    z-index: 20;
    bottom: max(1rem, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(36rem, calc(100% - 1.5rem));
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .6rem .5rem 1rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    backdrop-filter: blur(14px);
}

#musicNote {
    font-size: 1.3rem;
}

    #musicNote.spin {
        animation: spin 4s linear infinite;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#musicInfo {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

#musicTitle {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#musicStatus {
    font-size: .8rem;
    color: var(--muted);
}

#musicVolume {
    width: 5rem;
    accent-color: var(--gold);
}

#adminTriggerBtn {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    width: 48px;
    height: 48px;
    border: 0;
    background: none;
    font-size: 1.2rem;
    opacity: .06;
}

    #adminTriggerBtn:hover,
    #adminTriggerBtn:focus-visible {
        opacity: .7;
    }

.admin-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(5, 6, 20, .72);
    backdrop-filter: blur(6px);
}

.admin-modal {
    position: relative;
    width: min(34rem, 100%);
    max-height: 92dvh;
    overflow: auto;
    padding: 1.5rem;
    background: #15163a;
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}

    .admin-modal h2 {
        margin: 0 2.5rem 1rem 0;
        font: 800 1.5rem var(--display);
    }

.admin-close {
    position: absolute;
    top: .75rem;
    right: .75rem;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}

.admin-tabs {
    display: flex;
    gap: .25rem;
    padding: .25rem;
    margin-bottom: 1.25rem;
    background: rgba(255, 255, 255, .06);
    border-radius: 999px;
}

.admin-tab {
    flex: 1;
    padding: .5rem .6rem;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font-size: .9rem;
}

    .admin-tab.active {
        background: var(--gold);
        color: #1b1230;
        font-weight: 600;
    }

.form-group {
    margin-bottom: 1.1rem;
}

    .form-group label,
    .group-label {
        display: block;
        margin-bottom: .4rem;
        font-weight: 600;
        font-size: .95rem;
    }

.admin-modal input[type=text],
.admin-modal input[type=password],
.admin-modal input[type=datetime-local],
.admin-modal textarea {
    width: 100%;
    padding: .7rem .85rem;
    font: inherit;
    color: var(--ink);
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--line);
    border-radius: .8rem;
}

.admin-modal textarea {
    resize: vertical;
}

.char-counter {
    display: block;
    margin-top: .3rem;
    text-align: right;
    font-size: .8rem;
    color: var(--muted);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: 1.25rem;
}

.file-drop-zone {
    display: grid;
    place-items: center;
    padding: 1.25rem;
    border: 2px dashed var(--line);
    border-radius: 1rem;
    color: var(--muted);
    text-align: center;
    cursor: pointer;
}

    .file-drop-zone.drag-over {
        border-color: var(--gold);
        background: rgba(255, 200, 87, .08);
    }

.file-input {
    display: none;
}

.audio-preview {
    display: grid;
    gap: .4rem;
    margin-top: .6rem;
}

    .audio-preview audio {
        width: 100%;
    }

.file-name-label {
    font-size: .85rem;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.song-list {
    display: grid;
    gap: .5rem;
}

.song-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .75rem;
    background: rgba(255, 255, 255, .06);
    border-radius: .8rem;
}

.song-list-name {
    overflow-wrap: anywhere;
}

.admin-msg {
    min-height: 1.4em;
    margin: 1rem 0 0;
    color: var(--sky);
    font-size: .95rem;
}

    .admin-msg.error {
        color: var(--rose);
    }

.toast {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    left: 50%;
    z-index: 120;
    transform: translateX(-50%);
    padding: .75rem 1.25rem;
    background: var(--gold);
    color: #1b1230;
    font-weight: 600;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

@media (max-width: 560px) {
    #countdownDisplay {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        row-gap: 3.2rem;
    }

    #musicVolume {
        display: none;
    }

    .admin-tab {
        font-size: .8rem;
        padding: .5rem .3rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

.stage {
    display: grid;
    justify-items: center;
    gap: clamp(1.75rem, 4vw, 2.75rem);
}

.photo-frame {
    margin: 0;
    width: clamp(8.5rem, 30vw, 14rem);
    padding: .6rem .6rem 1.9rem;
    background: #fff6e6;
    border-radius: .35rem;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
    transform: rotate(-2.5deg);
}

.photo-stack {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: #1b1230;
}

    .photo-stack img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        opacity: 0;
        transition: opacity .9s ease;
    }

        .photo-stack img.active {
            opacity: 1;
        }

.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: .5rem;
    margin-top: .6rem;
    color: var(--muted);
}

    .thumb-grid:empty {
        display: none;
    }

.thumb-empty {
    grid-column: 1 / -1;
    margin: 0;
}

.thumb {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: .7rem;
    background: rgba(255, 255, 255, .06);
}

    .thumb img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .thumb button {
        position: absolute;
        top: .25rem;
        right: .25rem;
        min-width: 1.9rem;
        height: 1.9rem;
        padding: 0 .4rem;
        border: 0;
        border-radius: 999px;
        background: rgba(11, 13, 42, .82);
        color: var(--ink);
        font-size: .8rem;
    }

.age-line {
    margin: .7rem 0 0;
    color: var(--gold);
    font-weight: 600;
    font-size: clamp(1.1rem, 3vw, 1.5rem);
}

    .age-line:empty {
        display: none;
    }

.admin-modal input[type=date],
.admin-modal input[type=time] {
    width: 100%;
    padding: .7rem .85rem;
    font: inherit;
    color: var(--ink);
    color-scheme: dark;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--line);
    border-radius: .8rem;
}

.admin-modal input[type=datetime-local] {
    color-scheme: dark;
}

.admin-modal input:disabled {
    opacity: .45;
}

.hint {
    display: block;
    margin-top: .35rem;
    font-size: .85rem;
    color: var(--muted);
}
