:root {
  --bg: #212a44;
  --bg-panel: rgba(38, 48, 78, 0.85);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f2f5fc;
  --text-dim: rgba(242, 245, 252, 0.72);
  --text-faint: rgba(242, 245, 252, 0.45);
  --accent: #4be1f9;
  --accent-soft: rgba(75, 225, 249, 0.2);
  --live: #ff3d82;
  --paper: #f7f4ec;
  --grid-line: rgba(125, 200, 255, 0.35);
  --boxShadow: 0 4px 15px rgba(0, 0, 0, 0.35);
  --ease: all 0.2s ease;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  /* one grid cell per bar: 4 beats @ 143 BPM */
  --bar: 1.67832s;
}

/* LIGHT THEME — toggled via .theme-toggle, persisted in localStorage */
body.theme-light {
  --bg: #dde3f0;
  --bg-panel: rgba(255, 255, 255, 0.82);
  --line: rgba(24, 34, 62, 0.16);
  --text: #1d2540;
  --text-dim: rgba(29, 37, 64, 0.7);
  --text-faint: rgba(29, 37, 64, 0.45);
  --accent: #0d7fa6;
  --accent-soft: rgba(13, 127, 166, 0.12);
  --live: #df1560;
  --paper: #ffffff;
  --grid-line: rgba(75, 115, 210, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 38%, #3d4c7d 0%, #2a3457 45%, var(--bg) 80%);
  color: var(--text);
  font-family: var(--font-sans);
}

button {
  border: none;
  display: inline-block;
  color: var(--text);
  background-color: var(--accent);
  font-family: var(--font-sans);
  font-size: 1em;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: var(--ease);
  border-radius: 10px;
}

/* STATUS BAR */
.status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: linear-gradient(rgba(23, 29, 48, 0.92), rgba(23, 29, 48, 0.6) 70%, transparent);
}

/* game header: song title | beat meter (dead center) | chips */
.stage-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.stage-bar .session-meta {
  justify-content: flex-end;
}

.song-name {
  font-weight: 800;
  font-size: 1.05em;
  letter-spacing: 0.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.brand {
  font-weight: 800;
  font-size: 1.05em;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.brand span {
  color: var(--accent);
  font-weight: 400;
}

.session-meta {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.72em;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
  background: rgba(23, 29, 48, 0.55);
}

.chip-room {
  color: var(--accent);
  border-color: rgba(75, 225, 249, 0.45);
}

.chip:empty {
  display: none;
}

.chip-me {
  color: var(--live);
  border-color: rgba(255, 61, 130, 0.45);
}

/* BEAT METER — 8 beats = one 2-bar loop, driven by the audio clock */
.beat-meter {
  display: flex;
  gap: 7px;
  align-items: center;
}

.beat-meter i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.05s linear, box-shadow 0.05s linear;
}

/* downbeats */
.beat-meter i.downbeat {
  width: 10px;
  height: 10px;
}

.beat-meter i.on {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.beat-meter i:first-child.on {
  background: var(--live);
  box-shadow: 0 0 10px var(--live);
}

/* LOADING / OVERLAY SCREENS */
.loading {
  position: fixed;
  background: radial-gradient(ellipse at 50% 32%, #3a4874 0%, #283252 55%, #1e2740 90%);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  top: 0px;
  left: 0px;
  z-index: 5000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.loading.hide {
  display: none;
}

/* FLOATING MUSICAL NOTES */
.music-notes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.music-note {
  position: absolute;
  font-size: 2rem;
  opacity: 0;
  animation: floatNote linear infinite;
  color: rgba(125, 200, 255, 0.3);
}

.music-note:nth-child(1)  { left:  5%; font-size: 1.8rem; animation-duration: 8s;  animation-delay: 0s;   }
.music-note:nth-child(2)  { left: 15%; font-size: 2.5rem; animation-duration: 10s; animation-delay: 1.5s; }
.music-note:nth-child(3)  { left: 25%; font-size: 1.5rem; animation-duration: 7s;  animation-delay: 3s;   }
.music-note:nth-child(4)  { left: 38%; font-size: 2rem;   animation-duration: 9s;  animation-delay: 0.5s; }
.music-note:nth-child(5)  { left: 50%; font-size: 3rem;   animation-duration: 11s; animation-delay: 2s;   }
.music-note:nth-child(6)  { left: 62%; font-size: 1.8rem; animation-duration: 8s;  animation-delay: 4s;   }
.music-note:nth-child(7)  { left: 72%; font-size: 2.2rem; animation-duration: 9s;  animation-delay: 1s;   }
.music-note:nth-child(8)  { left: 82%; font-size: 1.6rem; animation-duration: 7s;  animation-delay: 3.5s; }
.music-note:nth-child(9)  { left: 90%; font-size: 2.8rem; animation-duration: 10s; animation-delay: 2.5s; }
.music-note:nth-child(10) { left: 45%; font-size: 2rem;   animation-duration: 12s; animation-delay: 5s;   }

@keyframes floatNote {
  0% {
    bottom: -10%;
    opacity: 0;
    transform: translateX(0) rotate(0deg);
  }
  10% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.15;
  }
  90% {
    opacity: 0.05;
  }
  100% {
    bottom: 110%;
    opacity: 0;
    transform: translateX(40px) rotate(25deg);
  }
}

/* LOADING DOTS — bounce on the beat (143 BPM x 4) */
.loading-dots > div {
  width: 1.6rem;
  height: 1.6rem;
  background-color: rgba(75, 225, 249, 0.85);
  display: inline-block;
  border-radius: 50%;
  animation: var(--bar) bounce infinite ease-in-out both;
  margin: 0 4px;
}

.loading-dots .bounce {
  animation-delay: -0.3s;
}

.loading-dots .bounce2 {
  animation-delay: -0.15s;
}

@keyframes bounce {
  0%,80%,100%{
    transform: scale(0);
  }
  40%{
    transform: scale(1);
  }
}

/* MASTER WAITING SCREEN */
.master-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 28px 24px;
  margin: 12px;
  max-width: 400px;
  width: 100%;
  position: relative;
  z-index: 1;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}

.master-waiting .title,
.waiting-message .title {
  font-size: 1.7em;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text);
  text-align: center;
  margin: 0;
}

.master-waiting .title em,
.waiting-message .title em {
  font-style: normal;
  font-weight: 400;
  color: var(--accent);
}

.master-waiting .subtitle {
  font-size: 0.9em;
  color: var(--text-dim);
  margin: -12px 0 0 0;
  text-align: center;
}

.session-facts {
  display: flex;
  gap: 6px;
  margin: -8px 0 0 0;
}

.qr-code {
  background: #fff;
  padding: 14px;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

/* QR FULLSCREEN OVERLAY */
.qr-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(15, 19, 33, 0.94);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s;
  cursor: pointer;
}

.qr-overlay.active {
  opacity: 1;
}

.qr-overlay svg {
  width: min(80vw, 80vh);
  height: min(80vw, 80vh);
  background: #fff;
  padding: 24px;
  border-radius: 20px;
}

.qr-code svg {
  display: block;
}

.share-link-container {
  display: flex;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.share-link-container input {
  flex: 1;
  padding: 12px 14px;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.78em;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
  min-width: 0;
}

.copy-btn {
  border-radius: 0 !important;
  padding: 12px 20px;
  font-size: 0.85em;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.copy-btn:hover {
  background: rgba(34, 211, 238, 0.28);
}

.player-count {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.9em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-count::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.8);
  display: inline-block;
}

.loading-status {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 0.8em;
  margin: 0;
}

.start-btn {
  margin-top: 4px;
  width: 100%;
  border-radius: 12px;
  padding: 16px;
  font-size: 1.1em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--live), #ff5252);
  box-shadow: 0 6px 24px rgba(255, 45, 120, 0.4);
}

.start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(255, 45, 120, 0.6);
}

/* DEMO LINK — small, in flow below the modal content */
.demo-link {
  display: block;
  text-align: right;
  margin-top: 14px;
  color: var(--text-faint);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.75em;
  transition: color 0.2s;
}

.demo-link:hover {
  color: var(--text-dim);
}

/* CLIENT WAITING SCREEN */
.waiting-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  position: relative;
  z-index: 1;
  padding: 24px;
  text-align: center;
}

.waiting-message p {
  color: var(--text-dim);
  font-size: 1em;
  margin: 0;
  text-align: center;
}

.waiting-message .loading-dots {
  margin-bottom: 0;
}

.avatar-big {
  font-size: 3.2em;
  line-height: 1;
}

.avatar-big:empty {
  display: none;
}

/*  STAGE  */
.container {
  width: 94%;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
}

.row {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
}

.instruments {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  z-index: 1;
  width: 100%;
  justify-content: center;
  margin-top: -6%;
}

.instrument {
  position: relative;
  width: calc(20% - 10px);
  padding-bottom: 22%;
  min-width: 0;
  max-width: 240px;
  background-color: var(--paper);
  background-repeat: no-repeat;
  background-size: 82%;
  background-position: center 38%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
}

@media (hover: hover) {
  .instrument:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  }
}

/* instrument name / variant label */
.instrument::after {
  content: attr(data-label);
  position: absolute;
  bottom: 6%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: clamp(9px, 1.5vw, 13px);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(11, 13, 20, 0.55);
  pointer-events: none;
}

/* state badge: the player's avatar sticker on the occupied tile */
.tile-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(11, 13, 20, 0.65);
  pointer-events: none;
}

.tile-badge img {
  display: block;
  width: clamp(18px, 2.4vw, 26px);
  height: clamp(18px, 2.4vw, 26px);
}

.tile-badge b {
  font-family: var(--font-mono);
  font-size: clamp(11px, 1.6vw, 15px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  padding-right: 3px;
}

.tile-badge.badge-me {
  background: var(--live);
}

/* On the master (stage/beamer view) taken instruments ARE the live band —
   highlight them and show who is playing */
body.is-master .instruments .instrument.taken {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 0 3px var(--accent), 0 0 24px rgba(75, 225, 249, 0.45);
}

/* "Allein spielen": instruments the master left running */
body.is-master .instruments .instrument.solo {
  box-shadow: 0 0 0 3px var(--accent), 0 0 24px rgba(75, 225, 249, 0.45);
}

body.is-master .instruments .instrument.taken .tile-badge {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

.variants .instrument {
  width: calc(20% - 8px);
  padding-bottom: 22%;
  max-width: 170px;
}

.variants {
  display: flex;
  justify-content: center;
  position: absolute;
  bottom: 4%;
  bottom: max(4%, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
}

.variant-row {
  width: 62%;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.hide {
  display: none;
}

/* avatar sticker sizes across the UI */
.avatar-chip {
  width: 1.35em;
  height: 1.35em;
  vertical-align: -0.38em;
}

.avatar-big-img {
  width: 84px;
  height: 84px;
}

.avatar-count {
  width: 1.7em;
  height: 1.7em;
  vertical-align: middle;
  margin-right: 2px;
}

.chip svg {
  width: 1.15em;
  height: 1.15em;
  display: block;
}

.stage-btn svg {
  width: 21px;
  height: 21px;
  display: block;
  margin: 0 auto;
}

.music-note svg {
  width: 1em;
  height: 1em;
  display: block;
}

.emph {
  opacity: 0.5;
}

.taken {
  opacity: 0.35;
  filter: grayscale(85%);
  cursor: not-allowed;
  pointer-events: none;
}

.mine,
.variants .instrument.active {
  opacity: 1;
  box-shadow: 0 0 0 3px var(--live), 0 0 24px rgba(255, 45, 120, 0.45);
}

.variants .instrument.active {
  box-shadow: 0 0 0 3px var(--accent), 0 0 24px rgba(34, 211, 238, 0.45);
  /* The host switches variants on the next bar line, so a freshly tapped
     variant swells in over one bar instead of snapping on: the tap is
     registered, the sound is on its way. Runs once per activation. */
  animation: cue var(--bar) ease-out;
}

@keyframes cue {
  from {
    opacity: 0.45;
    transform: scale(0.88);
  }
}

/* PERSPECTIVE GRID BACKDROP */
.wrap {
  width: 100%;
  height: 100%;
  position: absolute;
  margin: 0 auto;
  perspective: 360px;
  /* the animated planes extend far beyond the viewport — clip them here,
     otherwise scrollable pages (dashboard/editor) get horizontal overflow */
  overflow: hidden;
  perspective-origin: 50% 50%;
  /* fade the grid out toward the horizon: converging lines there collapse
     to subpixel spacing and shimmer (moiré) while the planes move */
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 43%, transparent 57%, #000 70%);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 43%, transparent 57%, #000 70%);
}

.top-plane, .bottom-plane {
  width: 200%;
  height: 130%;
  position: absolute;
  bottom: -30%;
  left: -50%;
  background-image: linear-gradient(var(--grid-line) 2px, transparent 2px), linear-gradient(90deg, var(--grid-line) 2px, transparent 2px);
  background-size: 100px 100px, 100px 100px;
  background-position: -1px -1px, -1px -1px;
  transform: rotateX(85deg) translateY(-100px);
  animation: planeMoveTop var(--bar) infinite linear;
  will-change: transform;
}

.bottom-plane {
  transform: rotateX(-85deg) translateY(0);
  top: -30%;
  animation: planeMoveBot var(--bar) infinite linear;
}

/* animate transform (composited, subpixel-smooth) instead of
   background-position (repaints and pixel-snaps every frame) —
   translateY runs along the tilted plane, one grid cell per bar */
@keyframes planeMoveTop {
  from {
    transform: rotateX(85deg) translateY(-100px);
  }
  to {
    transform: rotateX(85deg) translateY(0);
  }
}
@keyframes planeMoveBot {
  from {
    transform: rotateX(-85deg) translateY(0);
  }
  to {
    transform: rotateX(-85deg) translateY(-100px);
  }
}
@media (max-height: 350px) {
  .wrap {
    perspective: 210px;
  }
}

/* MOBILE */
@media (max-width: 600px) {
  .status-bar {
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 8px;
  }
  .brand {
    font-size: 0.9em;
  }
  .beat-meter {
    gap: 5px;
  }
  .beat-meter i {
    width: 6px;
    height: 6px;
  }
  .beat-meter i.downbeat {
    width: 8px;
    height: 8px;
  }
  .instruments {
    gap: 6px;
    margin-top: -4%;
  }
  .instrument {
    border-radius: 10px;
  }
  .variants .instrument {
    width: 23%;
    padding-bottom: 25%;
  }
  .variant-row {
    width: 94%;
    gap: 8px;
  }
  .variants {
    bottom: 5%;
    bottom: max(5%, env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .session-meta .chip:nth-child(2) {
    display: none;
  }
}

/* STAGE MODALS (master only): settings + share, above everything */
.stage-overlay {
  position: fixed;
  inset: 0;
  z-index: 6500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 13, 24, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.stage-overlay.open {
  opacity: 1;
}

.stage-overlay.hide {
  display: none;
}

.stage-modal {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  padding: 24px 26px;
  width: min(520px, 94vw);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
}

.stage-modal .modal-title {
  margin: 0 0 6px;
  font-size: 1.25em;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.modal-x {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1em;
  padding: 6px 9px;
  cursor: pointer;
  border-radius: 8px;
}

.modal-x:hover {
  color: var(--text);
}

/* share modal: the QR code IS the content */
.qr-wrap {
  position: relative;
  width: max-content;
  margin: 16px auto 10px;
  cursor: zoom-in;
}

.qr-wrap .qr-code svg {
  display: block;
  width: min(280px, 62vw);
  height: min(280px, 62vw);
}

.qr-zoom {
  position: absolute;
  right: -12px;
  bottom: -12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0d14;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.qr-zoom svg {
  width: 19px;
  height: 19px;
}

.share-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.92em;
  margin: 0 0 14px;
}

.bg-thumb {
  width: 52px;
  height: 34px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line);
}

.share-count {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text-dim);
  margin: 12px 0 4px;
  min-height: 1.8em;
}

.share-start {
  margin-top: 8px;
}

.bg-image-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.bg-image-tools.hide {
  display: none;
}

.bg-image-tools button {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 0.85em;
  font-weight: 600;
}

.bg-image-tools button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.form-mini {
  font-size: 0.8em;
  color: var(--text-faint);
}

/* floating stage action buttons (master, bottom left) */
.stage-actions {
  position: fixed;
  bottom: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 16px;
  z-index: 6000;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-actions.hide {
  display: none;
}

.start-pill {
  padding: 11px 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--live), #ff5c74);
  color: #fff;
  font-weight: 800;
  font-size: 1em;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 24px rgba(255, 45, 120, 0.45);
}

.start-pill:disabled {
  opacity: 0.6;
  cursor: wait;
}

.settings-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95em;
  letter-spacing: 0.04em;
}

.settings-info {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 0.72em;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.settings-label {
  margin: 12px 0 6px;
  font-family: var(--font-mono);
  font-size: 0.68em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.settings-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.settings-row button {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 0.85em;
  font-weight: 600;
}

.settings-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.settings-row button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* stage background: plain/custom image hide the retro grid */
body.bg-plain .wrap,
body.bg-image .wrap {
  display: none;
}

/* visualization canvas (waveform / dancing avatars), behind the tiles */
#viz {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
}

body.viz-wave #viz,
body.viz-pulse #viz {
  display: block;
}

/* session locked by the master: everything freezes (instruments + variants) */
body.locked .instruments .instrument,
body.locked .variants .instrument {
  cursor: not-allowed;
}

body.locked .instruments .instrument:not(.taken):not(.mine),
body.locked .variants .instrument:not(.active) {
  opacity: 0.45;
  filter: grayscale(60%);
}

/* round stage buttons (settings, share) — sit in .stage-actions */
.stage-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text-dim);
  line-height: 1;
  padding: 0;
}

.stage-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* LIGHT THEME — hardcoded surfaces */
body.theme-light {
  background: radial-gradient(ellipse at 50% 38%, #ffffff 0%, #edf1fa 45%, var(--bg) 85%);
}

body.theme-light .loading {
  background: radial-gradient(ellipse at 50% 32%, #ffffff 0%, #eef2fb 55%, #dde3f0 90%);
}

body.theme-light .status-bar {
  background: linear-gradient(rgba(245, 248, 255, 0.95), rgba(245, 248, 255, 0.65) 70%, transparent);
}

body.theme-light .chip {
  background: rgba(255, 255, 255, 0.65);
}

body.theme-light .beat-meter i {
  background: rgba(29, 37, 64, 0.22);
}

body.theme-light .music-note {
  color: rgba(75, 115, 210, 0.35);
}

body.theme-light .share-link-container input {
  background: rgba(24, 34, 62, 0.06);
}

body.theme-light .qr-code {
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(29, 37, 64, 0.18);
}

body.theme-light .qr-overlay {
  background: rgba(235, 240, 250, 0.96);
}

body.theme-light .instrument {
  border-color: rgba(24, 34, 62, 0.14);
  box-shadow: 0 6px 18px rgba(29, 37, 64, 0.16);
}

body.theme-light .instruments .instrument.taken .tile-badge {
  background: rgba(29, 37, 64, 0.12);
}

body.theme-light .master-waiting {
  box-shadow: 0 12px 40px rgba(29, 37, 64, 0.14);
}
