:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --panel: #f2f2f5;
  --accent: #3b2db8;
  --danger: #d92d20;
  --stage: #0b0b0d;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #111114; --fg: #ececf0; --muted: #a1a1a6; --panel: #1c1c21; --accent: #8f83ff; }
}
:root[data-theme="dark"] { --bg: #111114; --fg: #ececf0; --muted: #a1a1a6; --panel: #1c1c21; --accent: #8f83ff; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
[hidden] { display: none !important; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); min-height: 1.2em; }

.panel { max-width: 30rem; margin: 10vh auto; padding: 0 16px; }
.panel h1 { margin-bottom: 0.3rem; }
form { display: grid; gap: 0.8rem; margin-top: 1.2rem; }
label { display: grid; gap: 0.25rem; font-weight: 600; font-size: 0.9rem; }
input[type="text"], input:not([type]) {
  font: inherit; padding: 0.55rem 0.7rem; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  background: var(--panel); color: var(--fg);
}
fieldset { border: 0; padding: 0; margin: 0; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--fg); }

button {
  font: inherit; border-radius: 8px; border: 0; padding: 0.45rem 0.75rem; cursor: pointer;
  background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--fg);
}
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: #fff; font-weight: 600; padding: 0.6rem 1.1rem; }
button.danger { background: var(--danger); color: #fff; font-weight: 600; }
button.on { background: var(--accent); color: #fff; }

#call { display: flex; flex-direction: column; height: 100vh; position: relative; background: var(--bg); }
#call:fullscreen { width: 100vw; height: 100vh; }
#banner, #sound-blocked { background: #b54708; color: #fff; padding: 6px 12px; font-size: 0.85rem; text-align: center; }
#notice {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: min(90vw, 40rem);
  background: rgba(20, 20, 24, .92); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 0.85rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
}
.note { background: color-mix(in srgb, #e5b800 20%, transparent); padding: 8px 12px; border-radius: 8px; font-size: 0.85rem; }
#bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--panel);
}
#people { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 44px; }
.person { display: flex; flex-direction: column; align-items: center; font-size: 0.75rem; gap: 2px; position: relative; }
.bubble {
  width: 40px; height: 40px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 0.85rem; outline: 3px solid transparent; outline-offset: 1px;
}
.bubble video { width: 100%; height: 100%; object-fit: cover; }
.bubble.speaking { outline-color: #2ecc71; }
.person .flags { position: absolute; top: -4px; right: -6px; font-size: 0.7rem; }
.person > span:not(.flags) { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.away { opacity: 0.45; }
#controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#controls label { display: flex; flex-direction: row; gap: 4px; font-weight: 500; font-size: 0.8rem; align-items: center; }

#knocks:empty { display: none; }
#knocks { padding: 6px 12px; display: grid; gap: 6px; }
.knock { display: flex; gap: 8px; align-items: center; background: color-mix(in srgb, var(--accent) 15%, transparent); padding: 6px 10px; border-radius: 8px; }
.knock span { flex: 1; }

#reaction-picker {
  position: absolute; right: 12px; top: 64px; z-index: 5; background: var(--panel); border-radius: 12px;
  padding: 8px; display: grid; grid-template-columns: repeat(8, 36px); gap: 4px; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
#reaction-picker button { font-size: 22px; padding: 2px; background: transparent; }

#stage { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--stage); }
#tabs { display: flex; gap: 4px; padding: 4px 8px; }
#tabs:empty { display: none; }
#tabs button { color: #eee; font-size: 0.8rem; }
#tabs button.on { background: var(--accent); }
#screen-wrap { position: relative; flex: 1; min-height: 0; outline: none; }
#screen-wrap:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--stage); }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#screen-wrap.drawing { cursor: crosshair; }
#badge {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6); color: #fff;
  padding: 3px 10px; border-radius: 6px; font-size: 0.8rem; pointer-events: none;
}
#badge:empty { display: none; }
#empty {
  position: absolute; inset: 0; display: grid; place-items: center; color: #8a8a90; pointer-events: none;
  padding: 0 24px; text-align: center;
}

#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.floater { position: absolute; bottom: 6%; display: flex; flex-direction: column; align-items: center; animation: rise 2.6s ease-out forwards; }
.floater .emoji { font-size: 48px; }
.floater .who {
  font-size: 0.75rem; color: #fff; padding: 1px 8px; border-radius: 999px; font-weight: 600;
  max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.floater img { max-height: 200px; border-radius: 10px; }
@keyframes rise {
  0% { transform: translateY(40px) scale(.5); opacity: 0; }
  12% { transform: translateY(0) scale(1.1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translateY(-260px) scale(1); opacity: 0; }
}
#media { display: none; }
