:root {
    --red: #e50914;
    --red-hi: #ff3b46;
    --red-deep: #5c040a;
    --ink: #050507;
    --bg: #0b0b0d;
    --surface: #131316;
    --surface-2: #1a1a1e;
    --chip: #0a0a0c;
    --line: rgba(255, 255, 255, 0.09);
    --txt: #ffffff;
    --muted: #8f8f96;
    --ok: #2ebd59;
    --err: #ff5d5d;
    --r: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body {
    font-family: 'Be Vietnam Pro', 'Helvetica Neue', Arial, sans-serif;
    color: var(--txt);
    min-height: 100vh;
    background:
        radial-gradient(900px 340px at 50% -120px, rgba(229, 9, 20, 0.28), transparent 70%),
        radial-gradient(700px 500px at 85% 110%, rgba(229, 9, 20, 0.1), transparent 60%),
        radial-gradient(600px 500px at 10% 100%, rgba(255, 59, 70, 0.07), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

/* faint red grain glow */
.bg-orbs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.bg-orbs span { position: absolute; border-radius: 50%; filter: blur(110px); opacity: 0.32; }
.bg-orbs span:nth-child(1) { width: 560px; height: 300px; background: var(--red); top: -170px; left: 50%; transform: translateX(-50%); }
.bg-orbs span:nth-child(2), .bg-orbs span:nth-child(3) { display: none; }

.page { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; padding: 20px 18px 48px; }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
.brand-logo { height: 24px; width: auto; display: block; }
.brand-logo { height: 24px; width: auto; display: block; }
.status-pill {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.74rem; font-weight: 600; color: var(--muted);
    background: rgba(10, 10, 12, 0.8); border: 1px solid var(--line);
    padding: 7px 14px; border-radius: 999px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: blink 1.6s infinite; }
.dot.off { background: var(--err); box-shadow: none; animation: none; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- hero ---------- */
.hero { text-align: center; margin-bottom: 28px; }
.hero-badge {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 0.7rem; font-weight: 800; letter-spacing: 0.3em; text-indent: 0.3em;
    color: #fff; background: linear-gradient(180deg, var(--red-hi), var(--red) 60%, #a3060f);
    padding: 8px 22px; border-radius: 3px; margin-bottom: 20px;
    box-shadow: 0 8px 26px rgba(229, 9, 20, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.hero-title {
    font-size: clamp(2.6rem, 11vw, 4rem); font-weight: 900;
    letter-spacing: 0.05em; text-indent: 0.05em; text-transform: uppercase; line-height: 1; margin-bottom: 14px;
    text-shadow: 0 6px 34px rgba(0, 0, 0, 0.9);
}
.hero-title span { color: var(--red); text-shadow: 0 0 34px rgba(229, 9, 20, 0.65); }
.hero-sub { color: var(--muted); font-size: 0.93rem; max-width: 460px; margin: 0 auto; line-height: 1.6; }

/* ---------- machine ---------- */
.machine {
    position: relative;
    background: linear-gradient(180deg, #17171b, #101013);
    border: 1px solid var(--line);
    border-radius: 18px; padding: 32px 24px 24px;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.machine::before {
    content: ""; position: absolute; top: 0; left: 8%; right: 8%; height: 3px;
    background: linear-gradient(90deg, transparent, var(--red) 20%, var(--red-hi) 50%, var(--red) 80%, transparent);
    box-shadow: 0 0 18px rgba(229, 9, 20, 0.8);
}

.drum-wrap { margin-bottom: 24px; }
.drum {
    width: 144px; height: 144px; margin: 0 auto; border-radius: 50%;
    background: conic-gradient(from 0deg, var(--red-hi), #3d0206 30%, var(--red) 50%, #3d0206 70%, var(--red-hi));
    padding: 5px; animation: spin-slow 10s linear infinite;
    box-shadow: 0 0 46px rgba(229, 9, 20, 0.4), 0 14px 34px rgba(0, 0, 0, 0.7);
}
.drum.rolling { animation-duration: 0.65s; box-shadow: 0 0 70px rgba(229, 9, 20, 0.65), 0 14px 34px rgba(0, 0, 0, 0.7); }
@keyframes spin-slow { to { transform: rotate(360deg); } }
.drum-window {
    width: 100%; height: 100%; border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, #1b1b20, #000 75%);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.9rem; font-weight: 900; color: #fff; letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 22px rgba(255, 59, 70, 0.8);
    box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.9), inset 0 2px 6px rgba(255, 255, 255, 0.06);
    animation: spin-rev 10s linear infinite;
}
.drum.rolling .drum-window { animation-duration: 0.65s; }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
.drum.shake { animation: wobble 0.5s ease; }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-9deg) scale(1.05); } 75% { transform: rotate(9deg) scale(1.05); } }
.drum-base {
    width: 120px; height: 12px; margin: 12px auto 0; border-radius: 999px;
    background: rgba(0, 0, 0, 0.75);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.9), 0 0 16px rgba(229, 9, 20, 0.25);
}

/* ---------- steps ---------- */
.steps { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; text-align: left; }
.steps li {
    display: flex; align-items: center; gap: 12px;
    background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line);
    border-left: 3px solid #2c2c31;
    border-radius: 10px; padding: 9px 14px 9px 9px;
    font-size: 0.86rem; font-weight: 600; color: var(--muted);
    transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease;
}
.step-ico {
    flex: none; width: 36px; height: 36px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #161619, var(--chip));
    border: 1px solid rgba(229, 9, 20, 0.35);
    color: var(--red-hi);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.step-ico svg { width: 19px; height: 19px; }
.step-st { margin-left: auto; font-variant-numeric: tabular-nums; }
.step-st::after { content: "…"; opacity: 0.35; letter-spacing: 2px; }
.steps li.run { color: var(--txt); border-left-color: var(--red); background: linear-gradient(90deg, rgba(229, 9, 20, 0.12), rgba(0, 0, 0, 0.35)); }
.steps li.run .step-ico { background: linear-gradient(180deg, var(--red-hi), var(--red-deep)); color: #fff; border-color: transparent; box-shadow: 0 4px 16px rgba(229, 9, 20, 0.5); }
.steps li.run .step-st::after {
    content: ""; opacity: 1; width: 13px; height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.18); border-top-color: var(--red-hi);
    border-radius: 50%; display: inline-block; vertical-align: middle;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.steps li.done { color: var(--txt); border-left-color: var(--ok); }
.steps li.done .step-ico { border-color: rgba(46, 189, 89, 0.5); color: var(--ok); }
.steps li.done .step-st::after { content: "✓"; opacity: 1; color: var(--ok); font-weight: 900; }
.steps li.fail { border-left-color: var(--err); }
.steps li.fail .step-ico { border-color: rgba(255, 93, 93, 0.5); color: var(--err); }
.steps li.fail .step-st::after { content: "✕"; opacity: 1; color: var(--err); font-weight: 900; }

/* ---------- draw button ---------- */
.draw-btn {
    position: relative; width: 100%; border: none; cursor: pointer; font-family: inherit;
    background: linear-gradient(180deg, var(--red-hi) 0%, var(--red) 45%, #8f050d 100%);
    color: #fff; border-radius: 10px; padding: 17px 20px 15px;
    display: flex; flex-direction: column; gap: 3px; align-items: center;
    box-shadow: 0 14px 34px rgba(229, 9, 20, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
    overflow: hidden;
}
.draw-btn::after {
    content: ""; position: absolute; top: 0; bottom: 0; width: 60px;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.28), transparent);
    left: -80px; transform: skewX(-20deg);
}
.draw-btn:hover:not(:disabled)::after { animation: shine 0.8s ease; }
@keyframes shine { to { left: 130%; } }
.draw-btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.draw-btn:active:not(:disabled) { transform: scale(0.99); }
.draw-btn:disabled { cursor: wait; filter: grayscale(0.35) brightness(0.7); }
.draw-btn-txt { font-size: 1.22rem; font-weight: 900; letter-spacing: 0.16em; text-indent: 0.16em; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
.draw-btn-sub { font-size: 0.73rem; font-weight: 500; opacity: 0.88; }

/* ---------- result ticket ---------- */
.result { margin-top: 18px; animation: pop 0.4s ease; }
.result[hidden] { display: none; }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }
.ticket {
    position: relative; display: flex; border-radius: 14px; overflow: hidden;
    background: linear-gradient(135deg, #1d1d22, #121014 60%, #1a0d10);
    border: 1px solid rgba(229, 9, 20, 0.4);
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.65), 0 0 40px rgba(229, 9, 20, 0.14);
}
.ticket-stub {
    writing-mode: vertical-rl; font-size: 0.66rem; font-weight: 900; letter-spacing: 0.32em; text-indent: 0.32em;
    background: linear-gradient(180deg, var(--red-hi), var(--red) 55%, #8f050d); color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    padding: 16px 11px; display: flex; align-items: center; justify-content: center;
}
.ticket-main { flex: 1; padding: 18px; text-align: left; border-left: 2px dashed rgba(229, 9, 20, 0.45); }
.ticket-k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.2em; color: var(--red-hi); font-weight: 800; }
.ticket-id { font-size: 2.2rem; font-weight: 900; letter-spacing: 0.02em; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.ticket-meta span {
    font-size: 0.7rem; font-weight: 700; color: #cfcfd4;
    border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px;
    background: rgba(0, 0, 0, 0.4);
}
.ticket-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.watch-btn {
    flex: 1; min-width: 150px; text-align: center; text-decoration: none;
    background: linear-gradient(180deg, var(--red-hi), var(--red) 60%, #a3060f);
    color: #fff; font-weight: 800; font-size: 0.93rem;
    padding: 13px 18px; border-radius: 8px;
    box-shadow: 0 8px 22px rgba(229, 9, 20, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: filter 0.15s ease, transform 0.15s ease;
}
.watch-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.ghost-btn {
    background: rgba(0, 0, 0, 0.3); color: var(--txt); font-family: inherit;
    border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 8px;
    padding: 13px 18px; font-size: 0.83rem; font-weight: 700; cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.ghost-btn:hover { border-color: var(--red-hi); background: rgba(229, 9, 20, 0.1); }
.ghost-btn.sm { padding: 9px 16px; font-size: 0.76rem; }

/* ---------- history ---------- */
.history { margin-top: 28px; }
.history[hidden] { display: none; }
.sec-title { font-size: 1rem; font-weight: 800; letter-spacing: 0.04em; margin-bottom: 12px; text-transform: uppercase; }
.count {
    font-size: 0.72rem; color: #fff; background: linear-gradient(180deg, var(--red-hi), var(--red));
    border-radius: 4px; padding: 2px 9px; vertical-align: middle;
    box-shadow: 0 3px 10px rgba(229, 9, 20, 0.4);
}
.h-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.h-list li a {
    display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--txt);
    background: linear-gradient(180deg, #17171b, #101013);
    border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 8px;
    padding: 11px 14px; font-size: 0.82rem; font-weight: 600;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.h-list li a:hover { border-color: rgba(229, 9, 20, 0.6); border-left-color: var(--red-hi); transform: translateX(2px); }
.h-list .h-id { color: var(--red-hi); font-weight: 900; font-variant-numeric: tabular-nums; }
.h-list .h-ts { margin-left: auto; color: var(--muted); font-size: 0.7rem; font-weight: 500; }

.foot { text-align: center; color: #55555c; font-size: 0.74rem; margin-top: 36px; letter-spacing: 0.03em; }

@media (max-width: 480px) {
    .page { padding: 16px 14px 40px; }
    .machine { padding: 26px 16px 20px; }
    .ticket { flex-direction: column; }
    .ticket-stub { writing-mode: horizontal-tb; padding: 9px; }
    .ticket-main { border-left: none; border-top: 2px dashed rgba(229, 9, 20, 0.45); }
}
