:root {
    --bg: #0d1224;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-border: rgba(255, 255, 255, 0.12);
    --text: #eef1ff;
    --muted: #9aa3c7;
    --accent: #ffb703;
    --accent-2: #fb5607;
    --success: #2ec4b6;
    --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: "Outfit", system-ui, sans-serif;
    background: radial-gradient(circle at 20% 0%, #1c2550 0%, var(--bg) 60%);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}
.bg-orbs span {
    position: fixed; border-radius: 50%; filter: blur(80px); opacity: .35; z-index: 0;
    animation: float 14s ease-in-out infinite alternate;
}
.bg-orbs span:nth-child(1) { width: 380px; height: 380px; background: #fb5607; top: -100px; left: -80px; }
.bg-orbs span:nth-child(2) { width: 320px; height: 320px; background: #3a86ff; bottom: -80px; right: -60px; animation-delay: -4s; }
.bg-orbs span:nth-child(3) { width: 260px; height: 260px; background: #2ec4b6; top: 40%; left: 45%; animation-delay: -8s; }
@keyframes float { to { transform: translate(60px, 40px) scale(1.15); } }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100%; height: 100%; }

.app { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 32px 20px 48px; }
.app-header { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; animation: rise .6s ease both; }
.logo {
    font-size: 2.2rem; width: 64px; height: 64px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-radius: 18px;
    box-shadow: 0 10px 30px -8px var(--accent-2);
}
h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.subtitle { color: var(--muted); }

.layout { display: grid; grid-template-columns: 300px 1fr 280px; gap: 24px; align-items: start; }
@media (max-width: 1050px) { .layout { grid-template-columns: 1fr; } .wheel-area { order: -1; } }

.panel {
    background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
    padding: 22px; backdrop-filter: blur(14px); animation: rise .6s ease both .1s;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

.label { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.select-wrap { position: relative; margin: 8px 0 18px; }
.select-wrap::after {
    content: "▾"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
    color: var(--accent); pointer-events: none;
}
select {
    width: 100%; appearance: none; font: inherit; font-weight: 600; color: var(--text);
    background: rgba(0,0,0,.3); border: 1px solid var(--panel-border); border-radius: 12px;
    padding: 13px 40px 13px 14px; cursor: pointer; transition: border-color .2s, box-shadow .2s;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,183,3,.25); }
select option { background: #1a2140; }
select:disabled { opacity: .6; cursor: not-allowed; }

.winner-card {
    display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: 14px; min-height: 104px;
    background: linear-gradient(135deg, rgba(255,183,3,.12), rgba(251,86,7,.12));
    border: 1px dashed rgba(255,183,3,.4); margin-bottom: 18px; transition: transform .3s;
}
.winner-label { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.winner-name { font-size: 1.7rem; font-weight: 800; color: var(--accent); line-height: 1.2; }
.winner-comment { font-size: .85rem; color: var(--muted); font-style: italic; }
.winner-card.rolling .winner-name { color: var(--text); opacity: .8; }
.winner-card.reveal { animation: pop .7s cubic-bezier(.2,1.6,.4,1); border-style: solid; box-shadow: 0 0 40px -6px var(--accent); }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-bottom: 10px; }
.stats div { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 4px; }
.stats strong { display: block; font-size: 1.3rem; }
.stats span { font-size: .72rem; color: var(--muted); }
.progress { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin-bottom: 18px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--success), var(--accent)); transition: width .5s ease; }

.btn-row { display: flex; gap: 10px; }
.btn {
    flex: 1; font: inherit; font-weight: 700; padding: 13px; border-radius: 12px; cursor: pointer;
    border: 1px solid transparent; transition: transform .15s, box-shadow .2s, opacity .2s;
}
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #1a1000; box-shadow: 0 8px 24px -8px var(--accent-2); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 30px -8px var(--accent-2); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--panel-border); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.toggle { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: .85rem; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.wheel-area { display: flex; flex-direction: column; align-items: center; }
.wheel-wrap { position: relative; width: min(88vw, 500px); aspect-ratio: 1; animation: rise .7s ease both .2s; }
.wheel-wrap canvas {
    width: 100%; height: 100%; border-radius: 50%;
    box-shadow: 0 0 0 10px rgba(255,255,255,.08), 0 0 0 12px rgba(255,183,3,.6), 0 30px 60px -20px rgba(0,0,0,.7);
}
.wheel-wrap.spinning canvas { animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 10px rgba(255,255,255,.08), 0 0 0 12px var(--accent), 0 0 60px 6px rgba(255,183,3,.45); } }
.pointer {
    position: absolute; top: -14px; left: 50%; transform: translateX(-50%); z-index: 5;
    width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent;
    border-top: 36px solid var(--accent); filter: drop-shadow(0 4px 6px rgba(0,0,0,.5));
    transform-origin: 50% 0;
}
.pointer.tick { animation: tick .12s ease; }
@keyframes tick { 50% { transform: translateX(-50%) rotate(-14deg); } }
.hub {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 84px; height: 84px; border-radius: 50%; border: 5px solid var(--accent);
    background: #10162e; color: var(--accent); font: inherit; font-weight: 800; letter-spacing: .08em;
    cursor: pointer; transition: transform .2s; box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.hub:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.08); }
.hub:disabled { cursor: not-allowed; opacity: .8; }
.hint { margin-top: 22px; color: var(--muted); font-size: .85rem; }
kbd { background: rgba(255,255,255,.1); border: 1px solid var(--panel-border); border-radius: 6px; padding: 2px 6px; }

.list-panel h2 { font-size: 1.05rem; margin-bottom: 12px; }
.student-list { list-style: none; max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.student-list li {
    display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 10px;
    background: rgba(0,0,0,.2); font-size: .92rem; transition: all .3s; animation: rise .35s ease both;
}
.student-list li.done { opacity: .4; text-decoration: line-through; }
.student-list li.current { background: rgba(255,183,3,.18); outline: 1px solid var(--accent); opacity: 1; text-decoration: none; }
.student-list .tag { font-size: .72rem; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }

/* ===== Full-screen spinner (stage mode) ===== */
.full-btn { margin-top: 14px; }
.exit-full {
    display: none; position: fixed; top: 18px; right: 18px; z-index: 40;
    width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.08); color: #fff; font-size: 20px; cursor: pointer; transition: .2s;
}
.exit-full:hover { background: rgba(255,255,255,.2); transform: rotate(90deg); }
body.stage { overflow: hidden; }
body.stage .exit-full { display: block; }
body.stage .app-header, body.stage .panel, body.stage .hint, body.stage .full-btn { display: none !important; }
body.stage .app { max-width: none; padding: 0; }
body.stage .layout { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
body.stage .wheel-wrap { width: min(92vh, 92vw); animation: stageIn .6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes stageIn { from { transform: scale(.6) rotate(-20deg); opacity: 0; } }

/* ===== Winner full-screen reveal ===== */
.winner-overlay {
    position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at center, rgba(40,20,90,.92), rgba(5,8,20,.97));
    opacity: 0; visibility: hidden; transition: opacity .4s, visibility .4s; overflow: hidden;
}
.winner-overlay.show { opacity: 1; visibility: visible; }
.rays {
    position: absolute; width: 220vmax; height: 220vmax; opacity: .18;
    background: repeating-conic-gradient(#ffb703 0 8deg, transparent 8deg 22deg);
    animation: raySpin 18s linear infinite;
}
@keyframes raySpin { to { transform: rotate(360deg); } }
.overlay-content { position: relative; text-align: center; padding: 20px; transform: scale(.3); opacity: 0; }
.winner-overlay.show .overlay-content { animation: popIn .8s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes popIn { to { transform: scale(1); opacity: 1; } }
.overlay-label {
    display: inline-block; font-size: clamp(18px, 3vw, 32px); letter-spacing: .3em; text-transform: uppercase;
    color: #ffb703; font-weight: 600; margin-bottom: 10px; animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.08); text-shadow: 0 0 24px #ffb703; } }
.overlay-name { margin: 0 0 16px; font-size: clamp(48px, 12vw, 180px); font-weight: 800; line-height: 1.05; }
.overlay-name span {
    display: inline-block; opacity: 0; transform: translateY(80px) rotate(12deg) scale(.4);
    background: linear-gradient(135deg, #ffb703, #ff006e, #8338ec, #3a86ff); background-size: 300% 300%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 6px 30px rgba(255,0,110,.45));
}
.winner-overlay.show .overlay-name span {
    animation: letterIn .7s cubic-bezier(.2,1.6,.4,1) forwards, shimmer 3s ease-in-out infinite, bob 2.4s ease-in-out infinite 1.4s;
}
@keyframes letterIn { to { opacity: 1; transform: none; } }
@keyframes shimmer { 50% { background-position: 100% 50%; } }
@keyframes bob { 50% { transform: translateY(-10px); } }
.overlay-comment { display: block; font-size: clamp(16px, 2.2vw, 26px); color: #c9cff0; margin-bottom: 28px; min-height: 1em; }
.overlay-content .btn { font-size: 18px; padding: 14px 36px; }
