* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Alibaba PuHuiTi 3.0', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0d0c0b;
  color: #f5f2ec;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  min-height: 100dvh;
}

button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

img {
  display: block;
}

/* ================= 直播间（深色 + 暖金色；手机竖屏样式，宽屏布局见文件末尾「响应式」） ================= */
.room {
  --rm-bg: #0d0c0b;
  --rm-surface: #171512;
  --rm-surface-2: #211e1a;
  --rm-line: rgba(255, 255, 255, 0.08);
  --rm-text: #f5f2ec;
  --rm-muted: #a39d92;
  --rm-faint: #6c675f;
  --rm-accent: #d9a441;
  --rm-accent-2: #f2c879;
  --rm-name: #e8c47e;
  --rm-on-accent: #241a07;
  --rm-live: #ff4d5e;
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--rm-bg);
  color: var(--rm-text);
}

.room[hidden],
.login-view[hidden] {
  display: none !important;
}

/* Top bar */
.room-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(180deg, #16130f 0%, var(--rm-bg) 100%);
}

.room-top__brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-top__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  overflow: hidden;
}

.room-top__mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.room-top__name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.room-top__points {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 3px 0 10px;
  border: 1px solid rgba(242, 200, 121, 0.3);
  border-radius: 999px;
  background: rgba(217, 164, 65, 0.1);
  color: #f3dcaa;
  font-size: 12px;
  white-space: nowrap;
}

.room-top__points button {
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--rm-accent-2), var(--rm-accent));
  color: var(--rm-on-accent);
  font-size: 12px;
  font-weight: 600;
}

/* Video stage: 16:9, everything else is overlaid and takes no layout space */
.stage {
  position: relative;
  flex: none;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

@supports not (aspect-ratio: 16 / 9) {
  .stage {
    height: 0;
    padding-top: 56.25%;
  }
}

.stage__cover,
.stage__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage__cover {
  object-fit: cover;
  opacity: 0.55;
}

.stage__video {
  object-fit: contain;
  background: #000;
}

.stage [hidden] {
  display: none !important;
}

.stage__info {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: calc(100% - 32px);
  text-align: center;
  pointer-events: none;
}

.stage__status {
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(13, 12, 11, 0.72);
  font-size: 14px;
}

.stage__next {
  max-width: 100%;
  padding: 4px 12px;
  border: 1px solid rgba(242, 200, 121, 0.35);
  border-radius: 999px;
  background: rgba(13, 12, 11, 0.6);
  color: #f3dcaa;
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stage__badge {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(13, 12, 11, 0.6);
  font-size: 12px;
  pointer-events: none;
}

.stage__badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rm-live);
}

/* 右上角工具条：声音提示 + 画质按钮；画质菜单挂在工具条下方，有公告横幅时一起下移 */
.stage__tools {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage__unmute,
.stage__quality {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(13, 12, 11, 0.72);
  font-size: 12px;
  white-space: nowrap;
}

.stage__quality[aria-expanded="true"] {
  background: rgba(13, 12, 11, 0.92);
}

.stage__quality-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 88px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(13, 12, 11, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.stage__quality-menu button {
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

.stage__quality-menu button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.1);
  color: var(--rm-accent-2);
  font-weight: 600;
}

.stage--banner .stage__badge,
.stage--banner .stage__tools {
  top: 44px;
}

.stage__play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--rm-accent-2), var(--rm-accent));
  color: var(--rm-on-accent);
  font-size: 15px;
  font-weight: 600;
}

/* 直播控件条：只有声音和全屏（不显示时间、进度条）。画面隐藏时不显示，全屏时一直显示以便退出 */
.stage__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  pointer-events: none;
}

.stage__video[hidden] ~ .stage__controls {
  display: none;
}

.stage__video[hidden] ~ .stage__controls .stage__ctl--sound {
  visibility: hidden;
}

.stage__ctl {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(13, 12, 11, 0.55);
  pointer-events: auto;
}

.stage__ctl svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage__ctl .stage__ctl-off,
.stage__ctl.is-alt .stage__ctl-on {
  display: none;
}

.stage__ctl.is-alt .stage__ctl-off {
  display: block;
}

/* Today's notices banner (over the top of the video) */
.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 34px;
  padding-left: 10px;
  background: rgba(13, 12, 11, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.banner__icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: var(--rm-accent-2);
}

.banner__viewport {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin-left: 6px;
  overflow: hidden;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
  color: #f8ecd0;
}

.banner__track {
  display: inline-block;
  white-space: nowrap;
  line-height: 34px;
  animation: banner-scroll var(--dur, 14s) linear infinite;
}

.banner__close {
  flex: none;
  width: 34px;
  height: 34px;
  color: var(--rm-muted);
  font-size: 20px;
  line-height: 34px;
}

@keyframes banner-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Emoji floats (bottom-right of the video) */
.emoji-layer {
  position: absolute;
  right: 6px;
  bottom: 50px;
  z-index: 3;
  width: 56px;
  height: 70%;
  pointer-events: none;
}

.emoji-float {
  position: absolute;
  bottom: 0;
  left: 50%;
  font-size: 26px;
  line-height: 1;
  animation: emoji-up 1.8s ease-out forwards;
}

@keyframes emoji-up {
  0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  15% { transform: translate(calc(-50% + var(--dx, 0px) * 0.3), -12%) scale(1.05); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -300%) scale(0.9); opacity: 0; }
}

/* Tabs */
.tabs {
  flex: none;
  display: flex;
  gap: 4px;
  padding: 0 8px;
  border-bottom: 1px solid var(--rm-line);
  background: var(--rm-bg);
}

.tabs__item {
  position: relative;
  padding: 11px 12px 10px;
  color: var(--rm-muted);
  font-size: 15px;
}

.tabs__item.is-active {
  color: var(--rm-text);
  font-weight: 600;
}

.tabs__item.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 22px;
  height: 3px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: var(--rm-accent);
}

/* Chat / notice panels */
.panel {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.panel[hidden] {
  display: none;
}

.chat {
  padding: 8px 12px;
}

.chat__list {
  list-style: none;
}

.chat__list[hidden] {
  display: none;
}

.msg {
  padding: 4px 0;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg__name {
  color: var(--rm-name);
}

.msg__reply {
  color: var(--rm-muted);
}

.msg--gift .msg__text {
  color: var(--rm-accent-2);
}

.msg__icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin: 0 3px;
  vertical-align: -6px;
  object-fit: contain;
}

.chat__empty {
  padding: 28px 0;
  color: var(--rm-faint);
  font-size: 13px;
  text-align: center;
}

.chat__empty[hidden] {
  display: none;
}

.chat__new {
  position: sticky;
  left: 50%;
  bottom: 6px;
  display: block;
  margin: 6px auto 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--rm-accent);
  color: var(--rm-on-accent);
  font-size: 12px;
  font-weight: 600;
}

.chat__new[hidden] {
  display: none;
}

.notice {
  padding: 12px;
}

.notice__card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(242, 200, 121, 0.18);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(217, 164, 65, 0.1), rgba(217, 164, 65, 0.03));
}

.notice__head {
  display: flex;
  justify-content: space-between;
  color: var(--rm-accent-2);
  font-size: 13px;
}

.notice__text {
  font-size: 16px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.notice__time {
  color: var(--rm-faint);
  font-size: 12px;
}

.notice__actions {
  display: flex;
  gap: 10px;
}

.notice__actions button {
  flex: 1;
  height: 34px;
  border: 1px solid var(--rm-line);
  border-radius: 10px;
  background: var(--rm-surface-2);
  font-size: 13px;
}

.notice__actions button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Emoji row and composer */
.emoji-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 0;
}

.emoji-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  border-radius: 12px;
  background: var(--rm-surface-2);
  font-size: 19px;
}

.emoji-btn.is-off {
  opacity: 0.38;
  filter: grayscale(0.7);
}

.emoji-bar__hint {
  color: var(--rm-faint);
  font-size: 12px;
}

.composer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

.composer__gift {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(242, 200, 121, 0.35);
  border-radius: 50%;
  background: rgba(217, 164, 65, 0.12);
}

.composer__gift svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--rm-accent-2);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.composer__gift.is-off {
  opacity: 0.4;
}

.composer__input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rm-line);
  border-radius: 20px;
  outline: 0;
  background: var(--rm-surface-2);
  color: var(--rm-text);
  font: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming in on focus */
}

.composer__input:focus {
  border-color: rgba(217, 164, 65, 0.6);
}

.composer__input::placeholder {
  color: var(--rm-faint);
}

.composer__input:disabled {
  opacity: 0.6;
}

.composer__send {
  flex: none;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--rm-accent-2), var(--rm-accent));
  color: var(--rm-on-accent);
  font-size: 15px;
  font-weight: 600;
}

.composer__send:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Gift sheet */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.45);
}

.sheet[hidden] {
  display: none;
}

.sheet__panel {
  width: 100%;
  max-height: 72%;
  overflow-y: auto;
  padding: 14px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(242, 200, 121, 0.2);
  border-radius: 18px 18px 0 0;
  background: var(--rm-surface);
}

.sheet__head,
.sheet__group {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.sheet__head b {
  font-size: 16px;
}

.sheet__head span {
  color: #f3dcaa;
  font-size: 13px;
}

.sheet__group {
  margin: 14px 2px 8px;
}

.sheet__group b {
  font-size: 14px;
}

.sheet__group span {
  color: var(--rm-muted);
  font-size: 12px;
}

.gift-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.gift-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 8px 2px 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--rm-surface-2);
}

.gift-item img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.gift-item__name {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}

.gift-item__sub {
  color: var(--rm-muted);
  font-size: 10px;
  white-space: nowrap;
}

.gift-item[aria-pressed="true"] {
  border-color: var(--rm-accent);
  background: rgba(217, 164, 65, 0.16);
}

.gift-item.is-locked {
  opacity: 0.45;
}

.sheet__foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.sheet__send {
  min-width: 128px;
  height: 40px;
  padding: 0 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--rm-accent-2), var(--rm-accent));
  color: var(--rm-on-accent);
  font-size: 15px;
  font-weight: 600;
}

.sheet__send:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 48px);
  padding: 9px 16px;
  transform: translateX(-50%);
  border-radius: 12px;
  background: rgba(33, 30, 26, 0.96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .banner__track {
    animation: none;
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .emoji-float {
    animation-duration: 1s;
  }
}

/* ================= 登录墙（D1：没登录什么都看不到） ================= */
.login-view {
  --lg-accent: #d9a441;
  --lg-accent-2: #f2c879;
  --lg-text: #f5f2ec;
  --lg-muted: #9b958b;
  --lg-faint: #6c675f;
  --lg-surface: rgba(26, 24, 21, 0.74);
  --lg-field: rgba(10, 9, 8, 0.6);
  --lg-line: rgba(255, 255, 255, 0.08);
  --lg-danger: #ff6b6b;
  --lg-on-accent: #241a07;
  position: relative;
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(48px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 24px;
  color: var(--lg-text);
}

/* Full-screen backdrop: deep navy, a soft blue glow and a faint market line, drawn in CSS/SVG (no image download). */
.login-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(217, 164, 65, 0.28) 0%, rgba(217, 164, 65, 0.07) 45%, transparent 70%),
    radial-gradient(60% 40% at 100% 100%, rgba(242, 200, 121, 0.08) 0%, transparent 70%),
    linear-gradient(180deg, #121010 0%, #0d0c0b 55%, #0a0909 100%);
}

.login-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, transparent 55%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, transparent 55%);
}

.login-backdrop__chart {
  position: absolute;
  left: 0;
  right: 0;
  top: 40px;
  width: 100%;
  height: 220px;
  opacity: 0.32;
  mask-image: radial-gradient(60% 55% at 50% 60%, transparent 0%, #000 75%);
  -webkit-mask-image: radial-gradient(60% 55% at 50% 60%, transparent 0%, #000 75%);
}

.login-backdrop__chart polyline {
  fill: none;
  stroke: rgba(242, 200, 121, 0.55);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.login-backdrop__candles rect {
  fill: rgba(242, 200, 121, 0.18);
}

/* Brand + card are centred vertically when there is room (auto margins collapse to 0 on short screens). */
.login-brand {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.login-brand__mark {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(211, 181, 69, 0.3);
}

.login-brand__mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.login-brand__name {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.login-brand__sub {
  padding: 3px 12px;
  border: 1px solid rgba(242, 200, 121, 0.35);
  border-radius: 999px;
  background: rgba(217, 164, 65, 0.12);
  color: #f3dcaa;
  font-size: 12px;
  letter-spacing: 0.2em;
}

/* Card */
.login-card {
  margin-bottom: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 20px 20px;
  border: 1px solid var(--lg-line);
  border-radius: 22px;
  background: var(--lg-surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.login-card__title {
  font-size: 20px;
  font-weight: 600;
}

/* Fields */
.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-field[hidden] {
  display: none;
}

.login-field__label {
  color: #cbc5ba;
  font-size: 13px;
}

.login-input {
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 6px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: var(--lg-field);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.login-input:focus-within {
  border-color: var(--lg-accent);
  background: rgba(10, 9, 8, 0.85);
  box-shadow: 0 0 0 4px rgba(217, 164, 65, 0.18);
}

.login-input__icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-right: 10px;
  fill: none;
  stroke: var(--lg-faint);
  stroke-width: 1.6;
  stroke-linecap: round;
  transition: stroke 0.2s;
}

.login-input:focus-within .login-input__icon {
  stroke: var(--lg-accent-2);
}

.login-input input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--lg-text);
  font: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming in on focus */
}

.login-input input::placeholder {
  color: var(--lg-faint);
}

.login-input__eye {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--lg-faint);
}

.login-input__eye svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.login-input__eye[aria-pressed="false"] .eye-slash {
  display: none;
}

.login-input__eye:focus-visible {
  outline: 2px solid var(--lg-accent-2);
}

/* Error */
.login-card__error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: 12px;
  background: rgba(255, 107, 107, 0.1);
  color: #ffb3b3;
  font-size: 14px;
  line-height: 1.5;
  animation: login-shake 0.35s ease;
}

.login-card__error::before {
  content: "!";
  flex: 0 0 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--lg-danger);
  color: #1a0b0b;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.login-card__error[hidden] {
  display: none;
}

@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Submit */
.login-card__submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  margin-top: 4px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--lg-accent-2) 0%, var(--lg-accent) 55%, #b9832a 100%);
  box-shadow: 0 12px 28px rgba(217, 164, 65, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: var(--lg-on-accent);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3em;
  transition: transform 0.12s ease, box-shadow 0.2s, opacity 0.2s;
}

.login-card__submit:active {
  transform: scale(0.985);
  box-shadow: 0 6px 16px rgba(217, 164, 65, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.login-card__submit:focus-visible {
  outline: 2px solid var(--lg-accent-2);
  outline-offset: 3px;
}

.login-card__submit:disabled {
  cursor: progress;
  opacity: 0.75;
}

.login-card__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(36, 26, 7, 0.25);
  border-top-color: var(--lg-on-accent);
  border-radius: 50%;
  animation: login-spin 0.8s linear infinite;
}

.login-card__submit.is-loading .login-card__spinner {
  display: block;
}

.login-card__submit.is-loading .login-card__submit-text {
  letter-spacing: 0.1em;
}

@keyframes login-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .login-input,
  .login-card__submit {
    transition: none;
  }

  .login-card__error {
    animation: none;
  }
}

/* ================= 响应式 =================
 * 三种布局：
 * - 手机竖屏（宽 < 600）：上面这些规则，保持不变；
 * - 单列铺满（宽 ≥ 600，竖向或接近方形，如平板竖屏、拖窄的电脑窗口）：同一套单列，画面跟着变宽；
 * - 宽屏（宽 ≥ 640 且宽高比 ≥ 6:5，如电脑、平板横屏、手机横屏）：左边画面、右边聊天。
 *   用宽高比而不是只看宽度：竖着的平板弹出键盘时可视高度变小，只看「横向」会在打字时跳成宽屏。
 * 分栏容器 .room-main / .room-side / .room-bar 在单列布局里不生成盒子，子元素照旧是 .room 的上下排列；
 * 表情栏和输入框在页面结构里移到了画面下方和右栏，单列布局靠 order 排回聊天区之后。 */
.room-main,
.room-side,
.room-bar {
  display: contents;
}

.emoji-bar {
  order: 1;
}

.composer {
  order: 2;
}

/* 只在宽屏布局出现的元素 */
.room-top__live,
.room-top__label,
.room-top__service,
.gift-strip,
.room-bar__btn {
  display: none;
}

/* ---------- 单列铺满（平板竖屏、窄窗口） ---------- */
@media (min-width: 600px) {
  body {
    align-items: stretch;
  }

  .room {
    max-width: none;
  }

  .sheet {
    justify-content: center;
  }

  .sheet__panel {
    max-width: 600px;
  }

  .gift-grid {
    gap: 8px;
  }
}

/* ---------- 宽屏：左画面、右聊天 ---------- */
@media (min-width: 640px) and (min-aspect-ratio: 6/5) {
  body {
    display: block;
  }

  .room {
    --side-w: 340px;
    --top-h: 60px;
    --gap: 20px;
    --bar-h: 64px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side-w);
    grid-template-rows: var(--top-h) minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "main side";
    background:
      radial-gradient(90% 60% at 30% -10%, rgba(217, 164, 65, 0.08), transparent 70%),
      var(--rm-bg);
  }

  /* 顶栏：名称 + 直播状态，右侧积分签到、分享、客服 */
  .room-top {
    grid-area: top;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--rm-line);
    background: rgba(13, 12, 11, 0.9);
  }

  .room-top__mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .room-top__name {
    flex: 0 1 auto;
    font-size: 17px;
  }

  .room-top__live {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(255, 77, 94, 0.14);
    color: #ff8a96;
    font-size: 12px;
  }

  .room-top__live::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rm-live);
  }

  .room-top__live.is-off {
    background: rgba(255, 255, 255, 0.06);
    color: var(--rm-muted);
  }

  .room-top__live.is-off::before {
    background: var(--rm-faint);
  }

  .room-top__points {
    height: 34px;
    font-size: 13px;
  }

  .room-top__points button {
    height: 28px;
    padding: 0 14px;
    font-size: 13px;
  }

  .room-top__service {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px 0 11px;
    border: 1px solid var(--rm-line);
    border-radius: 999px;
    background: var(--rm-surface-2);
    font-size: 13px;
  }

  .room-top__service svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--rm-accent-2);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .room-top__label {
    display: inline;
  }

  /* 画面区：画面按 16:9 尽量放大，窗口矮时按高度收窄；画面和操作条整体垂直居中 */
  .room-main {
    --avail-h: calc(100vh - var(--top-h) - var(--gap) * 2 - var(--bar-h) - 10px);
    grid-area: main;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    padding: var(--gap) 24px;
  }

  @supports (height: 100dvh) {
    .room-main {
      --avail-h: calc(100dvh - var(--top-h) - var(--gap) * 2 - var(--bar-h) - 10px);
    }
  }

  .stage,
  .room-bar {
    width: min(100%, calc(var(--avail-h) * 16 / 9));
  }

  /* isolation：画面里的动效层（z-index 很高）只在画面内比较，礼物弹出层能盖在它上面 */
  .stage {
    isolation: isolate;
    border-radius: 14px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 18px 50px rgba(0, 0, 0, 0.5);
  }

  .stage__badge {
    left: 14px;
    top: 14px;
  }

  .stage__tools {
    right: 14px;
    top: 14px;
  }

  .stage__controls {
    padding: 10px 14px;
  }

  .stage--banner .stage__badge,
  .stage--banner .stage__tools {
    top: 52px;
  }

  .banner {
    height: 38px;
    padding-left: 14px;
  }

  .banner__track {
    line-height: 38px;
  }

  .banner__close {
    width: 40px;
    height: 38px;
  }

  .emoji-layer {
    right: 14px;
    bottom: 58px;
    width: 90px;
  }

  .emoji-float {
    font-size: 34px;
  }

  /* 画面下方操作条：表情、礼物快捷条、礼物、全屏 */
  .room-bar {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--bar-h);
  }

  .room-bar .emoji-bar {
    order: 0;
    flex: none;
    padding: 0;
  }

  .emoji-bar__hint {
    min-width: 64px;
  }

  .gift-strip {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 2px;
    padding-left: 12px;
    overflow: hidden;
    border-left: 1px solid var(--rm-line);
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }

  .gift-chip {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 58px;
    padding: 4px 0 3px;
    border-radius: 10px;
  }

  .gift-chip img {
    width: 34px;
    height: 34px;
    object-fit: contain;
  }

  .gift-chip span {
    max-width: 100%;
    overflow: hidden;
    color: var(--rm-muted);
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .gift-chip.is-locked {
    opacity: 0.45;
  }

  .room-bar__btn {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    margin-left: auto;
    padding: 0 16px 0 12px;
    border: 1px solid var(--rm-line);
    border-radius: 999px;
    background: var(--rm-surface-2);
    font-size: 14px;
  }

  .room-bar__btn + .room-bar__btn {
    margin-left: 0;
  }

  .room-bar__btn[hidden] {
    display: none;
  }

  .room-bar__btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--rm-accent-2);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .room-bar__btn--gift {
    border-color: rgba(242, 200, 121, 0.4);
    background: rgba(217, 164, 65, 0.14);
    color: #f3dcaa;
  }

  .room-bar.is-off .gift-strip,
  .room-bar.is-off .room-bar__btn--gift {
    opacity: 0.4;
  }

  /* 礼物面板：画面下方弹出，不遮右侧聊天（点面板外或 Esc 关闭） */
  .sheet {
    position: absolute;
    inset: auto 0 calc(100% + 8px) auto;
    display: block;
    background: none;
    z-index: 40;
  }

  .sheet__panel {
    width: min(440px, calc(100vw - var(--side-w) - 24px));
    max-width: none;
    max-height: min(540px, var(--avail-h));
    padding: 14px 14px 12px;
    border: 1px solid rgba(242, 200, 121, 0.22);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  }

  .sheet__foot {
    position: sticky;
    bottom: -12px;
    margin: 12px -14px -12px;
    padding: 10px 14px 12px;
    background: var(--rm-surface);
  }

  /* 右侧聊天栏；客服在顶栏，输入框左边不放礼物按钮 */
  .room-side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1px solid var(--rm-line);
    background: var(--rm-surface);
  }

  .room-side .tabs {
    padding: 0 10px;
    background: transparent;
  }

  #serviceTab,
  .composer__gift {
    display: none;
  }

  .chat {
    padding: 10px 16px;
  }

  .msg {
    margin: 0 -8px;
    padding: 4px 8px;
    border-radius: 8px;
  }

  .composer {
    padding: 12px 14px 14px;
    border-top: 1px solid var(--rm-line);
  }

  .composer__input {
    font-size: 14px;
  }

  .toast {
    left: calc((100% - var(--side-w)) / 2);
    bottom: 120px;
    z-index: 50;
  }

  /* 登录页：左品牌、右登录框（不加说明文字） */
  .login-view {
    max-width: 1040px;
    margin: 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(40px, 8vw, 120px);
    padding: 40px 48px;
  }

  .login-brand {
    flex: 0 1 380px;
    margin: 0;
    align-items: flex-start;
    gap: 14px;
    text-align: left;
  }

  .login-brand__mark {
    width: 88px;
    height: 88px;
    border-radius: 26px;
  }

  .login-brand__name {
    font-size: 40px;
    line-height: 1.2;
  }

  .login-brand__sub {
    font-size: 13px;
  }

  .login-card {
    flex: 0 0 400px;
    margin: 0;
    padding: 32px 28px 28px;
  }

  .login-backdrop__chart {
    top: 16%;
    height: 62%;
  }
}

/* 两条全屏规则分开写：浏览器不认识其中一个选择器时整条规则会失效 */
.stage:fullscreen {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.stage:-webkit-full-screen {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* 全屏：整块画面（含横幅、动效礼物、表情）一起全屏；信号中断时也留着控件条里的退出全屏 */
.stage:fullscreen .stage__controls {
  display: flex;
}

.stage:-webkit-full-screen .stage__controls {
  display: flex;
}

.stage:fullscreen .stage__ctl {
  width: 40px;
  height: 40px;
}

.stage:-webkit-full-screen .stage__ctl {
  width: 40px;
  height: 40px;
}

/* 大屏：右栏稍宽 */
@media (min-width: 1600px) and (min-aspect-ratio: 6/5) {
  .room {
    --side-w: 380px;
  }
}

/* 手机横屏等矮窗口：顶栏、间距收紧，礼物条只留按钮 */
@media (min-width: 640px) and (min-aspect-ratio: 6/5) and (max-height: 560px) {
  .room {
    --side-w: 300px;
    --top-h: 46px;
    --gap: 8px;
    --bar-h: 44px;
  }

  .room-main {
    padding: var(--gap) 12px;
  }

  .room-top__label,
  .gift-strip,
  .emoji-bar__hint {
    display: none;
  }

  .room-top__service {
    justify-content: center;
    width: 34px;
    padding: 0;
  }

  .emoji-btn {
    height: 32px;
  }

  .room-bar__btn {
    height: 34px;
  }

  .login-view {
    gap: 32px;
    padding: 16px 24px;
  }

  .login-brand__mark {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .login-brand__name {
    font-size: 24px;
  }

  .login-card {
    flex-basis: 340px;
    gap: 10px;
    padding: 18px 18px 16px;
  }

  .login-card__title {
    display: none;
  }

  .login-input {
    height: 44px;
  }

  .login-card__submit {
    height: 46px;
  }
}

/* 宽屏但左栏很窄（如 700 宽的窗口）：右栏收窄，礼物条和冷却提示收起，操作条只留表情和两个按钮，不挤进右栏 */
@media (min-width: 640px) and (min-aspect-ratio: 6/5) and (max-width: 899px) {
  .room {
    --side-w: 280px;
  }

  .room-main {
    padding: var(--gap) 12px;
  }

  .gift-strip,
  .emoji-bar__hint {
    display: none;
  }
}

/* 有鼠标的设备：悬停反馈 */
@media (hover: hover) and (pointer: fine) {
  .room-top__service:hover,
  .room-bar__btn:hover {
    border-color: rgba(242, 200, 121, 0.55);
  }

  .gift-chip:hover,
  .msg:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  .gift-item:hover {
    border-color: rgba(242, 200, 121, 0.3);
  }

  .emoji-btn:not(.is-off):hover,
  .tabs__item:hover {
    color: var(--rm-text);
    filter: brightness(1.15);
  }

  .composer__send:not(:disabled):hover,
  .room-top__points button:hover {
    filter: brightness(1.08);
  }
}
