:root {
  color-scheme: dark;
  --bw-ink: #fff4e3;
  --bw-panel: rgba(38, 17, 21, 0.54);
  --bw-panel-border: rgba(255, 224, 187, 0.15);
  --bw-muted: rgba(255, 236, 214, 0.55);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: #160a0f;
  overflow: hidden;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--bw-ink);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.bw-page {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse 80% 62% at 18% 18%, rgba(255, 174, 102, 0.15), transparent 64%),
    radial-gradient(ellipse 74% 70% at 82% 35%, rgba(216, 91, 106, 0.13), transparent 65%),
    radial-gradient(ellipse 96% 70% at 50% 112%, rgba(255, 158, 81, 0.14), transparent 70%),
    linear-gradient(165deg, #190b10 0%, #2a1216 45%, #160a0f 100%);
  animation: bw-fade-in 500ms ease both;
}

.bw-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: default;
  outline: none;
}

.bw-stage[data-fallback="true"] { cursor: pointer; }
.bw-stage:focus-visible { outline: 1px solid rgba(255, 213, 164, 0.32); outline-offset: -3px; }
.bw-canvas { display: block; width: 100%; height: 100%; }

.bw-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 72% 66% at 50% 46%, transparent 48%, rgba(11, 4, 8, 0.2) 74%, rgba(9, 3, 6, 0.55) 100%),
    linear-gradient(180deg, rgba(13, 5, 9, 0.28), transparent 16%, transparent 84%, rgba(9, 3, 6, 0.44));
}

.bw-wordmark {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  left: 26px;
  z-index: 6;
  color: rgba(255, 236, 208, 0.35);
  font: 500 10px/1.4 Georgia, "Times New Roman", serif;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}

.bw-hint {
  position: absolute;
  left: 32px;
  bottom: 32px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(540px, 55vw);
  color: rgba(255, 232, 199, 0.72);
  font-size: 12px;
  letter-spacing: 0.1em;
  line-height: 1.6;
  text-shadow: 0 1px 12px rgba(255, 167, 94, 0.28);
  opacity: 0;
  transform: translateY(7px);
  transition: opacity 620ms ease, transform 620ms ease;
  pointer-events: none;
}

.bw-hint::before {
  content: '';
  width: 22px;
  height: 1px;
  flex: none;
  background: linear-gradient(90deg, rgba(255, 207, 145, 0.06), rgba(255, 207, 145, 0.6));
}

.bw-hint.is-visible { opacity: 1; transform: translateY(0); }

.bw-camera {
  position: absolute;
  right: 26px;
  bottom: 26px;
  z-index: 10;
  width: 252px;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 36%, rgba(113, 66, 50, 0.48), transparent 64%),
    #13090c;
  border: 1px solid var(--bw-panel-border);
  box-shadow: 0 24px 70px rgba(3, 0, 2, 0.46), inset 0 0 0 1px rgba(255, 233, 203, 0.035);
  transition: opacity 280ms ease, transform 280ms ease, visibility 0s linear 0s;
}

.bw-camera.is-hidden {
  visibility: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease, visibility 0s linear 280ms;
}

.bw-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
  filter: saturate(0.78) contrast(1.02) brightness(0.82);
}

.bw-camera::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(11, 4, 8, 0.5), transparent 30%, transparent 64%, rgba(11, 4, 8, 0.28));
}

.bw-cam-top {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.bw-cam-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  max-width: calc(100% - 32px);
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--bw-panel);
  border: 1px solid rgba(255, 223, 188, 0.09);
  color: rgba(255, 238, 214, 0.76);
  font-size: 9.5px;
  line-height: 1.35;
  letter-spacing: 0.035em;
  backdrop-filter: blur(9px);
}

.bw-dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: #d8a35f;
  box-shadow: 0 0 8px rgba(239, 183, 103, 0.65);
  animation: bw-dot-pulse 1.8s ease-in-out infinite;
}

.bw-camera[data-state="ready"] .bw-dot,
.bw-camera[data-state="hand"] .bw-dot {
  background: #d9c487;
  box-shadow: 0 0 9px rgba(255, 220, 160, 0.8);
}

.bw-camera[data-state="hand"] .bw-dot { animation-duration: 900ms; }
.bw-camera[data-state="error"] .bw-dot,
.bw-camera[data-state="denied"] .bw-dot,
.bw-camera[data-state="trackingError"] .bw-dot {
  background: #ed8b85;
  box-shadow: 0 0 9px rgba(235, 120, 110, 0.55);
  animation: none;
}

.bw-cam-close {
  pointer-events: auto;
  -webkit-app-region: no-drag;
  width: 23px;
  height: 23px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 230, 200, 0.12);
  background: rgba(16, 8, 11, 0.55);
  color: rgba(255, 239, 218, 0.64);
  font: 300 15px/1 "Segoe UI", sans-serif;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: color 140ms ease, background 140ms ease;
}

.bw-cam-close:hover { color: #fff1d8; background: rgba(56, 28, 31, 0.75); }
.bw-cam-close:focus-visible { outline: 2px solid rgba(255, 203, 136, 0.82); outline-offset: 2px; }

.bw-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(ellipse 58% 45% at 50% 50%, rgba(127, 64, 44, 0.24), transparent 70%),
    rgba(16, 7, 11, 0.28);
  transition: opacity 420ms ease;
}

.bw-loading.is-done { opacity: 0; pointer-events: none; }

.bw-loader-star {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffe0af;
  box-shadow: 0 0 18px 5px rgba(255, 174, 96, 0.58);
  animation: bw-breathe 1.8s ease-in-out infinite;
}

.bw-loader-text {
  color: rgba(255, 231, 199, 0.55);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.bw-fatal {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  text-align: center;
  background: rgba(14, 6, 9, 0.58);
}

.bw-fatal-title { font-size: 15px; letter-spacing: 0.04em; color: rgba(255, 236, 214, 0.9); }
.bw-fatal-detail { font-size: 12px; color: rgba(255, 218, 188, 0.5); }

@keyframes bw-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes bw-breathe {
  0%, 100% { transform: scale(0.78); opacity: 0.45; }
  50% { transform: scale(1.2); opacity: 1; }
}
@keyframes bw-dot-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

@media (max-width: 900px) {
  .bw-wordmark { top: 18px; left: 18px; }
  .bw-camera { width: 200px; right: 16px; bottom: 16px; }
  .bw-hint { left: 18px; bottom: 20px; max-width: 46vw; font-size: 11px; }
}

@media (max-width: 560px) {
  .bw-camera { width: 156px; right: 12px; bottom: 12px; border-radius: 13px; }
  .bw-hint { max-width: calc(100vw - 198px); font-size: 10px; letter-spacing: 0.06em; }
  .bw-hint::before { display: none; }
  .bw-cam-status { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .bw-page, .bw-camera, .bw-hint, .bw-loading { animation: none; transition: none; }
  .bw-loader-star, .bw-dot { animation: none; }
}
