:root {
  --bg: #080a0f;
  --panel: #0f131b;
  --panel-2: #151a24;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .16);
  --text: #eef1f7;
  --muted: #8d95a7;
  --pink: #ff5c8a;
  --pink-2: #ff9ab8;
  --violet: #8b5cf6;
  --green: #3ddc97;
  --danger: #e5484d;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 620px at 8% -18%, rgba(255, 92, 138, .16), transparent 62%),
    radial-gradient(820px 520px at 102% -6%, rgba(139, 92, 246, .14), transparent 58%),
    var(--bg);
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

input { font-family: inherit; }

.hidden { display: none !important; }

.room {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.primary {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 8px 24px rgba(255, 92, 138, .28);
  transition: transform .15s, box-shadow .2s, filter .2s;
}

.primary:hover { filter: brightness(1.06); }
.primary:active { transform: scale(.985); }

/* ---------------- 进入页 ---------------- */

.join {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  position: relative;
  overflow: hidden;
}

.join-glow {
  position: absolute;
  top: -180px;
  right: -140px;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 92, 138, .22), transparent 65%);
  pointer-events: none;
}

.join-card {
  position: relative;
  width: 100%;
  max-width: 390px;
  padding: 34px 28px 24px;
  border-radius: 24px;
  background: rgba(17, 21, 30, .74);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 10px 26px rgba(255, 92, 138, .35);
  margin-bottom: 18px;
}

.join-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: .5px;
}

.join-card .sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .3px;
}

.field input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, .045);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.field input::placeholder { color: rgba(255, 255, 255, .28); }

.field input:focus {
  border-color: rgba(255, 92, 138, .55);
  background: rgba(255, 92, 138, .06);
  box-shadow: 0 0 0 4px rgba(255, 92, 138, .1);
}

.block {
  width: 100%;
  height: 50px;
  font-size: 16px;
  border-radius: 12px;
  margin-top: 6px;
}

.join-card .tip {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  text-align: center;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 17, .72);
  backdrop-filter: blur(16px);
  position: relative;
  z-index: 20;
}

.room-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.room-pill b {
  color: var(--text);
  font-weight: 600;
  letter-spacing: .8px;
}

.pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 151, .55); }
  70% { box-shadow: 0 0 0 7px rgba(61, 220, 151, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
}

.users {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  padding-right: 2px;
}

.avatar {
  width: 28px;
  height: 28px;
  margin-left: -7px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg,
    hsl(var(--h, 330) 78% 60%),
    hsl(calc(var(--h, 330) + 38) 72% 46%));
  border: 2px solid #0a0c11;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}

.avatar:first-child { margin-left: 0; }

.avatar.more {
  background: rgba(255, 255, 255, .12);
  color: var(--muted);
  font-size: 11px;
}

.copy-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  font-size: 12px;
  transition: .2s;
}

.copy-btn svg { width: 15px; height: 15px; }

.copy-btn:hover {
  color: var(--text);
  border-color: var(--line-2);
  background: rgba(255, 255, 255, .07);
}

.copy-btn:active { transform: scale(.96); }

/* ---------------- 播放区 ---------------- */

.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 14px 0;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1180px;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
}

.stage video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* 弹幕层 */

.dm-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.dm-layer.paused .dm { animation-play-state: paused; }

.dm {
  position: absolute;
  left: 0;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9), 0 0 8px rgba(0, 0, 0, .7);
  animation-name: dm-fly;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  will-change: transform;
}

@keyframes dm-fly {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-1 * var(--w) - 100%)); }
}

/* 控制条 */

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 38px 12px 10px;
  background: linear-gradient(to top,
    rgba(0, 0, 0, .88),
    rgba(0, 0, 0, .38) 55%,
    transparent);
}

.ctrl {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .09);
  color: #fff;
  font-size: 15px;
  backdrop-filter: blur(8px);
  transition: background .15s, transform .15s;
}

.ctrl:hover { background: rgba(255, 255, 255, .18); }
.ctrl:active { transform: scale(.93); }
.ctrl svg { width: 18px; height: 18px; }

.time {
  flex: none;
  font-size: 12px;
  color: rgba(255, 255, 255, .88);
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
  white-space: nowrap;
}

.seek {
  flex: 1;
  height: 6px;
  margin: 0;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right,
    var(--pink) 0 var(--p, 0%),
    rgba(255, 255, 255, .22) var(--p, 0%) 100%);
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 92, 138, .35), 0 2px 6px rgba(0, 0, 0, .5);
}

.seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: transparent;
}

.seek::-moz-range-track { height: 6px; background: transparent; }

/* 中间按钮 */

.big-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 74px;
  height: 74px;
  padding-left: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), #ff4f7f);
  color: #fff;
  font-size: 26px;
  z-index: 5;
  box-shadow: 0 12px 40px rgba(255, 92, 138, .45);
  transition: transform .15s;
}

.big-play:active { transform: translate(-50%, -50%) scale(.94); }

.gate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 10, .62);
  backdrop-filter: blur(3px);
  z-index: 7;
}

.gate button {
  height: 46px;
  padding: 0 26px;
  border-radius: 999px;
  font-size: 15px;
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  z-index: 1;
  background: radial-gradient(circle at 50% 45%, rgba(255, 92, 138, .07), transparent 60%);
}

.empty-hint p { margin: 0; }

.empty-hint .small {
  font-size: 12px;
  line-height: 1.8;
  color: rgba(255, 255, 255, .4);
}

.empty-hint code {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .08);
}

/* ---------------- 剧集 ---------------- */

.toolbar {
  width: 100%;
  max-width: 1180px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 0;
}

.episodes {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
}

.episodes::-webkit-scrollbar { display: none; }

.ep {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  max-width: 250px;
  padding: 0 13px;
  overflow: hidden;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, .045);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: .18s;
}

.ep:hover { color: var(--text); background: rgba(255, 255, 255, .08); }

.ep-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ep.active {
  color: #fff;
  border-color: rgba(255, 92, 138, .5);
  background: linear-gradient(135deg, rgba(255, 92, 138, .24), rgba(139, 92, 246, .2));
  box-shadow: 0 4px 18px rgba(255, 92, 138, .18);
}

.ep-del {
  display: none;
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
}

.episodes.managing .ep-del { display: inline-block; }
.episodes.managing .ep { border-color: rgba(229, 72, 77, .42); }

.chip-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, .04);
  border: 1px dashed var(--line-2);
  transition: .18s;
}

.chip-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); }

.chip-btn.active {
  color: var(--danger);
  border-style: solid;
  border-color: rgba(229, 72, 77, .6);
  background: rgba(229, 72, 77, .1);
}

.upload-btn {
  border-style: solid;
  color: var(--text);
  border-color: rgba(255, 92, 138, .35);
  background: linear-gradient(135deg, rgba(255, 92, 138, .18), rgba(139, 92, 246, .18));
}

.upload-btn:hover { border-color: rgba(255, 92, 138, .6); }

/* 上传进度 */

.upload-bar {
  position: relative;
  width: 100%;
  max-width: 1180px;
  height: 22px;
  margin-top: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
}

.upload-bar div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  transition: width .15s;
}

.upload-bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

/* ---------------- 弹幕列表（手机） ---------------- */

.dm-feed { display: none; }

/* ---------------- 弹幕输入 ---------------- */

.dm-form {
  width: 100%;
  max-width: 1180px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px calc(10px + var(--safe-b));
}

.colors {
  display: flex;
  gap: 6px;
  flex: none;
}

.color-dot {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s;
}

.color-dot.active {
  border-color: #fff;
  transform: scale(1.12);
}

.dm-form input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color .2s, background .2s;
}

.dm-form input::placeholder { color: rgba(255, 255, 255, .3); }

.dm-form input:focus {
  border-color: rgba(255, 92, 138, .5);
  background: rgba(255, 92, 138, .06);
}

.send-btn {
  flex: none;
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 6px 18px rgba(255, 92, 138, .28);
  transition: transform .15s;
}

.send-btn:active { transform: scale(.95); }

/* ---------------- 手机 ---------------- */

@media (max-width: 720px) {
  .topbar {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
  }

  .room-pill {
    height: 30px;
    padding: 0 10px;
    font-size: 11px;
    gap: 6px;
  }

  .avatar { width: 26px; height: 26px; font-size: 11px; }

  .copy-btn { height: 30px; padding: 0 10px; }
  .copy-text { display: none; }
  .copy-btn svg { width: 16px; height: 16px; }

  .stage-wrap { padding: 0; }

  .stage {
    flex: none;
    width: 100%;
    max-width: none;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .controls { padding: 30px 8px 8px; gap: 7px; }
  .ctrl { width: 36px; height: 36px; }
  .ctrl svg { width: 17px; height: 17px; }
  .time { font-size: 11px; }

  .big-play { width: 62px; height: 62px; font-size: 22px; }

  .dm { font-size: 16px; }

  .toolbar { padding: 9px 12px 0; gap: 7px; }

  .ep {
    height: 30px;
    max-width: 190px;
    padding: 0 11px;
    font-size: 12px;
  }

  .chip-btn { height: 30px; padding: 0 11px; font-size: 12px; }

  .upload-bar { margin: 8px 12px 0; width: calc(100% - 24px); }

  .dm-feed {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    flex: 1;
    min-height: 0;
    margin: 10px 12px 0;
    border-radius: 16px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--line);
    overflow: hidden;
  }

  .feed-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .5px;
  }

  .feed-count {
    font-variant-numeric: tabular-nums;
    opacity: .75;
  }

  .feed-list {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 6px 14px 10px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .feed-list::-webkit-scrollbar { display: none; }

  .feed-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    line-height: 1.5;
    animation: feed-in .18s ease-out;
  }

  .feed-item:first-child { margin-top: auto; }

  .feed-item .t {
    flex: none;
    padding-top: 2px;
    font-size: 11px;
    color: rgba(255, 255, 255, .32);
    font-variant-numeric: tabular-nums;
  }

  .feed-item .u {
    flex: none;
    max-width: 78px;
    padding-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--pink-2);
  }

  .feed-item .x { color: var(--text); word-break: break-word; }

  .feed-empty {
    height: 100%;
    display: grid;
    place-items: center;
    padding: 20px;
    text-align: center;
    font-size: 12px;
    line-height: 1.9;
    color: var(--muted);
  }

  .dm-form { padding: 10px 12px calc(10px + var(--safe-b)); }
  .dm-form input { height: 42px; font-size: 16px; }
  .send-btn { height: 42px; padding: 0 18px; }
  .colors { display: none; }

  .stage.fs { height: 100dvh; }
}

@keyframes feed-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 桌面 ---------------- */

@media (min-width: 721px) {
  html, body { height: 100dvh; overflow: hidden; }
  body { min-height: 0; }
}

/* 全屏（伪全屏，保留弹幕层） */

.stage.fs {
  position: fixed;
  inset: 0;
  z-index: 80;
  flex: none;
  max-width: none;
  border-radius: 0;
  border: 0;
  aspect-ratio: auto;
}

.stage.fs video { height: 100%; }
