* {
    box-sizing: border-box;
}

:root {
    --ink: #f5eadc;
    --muted: rgba(245, 234, 220, 0.56);
    --dim: rgba(245, 234, 220, 0.3);
    --accent: #eaa76b;
    --line: rgba(245, 234, 220, 0.16);
    --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
    --sans: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    --serif: "Noto Serif TC", "Songti TC", serif;
}

html,
body {
    width: 100%;
    min-width: 100%;
    height: 100%;
    min-height: 100%;
    margin: 0;
    overflow: hidden;
    background: #000;
}

body {
    color: var(--ink);
    font-family: var(--sans);
}

.lottery-page,
.film-shell,
.film-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
}

.lottery-page {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #000;
}

.film-shell {
    position: relative;
}

.film-stage {
    position: relative;
    overflow: hidden;
    outline: none;
    isolation: isolate;
}

.film-stage::before {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: none;
    content: "";
    pointer-events: none;
}

.film-stage::after {
    position: absolute;
    z-index: 3;
    inset: -35%;
    display: none;
    content: "";
    pointer-events: none;
}

.film-stage:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(234, 167, 107, 0.58);
}

.film-stage canvas {
    position: absolute;
    z-index: 1;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
    touch-action: auto;
}

.film-video-sources {
    position: absolute;
    z-index: 0;
    top: -2px;
    left: -2px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.film-video-source {
    display: block;
    width: 1px;
    height: 1px;
}

.film-stage.is-box-hovered canvas {
    cursor: pointer;
}

.stage-brand {
    position: absolute;
    z-index: 5;
    top: clamp(18px, 3vw, 42px);
    right: clamp(18px, 3.6vw, 58px);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    text-align: right;
    pointer-events: none;
}

.stage-brand span,
.stage-brand small,
.stage-help,
.stage-loading {
    font-family: var(--mono);
    text-transform: uppercase;
}

.stage-brand span {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--accent);
    font-size: clamp(8px, 0.72vw, 11px);
    letter-spacing: 0.2em;
}

.stage-brand span::before {
    width: 28px;
    height: 1px;
    background: currentColor;
    content: "";
    opacity: 0.72;
}

.stage-brand strong {
    font-family: var(--serif);
    font-size: clamp(20px, 2vw, 34px);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-shadow: 0 3px 24px rgba(0, 0, 0, 0.7);
}

.stage-brand small {
    color: var(--dim);
    font-size: clamp(7px, 0.58vw, 9px);
    letter-spacing: 0.16em;
}

.stage-help {
    position: absolute;
    z-index: 5;
    right: clamp(18px, 3.6vw, 58px);
    bottom: clamp(16px, 2.5vw, 36px);
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--dim);
    font-size: clamp(7px, 0.62vw, 9px);
    letter-spacing: 0.15em;
    opacity: 0;
    transition: opacity 600ms ease 500ms;
    pointer-events: none;
}

.stage-help::before {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(234, 167, 107, 0.65);
    content: "";
}

.film-stage.is-ready .stage-help {
    opacity: 1;
}

.stage-loading {
    position: absolute;
    z-index: 8;
    top: 50%;
    left: 50%;
    display: grid;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    background: rgba(8, 8, 8, 0.76);
    border-radius: 50%;
    opacity: 1;
    transform: translate(-50%, -50%);
    transition: opacity 420ms ease, visibility 420ms ease;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

.stage-loading::before {
    width: 16px;
    height: 16px;
    place-self: center;
    border: 1px solid rgba(234, 167, 107, 0.27);
    border-top-color: var(--accent);
    border-radius: 50%;
    content: "";
    animation: loading-spin 820ms linear infinite;
}

.film-stage.is-ready .stage-loading {
    visibility: hidden;
    opacity: 0;
}

.film-stage.has-error .stage-loading {
    border-color: rgba(214, 97, 76, 0.45);
    color: #f0b2a6;
}

.film-stage.has-error .stage-loading::before {
    display: none;
}

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 700px) {
    .stage-brand {
        top: 16px;
        right: 16px;
    }

    .stage-brand strong {
        font-size: 18px;
    }

    .stage-brand small {
        display: none;
    }

    .stage-help {
        display: none;
    }

    .stage-loading {
        width: 40px;
        height: 40px;
    }
}

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