:root {
  --bg: #1a1020; --bg2: #2a1a32; --card: #2f2038; --fg: #fff3e6; --muted: #c9b7c9; --accent: #ffb545; --accent2: #ff6f91;
  --blue: #5fd6ff; --green: #8bff6d; --danger: #ff4d6d; --radius: 16px; --fs: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: var(--fs)/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; min-height: 100vh; }
body.big { --fs: 22px; }
body.big .code { font-size: 72px; }
body.big .drums, body.big .panel-title { font-size: 1.2em; }
button { font: inherit; color: var(--fg); background: var(--bg2); border: 2px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 10px 18px; cursor: pointer; transition: transform .08s, background .15s; }
button:hover { background: #3a2645; }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); color: #1a1020; border-color: transparent; font-weight: 800; }
button.primary:hover { background: #ffc86b; }
button.big { padding: 16px 28px; font-size: 1.2em; border-radius: 16px; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: rgba(255,255,255,0.08); }
button.ready.on { background: var(--green); color: #1a1020; border-color: transparent; font-weight: 800; }
#topbar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: rgba(0,0,0,0.25); }
#topbar .spacer { flex: 1; }
#crumb { font-weight: 700; opacity: 0.9; }
main { flex: 1; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; gap: 16px; max-width: 1400px; width: 100%; margin: 0 auto; }
.hidden { display: none !important; }
.hero { text-align: center; padding: 40px 10px 10px; }
.hero h1 { font-size: 3.2em; margin: 0 0 8px; letter-spacing: 0.02em; color: var(--accent); text-shadow: 0 4px 0 #0d0810; }
.lead { max-width: 720px; margin: 0 auto 24px; font-size: 1.15em; color: var(--muted); }
.actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.actions.col { flex-direction: column; align-items: stretch; }
.hint { color: var(--muted); font-size: 0.95em; text-align: center; }
.howto { max-width: 760px; margin: 0 auto; background: var(--card); border-radius: var(--radius); padding: 14px 24px; }
.howto h2 { margin: 6px 0; font-size: 1.2em; }
.howto ol { margin: 6px 0 8px; padding-left: 22px; color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; }
.card.narrow { max-width: 560px; width: 100%; margin: 24px auto; display: flex; flex-direction: column; gap: 14px; }
.card.center { text-align: center; align-items: center; }
.row { display: flex; gap: 20px; justify-content: center; }
.error { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); }
#join-code { font-size: 40px; letter-spacing: 0.35em; text-align: center; text-transform: uppercase; padding: 10px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.2); background: #1a1020; color: var(--fg); width: 100%; }
.lobby-head { display: flex; gap: 28px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 18px 24px; flex-wrap: wrap; }
.label { color: var(--muted); font-size: 0.9em; }
.code { font-size: 56px; font-weight: 900; letter-spacing: 0.22em; color: var(--accent); font-family: ui-monospace, Menlo, Consolas, monospace; }
.lobby-text { flex: 1; min-width: 260px; }
.lobby-text p { margin: 4px 0; }
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.player-card { background: var(--card); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; border: 2px solid transparent; }
.player-card.me { border-color: var(--accent); }
.player-card h3 { margin: 0; font-size: 1.3em; }
.drums { color: var(--blue); font-weight: 700; }
.status-line { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #666; display: inline-block; }
.dot.ok { background: var(--green); } .dot.wait { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.qr { width: 180px; height: 180px; background: #fff; border-radius: 10px; padding: 6px; image-rendering: pixelated; }
.qr-caption { font-size: 0.85em; color: var(--muted); }
.lobby-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
/* game */
#screen-game { padding: 8px 12px; gap: 8px; }
#scene-wrap { position: relative; width: 100%; aspect-ratio: 16 / 7; max-height: 58vh; background: #000; border-radius: var(--radius); overflow: hidden; }
#scene { width: 100%; height: 100%; display: block; }
.on-scene { position: absolute; top: 8px; right: 8px; font-weight: 900; background: rgba(0,0,0,0.35); }
.pill { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); font-size: 11px; color: rgba(255,255,255,0.75); background: rgba(0,0,0,0.35); padding: 2px 10px; border-radius: 10px; }
#panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; min-height: 160px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.panel-title { display: flex; gap: 10px; align-items: baseline; font-weight: 700; }
.panel-title .acc { margin-left: auto; color: var(--muted); font-weight: 500; }
.video-box { position: relative; flex: 1; min-height: 140px; background: #0d0810; border-radius: 12px; overflow: hidden; }
.video-box video, .video-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.video-box .empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); text-align: center; padding: 10px; font-size: 0.9em; }
.empty-ico { font-size: 28px; }
.pads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pad { padding: 8px 4px; border-radius: 10px; background: #1a1020; border: 2px solid rgba(255,255,255,0.1); text-align: center; font-weight: 800; cursor: pointer; user-select: none; }
.pad small { display: block; font-weight: 400; color: var(--muted); font-size: 0.75em; }
.pad.mine { border-color: var(--pc); }
.pad.expect { box-shadow: 0 0 0 3px var(--pc) inset, 0 0 16px var(--pc); }
.pad.hit { background: var(--pc); color: #1a1020; }
.pad.off { opacity: 0.3; }
/* result */
.stars { font-size: 44px; letter-spacing: 6px; color: var(--accent); }
#result-table { border-collapse: collapse; margin: 6px auto; }
#result-table td, #result-table th { padding: 6px 14px; border-bottom: 1px solid rgba(255,255,255,0.1); text-align: center; }
/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(13,8,16,0.8); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.bar { width: 100%; height: 10px; background: rgba(255,255,255,0.1); border-radius: 5px; overflow: hidden; }
#load-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0d0810; color: var(--fg); padding: 10px 18px; border-radius: 12px; z-index: 30; box-shadow: 0 6px 24px rgba(0,0,0,0.5); max-width: 90vw; }
#toast.err { border: 2px solid var(--danger); }
@media (max-width: 800px) { .players, #panels { grid-template-columns: 1fr; } .hero h1 { font-size: 2.2em; } #scene-wrap { aspect-ratio: 16 / 9; } }
@media (min-width: 1600px) { :root { --fs: 20px; } }
