:root {
  color-scheme: dark;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #101214;
  color: #f4f1ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #101214;
}

.viewer-page {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

@supports (height: 100dvh) {
  .viewer-page {
    height: 100dvh;
  }
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #15181b;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d7b56d;
  color: #171717;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: #aaa39a;
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 6px;
  background: #d7b56d;
  color: #141414;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;
  min-height: calc(100vh - 76px);
}

.viewer-page .layout {
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.video-area {
  position: relative;
  display: grid;
  place-items: center;
  background: #070809;
  min-height: 0;
  overflow: hidden;
}

video {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 76px);
  object-fit: contain;
  background: #050607;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  background: #070809;
}

.empty-state h2 {
  font-size: 24px;
}

.empty-state p {
  color: #aaa39a;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  background: #15181b;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header span {
  color: #918b83;
  font-size: 12px;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #918b83;
  font-size: 12px;
}

#online-count {
  color: #d7b56d;
  font-weight: 700;
  white-space: nowrap;
}

.owner-layout {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
}

.owner-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.owner-stats div,
.owner-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #15181b;
}

.owner-stats div {
  padding: 18px;
}

.owner-stats span {
  display: block;
  color: #aaa39a;
  font-size: 13px;
}

.owner-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.owner-stats .is-live {
  color: #7ee0a4;
}

.owner-panel {
  min-height: 220px;
  padding: 18px;
}

.owner-chat-panel {
  grid-column: 1 / -1;
}

.owner-panel h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.owner-list {
  display: grid;
  gap: 10px;
}

.owner-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.owner-row strong {
  display: block;
  color: #f4f1ec;
}

.owner-row span {
  display: block;
  margin-top: 5px;
  color: #918b83;
  font-size: 12px;
}

.owner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.owner-actions button {
  padding: 8px 10px;
}

.owner-actions button[data-action="kick"] {
  background: #ff9a8c;
}

.owner-actions button[data-action="unban"] {
  background: #7ee0a4;
}

.owner-messages {
  max-height: 360px;
  overflow-y: auto;
}

.owner-message {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.owner-message div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d7b56d;
  font-size: 13px;
}

.owner-message time {
  color: #77716b;
}

.owner-message p {
  margin-top: 6px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.owner-empty {
  color: #918b83;
}

.owner-page {
  min-height: 100vh;
}

.owner-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.owner-live-layout {
  width: min(820px, 100%);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
}

.owner-live-status {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #15181b;
  padding: 18px;
}

.owner-live-status span {
  display: block;
  color: #aaa39a;
  font-size: 13px;
}

.owner-live-status strong {
  display: block;
  margin-top: 6px;
  color: #f4f1ec;
  font-size: 24px;
}

.owner-live-status .is-live {
  color: #7ee0a4;
}

.owner-chat {
  min-height: 520px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.owner-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #101214;
  color: #f4f1ec;
  padding: 0;
  overflow: auto;
}

.owner-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.owner-dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #15181b;
}

.owner-dialog-head h2 {
  font-size: 18px;
}

.owner-dialog-head p {
  margin-top: 6px;
  color: #aaa39a;
  font-size: 13px;
}

.owner-dialog .owner-panel {
  margin: 18px;
}

.messages {
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
  padding: 16px;
}

.message {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.message div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d7b56d;
  font-size: 13px;
}

.message time {
  color: #77716b;
}

.message p {
  margin-top: 6px;
  line-height: 1.5;
  color: #eee8de;
  overflow-wrap: anywhere;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #0f1113;
  color: #f4f1ec;
  padding: 10px 12px;
  outline: none;
}

input:focus {
  border-color: #d7b56d;
}

input:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.text-button {
  border-radius: 6px;
  background: #d7b56d;
  color: #141414;
  font-weight: 700;
  padding: 10px 16px;
  text-decoration: none;
}

.admin-layout {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 28px 20px;
  display: grid;
  gap: 18px;
}

.admin-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #15181b;
  padding: 22px;
}

.admin-panel h2 {
  margin-bottom: 18px;
  font-size: 18px;
}

.admin-panel h2:not(:first-child) {
  margin-top: 24px;
}

.admin-form {
  display: grid;
  gap: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.form-grid label {
  color: #aaa39a;
  font-size: 13px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.admin-actions button[type="button"] {
  background: #262b30;
  color: #f4f1ec;
}

.muted-panel p {
  color: #c8c1b8;
  line-height: 1.7;
}

.muted-panel p + p {
  margin-top: 8px;
}

.setting-list {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.setting-list label {
  color: #aaa39a;
  font-size: 13px;
}

.setting-list code {
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: #0f1113;
  color: #f4f1ec;
  padding: 10px 12px;
  overflow-wrap: anywhere;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 28px;
  background: #15181b;
}

.brand-mark {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-error {
  margin-top: 14px;
  color: #ff9a8c;
}

@media (max-width: 900px) {
  .topbar {
    padding: 14px 16px;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  .chat {
    grid-template-rows: auto auto minmax(0, 1fr);
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 0;
  }

  .video-area {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 0;
  }

  video {
    height: 100%;
    max-height: none;
  }

  .chat-header {
    grid-row: 1;
  }

  .messages {
    grid-row: 3;
    min-height: 0;
    padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .composer {
    grid-row: 2;
    grid-template-columns: minmax(0, 1fr) 56px;
    padding: 10px 14px 12px;
    border-top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #15181b;
  }

  input {
    min-height: 42px;
    font-size: 16px;
  }

  body.chat-focus .chat {
    min-height: 0;
  }

  .setting-list {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .owner-layout,
  .owner-stats {
    grid-template-columns: 1fr;
  }

  .owner-chat-panel {
    grid-column: auto;
  }

  .owner-row {
    grid-template-columns: 1fr;
  }

  .owner-actions {
    justify-content: flex-start;
  }

  .owner-top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .owner-live-layout {
    min-height: calc(100svh - 76px);
    padding: 16px;
  }

  .owner-chat {
    min-height: 460px;
  }
}

/* Two-room selection: normal-flow cards, no hidden players or background audio. */
.rooms-page { min-height:100svh; background:radial-gradient(ellipse at 50% 0, #25231e 0, #111416 60%); }
.rooms-shell { max-width:1040px; margin:0 auto; padding:64px 28px 36px; }
.rooms-heading { text-align:center; margin-bottom:36px; }
.rooms-eyebrow { color:#d8b66d; letter-spacing:3px; font-size:13px; }
.rooms-heading h2 { color:#f7f4eb; font-size:clamp(26px,4vw,38px); line-height:1.35; margin:12px 0; }
.rooms-heading p,.rooms-help,.room-card p { color:#a3a4a4; line-height:1.75; }
.room-cards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; }
.room-card { min-width:0; padding:30px; border:1px solid #494031; border-radius:18px; background:linear-gradient(135deg,#252722,#181b1d); }
.room-card-top { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.room-number { font-size:38px; color:#b59861; font-weight:700; letter-spacing:1px; }
.room-status { color:#b6b7b7; background:#2e3130; padding:6px 12px; border-radius:20px; font-size:13px; }
.room-status.is-live { color:#9be3ac; background:#20392a; }
.room-name { color:#f8f4e9; font-size:26px; line-height:1.5; margin:26px 0 6px; overflow-wrap:anywhere; }
.room-enter { display:flex; justify-content:space-between; gap:12px; margin-top:28px; padding:15px 18px; border-radius:9px; color:#211c13; background:#d8b66d; font-weight:700; text-decoration:none; overflow-wrap:anywhere; }
.room-enter:hover { background:#edcd88; }
.room-enter:focus-visible { outline:3px solid #fff; outline-offset:4px; }
.rooms-help { text-align:center; margin-top:28px; font-size:13px; }
.rooms-notice { padding:14px; background:#382c24; border:1px solid #695239; border-radius:8px; }
.room-switcher { grid-column:1 / -1; background:#1d2124; padding:18px 22px; border:1px solid #3c4144; border-radius:12px; }
.room-switcher label { display:inline-block; margin-right:14px; color:#e6dcc9; }
.room-switcher select { max-width:100%; padding:10px 14px; background:#121719; border:1px solid #6c5d40; border-radius:6px; color:#f8f4e9; font-size:16px; }
.room-switcher p { margin:10px 0 0; color:#a2a7a9; font-size:13px; }
.owner-live-layout .room-switcher { margin-bottom:14px; }
.top-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
@media(max-width:650px) {
 .rooms-shell { padding:32px 18px; }
 .rooms-heading { margin-bottom:24px; }
 .room-cards { grid-template-columns:1fr; gap:16px; }
 .room-card { padding:22px; }
 .room-name { margin-top:14px; font-size:23px; }
 .room-enter { margin-top:18px; }
 .viewer-page .topbar { flex-wrap:wrap; }
 .viewer-page .top-actions { margin-left:auto; }
 .room-switcher label { display:block; margin-bottom:8px; }
}
