:root {
  --ember: #e84a1b;
  --ember-hot: #ff6a2a;
  --paper: #f5ebe3;
  --muted: rgba(245, 235, 227, 0.72);
  --font-display: "ZCOOL XiaoWei", "Noto Sans SC", serif;
  --font-body: "Noto Sans SC", sans-serif;
  --vh: 100dvh;
  --vw: 100vw;
  --stage-w: 100vw;
  --stage-h: 100dvh;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: var(--paper);
  font-family: var(--font-body);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #000;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.boot.hide {
  opacity: 0;
}

.boot[hidden] {
  display: none;
}

.boot-brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: 3.2rem;
  letter-spacing: 0.12em;
  background: linear-gradient(120deg, #fff, #ffb347 50%, var(--ember-hot));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: boot-pulse 1.1s ease-in-out infinite;
}

@keyframes boot-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.03);
  }
}

.shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(232, 74, 27, 0.16), transparent 55%),
    #050505;
}

.rail {
  display: none;
}

.stage {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
  background: #000;
  overflow: hidden;
  z-index: 1;
}

.stage:fullscreen,
.stage:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 0;
}

.feed {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -ms-touch-action: none;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
}

.feed::-webkit-scrollbar {
  display: none;
}

.feed[hidden] {
  display: none;
}

.track {
  width: 100%;
  height: 100%;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.track.animating {
  transition: transform 0.36s cubic-bezier(0.22, 0.82, 0.24, 1);
}

.slide {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  contain: layout style paint;
}

.slide video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #000;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.slide-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.28) 0%, transparent 16%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, transparent 30%);
}

.slide-meta {
  position: absolute;
  left: max(1rem, env(safe-area-inset-left));
  right: 5.5rem;
  bottom: max(1.2rem, calc(0.6rem + env(safe-area-inset-bottom)));
  z-index: 2;
  pointer-events: none;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}

.brand-chip span {
  width: 1.15rem;
  height: 1.15rem;
  display: grid;
  place-items: center;
  border-radius: 0.25rem;
  background: linear-gradient(145deg, var(--ember-hot), var(--ember));
  color: #1a0c08;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 900;
}

.slide-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.slide-actions {
  position: absolute;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(5.2rem, calc(4.2rem + env(safe-area-inset-bottom)));
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  align-items: center;
}

.action {
  width: 2.7rem;
  height: 2.7rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.15rem;
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.action.active {
  color: #ff4d6d;
  background: rgba(255, 77, 109, 0.22);
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
  z-index: 4;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--ember-hot), #ffb347);
  will-change: width;
}

.waiting {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.12);
}

.waiting[hidden] {
  display: none;
}

.waiting::after {
  content: "";
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffb347;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.play-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.play-hint.show {
  opacity: 1;
}

.play-hint::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 18px 0 18px 30px;
  border-color: transparent transparent transparent rgba(255, 255, 255, 0.85);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
}

.sound-tip {
  position: fixed;
  top: max(0.9rem, calc(0.4rem + env(safe-area-inset-top)));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.82rem;
  backdrop-filter: blur(8px);
  pointer-events: none;
  animation: tip-in 0.35s ease both;
}

.sound-tip[hidden] {
  display: none;
}

@keyframes tip-in {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.empty-state {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #000;
  z-index: 5;
}

.empty-state[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.85rem;
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

/* Desktop / tablet landscape: Douyin-like center phone stage */
@media (min-width: 820px) {
  body {
    touch-action: auto;
  }

  .shell {
    grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
    align-items: center;
    justify-items: center;
    gap: 2rem;
    padding: 1.5rem;
  }

  .rail {
    display: block;
    justify-self: end;
    max-width: 220px;
    text-align: right;
  }

  .rail-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 0.08em;
  }

  .rail-brand span {
    width: 1.6rem;
    height: 1.6rem;
    display: grid;
    place-items: center;
    border-radius: 0.3rem;
    background: linear-gradient(145deg, var(--ember-hot), var(--ember));
    color: #1a0c08;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 900;
  }

  .rail-line {
    margin: 0.85rem 0 0;
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.95rem;
  }

  .stage {
    width: min(420px, calc(var(--vh) * 0.52));
    height: min(840px, calc(var(--vh) - 48px));
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    outline: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sound-tip {
    left: 50%;
  }
}
