* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #f2f7fa;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
body.dark { background: #111318; }
canvas { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }

#overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35); padding: 16px; z-index: 10; touch-action: auto;
}
#overlay.hidden { display: none; }
.panel {
  width: 100%; max-width: 340px; background: #fff; color: #222; border-radius: 14px;
  padding: 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); text-align: center;
}
body.dark .panel { background: #1c1f26; color: #e8e8e8; }
h1 { margin: 0 0 12px; font-size: 30px; }
#stats:empty, #status:empty { display: none; }
#stats { margin: 0 0 12px; line-height: 1.5; }
#status { color: #c55; margin: 10px 0 0; font-size: 14px; }
input#name {
  width: 100%; font-size: 18px; padding: 10px 12px; border-radius: 8px; border: 1px solid #ccc;
  background: inherit; color: inherit; user-select: text; -webkit-user-select: text;
}
#play {
  width: 100%; margin-top: 10px; font-size: 20px; font-weight: 700; padding: 12px; border: 0;
  border-radius: 8px; background: #3b9a4a; color: #fff; cursor: pointer;
}
#play:active { transform: scale(0.98); }
.row { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 14px; font-size: 14px; }
.help { font-size: 13px; opacity: 0.8; margin-top: 10px; }
.help p { margin: 4px 0; }
.foot { font-size: 11px; opacity: 0.6; margin: 12px 0 0; }
body.touch .desktop, body:not(.touch) .mobile { display: none; }

#controls {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
  display: none; gap: 14px; align-items: flex-end; z-index: 5;
}
body.touch #controls { display: flex; }
#controls button {
  border: 2px solid rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.3); color: #fff;
  border-radius: 50%; font-weight: 700; touch-action: none;
}
#btn-split { width: 84px; height: 84px; font-size: 17px; }
#btn-eject { width: 64px; height: 64px; font-size: 20px; margin-bottom: 40px; }
#controls button:active { background: rgba(255, 255, 255, 0.3); }
.foot a { color: inherit; }

/* ---- voice chat */
body:not(.voice) .voice-only, body:not(.voice) #btn-mic, body:not(.voice) #voice-list { display: none; }
#btn-mic {
  position: fixed; left: calc(12px + env(safe-area-inset-left)); bottom: calc(52px + env(safe-area-inset-bottom));
  z-index: 5; display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px;
  border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.35);
  color: #fff; font: 600 13px system-ui, sans-serif; cursor: pointer; touch-action: none;
}
#btn-mic .icon { font-size: 18px; }
#btn-mic.off .icon { filter: grayscale(1); opacity: 0.7; }
#btn-mic.on { background: rgba(40, 170, 80, 0.85); border-color: #8f8; }
#btn-mic.denied { background: rgba(190, 50, 50, 0.8); }
body.touch #btn-mic { padding: 10px 14px 10px 10px; font-size: 14px; }
body.touch #btn-mic .icon { font-size: 22px; }

#voice-list {
  position: fixed; left: calc(12px + env(safe-area-inset-left)); bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 5; display: flex; flex-direction: column-reverse; gap: 4px; max-height: 40vh; overflow: hidden;
}
body.touch #voice-list { bottom: calc(112px + env(safe-area-inset-bottom)); }
#voice-list button {
  align-self: flex-start; border: 0; border-radius: 6px; padding: 3px 8px; cursor: pointer;
  background: rgba(0, 0, 0, 0.45); color: #fff; font: 12px system-ui, sans-serif; touch-action: none;
}
#voice-list button.muted { opacity: 0.6; text-decoration: line-through; }

#toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 20;
  background: rgba(0, 0, 0, 0.8); color: #fff; padding: 8px 14px; border-radius: 8px;
  font: 14px system-ui, sans-serif; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
#voice-note { font-size: 12px; opacity: 0.75; margin: 8px 0 0; }
#voice-note:empty { display: none; }
