:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #07100d;
  color: #edf8f0;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: #07100d;
}

#camera,
#effects,
.veil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera {
  object-fit: cover;
  image-rendering: auto;
  backface-visibility: hidden;
  transform: translateZ(0);
  filter: saturate(1.02) contrast(1.06) brightness(0.92);
  transition: filter 400ms ease;
}

.stage.night #camera {
  filter: saturate(0.66) contrast(1.13) brightness(0.5) hue-rotate(8deg);
}

.stage.dream #camera {
  filter: saturate(1.12) contrast(1.05) brightness(0.78) hue-rotate(12deg);
}

#effects {
  z-index: 2;
}

.veil {
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(to top, rgba(2, 27, 18, 0.3), rgba(3, 16, 12, 0.02) 42%);
  box-shadow: inset 0 0 112px 18px rgba(0, 10, 7, 0.46);
  border: 1px solid rgba(192, 255, 219, 0.14);
}

.stage.night .veil {
  background: linear-gradient(to top, rgba(5, 15, 29, 0.45), rgba(7, 12, 23, 0.06) 48%);
  box-shadow: inset 0 0 132px 24px rgba(0, 4, 12, 0.62);
}

.stage.dream .veil {
  background: linear-gradient(to top, rgba(20, 7, 30, 0.32), rgba(5, 18, 18, 0.03) 46%);
  box-shadow: inset 0 0 118px 20px rgba(9, 3, 18, 0.48);
}

.topbar {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  left: 20px;
  right: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand,
.status,
.controls,
.gesture-readout {
  border: 1px solid rgba(152, 255, 205, 0.22);
  background: rgba(4, 17, 13, 0.72);
  backdrop-filter: blur(10px);
}

.brand {
  padding: 11px 13px 10px;
  border-radius: 5px;
}

.brand strong {
  display: block;
  color: #77f2b5;
  font-family: Consolas, monospace;
  font-size: 15px;
  line-height: 1;
}

.brand span {
  display: block;
  margin-top: 6px;
  color: #9eb8aa;
  font-family: Consolas, monospace;
  font-size: 9px;
  line-height: 1;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 35px;
  padding: 0 12px;
  border-radius: 5px;
  color: #d7e7de;
  font-size: 12px;
}

.status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e0ad58;
  box-shadow: 0 0 10px rgba(224, 173, 88, 0.9);
}

.status.active i {
  background: #6ff0aa;
  box-shadow: 0 0 12px rgba(111, 240, 170, 0.9);
}

.status.error i {
  background: #f06f78;
  box-shadow: 0 0 12px rgba(240, 111, 120, 0.9);
}

.start-panel {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: rgba(4, 16, 12, 0.9);
  transition: opacity 300ms ease, visibility 300ms ease;
}

.start-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.seed-mark {
  position: relative;
  width: 126px;
  height: 78px;
}

.seed-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 46px;
  background: #7bf2b7;
}

.seed-mark span {
  position: absolute;
  left: calc(50% - 7px);
  bottom: 36px;
  width: 14px;
  height: 25px;
  border-radius: 50% 50% 42% 42%;
  background: #73e8aa;
  box-shadow: 0 0 18px rgba(115, 232, 170, 0.62);
  transform-origin: 50% 30px;
}

.seed-mark span:nth-child(1) { transform: rotate(0deg) translateY(-13px); }
.seed-mark span:nth-child(2) { transform: rotate(72deg) translateY(-13px); }
.seed-mark span:nth-child(3) { transform: rotate(144deg) translateY(-13px); }
.seed-mark span:nth-child(4) { transform: rotate(216deg) translateY(-13px); }
.seed-mark span:nth-child(5) { transform: rotate(288deg) translateY(-13px); }

.start-panel h1 {
  max-width: 620px;
  margin: 0;
  font-family: Georgia, "Microsoft YaHei", serif;
  font-size: 44px;
  font-weight: 500;
}

.start-panel p {
  margin: -7px 0 0;
  color: #98afa3;
  font-size: 12px;
}

.primary,
.controls button {
  border: 1px solid rgba(153, 255, 206, 0.32);
  border-radius: 5px;
  background: rgba(13, 37, 27, 0.84);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.primary {
  min-width: 160px;
  min-height: 44px;
  padding: 10px 20px;
  background: #63df9d;
  color: #04130d;
  border-color: #63df9d;
  font-weight: 700;
}

.primary:hover,
.primary:focus-visible {
  background: #83f1b8;
}

.controls {
  position: absolute;
  z-index: 5;
  left: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 40px);
  padding: 8px;
  border-radius: 6px;
}

.controls button {
  min-height: 34px;
  padding: 0 12px;
  color: #bcd1c5;
  font-size: 12px;
}

.controls button:hover,
.controls button:focus-visible,
.controls button.active,
.controls button[aria-pressed="true"] {
  border-color: rgba(116, 241, 177, 0.72);
  background: rgba(42, 101, 70, 0.66);
  color: #effff5;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(148, 255, 203, 0.18);
  border-radius: 5px;
}

.segmented button {
  border-color: transparent;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 8px;
  color: #bcd1c5;
  font-size: 12px;
  cursor: pointer;
}

.sensitivity-control {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 8px;
  color: #bcd1c5;
  font-size: 12px;
  white-space: nowrap;
}

.sensitivity-control input {
  width: 82px;
  accent-color: #72edae;
}

.sensitivity-control output {
  min-width: 22px;
  color: #80f3b8;
  font-family: Consolas, monospace;
  text-align: right;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle span {
  position: relative;
  width: 27px;
  height: 15px;
  border: 1px solid rgba(167, 211, 188, 0.4);
  border-radius: 9px;
  background: rgba(1, 10, 7, 0.7);
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #91a89c;
  transition: transform 150ms ease, background 150ms ease;
}

.toggle input:checked + span::after {
  transform: translateX(12px);
  background: #72edae;
}

.gesture-readout {
  position: absolute;
  z-index: 5;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  min-width: 148px;
  padding: 11px 12px;
  border-radius: 5px;
  color: #80f3b8;
  font-family: Consolas, monospace;
  font-size: 10px;
  text-align: right;
  pointer-events: none;
}

@media (max-width: 760px) {
  .stage { min-height: 0; }
  .topbar { left: 12px; right: 12px; top: max(12px, env(safe-area-inset-top)); }
  .brand { padding: 9px 10px; }
  .brand span { display: none; }
  .status { max-width: 48vw; }
  .status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .controls {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: none;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .controls::-webkit-scrollbar { display: none; }
  .controls > * { flex: 0 0 auto; }
  .gesture-readout { right: 12px; bottom: 72px; }
  .start-panel h1 { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
