:root {
  /* Arcade night: PICO-8-derived colors on a deep indigo screen. */
  --night: #0f0e1f;
  --well: #0a0917;          /* inputs sit "into" the screen */
  --panel: #17152d;
  --panel-2: #1e1b3a;
  --panel-3: #29254b;
  --line: #2e2a57;
  --line-strong: #4a4382;
  --bone: #fff1e8;
  --lilac: #bcb6df;
  --lilac-dim: #8f87b5;
  --coin: #ffa300;
  --coin-hi: #ffd27a;
  --coin-lo: #d17a00;
  --coin-edge: #9a5200;
  --ink: #16132b;           /* dark text on bright fills */
  --oneup: #00e436;
  --oneup-soft: rgba(0, 228, 54, 0.22);
  --hit: #ff004d;
  --hit-hi: #ff6b90;
  --hit-lo: #c4003b;
  --hit-edge: #82002a;
  --star: #ffec27;
  --sky: #29adff;

  /* Player colors: every name maps to one (app.js playerColor), so the same
     friend has the same color on their tile and in chat. No green or red -
     those mean "talking" and "muted". */
  --p1: #ffa300;
  --p2: #29adff;
  --p3: #ff77a8;
  --p4: #ffec27;
  --p5: #ffccaa;
  --p6: #b59cff;

  --font-display: "Pixelify Sans", "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
  --font-hud: "Silkscreen", "Pixelify Sans", ui-monospace, monospace;
  --font: "Chakra Petch", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* Size of one "pixel" in the stepped corners below. */
  --px: 3px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--bone);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: calc(var(--px) + 2px); }
::selection { background: var(--coin); color: var(--ink); }
button, input { font: inherit; color: inherit; }

/* ---------- stepped "pixel" corners ----------
   Four hard shadows draw a border that skips the four corner squares - the
   way a sprite's outline does - so every box gets notched corners with no
   images or clip-path. Components change --edge to recolor it. The ring sits
   outside the box, so parents leave at least --px of room around it. */
.btn, input:not([type="range"]), .channel, .mic-check, .tile, .side-panel, .now-playing,
.suggest, .music-queue li, .chat-bubble, .pill, .status-chip, .toast, .initial, .ring, .mic-flag, .bar, .you-tag {
  --edge: var(--line);
  --ring:
    0 calc(var(--px) * -1) 0 0 var(--edge),
    0 var(--px) 0 0 var(--edge),
    calc(var(--px) * -1) 0 0 0 var(--edge),
    var(--px) 0 0 0 var(--edge);
  box-shadow: var(--ring);
  border: 0;
  border-radius: 0;
}

/* ---------- background scene (sprites come from pixel-art.js) ---------- */
.scene {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(ellipse 900px 640px at 0% 0%, rgba(255, 163, 0, 0.09), transparent 62%),
    radial-gradient(ellipse 760px 640px at 100% 100%, rgba(41, 173, 255, 0.08), transparent 60%),
    radial-gradient(ellipse 620px 520px at 100% 0%, rgba(255, 119, 168, 0.06), transparent 60%),
    var(--night);
}
/* a faint pixel dot grid, like an unlit LED panel */
.scene::before {
  content: ""; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect width='2' height='2' fill='%23fff1e8' fill-opacity='0.05'/%3E%3C/svg%3E");
}
/* scanlines + vignette over the sprites (but under every panel) */
.scene::after {
  content: ""; position: absolute; inset: 0; z-index: 4;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.5));
}
.scene-layer { position: absolute; inset: -32px; } /* bleeds past the edges so parallax never shows one */
.scene-layer[data-depth="1"] { z-index: 1; opacity: 0.34; }
.scene-layer[data-depth="2"] { z-index: 2; opacity: 0.56; }
.scene-layer[data-depth="3"] { z-index: 3; opacity: 0.75; }
/* once the content reaches the screen edges, sprites end up behind text -
   pull them back so they never fight it */
@media (max-width: 1180px) {
  .scene-layer[data-depth="2"] { opacity: 0.4; }
  .scene-layer[data-depth="3"] { opacity: 0.45; }
}
.sprite { position: absolute; animation: bob 2s steps(3, jump-none) infinite alternate; }
.sprite svg { display: block; width: 100%; height: 100%; }
/* moves in whole art pixels - see --bob in pixel-art.js */
@keyframes bob { to { transform: translateY(var(--bob, -6px)); } }
.sprite.twinkles { animation-name: twinkle; animation-timing-function: steps(1, end); animation-direction: normal; }
@keyframes twinkle { 50% { opacity: 0.15; } }
/* In a call the page sits beside a game: freeze the sprites (no frames spent
   on decoration) and dim them so the tiles own the screen. */
body:has(#call:not([hidden])) .sprite { animation-play-state: paused; }
body:has(#call:not([hidden])) .scene-layer { opacity: 0.22; }

#lobby, #call { position: relative; z-index: 1; }

/* ---------- shared bits ---------- */
/* status LEDs (.count draws its own: app.js rewrites that element's text) */
.led, .count::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--lilac-dim); }
[data-state="live"] .led, [data-state="live"].count::before, .mic-check[data-state="ready"] .led {
  background: var(--oneup); box-shadow: 0 0 10px var(--oneup-soft);
}
[data-state="loading"] .led, [data-state="reconnecting"] .led, [data-state="reconnecting"].count::before, .mic-check[data-state="checking"] .led {
  background: var(--star); animation: blink 1s steps(1, end) infinite;
}
[data-state="down"] .led, .mic-check[data-state="off"] .led { background: var(--hit); }
@keyframes blink { 50% { opacity: 0.2; } }

.status-chip {
  --px: 2px;
  display: inline-flex; align-items: center; gap: 0.6rem; margin: 0; padding: 0.45rem 0.8rem;
  background: rgba(15, 14, 31, 0.78); color: var(--lilac);
  font-family: var(--font-hud); font-size: 0.75rem; line-height: 1; white-space: nowrap;
}

.section-label {
  display: flex; align-items: center; gap: 0.75rem; margin: 2.25rem 0 0.9rem;
  font-family: var(--font-hud); font-weight: 400; font-size: 0.75rem; letter-spacing: 0.04em; color: var(--lilac-dim);
}
/* dashed pixel rule that runs out from the label */
.section-label::after {
  content: ""; flex: 1; height: 3px;
  background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px);
}

.panel-head {
  align-self: stretch; display: flex; align-items: center; gap: 0.6rem;
  margin: calc(var(--pad, 0px) * -1) calc(var(--pad, 0px) * -1) 0;
  padding: 0.8rem 1rem;
  border-bottom: 3px solid var(--line);
  font-family: var(--font-hud); font-size: 0.75rem; line-height: 1; color: var(--lilac);
}

.hint { margin: 0.4rem 0 0; font-size: 0.875rem; color: var(--lilac-dim); }
.hint:empty { display: none; }
.note { margin: 0; color: var(--lilac-dim); font-size: 0.875rem; min-height: 1.2em; }
.note:empty { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.pill {
  --px: 2px;
  display: inline-flex; align-items: center; gap: 0.35rem; flex: none;
  padding: 0.3rem 0.5rem; background: var(--panel-3); color: var(--lilac);
  font-family: var(--font-hud); font-size: 0.6875rem; line-height: 1; white-space: nowrap;
}
.pill-lock { --edge: rgba(255, 236, 39, 0.45); background: rgba(255, 236, 39, 0.1); color: var(--star); }
.pill-lock::before {
  content: ""; width: 10px; height: 10px; background: currentColor;
  -webkit-mask: var(--icon-lock, linear-gradient(transparent, transparent)) center / contain no-repeat;
  mask: var(--icon-lock, linear-gradient(transparent, transparent)) center / contain no-repeat;
}

/* themed scrollbars */
.channels, .grid, .music, .lyrics, .suggest, .music-queue, .chat-log {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.channels::-webkit-scrollbar, .grid::-webkit-scrollbar, .music::-webkit-scrollbar,
.lyrics::-webkit-scrollbar, .suggest::-webkit-scrollbar, .music-queue::-webkit-scrollbar, .chat-log::-webkit-scrollbar { width: 6px; }
.channels::-webkit-scrollbar-thumb, .grid::-webkit-scrollbar-thumb, .music::-webkit-scrollbar-thumb,
.lyrics::-webkit-scrollbar-thumb, .suggest::-webkit-scrollbar-thumb, .music-queue::-webkit-scrollbar-thumb, .chat-log::-webkit-scrollbar-thumb { background: var(--line-strong); }

/* ---------- buttons: chunky bevelled arcade keys ---------- */
.btn {
  --face: var(--panel-3);
  --hi: rgba(255, 255, 255, 0.09);
  --lo: rgba(0, 0, 0, 0.3);
  --edge: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
  padding: 0.75rem 1.1rem;
  background: var(--face); color: var(--bone);
  font-family: var(--font-hud); font-size: 0.8125rem; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none;
  box-shadow: var(--ring), inset 0 var(--px) 0 0 var(--hi), inset 0 calc(var(--px) * -1) 0 0 var(--lo);
  transition: transform 120ms var(--ease-out);
}
/* Press: the key sinks two pixels and its bevel flips - instant feedback. */
.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: var(--ring), inset 0 var(--px) 0 0 var(--lo);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { --face: var(--coin); --hi: var(--coin-hi); --lo: var(--coin-lo); --edge: var(--coin-edge); color: var(--ink); }
.btn.danger { --face: var(--hit); --hi: var(--hit-hi); --lo: var(--hit-lo); --edge: var(--hit-edge); color: #fff; }
.btn.ghost { --face: rgba(15, 14, 31, 0.6); --hi: transparent; --lo: transparent; --edge: var(--line-strong); color: var(--lilac); }
.btn[aria-pressed="true"] { --face: rgba(255, 163, 0, 0.12); --edge: var(--coin); color: var(--coin); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { --edge: var(--lilac-dim); color: var(--bone); }
  .btn.primary:hover:not(:disabled) { --face: #ffb12e; --edge: var(--coin-edge); color: var(--ink); }
  .btn.danger:hover:not(:disabled) { --face: #ff1f62; --edge: var(--hit-edge); color: #fff; }
  .btn[aria-pressed="true"]:hover { --edge: var(--coin-hi); color: var(--coin-hi); }
}

/* Icons are 10x10 pixel masks (pixel-art.js), drawn at 20px or 30px so each
   art pixel is a whole number of screen pixels and stays sharp. */
.icon-label::before, .btn.icon::before, .mic-btn::before, .volume-icon, .mic-flag::before {
  content: ""; flex: none; width: 20px; height: 20px; background: currentColor;
  -webkit-mask: var(--icon, linear-gradient(transparent, transparent)) center / contain no-repeat;
  mask: var(--icon, linear-gradient(transparent, transparent)) center / contain no-repeat;
}
.icon-lock { --icon: var(--icon-lock); }
.icon-copy { --icon: var(--icon-copy); }
.icon-note { --icon: var(--icon-note); }
.icon-chat { --icon: var(--icon-chat); }
.icon-send { --icon: var(--icon-send); }
.btn.icon { width: 2.75rem; height: 2.75rem; padding: 0; }
.btn.icon.icon-lg { width: 3.75rem; height: 3.75rem; }
.btn.icon.icon-lg::before { width: 30px; height: 30px; }

/* ---------- inputs ---------- */
input:not([type="range"]) {
  min-width: 0; padding: 0.8rem 1rem;
  background: var(--well); color: var(--bone); font-family: var(--font); font-size: 1rem;
}
input:not([type="range"])::placeholder { color: var(--lilac-dim); opacity: 0.8; }
input:not([type="range"]):focus { outline: none; --edge: var(--coin); }

/* ---------- lobby ---------- */
.lobby {
  min-height: 100%; max-width: 1200px; margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.75rem) clamp(1rem, 5vw, 4rem) clamp(2rem, 6vw, 4rem);
  display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); grid-template-rows: auto 1fr;
  column-gap: clamp(1.5rem, 6vw, 5rem); align-items: center;
}
.topbar {
  grid-column: 1 / -1; align-self: start;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding-bottom: clamp(2rem, 6vh, 4rem);
}
.brand { display: flex; align-items: center; gap: 0.75rem; margin: 0; }
.brand-mark { display: block; width: 36px; height: 33px; } /* 12x11 sprite at 3px */
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.75rem; line-height: 1; color: var(--bone); }

h1 {
  margin: 0 0 1.1rem;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.5rem, 5.4vw, 4.25rem);
  line-height: 1; color: var(--bone);
  text-shadow: 4px 4px 0 #2b2160;
  text-wrap: balance;
}
.lede { margin: 0 0 2.25rem; max-width: 38ch; font-size: 1.0625rem; color: var(--lilac); }

.form { display: grid; gap: 0.5rem; max-width: 30rem; margin: 0 0 1.5rem; }
.form label { font-family: var(--font-hud); font-size: 0.75rem; color: var(--lilac); }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row input { flex: 1 1 10rem; }

.channels {
  list-style: none; margin: 0; padding: var(--px); max-width: 30rem; max-height: 16rem; overflow-y: auto;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(var(--px) * 2 + 0.4rem);
}
.channel { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.5rem 0.5rem 0.9rem; background: var(--panel); }
.channel::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--lilac-dim); }
.channel[data-state="live"]::before { background: var(--oneup); box-shadow: 0 0 10px var(--oneup-soft); }
.channel.invited { --edge: var(--coin); }
@media (hover: hover) and (pointer: fine) {
  .channel:hover { --edge: var(--line-strong); }
  .channel.invited:hover { --edge: var(--coin); }
}
.cname { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cname::before { content: "#"; margin-right: 0.15em; color: var(--lilac-dim); }
.meta { font-family: var(--font-hud); font-size: 0.6875rem; color: var(--lilac-dim); white-space: nowrap; }
.actions { margin-left: auto; display: flex; gap: 0.6rem; }
.actions .btn { padding: 0.6rem 0.9rem; font-size: 0.75rem; }

/* Mic check: your own player card before you join */
.mic-check {
  --pad: 1.75rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.2rem;
  padding: var(--pad); text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.mic-check .panel-head { margin-bottom: 0.6rem; }
.mic-avatar { position: relative; width: clamp(6.5rem, 13vw, 8.5rem); aspect-ratio: 1; }
.initial {
  --avatar: var(--lilac-dim);
  --edge: var(--avatar);
  position: relative; z-index: 1; width: 100%; height: 100%; display: grid; place-items: center;
  background: var(--avatar); color: var(--ink);
  font-family: var(--font-display); font-weight: 700; line-height: 1;
  box-shadow: var(--ring), inset 0 var(--px) 0 0 rgba(255, 255, 255, 0.35), inset 0 calc(var(--px) * -2) 0 0 rgba(0, 0, 0, 0.22);
}
.mic-avatar .initial { font-size: clamp(2.2rem, 4.5vw, 3rem); }
/* the talking ring: a green pixel outline that app.js pulses */
.ring {
  --edge: var(--oneup);
  position: absolute; inset: calc(var(--px) * -3); opacity: 0; pointer-events: none;
  box-shadow: var(--ring), 0 0 26px 2px var(--oneup-soft);
}
.mic-status { margin: 0; font-weight: 600; font-size: 1rem; color: var(--lilac); }
.mic-avatar.speaking + .mic-status { color: var(--oneup); }

/* live input level - lit from the same analyser as the talking ring */
.meter { display: flex; gap: 3px; }
.meter i { width: 12px; height: 16px; background: var(--panel-3); }
.meter i.on { background: var(--oneup); }
.meter i.on:nth-child(n+8) { background: var(--star); }
.meter i.on:nth-child(n+11) { background: var(--hit); }
.mic-check[data-state="off"] .meter { opacity: 0.35; }

/* ---------- call ---------- */
.call { height: 100%; width: 100%; max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; padding: 1rem clamp(0.75rem, 3vw, 2rem) 0; }
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem;
  margin: var(--px) var(--px) 1.25rem; padding: 0.7rem 0.8rem 0.7rem 1.1rem;
  background: rgba(23, 21, 45, 0.92);
}
.room { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.room-hash { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1; color: var(--coin); }
.bar h2 {
  margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.1; color: var(--bone);
}
.room .pill { margin-left: 0.4rem; }
.bar-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.bar .btn { padding: 0.6rem 0.85rem; font-size: 0.75rem; }

.call-body { flex: 1; min-height: 0; display: flex; gap: 1.25rem; }
.grid {
  flex: 1; min-height: 0; overflow-y: auto; align-content: start;
  display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
  padding: calc(var(--px) + 2px) calc(var(--px) + 2px) 1rem;
}

/* Voice tile: a player card, no video */
.tile {
  position: relative; aspect-ratio: 1 / 1; padding: 1rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.9rem;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.tile .avatar { position: relative; width: 44%; aspect-ratio: 1 / 1; }
.tile .avatar .initial { font-size: clamp(1.4rem, 3vw, 2rem); }
.tile[data-speaking="true"] { --edge: var(--oneup); }
.tile .label { display: flex; align-items: center; gap: 0.45rem; max-width: 100%; font-weight: 600; font-size: 0.95rem; }
.tile .label .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you-tag { --px: 2px; --edge: var(--coin); flex: none; padding: 0.2rem 0.35rem; background: var(--coin); color: var(--ink); font-family: var(--font-hud); font-size: 0.625rem; line-height: 1; }
.mic-flag {
  --px: 2px; --edge: var(--hit-edge); --icon: var(--icon-mic-off);
  position: absolute; right: 0.7rem; bottom: 0.7rem; width: 22px; height: 22px;
  display: none; place-items: center; background: var(--hit); color: #fff;
}
.mic-flag::before { width: 10px; height: 10px; }
.tile[data-muted="true"] .mic-flag { display: grid; }
/* still connecting: the avatar shows through dimmed, the status sits where
   the name will be */
.tile .state {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: end center; padding-bottom: 1.2rem;
  background: linear-gradient(180deg, rgba(23, 21, 45, 0.6), var(--panel) 70%);
  color: var(--lilac); font-family: var(--font-hud); font-size: 0.75rem;
}
.tile[data-state="connected"] .state, .tile.local .state { display: none; }
.tile[data-audio="stalled"] { --edge: var(--star); }
.tile[data-audio="stalled"]::after {
  content: "reconnecting audio…"; position: absolute; left: 0; right: 0; bottom: 0.7rem;
  text-align: center; font-family: var(--font-hud); font-size: 0.625rem; color: var(--star);
}

.controls { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: 1.1rem 0 calc(1.25rem + env(safe-area-inset-bottom, 0px)); }
.mic-btn { --icon: var(--icon-mic); width: 3.75rem; height: 3.75rem; padding: 0; }
.mic-btn::before { width: 30px; height: 30px; }
.mic-btn[aria-pressed="true"] {
  --icon: var(--icon-mic-off); --face: var(--hit); --hi: var(--hit-hi); --lo: var(--hit-lo); --edge: var(--hit-edge); color: #fff;
}
.controls .btn.danger { height: 3.75rem; padding: 0 1.6rem; font-size: 0.875rem; }

/* ---------- side panels: music + chat ---------- */
.side-panel {
  flex: none; width: min(22rem, 38vw); background: var(--panel);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
@starting-style {
  .side-panel { opacity: 0; transform: translateX(12px); }
}
.music { --pad: 1rem; display: flex; flex-direction: column; gap: 1rem; padding: var(--pad); overflow-y: auto; }
.music .section-label { margin: 0.25rem 0 0; }
.chat { display: flex; flex-direction: column; overflow: hidden; }
.yt-player-host { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; } /* audio only - no visible video */

.music-search { display: flex; flex-direction: column; gap: 0.4rem; position: relative; }
.search-row { display: flex; gap: 0.6rem; }
.search-row input { flex: 1; padding: 0.7rem 0.9rem; font-size: 0.95rem; }
.search-row .btn { padding: 0.6rem 0.8rem; font-size: 0.75rem; }

.suggest {
  list-style: none; margin: var(--px) 0 0; padding: 0.3rem; background: var(--panel-2); max-height: 16rem;
  overflow-x: hidden; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.15rem; z-index: 5;
}
.suggest-item { display: flex; align-items: center; gap: 0.65rem; padding: 0.45rem 0.55rem; cursor: pointer; }
.suggest-item.active { background: var(--panel-3); box-shadow: inset 3px 0 0 var(--coin); }
@media (hover: hover) and (pointer: fine) {
  .suggest-item:hover { background: var(--panel-3); box-shadow: inset 3px 0 0 var(--coin); }
}
.suggest-art { flex: none; width: 2.25rem; height: 2.25rem; object-fit: cover; background: var(--panel-3); }
.suggest-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.suggest-title { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-artist { font-size: 0.8rem; color: var(--lilac-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.now-playing { display: grid; gap: 0.8rem; margin: var(--px); padding: 0.9rem; background: var(--panel-2); }
.np-card { position: relative; display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem; overflow: hidden; isolation: isolate; }
.np-card::before {
  content: ""; position: absolute; inset: -20%; z-index: -1;
  background-image: var(--np-backdrop, none); background-size: cover; background-position: center;
  filter: blur(18px) saturate(1.3) brightness(0.5); transform: scale(1.2);
}
.np-art { --px: 2px; position: relative; flex: none; width: 3.5rem; height: 3.5rem; overflow: hidden; background: var(--panel-3); box-shadow: 0 0 0 2px var(--night); }
.np-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.np-meta { min-width: 0; }
.np-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; line-height: 1.15; color: var(--bone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-artist { margin: 0.2rem 0 0; font-size: 0.85rem; color: var(--lilac); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* karaoke-style lyrics */
.lyrics {
  max-height: 11rem; overflow-y: auto; display: grid; gap: 0.55rem; padding: 0.75rem 0.25rem;
  font-size: 0.92rem; font-weight: 500; color: var(--lilac-dim); text-align: center; scroll-behavior: smooth;
  mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
}
.lyrics:empty { display: none; }
.lyrics .line { margin: 0; opacity: 0.6; transform: scale(0.95); transition: color 250ms ease, opacity 250ms ease, transform 250ms var(--ease-out); }
.lyrics .line.current { color: var(--coin); font-weight: 700; opacity: 1; transform: scale(1); }

.progress-row, .volume-row { display: flex; align-items: center; gap: 0.6rem; }
.np-time { flex: none; width: 2.4rem; font-family: var(--font-hud); font-size: 0.6875rem; color: var(--lilac-dim); }
#np-time-duration { text-align: right; }
.music-controls { display: flex; align-items: center; justify-content: center; gap: 1rem; }
#music-playpause { --icon: var(--icon-play); }
/* stays the main coin key while playing - the icon alone shows the state */
#music-playpause[aria-pressed="true"] { --icon: var(--icon-pause); --face: var(--coin); --edge: var(--coin-edge); color: var(--ink); }
#music-skip { --icon: var(--icon-skip); }
#music-prev { --icon: var(--icon-prev); }
#music-autoplay { --icon: var(--icon-autoplay); }
#music-autoplay[aria-pressed="false"] { opacity: 0.55; }
.volume-icon { --icon: var(--icon-volume); color: var(--lilac-dim); }

/* range sliders: a pixel "HP bar" with a square thumb. --fill comes from app.js. */
input[type="range"] {
  --fill: 0%;
  flex: 1; height: 18px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(90deg, var(--coin) var(--fill), var(--panel-3) var(--fill)); }
input[type="range"]::-moz-range-track { height: 6px; background: var(--panel-3); }
input[type="range"]::-moz-range-progress { height: 6px; background: var(--coin); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-top: -4px;
  background: var(--bone); border: 0; border-radius: 0; box-shadow: 0 0 0 3px var(--night);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--bone); border: 0; border-radius: 0; box-shadow: 0 0 0 3px var(--night); }
input[type="range"]:focus-visible { outline: 2px solid var(--sky); outline-offset: 4px; }

.music-queue { list-style: none; margin: 0; padding: var(--px); display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(var(--px) * 2 + 0.3rem); }
.music-queue:empty::before { content: "Nothing queued. Search above to add a song."; font-size: 0.875rem; color: var(--lilac-dim); }
.music-queue li { display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.7rem; background: var(--panel-2); font-size: 0.875rem; }
.mq-thumb { flex: none; width: 2.1rem; height: 2.1rem; object-fit: cover; background: var(--panel-3); }
.music-queue .mq-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-queue .mq-artist { color: var(--lilac-dim); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Recently played: same rows as the queue, but each one is a button that
   adds the song to Up next again. */
.music-recent li { padding: 0; }
.music-recent .mq-again {
  display: flex; align-items: center; gap: 0.65rem; width: 100%; min-width: 0;
  padding: 0.5rem 0.7rem; background: none; border: 0; text-align: left; cursor: pointer;
}
.music-recent .mq-again:hover, .music-recent .mq-again:focus-visible { background: var(--panel-3); }
.music-recent .mq-thumb { opacity: 0.7; }

/* chat: the log scrolls, the composer stays pinned */
.chat-log { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 1rem 1rem 0.5rem; display: flex; flex-direction: column; gap: 0.8rem; }
.chat-log li { max-width: 88%; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
@starting-style {
  .chat-log li { opacity: 0; transform: translateY(4px); }
}
.chat-log .chat-name { margin-bottom: 0.3rem; font-family: var(--font-hud); font-size: 0.6875rem; color: var(--lilac); }
.chat-log .chat-bubble { --px: 2px; margin: var(--px); padding: 0.5rem 0.75rem; background: var(--panel-2); font-size: 0.9rem; overflow-wrap: break-word; }
.chat-form { flex: none; display: flex; gap: 0.6rem; padding: 0.8rem; border-top: 3px solid var(--line); }
.chat-form input { flex: 1; padding: 0.65rem 0.85rem; font-size: 0.95rem; }

/* ---------- toast: a game dialog box ---------- */
.toast {
  --edge: var(--line-strong);
  position: fixed; left: 0; right: 0; bottom: 6rem; z-index: 10;
  width: fit-content; max-width: calc(100% - 2rem); margin: 0 auto; padding: 0.75rem 1.1rem;
  background: var(--panel-3); color: var(--bone); font-size: 0.9375rem; text-align: center;
  box-shadow: var(--ring), 0 12px 0 -4px rgba(0, 0, 0, 0.35);
  opacity: 0; pointer-events: none; transform: translateY(8px);
  /* leaving is quicker than arriving */
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.toast.show { opacity: 1; transform: translateY(0); transition-duration: 240ms; }

/* ---------- smaller screens ---------- */
@media (max-width: 900px) {
  .call-body { flex-direction: column; }
  .side-panel { width: auto; max-height: 42vh; margin: 0 var(--px); }
  .grid { flex: 1 1 40%; }
}
@media (max-width: 800px) {
  .lobby { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; align-items: start; row-gap: 1.75rem; }
  .topbar { padding-bottom: 0; }
  .mic-check {
    --pad: 1.1rem;
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 1.25rem; row-gap: 0.55rem;
    text-align: left; order: -1; margin: var(--px);
  }
  .topbar { order: -2; }
  .mic-check .panel-head { grid-column: 1 / -1; margin-bottom: 0.35rem; }
  .mic-avatar { grid-row: span 3; width: 4.75rem; }
  .mic-avatar .initial { font-size: 1.75rem; }
  .meter i { width: 8px; height: 12px; }
  .bar { padding: 0.6rem 0.7rem; }
  .bar-actions { margin-left: 0; width: 100%; }
  .bar .btn { flex: 1 1 auto; }
  .count { order: 1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); }
  .sprite { scale: 0.7; }
}
@media (max-width: 480px) {
  /* one row of icon keys; the label text stays as each button's accessible name */
  .bar .icon-label { flex: 1 1 0; gap: 0; padding: 0.7rem 0; font-size: 0; }
  .channel { flex-wrap: wrap; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
}

/* ---------- reduced motion: keep fades, drop movement ---------- */
@media (prefers-reduced-motion: reduce) {
  .sprite, .led, .count::before { animation: none !important; }
  .btn { transition: none; }
  .btn:active:not(:disabled) { transform: none; }
  .toast, .toast.show { transform: none; transition-property: opacity; }
  .side-panel, .chat-log li { transition-property: opacity; }
  .lyrics .line, .lyrics .line.current { transform: none; }
  .lyrics { scroll-behavior: auto; }
}
