:root {
  font-family: "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  color: #171719;
  background: #f7f7f8;
  --blue: #002fa7;
  --video-height: min(56.25vw, 405px);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.room {
  display: grid;
  grid-template-rows: var(--video-height) minmax(0, 1fr);
  width: min(100%, 720px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
}

.stage {
  position: relative;
  width: 100%;
  height: var(--video-height);
  overflow: hidden;
  background: #000;
}

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

.start-playback {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 58px;
  height: 58px;
  padding: 15px 13px 15px 17px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: rgb(30 30 32 / 58%);
  color: #fff;
  line-height: 0;
}

.start-playback svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.playback-started .start-playback,
.playback-ended .start-playback { display: none; }

.video-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 10px 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.stage.controls-visible .video-controls { opacity: 1; }

.video-controls button {
  width: 32px;
  height: 32px;
  padding: 7px;
  border: 0;
  background: transparent;
  color: #fff;
  line-height: 0;
  pointer-events: auto;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 75%));
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-compress { display: none; }
.is-fullscreen .icon-expand { display: none; }
.is-fullscreen .icon-compress { display: block; }

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

.stage.landscape-mode .danmaku,
.stage:fullscreen .danmaku { display: block; }

.danmaku-item {
  position: absolute;
  top: 16px;
  left: 100%;
  max-width: 74%;
  padding: 5px 10px;
  border-radius: 16px;
  background: rgb(15 15 16 / 68%);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  animation: fly 6.5s linear forwards;
}

.announcement-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10000;
  width: min(82vw, 520px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 18px 22px;
  transform: translate(-50%, -50%) scale(.98);
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 4px;
  background: rgb(0 0 0 / 72%);
  color: #fff;
  font-size: 22px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .18s ease, transform .18s ease;
}

.announcement-overlay.is-visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
}

@keyframes fly {
  to { transform: translateX(-150vw); }
}

.chat-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #f5f6f8;
}

.chat-head {
  display: flex;
  flex: 0 0 58px;
  align-items: flex-start;
  height: 58px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid #eceef0;
}

.chat-head strong {
  height: 58px;
  padding-top: 20px;
  border-bottom: 3px solid var(--blue);
  font-size: 16px;
  font-weight: 500;
}

.messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 16px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f5f6f8;
}

.messages::before {
  content: "";
  flex: 1 0 0;
}

.message {
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  padding: 8px 0 11px;
  text-align: left;
  border-bottom: 1px solid #e3e5e8;
}

.message strong {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 500;
}

.message p {
  margin: 0;
  color: #202124;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-note {
  flex: 0 0 auto;
  margin: 0;
  color: #b32645;
  font-size: 13px;
}

.composer {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e6e8eb;
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px solid #cfd2d7;
  border-radius: 22px;
  outline: 0;
  background: #fff;
  font-size: 16px;
}

.composer input:focus { border-color: var(--blue); }

.composer button {
  flex: 0 0 70px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.composer button:disabled { opacity: 0.55; }

.cart-button {
  position: absolute;
  right: 18px;
  bottom: calc(68px + env(safe-area-inset-bottom));
  z-index: 4;
  width: 42px;
  height: 42px;
  padding: 9px;
  border: 0;
  border-radius: 50%;
  background: #ffd43b;
  color: #222;
  box-shadow: 0 2px 8px rgb(0 0 0 / 14%);
}

.cart-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cart-button span {
  position: absolute;
  top: -3px;
  right: -2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  line-height: 17px;
}

.product-thumb {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  background: #f1f2f4;
  color: #7d8087;
  font-size: 11px;
}

.product-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-prompt {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 280px;
  height: 280px;
  padding: 20px;
  transform: translate(-50%, calc(-50% + 10px));
  border: 1px solid #e1e3e6;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 3px 12px rgb(0 0 0 / 10%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.product-prompt.is-visible {
  transform: translate(-50%, -50%);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.product-prompt .product-thumb {
  flex-basis: 116px;
  width: 116px;
  height: 116px;
}

.product-prompt > span:nth-child(3) {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.product-prompt strong { font-size: 16px; }

.product-prompt small {
  color: var(--blue);
  font-size: 15px;
}

.product-prompt > #prompt-order {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.product-prompt > .prompt-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 0;
  background: transparent;
  color: #696c72;
}

.prompt-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.product-sheet {
  position: fixed;
  inset: 0;
  z-index: 10000;
  visibility: hidden;
}

.product-sheet.is-open { visibility: visible; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgb(0 0 0 / 28%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.product-sheet.is-open .sheet-backdrop { opacity: 1; }

.sheet-body {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: min(100%, 720px);
  padding: 0 20px 28px;
  transform: translate(-50%, 100%);
  background: #fff;
  transition: transform 0.22s ease;
}

.product-sheet.is-open .sheet-body { transform: translate(-50%, 0); }

.sheet-body header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  border-bottom: 1px solid #eceef0;
}

.sheet-body header button {
  width: 36px;
  height: 36px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: #555;
}

.sheet-body header button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}

.product-row div {
  display: grid;
  flex: 1;
  gap: 3px;
  min-width: 0;
}

.product-row small {
  color: #7d8087;
  font-size: 11px;
}

.product-row b {
  color: var(--blue);
  font-size: 15px;
}

.product-row > button {
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
}

.product-row > button:disabled {
  background: #eceef0;
  color: #8a8d92;
}

.product-list {
  display: grid;
  min-width: 0;
}

.product-list:empty { display: none; }

body.video-landscape { background: #000; }

.stage.landscape-mode,
.stage:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100dvh;
  transform: none;
  background: #000;
}

.stage.landscape-mode video,
.stage:fullscreen video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage.landscape-mode.rotate-landscape {
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  width: var(--viewport-height);
  height: var(--viewport-width);
  transform: translate(-50%, -50%) rotate(90deg);
}

@media (max-width: 720px) {
  body {
    position: fixed;
    inset: 0;
  }

  .room {
    position: fixed;
    top: var(--visual-top, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    display: grid;
    grid-template-rows: var(--video-height) minmax(0, 1fr);
    width: 100%;
    max-width: 720px;
    height: var(--visual-height, 100dvh);
    margin: 0 auto;
    overflow: hidden;
  }

  .stage:not(.landscape-mode) {
    position: relative;
    z-index: 2;
    width: 100%;
    height: var(--video-height);
    transform: none;
  }

  .chat-panel {
    position: relative;
    z-index: 1;
    min-height: 0;
  }

  .chat-head {
    flex-basis: 48px;
    height: 48px;
    padding-inline: 16px;
  }

  .chat-head strong {
    height: 48px;
    padding-top: 15px;
    font-size: 15px;
  }

  .messages {
    min-height: 0;
    padding: 12px 16px 16px;
    touch-action: pan-y;
  }

  .message strong {
    margin-bottom: 3px;
    font-size: 13px;
  }

  .message p {
    font-size: 15px;
    line-height: 1.55;
  }

  .composer {
    position: relative;
    z-index: 5;
    gap: 6px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .composer button {
    flex-basis: 64px;
  }

  .product-prompt {
    width: min(280px, calc(100vw - 32px));
  }

  .sheet-body {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}
