:root { --ink: #14110e; --felt: #1f1a15; --seam: #3a3128; --paper: #f1e8d8; --dust: #a89a86; --lamp: #ff5b35; --serif: "New York", ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif; --sans: "Avenir Next", Avenir, "Segoe UI", "Noto Sans", sans-serif; color-scheme: dark }
* { box-sizing: border-box; margin: 0 }
[hidden] { display: none !important }
html, body { height: 100% }
body { background: radial-gradient(90% 70% at 50% -10%, #33271c, transparent 70%) var(--ink); color: var(--paper); font: 16px/1.45 var(--sans); overflow: hidden }
h1 { font: 500 clamp(2.2rem, 5vw, 4rem)/1.02 var(--serif); letter-spacing: -.025em; overflow-wrap: anywhere }
label, .kicker, .meta { color: var(--dust); font-size: .875rem }
input, select { width: 100%; min-height: 48px; padding: 0 14px; background: var(--felt); color: inherit; border: 1px solid var(--seam); border-radius: 6px; font: inherit }
button { min-height: 44px; padding: 0 16px; background: var(--felt); color: inherit; border: 1px solid var(--seam); border-radius: 6px; font: 500 .9375rem var(--sans); cursor: pointer; transition: background .15s, border-color .15s }
button:hover { border-color: var(--dust) }
button:disabled { opacity: .5; cursor: default }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px }
.go { background: var(--lamp); border-color: var(--lamp); color: #1b0a04; font-weight: 600 }
.go:hover { background: #ff7957; border-color: #ff7957 }
.bad { color: #ff9c84 }

main { display: none }
[data-view=lobby] #lobby, [data-view=over] #over, [data-view=gate] #gate { display: grid }
[data-view=call] #call { display: flex }

#lobby { height: 100%; padding: 32px clamp(20px, 6vw, 96px) 120px; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: clamp(24px, 5vw, 80px); align-items: center; overflow: auto }
.preview { position: relative; aspect-ratio: 16/10; background: var(--felt); border-radius: 10px; overflow: hidden; box-shadow: 0 30px 90px #0009, 0 0 0 1px var(--seam) }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1) }
#hint { position: absolute; inset: 0; display: grid; place-content: center; padding: 20px; text-align: center; color: var(--dust); pointer-events: none }
form { display: grid; gap: 10px }
#join h1 { margin-bottom: 24px }
#join .go, #login .go { margin-top: 10px; min-height: 52px }

#call { height: 100%; padding: 12px 12px calc(100px + env(safe-area-inset-bottom)); gap: 10px }
#grid { flex: 1; min-width: 0; min-height: 0; display: grid; gap: 10px; grid-template: repeat(var(--rows, 1), minmax(0, 1fr)) / repeat(var(--cols, 1), minmax(0, 1fr)) }
#stage { display: none; flex: 1; min-width: 0; min-height: 0; flex-direction: column; gap: 10px }
.staged #stage { display: flex }
.staged #grid { flex: 0 0 clamp(150px, 18vw, 260px); grid-template: none / 1fr; grid-auto-rows: max-content; overflow: auto }
.staged #grid figure { aspect-ratio: 16/10 }
figure { position: relative; min-height: 0; overflow: hidden; background: var(--felt); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--seam); animation: rise .35s both }
figure video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover }
figure.screen { flex: 1; background: #000 }
figure.screen video { object-fit: contain }
figure.self video { transform: scaleX(-1) }
figure.dark video { visibility: hidden }
figure i { position: absolute; inset: 0; display: grid; place-content: center; font: italic 500 clamp(3rem, 9vw, 7rem) var(--serif); color: var(--dust) }
figure.screen i { display: none }
figcaption { position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px); padding: 4px 10px; background: #14110ecc; border-radius: 4px; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
figure.mute figcaption::after { content: " · muted"; color: #ff9c84 }
figure.weak::after { content: "Connecting…"; position: absolute; top: 10px; left: 10px; padding: 4px 10px; background: #14110ecc; border-radius: 4px; color: var(--dust); font-size: .875rem }
@keyframes rise { from { opacity: 0; transform: scale(.97) } }

#bar { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); translate: -50%; display: none; gap: 6px; padding: 6px; background: #1f1a15f2; border: 1px solid var(--seam); border-radius: 12px }
[data-view=lobby] #bar, [data-view=call] #bar { display: flex }
[data-view=lobby] #bar .in-call { display: none }
#bar button { display: grid; justify-items: center; align-content: center; gap: 3px; width: 72px; height: 58px; padding: 0; background: none; border-color: transparent; font-size: .75rem }
#bar button:hover { background: var(--seam) }
#bar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round }
#bar [aria-pressed=true] .slash { display: none }
#mic[aria-pressed=false], #cam[aria-pressed=false] { color: #ff9c84 }
#screen[aria-pressed=true], #leave { background: var(--lamp) !important; color: #1b0a04 }
#banner { position: fixed; top: 18px; left: 50%; translate: -50%; max-width: calc(100vw - 32px); padding: 10px 18px; background: var(--paper); color: var(--ink); border-radius: 6px; z-index: 2 }

#over, #gate { height: 100%; padding: 24px; place-content: center; justify-items: center; gap: 16px; text-align: center }
#over p { color: var(--dust) }
#gate form { width: min(340px, 86vw); text-align: left }
#gate h1 { margin-bottom: 20px }
#wrong { min-height: 1.5em; color: #ff9c84 }

.admin { overflow: auto }
[data-view=desk] #desk { display: block; max-width: 860px; margin: 0 auto; padding: clamp(24px, 6vw, 72px) 20px }
header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px; margin-bottom: 36px }
#sum { flex: 1; color: var(--dust) }
#create { grid-template-columns: 1fr 170px auto; align-items: end; gap: 12px }
#create div { display: grid; gap: 6px }
#create .go { min-height: 48px }
#note { min-height: 1.5em; margin: 12px 0 20px; color: var(--dust) }
#rooms, .people { list-style: none; padding: 0 }
#rooms > li { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; padding: 20px 0; border-top: 1px solid var(--seam) }
#rooms h2 { font: 500 1.5rem/1.2 var(--serif); overflow-wrap: anywhere }
#rooms .on h2::before { content: ""; display: inline-block; width: .5em; height: .5em; margin-right: .45em; border-radius: 50%; background: var(--lamp) }
#rooms .meta { text-align: right }
#rooms code { align-self: center; color: var(--dust); font-size: .8125rem; overflow-wrap: anywhere }
.acts { display: flex; gap: 8px }
.people { grid-column: 1 / -1 }
.people li { display: flex; align-items: center; gap: 12px; padding: 6px 0 6px 16px }
.people span { overflow-wrap: anywhere }
.people small { flex: 1; color: var(--dust) }

@media (max-width: 760px), (orientation: portrait) {
  #lobby { grid-template-columns: 1fr; align-content: start; gap: 24px }
  #join h1 { margin-bottom: 12px }
  #call { flex-direction: column }
  .staged #grid { order: 2; flex: 0 0 110px; grid-template: 1fr / none; grid-auto-flow: column; grid-auto-columns: 160px }
}
@media (max-width: 620px) {
  #bar button { width: 62px }
  #create { grid-template-columns: 1fr }
  #rooms > li { grid-template-columns: 1fr }
  #rooms .meta { text-align: left }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important } }
