:root {
    --bg-0: #090807;
    --bg-1: #16110d;
    --ink: #f6f0e6;
    --muted: #b5a492;
    --gold: #e0b57a;
    --gold-2: #f3d7a8;
    --line: rgba(240, 214, 176, 0.18);
    --glass: rgba(22, 16, 12, 0.62);
    --danger: #e28b7a;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    --font: "Outfit", system-ui, sans-serif;
    --serif: "Fraunces", Georgia, serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

html:has(body.page:not(.is-edit)),
body.page:not(.is-edit) {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body.page {
    font-family: var(--font);
    color: var(--ink);
    background: radial-gradient(1200px 700px at 50% -10%, #3a2414 0%, var(--bg-0) 55%);
    min-height: 100vh;
    overflow-x: hidden;
}

.atmosphere {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.aurora {
    position: absolute;
    inset: -20%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(196, 122, 54, 0.22), transparent 45%),
        radial-gradient(ellipse at 80% 10%, rgba(120, 62, 28, 0.2), transparent 40%),
        radial-gradient(ellipse at 50% 90%, rgba(80, 40, 20, 0.25), transparent 50%);
    animation: drift 18s ease-in-out infinite alternate;
}

.grain {
    position: absolute;
    inset: 0;
    opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
}

@keyframes drift {
    from { transform: translate3d(-2%, -1%, 0) scale(1); }
    to { transform: translate3d(2%, 2%, 0) scale(1.08); }
}

.stage,
.login-wrap {
    position: relative;
    z-index: 1;
}

.stage {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
    padding: 72px 0 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: rise 0.9s ease both;
}

.page:not(.is-edit) .stage {
    box-sizing: border-box;
    width: min(1400px, calc(100% - clamp(24px, 6vw, 96px)));
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    padding: clamp(20px, 5.5vh, 64px) 0;
    justify-content: space-evenly;
    gap: clamp(16px, 3.2vh, 44px);
    overflow: hidden;
}

.page:not(.is-edit) .stage > * {
    flex-shrink: 0;
    min-height: 0;
}

.is-edit .stage {
    padding-top: 108px;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: none; }
}

.eyebrow {
    letter-spacing: 0.28em;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--gold);
    margin: 0 0 14px;
}

.page:not(.is-edit) .eyebrow {
    margin: 0;
    font-size: clamp(0.62rem, 1.6vh, 0.72rem);
}

.event-title {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(2.1rem, 6vw, 4.4rem);
    line-height: 1.05;
    margin: 0 0 36px;
    max-width: min(36ch, 100%);
    text-wrap: balance;
}

.page:not(.is-edit) .event-title {
    width: 100%;
    max-width: 100%;
    font-size: clamp(1.7rem, 2.1vw + 2.2vh, 4rem);
    margin: 0;
}

.event-title.is-editable,
.expired-text.is-editable {
    outline: none;
    border-radius: 12px;
    padding: 6px 10px;
    min-width: 8ch;
}

.event-title.is-editable:hover,
.expired-text.is-editable:hover,
.event-title.is-editable:focus,
.expired-text.is-editable:focus {
    background: rgba(224, 181, 122, 0.08);
    box-shadow: inset 0 0 0 1px var(--line);
}

[contenteditable][data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    opacity: 0.7;
}

.banner {
    width: min(920px, 100%);
    margin: 0 0 40px;
}

.page:not(.is-edit) .banner {
    margin: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    min-height: 0;
    max-height: 42svh;
    width: 100%;
}

.page:not(.is-edit) .banner.is-empty {
    max-height: 18svh;
}

.banner-frame {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    aspect-ratio: 16 / 6.2;
    background: linear-gradient(160deg, #2a1c13, #120e0b);
    box-shadow: var(--shadow), inset 0 0 0 1px var(--line);
}

.page:not(.is-edit) .banner-frame {
    width: 100%;
    height: 100%;
    max-height: 42svh;
    aspect-ratio: auto;
}

.banner.is-empty .banner-frame {
    aspect-ratio: 16 / 4.2;
}

.page:not(.is-edit) .banner.is-empty .banner-frame {
    max-height: 18svh;
    aspect-ratio: auto;
}

.banner-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.08);
    animation: kenburns 22s ease-in-out infinite alternate;
}

@keyframes kenburns {
    from { transform: scale(1.08) translate3d(-1.5%, 0, 0); }
    to { transform: scale(1.18) translate3d(1.5%, -1%, 0); }
}

.banner-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    letter-spacing: 0.08em;
}

.banner-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: end;
    margin-top: 14px;
}

.countdown {
    width: 100%;
    min-height: 160px;
}

.page:not(.is-edit) .countdown {
    min-height: 0;
    flex: 0 0 auto;
}

.units {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    width: min(780px, 100%);
    margin: 0 auto;
}

.page:not(.is-edit) .units {
    gap: clamp(10px, 1.6vh, 22px);
    width: min(1100px, 100%);
}

.units[hidden],
.idle-message[hidden],
.expired[hidden],
.banner-frame img[hidden],
.banner-placeholder[hidden] {
    display: none !important;
}

.unit-card {
    background: linear-gradient(180deg, rgba(255, 230, 190, 0.08), rgba(0, 0, 0, 0.25));
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px 8px 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    perspective: 600px;
}

.page:not(.is-edit) .unit-card {
    padding: clamp(10px, 1.8vh, 20px) 6px clamp(8px, 1.4vh, 16px);
    border-radius: 14px;
}

.unit-value {
    display: inline-block;
    font-family: var(--serif);
    font-size: clamp(2rem, 7vw, 4.2rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--gold-2);
    transform-origin: 50% 50%;
}

.page:not(.is-edit) .unit-value {
    font-size: clamp(1.5rem, 5.2vh, 3.6rem);
}

.unit-value.is-flip {
    animation: flip 0.55s cubic-bezier(0.4, 0.1, 0.2, 1);
}

@keyframes flip {
    0% { transform: rotateX(0deg); filter: brightness(1); }
    40% { transform: rotateX(-90deg); filter: brightness(1.6); }
    100% { transform: rotateX(0deg); filter: brightness(1); }
}

.unit-card.is-pulse {
    box-shadow: 0 0 0 1px rgba(224, 181, 122, 0.45), 0 12px 40px rgba(224, 181, 122, 0.16);
}

.unit-label {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.72rem;
}

.page:not(.is-edit) .unit-label {
    margin-top: clamp(4px, 0.8vh, 10px);
    font-size: clamp(0.58rem, 1.4vh, 0.72rem);
}

.idle-message,
.expired-text {
    font-family: var(--serif);
    font-size: clamp(1.4rem, 3.4vw, 2.2rem);
    line-height: 1.35;
    max-width: 22ch;
    margin: 12px auto 0;
    color: var(--gold-2);
}

.page:not(.is-edit) .idle-message,
.page:not(.is-edit) .expired-text {
    font-size: clamp(1.15rem, 3.2vh, 2.1rem);
    margin: 0 auto;
    max-width: min(40ch, 100%);
}

.idle-message {
    color: var(--muted);
    font-size: 1.15rem;
    font-family: var(--font);
}

.expired {
    animation: expire-in 0.8s ease both;
}

@keyframes expire-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.units.is-leaving {
    animation: expire-out 0.45s ease both;
}

@keyframes expire-out {
    to { opacity: 0; transform: translateY(-10px) scale(0.97); }
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.glass-card {
    width: min(440px, 100%);
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 36px 32px 32px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.login-title {
    font-family: var(--serif);
    font-size: 2.4rem;
    margin: 0 0 8px;
}

.login-lead {
    color: var(--muted);
    margin: 0 0 24px;
    line-height: 1.5;
}

.field {
    display: grid;
    gap: 6px;
    text-align: left;
    margin-bottom: 14px;
}

.field span,
.field-label {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.field input {
    font: inherit;
    color: var(--ink);
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    width: 100%;
}

.field input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(224, 181, 122, 0.18);
}

.field input[type="datetime-local"] {
    color-scheme: dark;
    position: relative;
    padding-right: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23f3d7a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px 20px;
}

.field input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    position: absolute;
    inset: 0 0 0 auto;
    width: 44px;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    background: transparent;
    filter: none;
}

.field.compact {
    margin: 0;
    min-width: min(320px, 100%);
}

.target-field {
    width: min(360px, 100%);
    margin: 0 auto 28px;
}

.form-error {
    color: var(--danger);
    margin: 0 0 12px;
}

.btn {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    border-radius: 999px;
    padding: 10px 18px;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--gold);
}

.btn-gold {
    background: linear-gradient(180deg, var(--gold-2), var(--gold));
    color: #2a1a0c;
    border-color: transparent;
    font-weight: 600;
}

.btn-danger {
    color: var(--danger);
    border-color: rgba(226, 139, 122, 0.4);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
}

.login-card .btn {
    width: 100%;
    margin-top: 8px;
}

.file-btn {
    display: inline-flex;
    align-items: center;
}

.editor-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(12, 9, 7, 0.78);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.editor-brand {
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--gold);
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.expired-editor {
    width: min(640px, 100%);
    margin-top: 36px;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 16px;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 8;
    background: #2a2118;
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 12px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow);
}

.toast.is-error {
    border-color: rgba(226, 139, 122, 0.5);
    color: #ffd4cc;
}

@media (max-width: 720px) {
    .units {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page:not(.is-edit) .units {
        gap: 8px;
        width: min(420px, 100%);
    }

    .page:not(.is-edit) .banner,
    .page:not(.is-edit) .banner-frame {
        max-height: 24svh;
    }

    .editor-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .banner-frame {
        aspect-ratio: 16 / 8;
    }

    .page:not(.is-edit) .banner-frame {
        aspect-ratio: auto;
        border-radius: 16px;
    }
}
