:root {
    --terpal: #1746C7;
    --tinta: #4A3000;
    --kilau: #FFF3B5;
    --sein: #FFD21F;
    --cabe: #E5261F;
    --kertas: #FFFDF5;
    --display: "Unbounded", "Arial Black", sans-serif;
    --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    background: #000;
    color: #ffffff;
    font-family: var(--body);
    font-weight: 500;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

p { margin: 0; }

/* The stall: one gold column, wheel rising from the bottom edge. */
.booth {
    display: flex;
    flex-direction: column;
    max-width: 480px;
    height: 100dvh;
    min-height: 580px;
    margin: 0 auto;
    padding-top: env(safe-area-inset-top);
    overflow: hidden;
    /* plain warm black; an image from background_url in app/config.php covers it */
    background: #0D0A04 center / cover no-repeat;
}

.sign { padding: 22px 22px 0; }

.sign h1 {
    margin: 0;
    font-family: var(--display);
    font-weight: 800;
    font-size: clamp(36px, 11.4vw, 54px);
    line-height: 1.05;
    letter-spacing: -.02em;
    /* gold-leaf lettering */
    color: #E9B93A;
    background: linear-gradient(180deg, #FFF0A6 0%, #F0C34E 45%, #B8860B 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sign p {
    margin-top: 8px;
    font-size: 16px;
    font-weight: 700;
}

.entry {
    display: grid;
    padding: 16px 22px 18px;
}

.entry label {
    margin-bottom: 5px;
    font-size: 15px;
    font-weight: 700;
}

.entry input {
    width: 100%;
    height: 50px;
    margin-bottom: 12px;
    padding: 0 14px;
    border-radius: 12px;
    background: rgb(253 204 73 / 91%);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 1px 0 rgba(233, 185, 58, .45);
    color: blue;
    font: 700 18px var(--body);
    border:groove 2px gold;
}

#code { text-transform: uppercase; letter-spacing: .06em; }

.entry input:focus-visible,
.entry button:focus-visible,
.ticket button:focus-visible {
    outline: 3px solid var(--tinta);
    outline-offset: 3px;
}

.entry input:focus-visible,
.entry button:focus-visible { outline-color: #F0C34E; }

.entry input:read-only { opacity: .75; }

.error {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--cabe);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.error[hidden] { display: none; }

.entry button,
.ticket button {
    width: 100%;
    height: 58px;
    margin-top: 4px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(180deg, #F2402F, #BF160E);
    box-shadow: inset 0 1px 0 #FF9A8F, 0 8px 16px rgba(0, 0, 0, .35);
    color: #fff;
    font: 800 18px var(--display);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .08s, box-shadow .08s;
}

.entry button:active:not(:disabled),
.ticket button:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 #FF9A8F, 0 3px 6px rgba(0, 0, 0, .35);
}

.entry button:disabled {
    transform: translateY(2px);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, .4);
    background: #C9705F;
    cursor: default;
}

/* Wheel is 150% of the column wide, so only its upper part shows. */
.stage {
    position: relative;
    flex: 1;
    min-height: 210px;
    overflow: hidden;
}

.pointer {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 50%;
    width: 44px;
    margin-left: -22px;
    transform-origin: 50% 10%;
}

.wheel {
    position: absolute;
    top: 24px;
    left: -25%;
    width: 150%;
    aspect-ratio: 1;
    will-change: transform;
}

/* After the stop: losers dim, the winner pulses. */
.seg { transition: opacity .25s; }
.reveal .seg:not(.win) { opacity: .28; }
.reveal .win { animation: win .32s ease-in-out 3 alternate; }

@keyframes win {
    to { filter: brightness(1.3) saturate(1.2); }
}

.sheen { pointer-events: none; }

.seg-emoji { font-size: 42px; }

.seg-label {
    font-family: var(--display);
    font-size: 15px;
    font-weight: 500;
}

.bulb {
    fill: var(--kertas);
    stroke: var(--tinta);
    stroke-width: 3;
}

.spinning .bulb { animation: blink .5s steps(1) infinite; }
.spinning .bulb:nth-child(even) { animation-delay: .25s; }

@keyframes blink {
    50% { fill: var(--cabe); }
}

/* Floating call-to-action, pinned to the bottom in every state (it moves into the ticket dialog while that is open). */
.cta {
    position: fixed;
    z-index: 5;
    left: 50%;
    bottom: calc(14px + env(safe-area-inset-bottom));
    display: grid;
    place-items: center;
    width: min(100% - 32px, 448px);
    height: 54px;
    transform: translateX(-50%);
    border-radius: 99px;
    background: linear-gradient(180deg, #FFF0A6 0%, #F0C34E 45%, #B8860B 100%);
    box-shadow: inset 0 1px 0 #FFFBE0, 0 10px 24px rgba(0, 0, 0, .6);
    color: #2B1B00;
    font: 800 15px var(--display);
    text-decoration: none;
    touch-action: manipulation;
}

.cta:active { transform: translateX(-50%) translateY(2px); }
.cta:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* Prize ticket (karcis) */
.ticket {
    width: min(88vw, 360px);
    padding: 0;
    border: 0;
    overflow: visible;
    background: transparent;
    color: var(--tinta);
}

#confetti {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
}

.ticket::backdrop { background: rgba(0, 0, 0, .8); }

.ticket-paper {
    --stub: 98px;
    border-radius: 16px;
    background: var(--kertas);
    text-align: center;
    transform: rotate(-2deg);
    /* two halves, each with one punched notch on the perforation line */
    -webkit-mask:
        radial-gradient(circle at 0 calc(100% - var(--stub)), transparent 13px, #000 13.5px) left / 51% 100% no-repeat,
        radial-gradient(circle at 100% calc(100% - var(--stub)), transparent 13px, #000 13.5px) right / 51% 100% no-repeat;
    mask:
        radial-gradient(circle at 0 calc(100% - var(--stub)), transparent 13px, #000 13.5px) left / 51% 100% no-repeat,
        radial-gradient(circle at 100% calc(100% - var(--stub)), transparent 13px, #000 13.5px) right / 51% 100% no-repeat;
}

.ticket[open] .ticket-paper { animation: drop .5s cubic-bezier(.2, 1.5, .4, 1); }

@keyframes drop {
    from { transform: translateY(-60px) rotate(8deg) scale(.7); opacity: 0; }
}

.ticket-body { padding: 26px 24px 22px; }

.ticket-emoji { font-size: 92px; line-height: 1.1; }

.ticket-name {
    margin-top: 10px;
    font-size: 21px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.ticket-lead { margin-top: 4px; font-size: 16px; }

.ticket-prize {
    margin-top: 10px;
    font-family: var(--display);
    font-weight: 800;
    font-size: 26px;
    line-height: 1.12;
    color: var(--cabe);
    overflow-wrap: anywhere;
}

.ticket-fine { margin-top: 14px; font-size: 13px; font-weight: 700; opacity: .7; }

.ticket-stub {
    height: var(--stub);
    padding: 16px 24px 0;
    border-top: 3px dashed var(--tinta);
}

.ticket-stub button { margin: 0; }

/* Short phones: title on one line so the wheel keeps its room. */
@media (max-height: 700px) {
    .sign { padding-top: 16px; }
    .sign h1 { font-size: 34px; white-space: nowrap; }
    .sign p { margin-top: 10px; }
    .entry { padding-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .spinning .bulb,
    .reveal .win,
    .ticket[open] .ticket-paper { animation: none; }
}
