:root {
    --stage-ratio: 9 / 16;
    --stage-width: min(100vw, calc(100dvh * 0.5625));
    --stage-height: min(100dvh, calc(100vw * 1.777777778));
    --wheel-left: 6.18%;
    --wheel-top: 24.84%;
    --wheel-size: 87.64%;
    --navy: #172f58;
    --teal: #18b9b0;
    --coral: #f36d6a;
    --yellow: #f2bd52;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background: #050b14;
    color: var(--white);
    font-family: "Avenir Next", Avenir, Montserrat, "Segoe UI", Arial, sans-serif;
    overscroll-behavior: none;
}

button,
a {
    font: inherit;
}

.app-shell {
    display: flex;
    width: 100%;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 20%, rgba(43, 85, 128, 0.28), transparent 48%),
        #050b14;
}

.app-stage {
    position: relative;
    width: var(--stage-width);
    height: var(--stage-height);
    max-width: 100vw;
    max-height: 100dvh;
    aspect-ratio: var(--stage-ratio);
    overflow: hidden;
    isolation: isolate;
    background: var(--navy);
    user-select: none;
    -webkit-user-select: none;
}

.screen {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: none;
    overflow: hidden;
}

.screen.is-active {
    display: block;
    animation: screen-in 240ms ease-out both;
}

.screen[hidden] {
    display: none !important;
}

.art-background {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.wheel-surface {
    position: absolute;
    top: var(--wheel-top);
    left: var(--wheel-left);
    z-index: 3;
    width: var(--wheel-size);
    aspect-ratio: 1;
    border-radius: 50%;
    outline: none;
    cursor: grab;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.wheel-surface:active {
    cursor: grabbing;
}

.wheel-crop {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    filter: drop-shadow(0 1.2rem 1.35rem rgba(1, 15, 31, 0.14));
}

.wheel-rotator {
    transform-box: view-box;
    transform-origin: center;
    will-change: transform;
}

.wheel-focus-ring {
    position: absolute;
    inset: -0.65%;
    border: 0.24rem solid transparent;
    border-radius: 50%;
    pointer-events: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.wheel-surface:focus-visible .wheel-focus-ring {
    border-color: rgba(255, 255, 255, 0.94);
    box-shadow: 0 0 0 0.35rem rgba(24, 185, 176, 0.44);
}

.app-stage[data-state="dragging"] .wheel-focus-ring {
    border-color: rgba(242, 189, 82, 0.8);
    box-shadow: 0 0 2.1rem rgba(242, 189, 82, 0.42);
}

.app-stage[data-state="spinning"] .wheel-surface {
    cursor: wait;
}

.app-stage[data-state="spinning"] .wheel-focus-ring {
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 2.2rem rgba(24, 185, 176, 0.32);
}

.app-stage[data-state="result"] .wheel-focus-ring {
    border-color: rgba(242, 189, 82, 0.92);
    box-shadow:
        0 0 0 0.32rem rgba(255, 255, 255, 0.18),
        0 0 2.8rem rgba(242, 189, 82, 0.54);
    animation: result-glow 1.45s ease-in-out infinite alternate;
}

.interaction-panel {
    position: absolute;
    left: 7.8%;
    right: 7.8%;
    bottom: 15.7%;
    z-index: 5;
    min-height: 7.2%;
    padding: 0.68rem 1rem 0.74rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: clamp(0.9rem, 2.4vh, 1.45rem);
    background: linear-gradient(135deg, rgba(12, 39, 75, 0.84), rgba(20, 49, 85, 0.72));
    box-shadow: 0 0.85rem 2.2rem rgba(3, 18, 39, 0.26);
    text-align: center;
    backdrop-filter: blur(10px) saturate(120%);
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.interaction-kicker,
.interaction-hint,
.result-label,
.reset-countdown {
    margin: 0;
}

.interaction-kicker {
    color: var(--yellow);
    font-size: clamp(0.58rem, 1.45vh, 0.78rem);
    font-weight: 900;
    letter-spacing: 0.18em;
}

.interaction-hint {
    margin-top: 0.22rem;
    color: rgba(255, 255, 255, 0.94);
    font-size: clamp(0.82rem, 2.05vh, 1.17rem);
    font-weight: 650;
    line-height: 1.18;
}

.result-label {
    display: none;
    margin-top: 0.18rem;
    color: var(--white);
    font-size: clamp(0.92rem, 2.35vh, 1.35rem);
    font-weight: 850;
    line-height: 1.08;
    text-wrap: balance;
}

.reset-countdown {
    min-height: 1em;
    margin-top: 0.24rem;
    color: rgba(255, 255, 255, 0.68);
    font-size: clamp(0.58rem, 1.35vh, 0.73rem);
    font-weight: 650;
}

.save-status {
    min-height: 1em;
    margin: 0.24rem 0 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: clamp(0.56rem, 1.28vh, 0.72rem);
    font-weight: 700;
}

.save-status[data-status="success"] {
    color: #a9f0d7;
}

.save-status[data-status="error"] {
    color: #ffe0e4;
}

.save-retry-button,
.discard-pending-button {
    min-height: 2.75rem;
    margin: 0.4rem auto 0;
    padding: 0.55rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    color: var(--white);
    font-size: clamp(0.56rem, 1.3vh, 0.72rem);
    font-weight: 850;
    cursor: pointer;
}

.save-retry-button:hover,
.save-retry-button:focus-visible,
.discard-pending-button:hover,
.discard-pending-button:focus-visible {
    border-color: var(--yellow);
    background: rgba(242, 189, 82, 0.16);
}

.discard-pending-button {
    border-color: rgba(255, 224, 228, 0.58);
    background: rgba(139, 37, 51, 0.38);
}

.app-stage[data-state="result"] .interaction-panel {
    border-color: rgba(242, 189, 82, 0.54);
    background: linear-gradient(135deg, rgba(12, 39, 75, 0.94), rgba(43, 74, 104, 0.9));
    transform: translateY(-0.18rem);
}

.app-stage[data-state="result"] .interaction-hint {
    display: none;
}

.app-stage[data-state="result"] .result-label {
    display: block;
}

.status-indicator {
    position: absolute;
    right: 3.2%;
    bottom: 1.4%;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.38rem;
    min-height: 1.5rem;
    padding: 0.3rem 0.56rem;
    border-radius: 999px;
    background: rgba(7, 31, 59, 0.54);
    color: rgba(255, 255, 255, 0.7);
    font-size: clamp(0.46rem, 1.15vh, 0.65rem);
    font-weight: 850;
    letter-spacing: 0.09em;
    backdrop-filter: blur(7px);
}

.status-dot {
    width: 0.46rem;
    height: 0.46rem;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 0.55rem rgba(24, 185, 176, 0.86);
}

.app-stage[data-state="spinning"] .status-dot {
    background: var(--yellow);
    box-shadow: 0 0 0.7rem rgba(242, 189, 82, 0.88);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes result-glow {
    from {
        opacity: 0.72;
    }

    to {
        opacity: 1;
    }
}

@keyframes screen-in {
    from {
        opacity: 0;
        transform: scale(1.012);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 480px) {
    .interaction-panel {
        padding-inline: 0.76rem;
    }

}

@media (prefers-reduced-motion: reduce) {
    .screen.is-active,
    .wheel-focus-ring,
    .interaction-panel {
        animation: none;
        transition: none;
    }

    .app-stage[data-state="result"] .wheel-focus-ring {
        animation: none;
    }
}
