* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif; background: #0d1118; color: #eaf0f5; }
main { max-width: 1280px; margin: auto; padding: 28px 24px 36px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.room-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 390px); gap: 20px; align-items: start; }
.brand { color: #78c9b3; font-size: 10px; font-weight: 700; letter-spacing: .17em; }
h1 { margin: 8px 0 4px; font-size: 24px; }
.badge { flex: none; padding: 7px 11px; border: 1px solid #425165; border-radius: 20px; color: #b9c4d1; font-size: 11px; }
.badge.live { border-color: #2e806f; color: #92e0c8; background: #163e36; }
.badge.error { border-color: #975450; color: #ffd1c8; background: #4e2727; }
.player { position: relative; width: 100%; height: clamp(340px, 64vh, 700px); overflow: hidden; border: 1px solid #2a3745; border-radius: 14px; background: #05080b; }
video { width: 100%; height: 100%; object-fit: contain; }
.player.is-portrait { --portrait-width-ratio: .5625; width: min(100%, calc(76svh * var(--portrait-width-ratio))); height: auto; aspect-ratio: var(--portrait-width-ratio); margin-inline: auto; }
.player.is-portrait video { display: block; }
/* The smallest built-in portrait image area spans over 44% of the video.
   Keep the overlay in the shared image area with a cap of half that height. */
.portrait-chat { display: none; position: absolute; z-index: 1; left: max(10px, 5%); bottom: 45%; width: max-content; max-width: min(86%, 25em); max-height: 22%; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; list-style: none; margin: 0; padding: 0; color: #fff; background: transparent; font-size: clamp(11px, 3.5vw, 14px); line-height: 1.45; }
.is-portrait .portrait-chat, .playback-only .portrait-chat { display: block; }
.portrait-chat li + li { margin-top: 4px; }
.portrait-chat p { margin: 0; padding: 2px 6px; overflow-wrap: anywhere; background: rgb(13 17 24 / 64%); border-radius: 5px; text-shadow: 0 1px 2px #000; }
.portrait-chat strong { color: #bafbe8; }
.playback-only .page-header, .playback-only .interaction, .playback-only #room-recent { display: none; }
.playback-only main { max-width: none; padding: 0; }
.playback-only .room-layout { display: block; }
.playback-only .player { margin-inline: auto; border: 0; border-radius: 0; max-height: 88svh; }
.playback-only .player.is-portrait { width: min(100%, calc(88svh * var(--portrait-width-ratio))); }
.playback-only .player:not(.is-portrait) .portrait-chat { bottom: 5%; }
.playback-only .controls { justify-content: center; margin-top: 8px; }
.playback-only #viewers { display: none; }
.placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; background: #0b1119; text-align: center; pointer-events: none; }
.placeholder[hidden] { display: none; }
.placeholder strong { font-size: 16px; }
.placeholder small { max-width: 80%; color: #8798ab; line-height: 1.7; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: #78c9b3; box-shadow: 0 0 0 9px #78c9b321; }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 17px; }
button { min-height: 40px; padding: 0 18px; border: 0; border-radius: 8px; background: #80cfb9; color: #102c28; font-size: 13px; font-weight: 700; cursor: pointer; }
button:hover { background: #a0e1ce; }
button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
#viewers { color: #a5b4c3; font-size: 12px; line-height: 1.7; }
#sound-hint { margin: 8px 0 0; color: #c4d0db; font-size: 13px; }
.recent-messages { margin-top: 16px; padding: 12px 14px; border: 1px solid #2a3745; border-radius: 12px; background: #131b25; }
.recent-messages h2 { margin: 0 0 8px; color: #c4d0db; font-size: 14px; }
.recent-messages ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.recent-messages strong { color: #b3e2d6; }
[hidden] { display: none !important; }
.interaction { min-width: 0; padding: 16px; border: 1px solid #2a3745; border-radius: 14px; background: #131b25; }
.room-header, .identity, .form-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-header { margin-bottom: 16px; }
.interaction h2 { margin: 0; font-size: 17px; }
#room-voice { flex: none; color: #a1d5c5; font-size: 12px; }
.join-form label, .identity small { display: block; margin-bottom: 6px; font-size: 12px; color: #aebdcc; }
.identity { padding: 8px 0; }
.identity > div { min-width: 0; }
.identity strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
.identity small { margin: 4px 0 0; overflow-wrap: anywhere; font-size: 11px; font-variant-numeric: tabular-nums; }
.secondary { padding: 0 12px; border: 1px solid #425165; color: #dce7f0; background: #1d2a39; }
.secondary:hover { background: #2a3c4e; }
.mic-control { display: flex; align-items: center; gap: 10px; }
#room-mic-status, #room-speaker { color: #b3e2d6; font-size: 12px; line-height: 1.55; }
#room-speaker { margin: 8px 0 0; overflow-wrap: anywhere; }
.interaction input, .interaction select { min-width: 0; min-height: 42px; padding: 0 10px; border: 1px solid #425165; border-radius: 8px; background: #0b1119; color: #eaf0f5; font: inherit; font-size: 13px; }
.interaction input { flex: 1; }
.interaction button { flex: none; }
.interaction input:focus-visible, .interaction select:focus-visible { outline: 2px solid #80cfb9; outline-offset: 2px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.room-feed { height: clamp(220px, 43vh, 485px); margin: 12px 0; overflow-y: auto; overscroll-behavior: contain; border-block: 1px solid #2a3745; scrollbar-gutter: stable; }
#room-empty, #interaction-status { margin: 8px 0 0; color: #aebdcc; font-size: 12px; line-height: 1.6; }
#room-messages { padding: 0; margin: 0; list-style: none; }
.room-entry { padding: 10px 0; border-bottom: 1px solid #253140; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.room-author { color: #b3e2d6; font-weight: 700; }
.room-meta, .room-entry time, .room-entry-status { margin-left: 6px; color: #a5b4c3; font-size: 11px; }
.room-entry time { float: right; }
.room-entry p { margin: 4px 0 0; white-space: pre-wrap; }
.room-entry .room-reply { padding: 6px 8px; border-left: 2px solid #73b8a5; background: #1a2b32; }
.room-reply strong { margin-right: 7px; color: #a1d5c5; }
.room-entry-status { display: block; margin: 3px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (max-width: 850px) {
  .room-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .player { height: clamp(260px, 54svh, 500px); }
  .room-feed { height: clamp(165px, 30svh, 300px); }
}
@media (max-width: 480px) {
  main { padding: 18px 12px; }
  h1 { font-size: 20px; }
  .interaction { padding: 12px; }
  .interaction button { padding-inline: 10px; }
}
