:root {
  --bg: #07080c;
  --bg-2: #0c0e15;
  --surface: #11141d;
  --surface-2: #181c28;
  --border: #242a3b;
  --border-hi: #343c55;
  --text: #e9ebf3;
  --muted: #8a91a8;
  --faint: #5a6178;
  --accent: #9b7bff;
  --accent-2: #5ce1ff;
  --accent-glow: rgba(155, 123, 255, .45);
  --live: #ff2e57;
  --live-glow: rgba(255, 46, 87, .5);
  --ok: #3ee89b;
  --warn: #ffc23d;
  --radius: 14px;
  --font: 'Pretendard Variable', Pretendard, system-ui, sans-serif;
  --display: 'Rajdhani', var(--font);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(155, 123, 255, .16), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(92, 225, 255, .10), transparent 60%),
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 44px 44px;
  mask-image: radial-gradient(ellipse at center, #000 40%, transparent 85%);
}

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: .22em; }
.brand .mark { width: 24px; height: 24px; color: var(--accent); filter: drop-shadow(0 0 8px var(--accent-glow)); }
.brand-lg { font-size: 34px; justify-content: center; }
.brand-lg .mark { width: 38px; height: 38px; }

.card {
  background: linear-gradient(180deg, rgba(24, 28, 40, .92), rgba(17, 20, 29, .92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .04);
  backdrop-filter: blur(14px);
}

/* join */
.join { position: relative; z-index: 1; height: 100%; display: grid; place-items: center; padding: 16px; }
.join-card { width: min(380px, 100%); padding: 36px 28px 28px; display: flex; flex-direction: column; gap: 16px; }
.join-sub { margin: -6px 0 10px; text-align: center; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.field input, .field select {
  height: 44px; padding: 0 14px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(155, 123, 255, .18); }
.join-error { min-height: 1.2em; margin: 0; color: var(--live); font-size: 13px; text-align: center; }
.join-host { margin-top: -4px; text-align: center; font-size: 12.5px; color: var(--faint); text-decoration: none; }
.join-host b { color: var(--muted); font-weight: 600; }
.join-host:hover b { color: var(--accent); }

.field > span small { font-weight: 500; letter-spacing: 0; color: var(--faint); margin-left: 4px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); }
.tabs button { height: 36px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--accent) inset; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

.btn {
  height: 46px; border: 0; border-radius: 10px; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: .12em;
  transition: transform .08s, box-shadow .2s, filter .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary {
  margin-top: 6px; color: #0b0718;
  background: linear-gradient(135deg, var(--accent), #c3a9ff);
  box-shadow: 0 8px 26px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.08); }

/* room */
.room { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 18px; padding: 14px 20px;
  background: linear-gradient(180deg, rgba(7, 8, 12, .9), transparent);
  transition: opacity .3s;
}
.live-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.live-host { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-time { color: var(--muted); font-size: 13px; }
.badge {
  font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .16em;
  padding: 4px 10px 3px; border-radius: 6px;
}
.badge-off { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.badge-live { color: #fff; background: var(--live); box-shadow: 0 0 18px var(--live-glow); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 6px var(--live-glow); } }

.topbar-right { position: relative; display: flex; gap: 8px; }
.user-pill { padding: 0 12px 0 4px; font-family: var(--font); font-weight: 600; }
.user-pill .avatar { width: 26px; height: 26px; border-radius: 50%; }
.pop { position: absolute; right: 0; top: 44px; z-index: 8; }
.user-pop { width: 200px; padding: 6px; display: flex; flex-direction: column; }
.menu-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; cursor: pointer; text-decoration: none; }
.menu-item:hover { background: rgba(255, 255, 255, .06); }
.menu-item.danger { color: var(--live); }
.pill {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: rgba(17, 20, 29, .8);
  cursor: pointer; font-family: var(--mono); font-size: 13px;
}
.pill:hover { border-color: var(--border-hi); }
.pill svg { width: 16px; height: 16px; color: var(--accent-2); }
.viewers-pop { width: 230px; padding: 12px; right: auto; left: 0; }
.pop-title { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.viewers-pop ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.viewers-pop li { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #0b0718;
}
.me-tag { margin-left: auto; font-size: 11px; color: var(--faint); }

.banner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 6;
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  background: rgba(255, 194, 61, .12); border: 1px solid rgba(255, 194, 61, .4); color: var(--warn);
}
.banner.reload { cursor: pointer; }
.banner.reload:hover { background: rgba(255, 194, 61, .2); }

.stage { position: relative; flex: 1; min-height: 0; background: #000; }
/* tiles: single = one full stream, grid = all equal, focus = one big + strip */
.tiles { position: absolute; inset: 0; display: grid; gap: 8px; }
.tiles.single { grid-template: 1fr / 1fr; }
.tiles.grid { padding: 64px 12px 72px; grid-template-columns: repeat(var(--cols), var(--tile-w)); grid-auto-rows: calc(var(--tile-w) * 9 / 16); justify-content: center; align-content: center; }
/* focus: big tile spans every column; strip tiles sit in the fixed middle columns of row 2 */
.tiles.focus { padding: 0 0 62px; grid-template-columns: 1fr repeat(var(--others), 228px) 1fr; grid-template-rows: minmax(0, 1fr) 128px; }
.tile { position: relative; min-width: 0; min-height: 0; background: #000; overflow: hidden; cursor: pointer; }
.tiles.grid .tile, .tiles.focus .tile:not(.focused) { border-radius: 12px; border: 1px solid var(--border); transition: border-color .15s, box-shadow .15s; }
.tiles.grid .tile:hover, .tiles.focus .tile:not(.focused):hover { border-color: var(--accent); box-shadow: 0 0 20px rgba(155, 123, 255, .25); }
.tiles.focus .tile.focused { cursor: default; }
.tiles.single .tile { cursor: default; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile.audible { border-color: rgba(62, 232, 155, .7) !important; }
.tile-label {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; max-width: calc(100% - 64px);
  padding: 5px 10px; border-radius: 8px; background: rgba(7, 8, 12, .78); font-size: 13px; font-weight: 600;
}
.tile-label .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live-glow); flex: none; }
.tile-label .tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiles.single .tile-label, .tiles.focus .tile.focused .tile-label { display: none; }
.tile-audio {
  position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: row-reverse; align-items: center; gap: 6px;
  padding: 3px; border-radius: 9px; background: rgba(7, 8, 12, .8);
}
.tile-audio button { width: 30px; height: 30px; border-radius: 7px; border: 0; cursor: pointer; display: grid; place-items: center; background: transparent; color: var(--ok); }
.tile-audio button:hover { background: rgba(255, 255, 255, .08); }
.tile-audio svg { width: 18px; height: 18px; }
.tile-audio.muted button { color: var(--live); }
.tile-audio input[type=range] { width: 0; opacity: 0; margin: 0; transition: width .15s, opacity .15s; }
.tile-audio:hover input[type=range], .tile-audio:focus-within input[type=range] { width: 90px; opacity: 1; margin: 0 4px 0 8px; }
.tile-close {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(7, 8, 12, .8); color: var(--muted); font-size: 14px;
  opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-close, .tile-close:focus-visible { opacity: 1; }
.tile-close:hover { color: var(--text); background: rgba(255, 46, 87, .5); }
.tile-audio { opacity: 0; transition: opacity .15s; }
.tile:hover .tile-audio, .tile-audio:focus-within, .tile-audio.muted { opacity: 1; }
.tile.focused .tile-close, .tiles.single .tile-close { top: 70px; right: 20px; }
.tile.focused .tile-audio, .tiles.single .tile-audio { bottom: 76px; right: 20px; }
.tile-own { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: #000; text-align: center; padding: 8px; }
.tile-own b { font-family: var(--display); letter-spacing: .12em; font-size: 18px; color: var(--live); }
.tile-own span { font-size: 12.5px; color: var(--muted); }
.tiles.focus .tile:not(.focused) .tile-label { left: 6px; bottom: 6px; padding: 3px 8px; font-size: 12px; }
.tiles.focus .tile:not(.focused) .tile-audio { right: 5px; bottom: 5px; }
.tiles.focus .tile:not(.focused) .tile-audio button { width: 24px; height: 24px; }
.tiles.focus .tile:not(.focused) .tile-audio:hover input[type=range] { width: 64px; }
.tiles.focus .tile:not(.focused) .tile-close { top: 5px; right: 5px; width: 24px; height: 24px; }
.tiles.focus .tile:not(.focused) .tile-own b { font-size: 13px; }
.tiles.focus .tile:not(.focused) .tile-own span { display: none; }

.ctl-wrap { position: relative; }
.ctl-pill { font-family: var(--font); font-size: 12.5px; height: 32px; }
.up-pop { top: auto; bottom: 42px; right: 0; width: 220px; padding: 12px; }
.hidden-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hidden-list li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.hidden-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden-list button { border: 1px solid var(--border-hi); background: transparent; color: var(--text); border-radius: 7px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.hidden-list button:hover { border-color: var(--accent); }
.stage.idle { cursor: none; }
.stage.idle ~ .topbar, .room.idle .topbar, .room.idle .controls { opacity: 0; }

.offline {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 16px;
  background: radial-gradient(600px 400px at 50% 45%, rgba(155, 123, 255, .10), transparent 70%), var(--bg);
}
.offline h1 { margin: 26px 0 0; font-family: var(--display); font-size: 30px; letter-spacing: .08em; }
.offline p { margin: 0; color: var(--muted); }
.radar { position: relative; width: 120px; height: 120px; display: grid; place-items: center; color: var(--accent); }
.radar svg { width: 46px; height: 46px; filter: drop-shadow(0 0 12px var(--accent-glow)); }
.radar span {
  position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--accent);
  opacity: 0; animation: ring 3s cubic-bezier(.2, .6, .3, 1) infinite;
}
.radar span:nth-child(2) { animation-delay: 1s; }
.radar span:nth-child(3) { animation-delay: 2s; }
@keyframes ring { 0% { transform: scale(.35); opacity: .9; } 100% { transform: scale(1.4); opacity: 0; } }

.stats {
  position: absolute; top: 70px; left: 20px; z-index: 4;
  padding: 10px 12px; border-radius: 10px; font-size: 12px; line-height: 1.7;
  background: rgba(7, 8, 12, .78); border: 1px solid var(--border); white-space: pre;
}
.stats b { color: var(--accent-2); font-weight: 600; }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 26px 18px 16px;
  background: linear-gradient(0deg, rgba(7, 8, 12, .92), transparent);
  transition: opacity .3s;
}
.spacer { flex: 1; }
.quality { font-size: 12px; color: var(--muted); padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; }
.quality:empty { display: none; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
  border: 0; background: transparent; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); }
.icon-btn svg { width: 22px; height: 22px; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 110px; height: 4px; border-radius: 4px; background: var(--border-hi); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 4px rgba(155, 123, 255, .25); cursor: pointer; }

.toasts { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 9px 16px; border-radius: 10px; font-size: 13px;
  background: rgba(24, 28, 40, .95); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: toast-in .25s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.unmute-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4;
  display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-radius: 12px; cursor: pointer;
  background: rgba(7, 8, 12, .85); border: 1px solid var(--accent); color: var(--text);
  font-weight: 600; box-shadow: 0 0 30px var(--accent-glow);
}

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar .brand span { display: none; }
  .live-time { display: none; }
  input[type=range] { width: 80px; }
  .quality { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .radar span, .badge-live { animation: none; }
}

/* modal / admin */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(3, 4, 7, .72); backdrop-filter: blur(4px); }
.modal-card { width: min(720px, 100%); max-height: 100%; overflow: auto; padding: 20px 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 17px; }
.admin-card h3 { margin: 22px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.invite-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.invite-form .field { min-width: 110px; }
.invite-form .field.grow { flex: 1; min-width: 160px; }
.invite-form .btn { margin: 0; height: 44px; padding: 0 20px; font-size: 15px; }
.new-invite { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: rgba(62, 232, 155, .08); border: 1px solid rgba(62, 232, 155, .4); }
.new-invite .mono { flex: 1; font-size: 18px; font-weight: 600; color: var(--ok); letter-spacing: .06em; user-select: all; }
.btn-ghost { height: 36px; padding: 0 14px; font-size: 13px; letter-spacing: .04em; background: transparent; border: 1px solid var(--border-hi); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rows li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); font-size: 13.5px; }
.rows li.empty { color: var(--faint); justify-content: center; }
.rows li.off { opacity: .55; }
.rows .main { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 2px; }
.rows .main b { font-weight: 600; }
.rows .sub { font-size: 12px; color: var(--faint); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--border-hi); color: var(--muted); }
.tag.host { color: var(--accent-2); border-color: rgba(92, 225, 255, .4); }
.tag.admin { color: var(--accent); border-color: rgba(155, 123, 255, .5); }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.link-btn { border: 0; background: transparent; color: var(--live); font-size: 12.5px; cursor: pointer; padding: 4px 6px; }
.link-btn:hover { text-decoration: underline; }

/* inside the host app the broadcast panel sits right next to the player: no brand / status corner */
.in-app .topbar .brand, .in-app #live-badge { display: none; }
