/* ---------- LAST SEAT ----------
   Musical chairs with physics. The hall lives on the canvas; everything here is the DOM HUD above it.
   Layout: .ls = column (top chips, banner row, middle). The canvas draws the hall into .ls-stage's rectangle, so the
   hall always fits the space the HUD leaves free. The banner row has a fixed height (nothing may resize the stage).
   Only buttons take pointer events: every touch on the hall reaches the canvas (touch joystick). */
.ls-root { --ls-pink: #ff3d9a; --ls-cyan: #3de6ff; --ls-gold: #ffd23d; --ls-green: #4dff9a; --ls-red: #ff5470; --ls-panel: rgba(12, 6, 36, .84); }
.ls { position: absolute; inset: 0; display: flex; flex-direction: column; pointer-events: none; color: var(--text); font-family: var(--font); user-select: none; -webkit-user-select: none; }
.ls button { font: inherit; color: inherit; pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: none; }
.ls [hidden] { display: none !important; }

/* top chips (no backdrop-filter anywhere: the canvas behind redraws every frame) */
.ls-top { position: relative; display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; gap: 8px; padding: 8px 54px 2px; min-height: 42px; overflow: hidden; }
.ls-chip { padding: 5px 13px; border-radius: 14px; font-weight: 900; font-size: 14px; white-space: nowrap; background: var(--ls-panel); border: 1px solid rgba(139, 92, 255, .42); box-shadow: 0 0 14px rgba(255, 61, 154, .12); }
.ls-rd { color: var(--ls-gold); border-color: rgba(255, 210, 61, .5); }
.ls-mute { position: absolute; right: 10px; top: 7px; background: var(--ls-panel); border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px; padding: 4px 10px; font-size: 16px; line-height: 1.3; }

/* banner: what is going on right now */
.ls-ban { --bc: var(--ls-pink); position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 84px; padding: 2px 12px 0; text-align: center; overflow: hidden; }
.ls-bmain { display: flex; align-items: center; justify-content: center; gap: 14px; max-width: 100%; }
.ls-bn { font-family: var(--display); font-size: clamp(22px, 5.2vw, 38px); letter-spacing: 1.5px; line-height: 1.1; color: #fff; text-shadow: 0 0 20px var(--bc), 0 3px 0 rgba(10, 5, 28, .9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-bsub { margin-top: 2px; min-height: 18px; max-width: 100%; font-size: 13px; font-weight: 800; color: #e4defa; text-shadow: 0 2px 0 rgba(10, 5, 28, .8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-ban[data-m="countdown"] { --bc: var(--ls-cyan); }
.ls-ban[data-m="music"] { --bc: var(--ls-pink); }
.ls-ban[data-m="scramble"] { --bc: var(--ls-gold); }
.ls-ban[data-m="scramble"] .ls-bn { color: var(--ls-gold); animation: ls-throb .5s ease-in-out infinite alternate; }
.ls-ban[data-m="result"] { --bc: #ff8a3d; }
.ls-ban[data-m="out"] { --bc: var(--ls-red); }
.ls-ban[data-m="out"] .ls-bn { color: #ff8a9a; }
.ls-ban[data-m="safe"] { --bc: var(--ls-green); }
.ls-ban[data-m="safe"] .ls-bn, .ls-ban[data-m="over"] .ls-bn { color: var(--ls-gold); }
.ls-ban[data-m="over"] { --bc: var(--ls-gold); }
@keyframes ls-throb { from { transform: scale(1); } to { transform: scale(1.06); } }

/* little equalizer next to the music title */
.ls-eq { display: flex; align-items: flex-end; gap: 3px; height: 26px; opacity: 0; transition: opacity .2s; }
.ls-eq.on { opacity: 1; }
.ls-eq i { display: block; width: 4px; height: 100%; border-radius: 2px; transform-origin: 50% 100%; transform: scaleY(.1); background: linear-gradient(0deg, var(--ls-cyan), var(--ls-pink)); box-shadow: 0 0 8px rgba(255, 61, 154, .6); }
.ls-ban:not([data-m="music"]) .ls-eq { display: none; }

/* timer bar of the scramble / countdown (always reserves its row) */
.ls-tbar { width: min(420px, 78%); height: 8px; margin-top: 4px; border-radius: 6px; background: rgba(255, 255, 255, .12); overflow: hidden; visibility: hidden; flex: none; }
.ls-tbar.show { visibility: visible; }
.ls-tbar i { display: block; height: 100%; width: 100%; transform-origin: 0 50%; border-radius: 6px; background: linear-gradient(90deg, var(--ls-green), var(--ls-gold)); box-shadow: 0 0 12px rgba(255, 210, 61, .7); }
.ls-tbar.low i { background: linear-gradient(90deg, var(--ls-red), #ff8a3d); animation: ls-blink .24s linear infinite alternate; }
@keyframes ls-blink { to { opacity: .55; } }

/* middle: stage (the canvas shows through) + player list */
.ls-mid { flex: 1; min-height: 0; display: flex; flex-direction: row; }
.ls-stage { position: relative; flex: 1; min-width: 0; min-height: 0; }
.ls-side { width: 214px; flex: none; padding: 6px 10px 10px 0; overflow: hidden; }
.ls-list { display: flex; flex-direction: column; gap: 5px; }

.ls-row { position: relative; display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; border-radius: 16px; background: var(--ls-panel); border: 1px solid rgba(255, 255, 255, .12); min-height: 36px; overflow: hidden; }
.ls-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pc, #9a92c4); box-shadow: 0 0 8px var(--pc, #9a92c4); }
.ls-row.me { border-color: var(--ls-gold); box-shadow: 0 0 0 1px rgba(255, 210, 61, .35); }
.ls-row.sit { border-color: rgba(77, 255, 160, .7); }
.ls-row.win { border-color: var(--ls-gold); box-shadow: 0 0 14px rgba(255, 210, 61, .45); }
.ls-row.out { opacity: .5; filter: grayscale(.8); }
.ls-av { display: flex; flex: none; width: 28px; height: 28px; margin-left: 2px; }
.ls-av canvas { width: 28px; height: 28px; display: block; }
.ls-nm { flex: 1; min-width: 0; font-size: 13px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-sc { font-size: 11px; font-weight: 800; color: #cfc8ee; flex: none; }
.ls-stt { font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; color: #b9b0e8; flex: none; text-align: right; }
.ls-row.sit .ls-stt { color: var(--ls-green); }
.ls-row.out .ls-stt { color: #ff8a9a; }

/* big centre messages */
.ls-big { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); font-family: var(--display); font-size: clamp(64px, 17vmin, 170px); line-height: 1; color: #fff; letter-spacing: 2px; white-space: nowrap; text-shadow: 0 0 28px var(--ls-cyan), 0 6px 0 rgba(10, 5, 28, .9); }
.ls-big.go { color: var(--ls-green); text-shadow: 0 0 30px var(--ls-green), 0 6px 0 rgba(10, 5, 28, .9); }
.ls-big.stop { font-size: clamp(54px, 15vmin, 150px); color: #fff3a0; text-shadow: 0 0 36px var(--ls-red), 0 0 12px var(--ls-gold), 0 6px 0 rgba(60, 5, 20, .9); }
.ls-big.on { animation: ls-pop .9s cubic-bezier(.2, 1.3, .3, 1) both; }
.ls-big.on.stop { animation: ls-slam 1s cubic-bezier(.2, 1.4, .3, 1) both; }
@keyframes ls-pop { 0% { transform: translate(-50%, -50%) scale(1.7); opacity: 0; } 22% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(.85); opacity: 0; } }
@keyframes ls-slam { 0% { transform: translate(-50%, -50%) scale(2.6) rotate(-4deg); opacity: 0; } 14% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; } 70% { transform: translate(-50%, -50%) scale(1.04); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(.9); opacity: 0; } }

.ls-toast { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); max-width: 92%; padding: 6px 14px; border-radius: 12px; font-size: 14px; font-weight: 800; text-align: center; color: #fff; background: rgba(120, 10, 30, .86); border: 1px solid rgba(255, 90, 120, .7); opacity: 0; transition: opacity .2s; }
.ls-toast.show { opacity: 1; }
.ls-spec { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); padding: 5px 16px; border-radius: 14px; font-size: 14px; font-weight: 900; color: #cfd6ff; background: var(--ls-panel); border: 1px solid rgba(207, 214, 255, .4); white-space: nowrap; }
.ls-hint { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 12px; font-weight: 700; color: rgba(228, 222, 250, .72); text-shadow: 0 2px 0 rgba(10, 5, 28, .85); padding: 0 8px; }

/* winner overlay */
.ls-final { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6, 3, 20, .5); animation: ls-fade .35s both; }
.ls-fcard { text-align: center; padding: 14px 24px 16px; border-radius: 24px; background: rgba(12, 6, 36, .8); border: 2px solid rgba(255, 210, 61, .7); box-shadow: 0 0 40px rgba(255, 210, 61, .35); animation: ls-pop-in .5s cubic-bezier(.2, 1.4, .3, 1) both; max-width: 92%; }
.ls-fcrown { font-size: 54px; line-height: 1; animation: ls-bounce .9s ease-in-out infinite alternate; }
.ls-ftitle { font-family: var(--display); font-size: clamp(26px, 6vw, 46px); color: var(--ls-gold); text-shadow: 0 0 22px rgba(255, 210, 61, .7), 0 4px 0 rgba(10, 5, 28, .9); margin: 4px 0 8px; overflow-wrap: anywhere; }
.ls-fplaces { display: flex; flex-direction: column; gap: 3px; align-items: stretch; }
.ls-fplace { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; color: #e4defa; }
.ls-fm { font-size: 18px; }
@keyframes ls-fade { from { opacity: 0; } }
@keyframes ls-pop-in { from { transform: scale(.6); opacity: 0; } }
@keyframes ls-bounce { to { transform: translateY(-8px) rotate(4deg); } }

/* touch buttons (shown on touch devices only) */
.ls-btns { position: absolute; right: 10px; bottom: 12px; display: flex; align-items: flex-end; gap: 14px; }
.ls-btn { position: relative; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .55); color: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 0 18px rgba(0, 0, 0, .35); }
.ls-btn b { position: relative; z-index: 1; font-family: var(--display); letter-spacing: 1px; text-shadow: 0 2px 0 rgba(10, 5, 28, .85); }
.ls-bsit { width: 108px; height: 108px; background: radial-gradient(circle at 35% 30%, #77ffc0, #14b87a 70%); border-color: #d9fff0; }
.ls-bsit b { font-size: 17px; }
.ls-bsit.hot { animation: ls-beat .45s ease-in-out infinite alternate; box-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 0 28px rgba(77, 255, 160, .85); }
.ls-bsit.done { filter: grayscale(.7) brightness(.8); }
.ls-bdash { width: 76px; height: 76px; background: radial-gradient(circle at 35% 30%, #8ae8ff, #1b84c4 70%); border-color: #d6f6ff; }
.ls-bdash b { font-size: 14px; }
.ls-bdash::after { content: ""; position: absolute; inset: 0; background: conic-gradient(rgba(10, 5, 28, .6) calc(var(--cd, 0) * 1turn), transparent 0); }
.ls-bdash.wait { filter: saturate(.55); }
.ls-btn.down { transform: translateY(3px) scale(.96); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
@keyframes ls-beat { to { transform: scale(1.07); } }

/* narrow screens: the list becomes a compact wrapping row above the stage */
@media (max-width: 860px) {
  .ls-top { padding-left: 8px; padding-right: 54px; gap: 6px; }
  .ls-chip { padding: 4px 9px; font-size: 12px; }
  .ls-ban { height: 70px; }
  .ls-bsub { font-size: 12px; }
  .ls-mid { flex-direction: column; }
  .ls-side { order: -1; width: auto; padding: 2px 8px 0; }
  .ls-list { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .ls-row { min-height: 0; padding: 2px 8px 2px 10px; border-radius: 999px; flex: 0 1 auto; max-width: 48%; }
  .ls-av, .ls-stt { display: none; }
  .ls-nm { font-size: 11px; max-width: 80px; }
  .ls-row.out .ls-nm { text-decoration: line-through; }
  .ls-hint { font-size: 11px; bottom: 2px; }
}
@media (max-height: 760px) and (min-width: 861px) {
  .ls-list { gap: 3px; }
  .ls-row { min-height: 29px; padding-top: 1px; padding-bottom: 1px; }
  .ls-av, .ls-av canvas { width: 22px; height: 22px; }
  .ls-ban { height: 72px; }
}
@media (max-height: 520px) {
  .ls-ban { height: 58px; }
  .ls-bn { font-size: 22px; }
  .ls-bsub { display: none; }
  .ls-btns { gap: 10px; }
  .ls-bsit { width: 88px; height: 88px; }
  .ls-bdash { width: 64px; height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .ls-big.on, .ls-big.on.stop, .ls-ban[data-m="scramble"] .ls-bn, .ls-bsit.hot, .ls-fcrown { animation: none; }
  .ls-big.on { opacity: 1; }
}
