:root {
  --pink: #ff5c8a; --yellow: #ffe156; --cyan: #4cd7ff; --purple: #8a7bff; --bg: #140a26;
  --font: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); font-family: var(--font); color: #fff; user-select: none; -webkit-user-select: none; touch-action: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
#menu { background: radial-gradient(ellipse at 50% 30%, rgba(255,92,138,0.18), rgba(20,10,38,0.55) 60%, rgba(20,10,38,0.85)); backdrop-filter: blur(2px); }
.menu-card, .podium-card { width: min(520px, 100%); background: rgba(22, 10, 45, 0.78); border: 3px solid rgba(255,255,255,0.14); border-radius: 28px; padding: 28px 28px 22px; box-shadow: 0 30px 80px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1); text-align: center; }
.logo { margin: 0 0 6px; font-size: clamp(56px, 13vw, 92px); letter-spacing: -2px; line-height: 1; font-weight: 900; color: #fff; text-shadow: 0 6px 0 #c2185b, 0 10px 24px rgba(0,0,0,0.5); transform: rotate(-3deg); }
.logo span { display: inline-block; animation: wob 2.2s ease-in-out infinite; }
.logo span:nth-child(odd) { color: var(--yellow); text-shadow: 0 6px 0 #b8860b, 0 10px 24px rgba(0,0,0,0.5); }
.logo span:nth-child(2) { animation-delay: .15s } .logo span:nth-child(3) { animation-delay: .3s } .logo span:nth-child(4) { animation-delay: .45s } .logo span:nth-child(5) { animation-delay: .6s } .logo span:nth-child(6) { animation-delay: .75s } .logo span:nth-child(7) { animation-delay: .9s }
@keyframes wob { 0%,100% { transform: translateY(0) scaleY(1) } 50% { transform: translateY(-8px) scaleY(1.08) } 70% { transform: translateY(2px) scaleY(0.95) } }
.tagline { margin: 4px 0 18px; opacity: .85; font-size: 15px; line-height: 1.35; }
.row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; justify-content: center; }
#name, #code { flex: 1; min-width: 140px; padding: 12px 14px; font-size: 18px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.18); background: rgba(0,0,0,0.3); color: #fff; outline: none; }
#name:focus, #code:focus { border-color: var(--yellow); }
#code { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 900; max-width: 150px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform .1s; box-shadow: inset 0 -5px 0 rgba(0,0,0,0.25); }
.swatch:hover { transform: scale(1.12); }
.swatch.sel { border-color: #fff; transform: scale(1.18); }
.buttons { display: flex; flex-direction: column; gap: 10px; }
.join-row { display: flex; gap: 10px; }
.join-row button { flex: 1; }
button.big { padding: 14px 20px; font-size: 20px; font-weight: 900; border-radius: 16px; border: 0; background: #3a2a63; color: #fff; box-shadow: 0 5px 0 #231846, 0 10px 20px rgba(0,0,0,0.35); transition: transform .08s, box-shadow .08s; letter-spacing: 1px; }
button.big:hover { filter: brightness(1.1); }
button.big:active { transform: translateY(4px); box-shadow: 0 1px 0 #231846; }
button.big.primary { background: linear-gradient(180deg, #ff7aa2, #ff3d78); box-shadow: 0 5px 0 #b01f4f, 0 10px 24px rgba(255,61,120,0.35); }
button.big.primary:active { box-shadow: 0 1px 0 #b01f4f; }
button:disabled { opacity: .5; cursor: default; }
.error { color: #ff8da8; min-height: 18px; margin: 10px 0 0; font-weight: 700; }
.howto { margin-top: 14px; font-size: 12px; opacity: .7; line-height: 1.6; }
.howto b { color: var(--yellow); }
.menu-foot { margin-top: 14px; font-size: 12px; opacity: .55; text-align: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }
#top-left { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 8px; max-width: 46vw; }
.room-pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.45); padding: 7px 10px 7px 12px; border-radius: 999px; font-size: 14px; backdrop-filter: blur(6px); }
.room-pill .label { opacity: .6; font-size: 11px; letter-spacing: 2px; }
.room-pill b { font-size: 18px; letter-spacing: 3px; color: var(--yellow); }
.room-pill button { border: 0; background: rgba(255,255,255,0.12); color: #fff; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 700; }
.room-pill button:hover { background: rgba(255,255,255,0.25); }
#feed { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px #000; }
#feed div { background: rgba(0,0,0,0.35); padding: 4px 9px; border-radius: 8px; animation: feedin .25s ease-out; opacity: .95; }
@keyframes feedin { from { transform: translateX(-20px); opacity: 0 } to { transform: none; opacity: .95 } }
#top-center { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); text-align: center; }
#timer { font-size: 38px; font-weight: 900; letter-spacing: 2px; text-shadow: 0 3px 0 rgba(0,0,0,0.5), 0 6px 20px rgba(0,0,0,0.5); }
#timer.hot { color: #ff5c5c; animation: pulse .6s infinite; }
@keyframes pulse { 50% { transform: scale(1.12) } }
#phase-label { font-size: 13px; letter-spacing: 3px; opacity: .8; font-weight: 700; }
#scoreboard { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 5px; min-width: 190px; }
.sb-row { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.45); padding: 6px 10px; border-radius: 12px; font-weight: 800; font-size: 15px; backdrop-filter: blur(6px); transition: transform .2s; }
.sb-row.me { outline: 2px solid rgba(255,255,255,0.6); }
.sb-row.dead { opacity: .5; }
.sb-row .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.3); }
.sb-row .nm { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sb-row .sc { font-variant-numeric: tabular-nums; color: var(--yellow); }
.sb-row .crown { font-size: 14px; }
#announce { position: absolute; top: 20%; left: 50%; transform: translateX(-50%); font-size: clamp(22px, 4.5vw, 44px); font-weight: 900; text-align: center; width: 92vw; text-shadow: 0 4px 0 rgba(0,0,0,0.6), 0 8px 30px rgba(0,0,0,0.6); opacity: 0; transition: opacity .25s; text-transform: uppercase; letter-spacing: 1px; line-height: 1.1; }
#announce.show { opacity: 1; animation: slam .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes slam { 0% { transform: translateX(-50%) scale(2.2) rotate(-6deg); opacity: 0 } 100% { transform: translateX(-50%) scale(1) rotate(-2deg); opacity: 1 } }
#countdown { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(90px, 22vw, 200px); font-weight: 900; color: var(--yellow); text-shadow: 0 10px 0 #b8860b, 0 20px 50px rgba(0,0,0,0.6); pointer-events: none; }
#countdown.pop { animation: cdpop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes cdpop { 0% { transform: translate(-50%,-50%) scale(2.4) rotate(-8deg) } 100% { transform: translate(-50%,-50%) scale(1) rotate(0deg) } }
#bottom-center { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#host-controls { display: flex; gap: 10px; }
#wait-msg { background: rgba(0,0,0,0.5); padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.controls-hint { position: absolute; bottom: 14px; left: 14px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; opacity: .65; text-shadow: 0 1px 2px #000; }
.controls-hint b { color: var(--yellow); }
#dash-cd { position: absolute; bottom: 18px; right: 18px; width: 86px; height: 86px; border-radius: 50%; background: rgba(0,0,0,0.5); overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 14px; letter-spacing: 2px; border: 3px solid rgba(255,255,255,0.25); }
#dash-cd-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; background: linear-gradient(180deg, #ff7aa2, #ff3d78); transition: height .05s linear; }
#dash-cd span { position: relative; text-shadow: 0 2px 2px rgba(0,0,0,0.6); }
#dash-cd.ready { animation: readypop .3s; border-color: #fff; }
@keyframes readypop { 50% { transform: scale(1.15) } }

/* ---------- touch ---------- */
#touch { position: absolute; inset: 0; pointer-events: none; }
#stick { position: absolute; left: 26px; bottom: 26px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.25); pointer-events: auto; }
#stick-knob { position: absolute; left: 45px; top: 45px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.55); }
#touch-buttons { position: absolute; right: 20px; bottom: 120px; display: flex; flex-direction: column; gap: 12px; align-items: flex-end; }
#touch-buttons button { pointer-events: auto; width: 86px; height: 86px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.3); background: rgba(255,92,138,0.55); color: #fff; font-weight: 900; font-size: 16px; letter-spacing: 1px; }
#touch-buttons #t-jump { background: rgba(76,215,255,0.55); width: 100px; height: 100px; }
#touch-buttons #t-emote { width: 60px; height: 60px; font-size: 26px; background: rgba(0,0,0,0.4); }
body.touch .controls-hint, body.touch #dash-cd { display: none; }
body.touch #bottom-center { bottom: 240px; }

/* ---------- podium ---------- */
#podium { background: rgba(10, 4, 24, 0.55); }
.podium-card h2 { margin: 0 0 14px; font-size: clamp(32px, 8vw, 52px); letter-spacing: 2px; color: var(--yellow); text-shadow: 0 5px 0 #b8860b; transform: rotate(-2deg); }
#podium-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.pd-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,0.08); font-weight: 800; font-size: 18px; text-align: left; }
.pd-row.first { background: linear-gradient(90deg, rgba(255,225,86,0.35), rgba(255,225,86,0.08)); font-size: 22px; border: 2px solid rgba(255,225,86,0.5); }
.pd-row .rank { width: 30px; text-align: center; font-size: 22px; }
.pd-row .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.pd-row .nm { flex: 1; }
.pd-row .pts { color: var(--yellow); font-variant-numeric: tabular-nums; }
.pd-row small { opacity: .7; font-weight: 600; font-size: 12px; margin-left: 8px; }
#podium-stats { font-size: 14px; opacity: .85; line-height: 1.6; margin-bottom: 14px; }
.podium-buttons { display: flex; gap: 10px; justify-content: center; }
#podium-next { margin: 14px 0 0; opacity: .7; font-weight: 700; }

@media (max-width: 640px) {
  #scoreboard { min-width: 120px; gap: 3px; } .sb-row { font-size: 11px; padding: 3px 7px; gap: 5px; border-radius: 8px; } .sb-row .dot { width: 10px; height: 10px; }
  #top-center { top: 50px; } #timer { font-size: 26px; } #phase-label { font-size: 10px; letter-spacing: 2px; }
  #top-left { max-width: 60vw; gap: 5px; }
  .room-pill { font-size: 11px; gap: 4px; padding: 4px 7px; } .room-pill .label { display: none; } .room-pill b { font-size: 13px; letter-spacing: 2px; }
  .room-pill button { padding: 4px 7px; font-size: 11px; }
  #feed { font-size: 10px; } #feed div { padding: 3px 6px; }
  #announce { top: 24%; font-size: 22px; }
  #countdown { top: 36%; }
  .menu-card, .podium-card { padding: 20px 16px 16px; border-radius: 22px; }
  .pd-row { font-size: 15px; padding: 8px 10px; } .pd-row.first { font-size: 17px; } .pd-row small { display: block; margin-left: 0; }
}
