@font-face { font-family: Itim; src: url(../assets/fonts/itim-thai-400-normal.woff2) format('woff2');
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; font-display: swap; }
@font-face { font-family: Itim; src: url(../assets/fonts/itim-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; font-display: swap; }

:root {
  --sky: #cfe9ff;
  --panel: #ffffff;
  --soft: #f4f6fa;
  --line: #e4e8f0;
  --ink: #23263a;
  --muted: #6b7385;
  --accent: #ff9f1c;
  --accent-deep: #e9860a;
  --accent-soft: #fff1dc;
  --blue: #2f6de0;
  --blue-soft: #e6efff;
  --green: #1fb46a;
  --red: #e5484d;
  --red-soft: #ffe8e8;
  --shadow: 0 6px 24px rgba(35, 45, 80, .14), 0 1px 3px rgba(35, 45, 80, .08);
  --r: 16px;
  font-family: Itim, "Noto Sans Thai", "Leelawadee UI", Thonburi, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); }
body { font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#boot { position: fixed; inset: 0; display: grid; place-items: center; font-size: 22px; color: var(--muted); background: var(--sky); z-index: 50; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }

.chip { position: fixed; background: var(--panel); border-radius: 999px; box-shadow: var(--shadow); padding: 8px 16px; display: flex; gap: 10px; align-items: center; }
#where { top: 12px; left: 12px; font-size: 16px; }
#where-call { color: var(--muted); font-size: 14px; }
#where-call:empty { display: none; }
#netstate { top: 58px; left: 12px; background: var(--red-soft); color: var(--red); }

#recbanner { position: fixed; top: 12px; right: 12px; background: var(--red); color: #fff; border-radius: 999px; padding: 8px 16px; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow); }
#recbanner .dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; }

/* Video tiles of the people in the call */
#tiles { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; max-width: calc(100vw - 420px); overflow-x: auto; padding: 2px; scrollbar-width: none; }
#tiles:empty { display: none; }
.tile { position: relative; width: 168px; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; flex: none; box-shadow: var(--shadow); background: #3a3f55; cursor: pointer; transition: box-shadow .15s; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.screen video { object-fit: contain; background: #10162a; }
.tile.me video { transform: scaleX(-1); }
.tile .face { position: absolute; inset: 0; display: grid; place-items: center; font-size: 38px; color: rgba(255, 255, 255, .95); }
.tile .name { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 40px); background: rgba(20, 24, 40, .66); color: #fff; font-size: 13px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .muted { position: absolute; right: 6px; bottom: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; }
.tile .muted svg { width: 14px; height: 14px; }
.tile .hand { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.tile .hand svg { width: 16px; height: 16px; }
/* (speaking box: see below) */
.tile .linking { position: absolute; left: 0; right: 0; top: 0; padding: 4px 8px; background: rgba(255, 159, 28, .92); color: #fff; font-size: 12px; text-align: center; }
#hud:has(#sheet:not([hidden])) #mapwrap { display: none; }
@media (max-width: 1200px) { #mapwrap { bottom: 96px; } }

#stage { position: fixed; left: 50%; top: 126px; transform: translateX(-50%); width: min(72vw, 1180px); background: #10162a; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
#stage-box { aspect-ratio: 16 / 9; max-height: calc(100vh - 260px); width: 100%; position: relative; overflow: hidden; touch-action: none; cursor: zoom-in; }
#stage-box.zoomed { cursor: grab; }
#stage-box.dragging { cursor: grabbing; }
.zoomer { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; display: grid; place-items: center; }
.zoomer video { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage-bar { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; background: linear-gradient(rgba(10, 14, 28, .6), transparent); color: #fff; pointer-events: none; }
.stage-bar > * { pointer-events: auto; }
.stage-tools { display: flex; gap: 2px; align-items: center; background: rgba(10, 14, 28, .55); border-radius: 12px; padding: 2px; }
.stage-tools .icon-btn:hover { background: rgba(255, 255, 255, .16); }
.zoom-pct { min-width: 52px; height: 32px; border-radius: 10px; font-size: 13px; color: #fff; }
.zoom-pct:hover { background: rgba(255, 255, 255, .16); }
.stage-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(10, 14, 28, .62); color: #fff; font-size: 13px; padding: 5px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap; transition: opacity .4s; }
.stage-hint.gone { opacity: 0; }
#stage:fullscreen { width: 100vw; height: 100vh; max-width: none; left: 0; top: 0; transform: none; border-radius: 0; }
#stage:fullscreen #stage-box { aspect-ratio: auto; max-height: none; height: 100vh; }
#stage:-webkit-full-screen { width: 100vw; height: 100vh; left: 0; top: 0; transform: none; border-radius: 0; }
#stage:-webkit-full-screen #stage-box { aspect-ratio: auto; max-height: none; height: 100vh; }

/* Context actions above the control bar */
#prompt { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 90vw; }
#prompt:empty { display: none; }
.act { background: var(--panel); border-radius: 999px; box-shadow: var(--shadow); padding: 9px 16px; display: flex; gap: 8px; align-items: center; font-size: 15px; }
.act:hover { background: var(--accent-soft); }
.act.primary { background: var(--accent); color: #fff; }
.act.primary:hover { background: var(--accent-deep); }
.act.danger { background: var(--red-soft); color: var(--red); }
.act kbd { font: inherit; font-size: 12px; background: var(--soft); color: var(--muted); border-radius: 6px; padding: 1px 6px; }
.act.primary kbd { background: rgba(255, 255, 255, .25); color: #fff; }
.act svg { width: 18px; height: 18px; }

/* Control bar */
#bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--panel); border-radius: 22px; box-shadow: var(--shadow); padding: 6px; display: flex; gap: 2px; align-items: stretch; }
#bar .group { display: flex; gap: 2px; padding: 0 4px; }
#bar .group + .group { border-left: 1px solid var(--line); }
.ctl { position: relative; width: 62px; border-radius: 16px; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink); }
.ctl span { font-size: 12px; color: var(--muted); }
.ctl:hover { background: var(--soft); }
.ctl.off { color: var(--red); }
.ctl.off span { color: var(--red); }
.ctl.on { background: var(--blue-soft); color: var(--blue); }
.ctl.on span { color: var(--blue); }
.ctl.live { background: var(--red); color: #fff; }
.ctl.live span { color: #fff; }
.ctl .badge, .ctl .count { position: absolute; top: 4px; right: 10px; min-width: 18px; height: 18px; border-radius: 9px; font-size: 11px; font-weight: normal; display: grid; place-items: center; padding: 0 5px; }
.ctl .badge { background: var(--red); color: #fff; }
.ctl .count { background: var(--soft); color: var(--muted); }
.ctl .count:empty { display: none; }

.pop { position: fixed; background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 8px; }
#reacts { bottom: 92px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
#reacts button { font-size: 26px; width: 46px; height: 46px; border-radius: 12px; }
#reacts button:hover { background: var(--soft); }

.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: inherit; }
.icon-btn:hover { background: rgba(127, 140, 170, .16); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.small svg { width: 18px; height: 18px; }

/* Side panels */
.panel { position: fixed; top: 12px; bottom: 94px; width: 340px; background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.panel.right { right: 12px; }
.panel header { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 6px 18px; }
.panel h2 { font-size: 20px; font-weight: normal; margin: 0; }
.tabs { display: flex; gap: 4px; padding: 4px 12px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.tab { padding: 6px 12px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.tab.sel { background: var(--ink); color: #fff; }
.tab .n { background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; }

#chat-list { flex: 1; overflow-y: auto; padding: 4px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; align-self: flex-start; }
.msg .who { font-size: 12px; color: var(--muted); margin: 0 0 2px 10px; }
.msg .text { background: var(--soft); border-radius: 16px 16px 16px 4px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.msg.mine { align-self: flex-end; }
.msg.mine .who { text-align: right; margin: 0 10px 2px 0; }
.msg.mine .text { background: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg .text a { color: inherit; }
.chat-empty { color: var(--muted); text-align: center; margin: 40px 12px; line-height: 1.6; }
#chat-form { display: flex; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
#chat-input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 9px 12px; outline: none; }
#chat-input:focus { border-color: var(--accent); background: #fff; }
#chat-form .icon-btn { background: var(--accent); color: #fff; }

#people-list, #videos-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; }
.person:hover { background: var(--soft); }
.person .av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 18px; flex: none; position: relative; }
.person .av.on::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 2px solid #fff; }
.person .av.away::after { background: #aab1bf; }
.person .meta { flex: 1; min-width: 0; }
.person .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .zn { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .btns { display: flex; gap: 2px; }
.section-title { font-size: 13px; color: var(--muted); margin: 12px 10px 4px; display: flex; align-items: center; gap: 8px; }
.section-title .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.section-title .dot.off { background: #aab1bf; }
.people-tools { padding: 0 12px 2px; display: flex; flex-direction: column; gap: 6px; flex: none; }
#people-q { border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 8px 12px; outline: none; }
#people-q:focus { border-color: var(--accent); background: #fff; }
.people-tools .tabs { padding: 0; }
.person.offline .av { filter: grayscale(.75); opacity: .55; }
.person.offline .nm { color: var(--muted); }
.person .av.off::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #c3c8d2; border: 2px solid #fff; }
.person .zn .on-txt { color: var(--green); }

.video-row { padding: 10px; border-radius: 14px; display: flex; flex-direction: column; gap: 6px; }
.video-row:hover { background: var(--soft); }
.video-row .t { font-size: 16px; }
.video-row .s { font-size: 13px; color: var(--muted); }
.video-row .row { display: flex; gap: 6px; flex-wrap: wrap; }
.video-row video { width: 100%; border-radius: 10px; background: #000; }
.mini { padding: 5px 12px; border-radius: 999px; background: var(--soft); font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.mini:hover { background: var(--line); }
.mini.danger { color: var(--red); }
.mini svg { width: 16px; height: 16px; }

#mapwrap { position: fixed; left: 12px; bottom: 14px; background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 6px; }
#minimap { width: 168px; height: 190px; display: block; cursor: pointer; border-radius: 12px; }
#mapwrap.big #minimap { width: 300px; height: 340px; }

#card { min-width: 220px; padding: 14px; }
#card h3 { margin: 0 0 2px; font-weight: normal; font-size: 18px; }
#card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
#card .row { display: flex; gap: 6px; flex-wrap: wrap; }

/* Side sheet for the character maker and the decorator */
#sheet { position: fixed; left: 12px; top: 12px; bottom: 94px; width: 380px; background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
#sheet header { display: flex; justify-content: space-between; align-items: center; padding: 14px 12px 6px 18px; }
#sheet h2 { margin: 0; font-weight: normal; font-size: 20px; }
#sheet .body { flex: 1; overflow-y: auto; padding: 4px 14px 14px; }
#sheet footer { display: flex; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
#sheet footer .primary { flex: 1; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { padding: 7px 12px; border-radius: 12px; background: var(--soft); font-size: 14px; border: 2px solid transparent; }
.opt:hover { background: var(--line); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatch.sel { box-shadow: 0 0 0 3px var(--accent); }
.lbl { font-size: 13px; color: var(--muted); margin: 14px 2px 6px; }
.items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.item { background: var(--soft); border-radius: 14px; padding: 6px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; border: 2px solid transparent; }
.item img { width: 84px; height: 84px; }
.item:hover { background: var(--line); }
.item.sel { border-color: var(--accent); background: var(--accent-soft); }
.floor-sw { width: 52px; height: 40px; border-radius: 10px; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.floor-sw.sel { box-shadow: 0 0 0 3px var(--accent); }
.edit-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 8px 2px; }

.primary { background: var(--accent); color: #fff; border-radius: 14px; padding: 11px 18px; font-size: 16px; }
.primary:hover { background: var(--accent-deep); }
.primary.big { width: 100%; padding: 14px; font-size: 18px; border-radius: 16px; }
.secondary { background: var(--soft); border-radius: 14px; padding: 11px 16px; }
.secondary:hover { background: var(--line); }

/* Join screen: the card on the left, the character on the right */
#join { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; padding: 24px; pointer-events: none; }
.join-card { pointer-events: auto; width: min(440px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; background: var(--panel); border-radius: 24px; box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; gap: 14px; align-items: center; }
.brand .logo { width: 58px; height: 58px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 19px; flex: none; }
.brand h1 { margin: 0; font-weight: normal; font-size: 28px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input { border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 11px 14px; outline: none; font-size: 17px; color: var(--ink); }
.field input:focus { border-color: var(--accent); background: #fff; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.presets .opt { padding: 8px 4px; text-align: center; font-size: 13px; }
.devices { display: flex; gap: 16px; flex-wrap: wrap; }
#j-google-btn { min-height: 44px; }
.gme { display: flex; gap: 10px; align-items: center; background: var(--soft); border-radius: 14px; padding: 8px 10px; color: var(--ink); }
.gme img { width: 40px; height: 40px; border-radius: 50%; background: var(--line); }
.gme div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gme small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.person .av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.person .em { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signout { margin-top: 14px; }
.switch { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.note { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 0; }
.note.warn { color: var(--red); }

#toasts { position: fixed; left: 50%; top: 130px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 30; pointer-events: none; }
.toast { background: rgba(28, 32, 50, .9); color: #fff; border-radius: 14px; padding: 10px 16px; max-width: 520px; text-align: center; line-height: 1.45; animation: toast .2s ease-out; }
.toast.action { pointer-events: auto; display: flex; gap: 10px; align-items: center; }
.toast.action button { background: var(--accent); color: #fff; border-radius: 10px; padding: 5px 12px; }
.toast.action button.no { background: rgba(255, 255, 255, .16); }
@keyframes toast { from { opacity: 0; transform: translateY(-6px); } }

.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; color: var(--ink); border-radius: 14px; padding: 6px 12px; max-width: 240px; font-size: 14px; line-height: 1.4; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
.float { position: absolute; transform: translate(-50%, -100%); font-size: 34px; animation: float 2.2s ease-out forwards; }
@keyframes float { to { transform: translate(-50%, -260%); opacity: 0; } }

@media (max-width: 900px) {
  #tiles { max-width: calc(100vw - 24px); top: 58px; }
  .tile { width: 120px; }
  .panel, #sheet { left: 8px; right: 8px; width: auto; top: auto; height: 62vh; bottom: 88px; }
  #mapwrap { display: none; }
  .ctl { width: 46px; }
  .ctl span { display: none; }
  #bar { bottom: 10px; max-width: calc(100vw - 16px); overflow-x: auto; }
  #stage { width: calc(100vw - 16px); top: 140px; }
  #join { align-items: flex-end; }
}

/* ---------- Phones ---------- */
.ctl[hidden] { display: none !important; }
#b-more { display: none; }
/* The thumbstick: resting at the lower left, it jumps under the thumb while held. Input is read on the 3D view. */
#hud > #joy { position: fixed; left: 22px; bottom: calc(150px + env(safe-area-inset-bottom)); width: 112px; height: 112px; border-radius: 50%; background: rgba(255, 255, 255, .22); border: 3px solid rgba(255, 255, 255, .72); box-shadow: 0 2px 12px rgba(20, 30, 60, .16); pointer-events: none; }
#hud > #joy[hidden] { display: none; }
#joy.held { background: rgba(255, 255, 255, .36); border-color: #fff; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(255, 255, 255, .94); box-shadow: 0 2px 8px rgba(20, 30, 60, .28); }
.touch .act kbd { display: none; }
body.touch { touch-action: manipulation; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
.touch #hud { -webkit-user-select: none; user-select: none; }

@media (max-width: 600px) {
  /* Five buttons always; "เพิ่มเติม" opens the other seven in rows above them */
  #bar { left: 8px; right: 8px; transform: none; max-width: none; bottom: calc(8px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; overflow: visible; padding: 5px; border-radius: 20px; }
  #bar .group { display: contents; }
  .ctl { width: auto; padding: 7px 0 5px; border-radius: 14px; }
  .ctl span { display: block; font-size: 11px; white-space: nowrap; }
  .ctl .badge, .ctl .count { right: 6px; top: 2px; }
  #bar .extra { display: none; order: -2; }
  /* A line between the extra rows and the five main buttons, which always keep the bottom row */
  #bar.more::after { content: ''; order: -1; grid-column: 1 / -1; height: 1px; background: var(--line); margin: 3px 8px; }
  #bar.more .extra { display: flex; }
  #bar.more { box-shadow: 0 -6px 30px rgba(20, 30, 60, .22); }
  #b-more { display: flex; }
  #bar.more #b-more { background: var(--blue-soft); color: var(--blue); }
  #reacts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .panel { left: 8px; right: 8px; width: auto; top: auto; height: 64dvh; bottom: calc(74px + env(safe-area-inset-bottom)); }
  /* The character maker and decorating leave the top half for the character or the room */
  #sheet { left: 8px; right: 8px; width: auto; top: auto; height: 50dvh; bottom: calc(74px + env(safe-area-inset-bottom)); }
  #stage { top: 112px; }
  #stage-box { max-height: calc(100dvh - 300px); }
  #toasts { top: 120px; width: calc(100vw - 32px); }
  #where { font-size: 14px; top: calc(8px + env(safe-area-inset-top)); left: 8px; }
  #tiles { top: calc(52px + env(safe-area-inset-top)); }
  #prompt { bottom: calc(78px + env(safe-area-inset-bottom)); left: auto; right: 10px; transform: none; flex-direction: column; align-items: flex-end; }
  /* Phones zoom the page into any text box with letters under 16px */
  input, textarea, select { font-size: 16px !important; }
}
@media (max-width: 600px) {
  /* With the character maker or decorating open, camera tiles would sit on the character's face */
  #hud:has(#sheet:not([hidden])) #tiles { display: none; }
}
/* A phone turned sideways: panels go to the sides as on a computer, leaving the middle for the office */
@media (max-height: 500px) and (orientation: landscape) {
  .panel { left: auto; right: 8px; top: 8px; bottom: 70px; width: 340px; height: auto; }
  #sheet { right: auto; left: 8px; top: 8px; bottom: 70px; width: 340px; height: auto; }
  #bar { bottom: calc(6px + env(safe-area-inset-bottom)); }
  #toasts { top: 64px; }
}

/* ---------- Laser pointer on a shared screen ---------- */
.laser-btn { width: auto !important; padding: 0 9px 0 7px !important; gap: 4px; display: flex; align-items: center; color: #fff; }
.laser-btn[hidden] { display: none; }
.laser-btn span { font-size: 13px; }
.laser-btn.on { background: #ff2d55 !important; }
#stage-box.laser { cursor: crosshair; }
#stage-dots { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ldot { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px #fff, 0 0 14px 5px var(--c); transition: left 70ms linear, top 70ms linear; }
.ldot b { position: absolute; left: 20px; top: -5px; background: var(--c); color: #fff; font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 999px; white-space: nowrap; font-weight: normal; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.ldot.ping::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid var(--c); animation: ldot-ping .8s ease-out forwards; }
@keyframes ldot-ping { to { transform: scale(3.2); opacity: 0; } }

/* ---------- Speaking, paused cameras, the wait for a shared screen ---------- */
.tile.speaking { box-shadow: 0 0 0 4px #22c55e, 0 0 22px 6px rgba(34, 197, 94, .6), var(--shadow); }
.tile.speaking .name { background: #16a34a; }
.tile .talk-bars { position: absolute; right: 8px; top: 8px; display: none; gap: 2px; align-items: flex-end; height: 16px; padding: 3px 5px; border-radius: 8px; background: #16a34a; }
.tile.speaking .talk-bars { display: flex; }
.tile .talk-bars i { width: 3px; background: #fff; border-radius: 2px; animation: talkbar .5s ease-in-out infinite alternate; }
.tile .talk-bars i:nth-child(1) { height: 5px; } .tile .talk-bars i:nth-child(2) { height: 10px; animation-delay: .15s; } .tile .talk-bars i:nth-child(3) { height: 7px; animation-delay: .3s; }
@keyframes talkbar { to { transform: scaleY(1.6); } }
.tile .cam-paused { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(20, 24, 40, .55); color: #fff; display: grid; place-items: center; }
.tile .cam-paused svg { width: 13px; height: 13px; }
.tile.speaking .cam-paused { display: none; }
.stage-wait { position: absolute; inset: 0; display: flex; gap: 12px; align-items: center; justify-content: center; color: #fff; font-size: 17px; background: #10162a; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Ping, calling, ringing ---------- */
.chip.ping { top: 12px; left: auto; right: 12px; padding: 5px 12px; font-size: 13px; gap: 6px; cursor: pointer; }
.chip.ping::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.ping.good { color: var(--green); } .chip.ping.mid { color: #d28a00; } .chip.ping.bad { color: var(--red); }
#hud:has(#recbanner:not([hidden])) .chip.ping { top: 56px; }
#hud:has(#tool:not([hidden])) .chip.ping, #hud:has(#chat:not([hidden])) .chip.ping, #hud:has(#people:not([hidden])) .chip.ping, #hud:has(#videos:not([hidden])) .chip.ping { display: none; }
#dialing { top: 58px; left: 50%; transform: translateX(-50%); background: var(--blue); color: #fff; z-index: 25; }
#dialing svg { animation: wobble .5s ease-in-out infinite alternate; }
@keyframes wobble { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
#ring { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20, 26, 46, .35); z-index: 40; }
.ring-card { background: var(--panel); border-radius: 24px; box-shadow: var(--shadow); padding: 26px 28px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 300px; animation: toast .2s ease-out; }
.ring-av { width: 76px; height: 76px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 34px; display: grid; place-items: center; margin-bottom: 6px; animation: ringpulse 1.1s ease-out infinite; }
@keyframes ringpulse { 0% { box-shadow: 0 0 0 0 rgba(47, 109, 224, .55); } 100% { box-shadow: 0 0 0 24px rgba(47, 109, 224, 0); } }
.ring-card b { font-size: 22px; font-weight: normal; }
.ring-card small { color: var(--muted); margin-bottom: 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns .primary, .row-btns .secondary { display: inline-flex; gap: 8px; align-items: center; }
.icon-btn.call { color: var(--green); }

/* ---------- Camera buttons ---------- */
#camdock { position: fixed; right: 12px; bottom: 96px; display: flex; gap: 2px; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 3px; }
#hud:has(.panel:not([hidden])) #camdock, #hud:has(#sheet:not([hidden])) #camdock { display: none; }
@media (max-width: 900px) { #camdock { bottom: 84px; } }
@media (max-width: 600px) { #camdock { flex-direction: column; right: 8px; bottom: auto; top: calc(96px + env(safe-area-inset-top)); } #camdock #cam-in, #camdock #cam-out { display: none; } }

/* ---------- The small map and the big one ---------- */
#mapwrap { cursor: pointer; }
#mapwrap .map-tip { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 11px; background: rgba(28, 32, 50, .7); color: #fff; padding: 1px 8px; border-radius: 999px; opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; }
#mapwrap:hover .map-tip { opacity: 1; }
#bigmap { position: fixed; inset: 0; z-index: 30; background: rgba(20, 26, 46, .32); display: grid; place-items: center; padding: 16px; }
.bigmap-card { width: min(1400px, 100%); height: min(860px, 100%); background: var(--panel); border-radius: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.bigmap-bar { display: flex; gap: 8px; align-items: center; padding: 10px 12px 8px 18px; flex-wrap: wrap; }
.bigmap-bar h2 { margin: 0 8px 0 0; font-weight: normal; font-size: 20px; }
#bigmap-q { flex: 1; min-width: 140px; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 8px 12px; outline: none; }
#bigmap-q:focus { border-color: var(--accent); background: #fff; }
#bigmap-hits { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px; }
#bigmap-hits:empty { display: none; }
#bigmap-hits .hint { margin: 2px; }
.map-hit { background: var(--blue-soft); color: var(--blue); border-radius: 999px; padding: 5px 12px; font-size: 14px; margin-bottom: 6px; }
#bigmap-cv { flex: 1; min-height: 0; width: 100%; display: block; cursor: crosshair; touch-action: none; }
#bigmap-cv.dragging { cursor: grabbing; }
.bigmap-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(28, 32, 50, .78); color: #fff; font-size: 13px; padding: 5px 14px; border-radius: 999px; pointer-events: none; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }

/* ---------- Menu panels ---------- */
#tool header { justify-content: flex-start; gap: 4px; padding-left: 8px; }
#tool header h2 { flex: 1; }
#tool-back { font-size: 26px; line-height: 1; }
#tool-back[hidden] { display: none; }
#tool-body { flex: 1; overflow-y: auto; padding: 2px 14px 16px; display: flex; flex-direction: column; gap: 8px; }
#tool-body .field select, #tool-body .field input, .bk-day input { border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 9px 12px; outline: none; font-size: 15px; color: var(--ink); }
#tool-body .field input:focus, #tool-body .field select:focus { border-color: var(--accent); background: #fff; }
#tool-body .primary, #tool-body .secondary { display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
#tool-body .lbl { margin: 10px 2px 0; }
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-item { display: flex; gap: 14px; align-items: center; text-align: left; padding: 12px; border-radius: 14px; }
.menu-item:hover { background: var(--soft); }
.menu-item > svg { width: 26px; height: 26px; color: var(--accent-deep); }
.menu-item span { display: flex; flex-direction: column; gap: 1px; }
.menu-item b { font-weight: normal; font-size: 16px; }
.menu-item small { color: var(--muted); font-size: 13px; }
.switch.big { align-items: flex-start; gap: 12px; padding: 6px 2px; }
.switch.big input { margin-top: 3px; flex: none; }
.switch.big span { display: flex; flex-direction: column; }
.switch.big small { color: var(--muted); font-size: 13px; line-height: 1.45; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bk-day { display: flex; gap: 4px; align-items: center; }
.bk-day input { flex: 1; min-width: 0; }
.bk-rooms { display: flex; flex-direction: column; gap: 6px; position: relative; padding-bottom: 18px; }
.bk-room.sel .bk-name span { color: var(--blue); }
.bk-name { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.bk-name .mini { padding: 2px 8px; font-size: 12px; }
.bk-bar { position: relative; height: 26px; border-radius: 8px; background: repeating-linear-gradient(90deg, var(--soft) 0 calc(100% / 15 - 1px), var(--line) calc(100% / 15 - 1px) calc(100% / 15)); cursor: pointer; overflow: hidden; }
.bk-room.sel .bk-bar { box-shadow: inset 0 0 0 2px #b9cff7; }
.bk { position: absolute; top: 2px; bottom: 2px; background: #8b5cf6; border-radius: 6px; color: #fff; font-size: 11px; padding: 0 4px; overflow: hidden; white-space: nowrap; cursor: pointer; display: flex; align-items: center; }
.bk.mine { background: var(--accent); }
.bk-bar .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); }
.bk-hours { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; font-size: 11px; color: var(--muted); }
.bk-hours span { position: absolute; transform: translateX(-50%); }
.bk-hours span:first-child { transform: none; } .bk-hours span:last-child { transform: translateX(-100%); }
.bk-form { display: flex; flex-direction: column; gap: 8px; background: var(--soft); border-radius: 16px; padding: 12px; }
.bk-form .field input, .bk-form .field select { background: #fff !important; }
.bk-row { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--soft); }
.bk-row > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bk-row small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.bk-row .mini { background: #fff; }
.inv-made { display: flex; flex-direction: column; gap: 6px; background: var(--accent-soft); border-radius: 14px; padding: 12px; }
.inv-made input { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; background: #fff; }
.meter { position: relative; height: 18px; border-radius: 9px; background: var(--soft); overflow: hidden; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #9fb7c9; border-radius: 9px; transition: width 60ms linear; }
.meter-fill.loud { background: var(--green); }
.meter-floor, .meter-gate { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--red); }
.meter-gate { background: var(--blue); }
.noise-verdict { font-size: 15px; padding: 8px 12px; border-radius: 12px; background: var(--soft); }
.noise-verdict.ok { background: #e3f8ec; color: #137a46; } .noise-verdict.mid { background: #fff5dc; color: #8a5b00; } .noise-verdict.bad { background: var(--red-soft); color: var(--red); }
.net-box { display: flex; flex-direction: column; gap: 8px; }
.net-ping { display: flex; gap: 12px; align-items: center; background: var(--soft); border-radius: 14px; padding: 10px 14px; }
.net-ping b { font-size: 26px; font-weight: normal; }
.net-ping span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.net-ping.good b { color: var(--green); } .net-ping.mid b { color: #d28a00; } .net-ping.bad b { color: var(--red); }
.net-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.net-table th { text-align: left; color: var(--muted); font-weight: normal; padding: 4px; }
.net-table td { padding: 5px 4px; border-top: 1px solid var(--line); }
.sign-prev { display: grid; place-items: center; padding: 8px 0; }
.sign-prev div { min-width: 70%; max-width: 100%; border-radius: 18px; padding: 10px 18px; display: flex; flex-direction: column; align-items: center; box-shadow: var(--shadow); }
.sign-prev b { font-size: 24px; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sign-prev small { opacity: .9; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.icon-grid .opt { font-size: 20px; padding: 6px 0; text-align: center; }
.icon-grid .opt:first-child { font-size: 12px; }
.adm-sec { border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.adm-sec h3 { margin: 0; font-weight: normal; font-size: 17px; display: flex; gap: 8px; align-items: center; }
.adm-sec h3 svg { color: var(--accent-deep); }
.stat-line { margin: 0; }
.stat-line b { font-size: 20px; font-weight: normal; color: var(--accent-deep); }
.adm-members { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.adm-mem { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 12px; background: var(--soft); }
.adm-mem > div:first-child { display: flex; flex-direction: column; }
.adm-mem small { color: var(--muted); font-size: 12px; }
.adm-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.adm-btns .mini { background: #fff; font-size: 12px; padding: 4px 10px; }
select.mini { padding: 4px 8px; font-size: 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.badge-admin, .badge-guest { font-size: 11px; background: var(--accent-soft); color: var(--accent-deep); border-radius: 999px; padding: 0 7px; margin-left: 6px; vertical-align: 1px; }
.badge-guest { background: #efe7ff; color: #6d3fe0; }
.spoiler { background: var(--line); color: var(--muted); padding: 1px 8px; border-radius: 6px; cursor: pointer; }
.hint ol { margin: 6px 0 0; padding-left: 18px; }
.hint summary { cursor: pointer; color: var(--blue); }
.hint code, .adm-sec code { background: var(--soft); padding: 0 5px; border-radius: 5px; overflow-wrap: anywhere; }
.note.invite { background: #efe7ff; color: #5b31c9; border-radius: 12px; padding: 10px 12px; }
.person { cursor: pointer; }
/* Guests have no decorating, recording or video library */
body.guest #b-decor, body.guest #b-rec, body.guest #b-videos { display: none !important; }
.big-link { display: flex; gap: 8px; align-items: center; justify-content: center; text-decoration: none; }
.admin-link { align-self: center; font-size: 13px; color: var(--muted); }
.note.setup { background: var(--accent-soft); color: #8a4f00; border-radius: 12px; padding: 10px 12px; }
.note.setup a { color: var(--accent-deep); }
