:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: rgba(247, 251, 255, 0.72);
  --glass: rgba(10, 18, 28, 0.44);
  --line: rgba(255, 255, 255, 0.18);
  --accent: #61d7ff;
  --accent-2: #ffcf73;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #06101a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  cursor: grab;
  user-select: none;
  background: #06101a;
}

.stage:active {
  cursor: grabbing;
}

.layer,
.camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.layer {
  z-index: 1;
}

#ocean {
  z-index: 2;
}

.camera {
  z-index: 1;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transform: scaleX(-1);
  transform-origin: center;
}

#veil {
  z-index: 3;
}

#hands {
  z-index: 4;
  pointer-events: none;
}

.source-video,
.source-media {
  position: fixed;
  left: -2px;
  top: -2px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.camera.active {
  opacity: 1;
}

.onboarding {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
  padding: clamp(28px, 7vw, 92px);
  color: var(--ink);
  overflow-y: auto;
  background:
    linear-gradient(90deg, rgba(3, 8, 13, 0.88), rgba(3, 8, 13, 0.58) 52%, rgba(3, 8, 13, 0.2)),
    radial-gradient(circle at 72% 44%, rgba(118, 226, 255, 0.12), transparent 34%),
    rgba(3, 8, 13, 0.72);
  transition: opacity 520ms ease, visibility 520ms ease;
}

.onboarding.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ritualMark {
  position: relative;
  width: 96px;
  height: 44px;
}

.ritualMark span {
  position: absolute;
  top: 18px;
  width: 54px;
  height: 2px;
  border-radius: 999px;
  background: rgba(230, 255, 255, 0.84);
  box-shadow: 0 0 18px rgba(128, 231, 255, 0.45);
}

.ritualMark span:first-child {
  left: 0;
  transform: rotate(-16deg);
  transform-origin: right center;
}

.ritualMark span:last-child {
  right: 0;
  transform: rotate(16deg);
  transform-origin: left center;
}

.ritualKicker {
  margin: 0;
  color: rgba(255, 207, 115, 0.9);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
}

.onboarding h1 {
  margin: 0;
  width: min(720px, 100%);
  font-size: clamp(44px, 7vw, 92px);
  line-height: 0.94;
  letter-spacing: 0;
}

.ritualCopy {
  margin: 0;
  width: min(620px, 100%);
  color: rgba(247, 251, 255, 0.78);
  font-size: clamp(16px, 1.55vw, 21px);
  line-height: 1.65;
}

.ritualSteps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.ritualSteps span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(247, 251, 255, 0.78);
  background: rgba(255, 255, 255, 0.05);
}

.ritualChoice {
  width: min(430px, 100%);
  padding: 18px;
  border: 1px solid rgba(210, 249, 255, 0.26);
  border-radius: 8px;
  background: rgba(1, 11, 17, 0.68);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.ritualChoiceTitle {
  margin: 0 0 6px;
  color: rgba(245, 255, 255, 0.96);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

.ritualChoiceCopy {
  margin: 0 0 14px;
  color: rgba(247, 251, 255, 0.66);
  font-size: 13px;
  line-height: 1.55;
}

.ritualUpload {
  min-height: 52px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 9px 15px;
  border: 1px solid rgba(211, 253, 255, 0.64);
  border-radius: 8px;
  color: #031017;
  background: rgba(230, 255, 255, 0.96);
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(95, 228, 255, 0.18);
}

.ritualUpload span {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.1;
}

.ritualUpload small {
  color: rgba(3, 16, 23, 0.66);
  font-size: 11px;
  line-height: 1.1;
}

.ritualButton {
  min-height: 48px;
  margin-top: 4px;
  padding: 0 18px;
  border: 1px solid rgba(207, 251, 255, 0.54);
  border-radius: 8px;
  color: #031017;
  background: rgba(224, 255, 255, 0.92);
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(78, 215, 255, 0.16);
}

.ritualButton:disabled {
  cursor: progress;
  opacity: 0.72;
}

.ritualStatus {
  min-height: 20px;
  margin: 0;
  color: rgba(247, 251, 255, 0.62);
  font-size: 13px;
}

.hud {
  position: absolute;
  z-index: 5;
  left: clamp(18px, 4vw, 54px);
  right: clamp(18px, 4vw, 54px);
  top: clamp(18px, 4vw, 42px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink);
  pointer-events: none;
}

.hud > div {
  display: none;
}

.uploadButton {
  pointer-events: auto;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--glass);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  width: fit-content;
}

.uploadTitle {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

.uploadHint {
  color: rgba(247, 251, 255, 0.62);
  font-size: 11px;
  line-height: 1.15;
}

.videoUploadInput {
  display: none;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  max-width: 460px;
  font-size: clamp(30px, 4.8vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: 0 18px 54px rgba(0, 0, 0, 0.45);
}

#cameraButton {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--glass);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
}

#cameraButton:hover {
  border-color: rgba(97, 215, 255, 0.55);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #ff6464;
  box-shadow: 0 0 0 5px rgba(255, 100, 100, 0.16);
}

.status {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: clamp(18px, 4vw, 40px);
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 36px));
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--glass);
  backdrop-filter: blur(14px);
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
}

.debugPanel {
  position: absolute;
  display: none;
  z-index: 7;
  left: 16px;
  bottom: 16px;
  width: min(360px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: rgba(245, 255, 255, 0.86);
  background: rgba(4, 10, 16, 0.58);
  backdrop-filter: blur(12px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  pointer-events: none;
}

body.debug .debugPanel,
body.show-debug .debugPanel {
  display: block;
}

.hand {
  position: absolute;
  z-index: 6;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  opacity: 0;
  transform: translate3d(-100px, -100px, 0) scale(0.8);
  transition: opacity 160ms ease, transform 120ms ease;
  pointer-events: none;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.24), inset 0 0 10px rgba(255, 255, 255, 0.12);
}

.hand::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.52);
}

.hand.visible {
  opacity: 0;
}

body.debug .hand.visible {
  opacity: 0.18;
}

@media (max-width: 700px) {
  .stage {
    min-height: 100dvh;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(36px, 13vw, 68px);
  }

  #cameraButton {
    width: fit-content;
  }

  .uploadButton {
    width: fit-content;
  }

  .onboarding {
    justify-content: center;
    gap: 12px;
    padding: 22px 20px 34px;
  }

  .onboarding h1 {
    font-size: clamp(38px, 11vw, 64px);
  }

  .ritualCopy {
    font-size: 15px;
    line-height: 1.5;
  }

  .ritualSteps {
    gap: 8px;
  }

  .ritualSteps span {
    min-height: 32px;
    font-size: 13px;
  }

  .ritualChoice {
    padding: 14px;
  }
}
