:root { --pink: #ff4f9a; --cyan: #5ce1e6; --gold: #ffc93c; --orange: #ff7a1a; --ink: #120b2a; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: #fff; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 700; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui button { pointer-events: auto; }
h1, h2, b, button, #toast, #count, #wave b { font-family: system-ui, sans-serif; font-weight: 400; letter-spacing: 0.02em; }

/* ---- playing */
.top { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 18px; right: 168px; display: flex; align-items: center; gap: 18px; }
.stat { min-width: 108px; padding: 6px 16px 8px; border-radius: 16px; background: rgba(18, 11, 42, 0.72); border: 2px solid rgba(92, 225, 230, 0.4); backdrop-filter: blur(6px); }
.stat.right { text-align: right; }
.stat small { display: block; font-size: 11px; letter-spacing: 0.14em; opacity: 0.7; }
.stat b { font-size: 34px; line-height: 1; }
.stat.fire { border-color: var(--pink); box-shadow: 0 0 24px rgba(255, 79, 154, 0.7); }
.stat.fire b { color: var(--pink); }
.clock { flex: 1; display: flex; align-items: center; gap: 12px; }
.clock b { font-size: 40px; min-width: 52px; text-align: right; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
#bar { flex: 1; height: 16px; border-radius: 10px; background: rgba(18, 11, 42, 0.72); border: 2px solid rgba(255, 255, 255, 0.25); overflow: hidden; }
#bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--cyan), var(--gold)); border-radius: 8px; transition: width 0.15s linear; }
#bar.low i { background: var(--pink); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { opacity: 0.45; } }
#wave { position: absolute; top: 118px; left: 0; right: 0; text-align: center; opacity: 0; }
#wave b { display: block; font-size: 30px; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45); }
#wave span { font-size: 16px; opacity: 0.9; }
#wave.pop { animation: banner 4.2s ease-out both; }
@keyframes banner { 0% { opacity: 0; transform: translateY(-12px); } 8%, 78% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#toast { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-size: 46px; opacity: 0; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45); }
#toast.pop { animation: toast 1.1s ease-out both; }
#toast.swish { color: var(--cyan); }
#toast.gold { color: var(--gold); font-size: 58px; }
#toast.fire { color: var(--pink); font-size: 62px; }
#toast.miss { color: #b9b3d6; font-size: 30px; }
@keyframes toast { 0% { opacity: 0; transform: scale(0.6); } 14% { opacity: 1; transform: scale(1.12); } 26% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }
#read { position: absolute; bottom: 26px; left: 0; right: 0; text-align: center; font-size: 18px; letter-spacing: 0.12em; opacity: 0; }
#read.pop { animation: read 1.6s ease-out both; }
@keyframes read { 0% { opacity: 0; } 10%, 70% { opacity: 0.95; } 100% { opacity: 0; } }
#count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 150px; color: var(--gold); text-shadow: 0 8px 0 rgba(0, 0, 0, 0.45); }

/* ---- the camera's corner */
#camera { position: absolute; left: 16px; bottom: 16px; width: min(300px, 34vw); opacity: 0; transition: opacity 0.3s; z-index: 5; }
#camera.on { opacity: 1; }
#pip { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #0c0818; border: 2px solid rgba(92, 225, 230, 0.55); }
#pip video, #pip canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#hint { margin-top: 6px; min-height: 20px; font-size: 14px; color: var(--gold); text-shadow: 0 1px 3px #000; }

/* ---- screens */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: min(18px, 2vh); padding: 24px; text-align: center; background: radial-gradient(ellipse at center, rgba(18, 11, 42, 0.55), rgba(18, 11, 42, 0.9)); pointer-events: auto; }
.screen[hidden] { display: none; }
h1 { margin: 0; font-size: min(clamp(64px, 13vw, 150px), 17vh); line-height: 0.86; color: #ffe9f3; text-shadow: 0 0 34px var(--pink), 0 6px 0 rgba(0, 0, 0, 0.4); }
h1 span { color: var(--gold); text-shadow: 0 0 34px var(--orange), 0 6px 0 rgba(0, 0, 0, 0.4); }
h2 { margin: 0; font-size: 64px; color: var(--gold); }
.how { max-width: 640px; margin: 0; font-size: min(18px, 2.9vh); line-height: 1.5; }
.how b { color: var(--cyan); }
.keys { margin: 0; font-size: 14px; opacity: 0.75; }
kbd { font: inherit; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.14); }
.row { display: flex; gap: 56px; flex-wrap: wrap; justify-content: center; margin: 8px 0; }
button { font-size: min(30px, 4.6vh); padding: min(18px, 2.4vh) 40px; min-width: 250px; border-radius: 22px; border: 3px solid var(--cyan); background: rgba(18, 11, 42, 0.8); color: #fff; cursor: pointer; transition: transform 0.12s; }
button.go { background: var(--pink); border-color: #ffd0e4; box-shadow: 0 8px 0 #a61e5c, 0 0 36px rgba(255, 79, 154, 0.6); }
button:hover, button.mocap-hover { transform: scale(1.05); }
.final b { display: block; font-size: 130px; line-height: 1; text-shadow: 0 0 34px var(--pink); }
.final small { font-size: 18px; opacity: 0.8; }
#summary { margin: 0; font-size: 18px; opacity: 0.9; }
@media (max-width: 640px) { .stat b { font-size: 26px; } .stat { min-width: 84px; } #toast { font-size: 34px; } button { min-width: 200px; font-size: 24px; } .row { gap: 22px; } }

/* ---- three games */
.modes { display: flex; gap: min(44px, 4vw); flex-wrap: wrap; justify-content: center; margin: 6px 0; }
button.mode { min-width: 0; width: min(270px, 28vw); padding: min(20px, 2.6vh) 14px; display: flex; flex-direction: column; gap: 6px; align-items: center; border-color: var(--pink); box-shadow: 0 8px 0 #a61e5c, 0 0 30px rgba(255, 79, 154, 0.45); }
button.mode:nth-child(2) { border-color: var(--gold); box-shadow: 0 8px 0 #9a6b00, 0 0 30px rgba(255, 201, 60, 0.4); }
button.mode:nth-child(3) { border-color: var(--cyan); box-shadow: 0 8px 0 #1c7d82, 0 0 30px rgba(92, 225, 230, 0.4); }
button.mode b { font-size: min(32px, 4.8vh); }
button.mode span { font: 700 min(15px, 2.4vh) system-ui, -apple-system, "Segoe UI", sans-serif; opacity: 0.9; }
button.mode small { font: 700 13px system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--gold); min-height: 16px; }
button.small { font-size: min(20px, 3.2vh); padding: 10px 26px; min-width: 0; }
#lives, #ballColor { display: none; }
#hud[data-mode="buzzer"] #bar, #hud[data-mode="buzzer"] #time { display: none; }
#hud[data-mode="buzzer"] #lives { display: block; flex: 1; text-align: center; font-size: 44px; letter-spacing: 0.25em; color: var(--pink); text-shadow: 0 0 18px rgba(255, 79, 154, 0.8); }
#hud[data-mode="colors"] #ballColor { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 14px; background: rgba(18, 11, 42, 0.72); }
#ballColor small { font-size: 10px; letter-spacing: 0.12em; opacity: 0.75; }
#ballColor i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; }
#ballColor i:last-child { width: 16px; height: 16px; opacity: 0.8; }
@media (max-width: 640px) { button.mode { width: 80vw; } }

/* ---- the strength meter: the hand's height against the three distances */
#meter { position: absolute; right: 22px; top: 50%; transform: translateY(-46%); width: 74px; height: min(46vh, 380px); border-radius: 16px; overflow: hidden; background: rgba(18, 11, 42, 0.72); border: 2px solid rgba(255, 255, 255, 0.3); --near: 45%; --mid: 66%; }
#meter[hidden] { display: none; }
#meter .zone { position: absolute; left: 0; right: 0; display: grid; place-items: center; font-size: 11px; letter-spacing: 0.12em; color: rgba(255, 255, 255, 0.85); transition: background 0.15s; }
#meter .near { bottom: 0; height: var(--near); background: rgba(92, 225, 230, 0.16); }
#meter .mid { bottom: var(--near); height: calc(var(--mid) - var(--near)); background: rgba(255, 201, 60, 0.18); border-top: 2px solid rgba(255, 255, 255, 0.35); border-bottom: 2px solid rgba(255, 255, 255, 0.35); }
#meter .far { bottom: var(--mid); top: 0; background: rgba(255, 79, 154, 0.2); }
#meter[data-flash="0"] .near { background: var(--cyan); color: #0b1020; }
#meter[data-flash="1"] .mid { background: var(--gold); color: #0b1020; }
#meter[data-flash="2"] .far { background: var(--pink); color: #0b1020; }
#marker { position: absolute; left: -2px; right: -2px; height: 6px; margin-bottom: -3px; border-radius: 3px; background: #fff; box-shadow: 0 0 12px #fff; transition: bottom 0.05s linear; }
#marker[hidden] { display: none; }
#meter.idle { opacity: 0.55; }
#meterNote { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 9px; line-height: 1.1; color: var(--gold); }
@media (max-width: 640px) { #meter { width: 54px; right: 10px; } }
h1, h2, b, button, #toast, #count, #wave b { font-family: "Arial Black", "Arial Rounded MT Bold", system-ui, sans-serif; font-weight: 900; }
[hidden] { display: none !important; }
#hud[data-game="1"] #bar, #hud[data-game="1"] #time { display: none; }
#hud[data-game="1"] #lives { display: block; flex: 1; text-align: center; font-size: 44px; letter-spacing: 0.25em; color: var(--pink); text-shadow: 0 0 18px rgba(255, 79, 154, 0.8); }
#hud[data-game="2"] #ballColor { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 14px; background: rgba(18, 11, 42, 0.72); }
.note { margin: 0; min-height: 20px; font-size: 14px; color: var(--gold); }
.ways { display: flex; gap: min(30px, 3vw); flex-wrap: wrap; justify-content: center; }
.ways button { min-width: 0; width: min(250px, 42vw); display: flex; flex-direction: column; gap: 4px; align-items: center; padding: min(18px, 2.4vh) 12px; }
.ways button b { font-size: min(24px, 3.8vh); }
.ways button span { font: 700 min(14px, 2.3vh) system-ui, sans-serif; opacity: 0.9; }
#lobby-seats, #places { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: min(420px, 86vw); }
#lobby-seats li, #places li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 14px; border-radius: 12px; background: rgba(18, 11, 42, 0.75); border: 1px solid rgba(255, 255, 255, 0.18); font-size: 16px; }
#lobby-seats li.me, #places li.me { border-color: var(--cyan); }
#lobby-seats li small { opacity: 0.75; }
.linkrow { display: flex; gap: 10px; align-items: center; }
.linkrow input { width: min(360px, 56vw); padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(12, 8, 24, 0.9); color: #fff; font: 13px ui-monospace, monospace; }
#others { position: absolute; left: 18px; top: 96px; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
#others li { padding: 3px 10px; border-radius: 10px; background: rgba(18, 11, 42, 0.7); display: flex; gap: 10px; justify-content: space-between; min-width: 150px; }
#others li b { font-family: inherit; }
#others li.out { opacity: 0.45; }
#others li i { width: 8px; height: 8px; border-radius: 50%; align-self: center; background: #6f6; }
#others li i.away { background: #fa3; }
#over .final b { font-size: min(110px, 16vh); }
