:root {
  color-scheme: dark;
  --bg: #0d151d;
  --panel: rgba(8, 14, 22, 0.78);
  --panel-solid: #101820;
  --line: #1e2e3e;
  --text: #f4f7fb;
  --muted: #8aa4b8;
  --dim: #60889a;
  --accent: #f97316;
  --accent-strong: #ea580c;
  --accent-soft: rgba(249, 115, 22, 0.14);
  --accent-line: rgba(249, 115, 22, 0.34);
  --accent-ink: #1c0f05;
  --danger: #ff5b6e;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.stage {
  position: fixed;
  inset: 0;
  background: #000;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#video-canvas {
  opacity: 0.18;
}

#depth-canvas {
  opacity: 0.92;
  mix-blend-mode: normal;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 16px;
  background: rgba(0, 0, 0, 0.86);
}

#start-overlay {
  padding: 16px 0 0;
  --footer-bg: transparent;
  --footer-border: var(--line);
  --footer-text: var(--dim);
  --footer-accent: var(--accent);
  --start-edge-padding: 16px;
  --start-card-gutter: 32px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  align-self: center;
  padding: 0 var(--start-edge-padding) 14px;
}

.site-nav__home {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  padding: 4px 6px 4px 2px;
  border-radius: 6px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-nav__home:hover,
.site-nav__title:hover {
  color: var(--accent);
}

.site-nav__title {
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

#footer-container {
  width: 100%;
  align-self: center;
  padding-top: 8px;
}

#footer-container footer {
  margin-top: 0;
  padding: 0.6rem 1rem;
  border-top-color: var(--line);
  border-radius: 0;
  font-size: 11px;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.panel,
.start-card {
  width: min(540px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-solid);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
}

.panel {
  margin: auto 0;
  padding: 24px;
}

.start-card {
  width: min(540px, calc(100% - var(--start-card-gutter)));
  margin: auto;
  overflow: hidden;
}

.start-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: clamp(16px, 4vw, 28px) clamp(18px, 5vw, 32px);
  background: linear-gradient(135deg, #241812 0%, #111720 100%);
  border-bottom: 1px solid var(--line);
}

.start-icon {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  display: block;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 0 24px rgba(249, 115, 22, 0.24);
}

.start-header-info {
  flex: 1;
  min-width: 0;
}

.start-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.start-app-name {
  font-size: 24px;
  font-weight: 740;
  letter-spacing: 0;
}

.start-badge {
  padding: 2px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.start-subtitle {
  margin-top: 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.start-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.start-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(16px, 4vw, 24px) clamp(18px, 5vw, 32px);
}

.start-cam-label {
  margin-bottom: 8px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.start-camera-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.start-cam-select,
select {
  min-height: 36px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1018;
  color: #d7e6f4;
  padding: 0 10px;
}

.start-cam-select {
  height: 44px;
  flex: 1;
}

.start-refresh-btn {
  width: 44px;
  height: 44px;
  padding: 0;
}

.start-cam-hint,
.note {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
}

.start-divider {
  height: 1px;
  background: var(--line);
}

.start-actions {
  display: flex;
  gap: 10px;
}

.start-actions button {
  flex: 1;
  height: 60px;
}

.start-notes {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a1018;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.8;
}

.start-notes p {
  margin: 0;
}

.start-footer {
  margin: 0;
  text-align: center;
}

.start-footer a {
  color: var(--dim);
  font-size: 11px;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.start-footer a:hover {
  color: var(--accent);
}

button {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.start-go-btn {
  border: 0;
  background: linear-gradient(135deg, #f97316, #f59e0b);
  color: var(--accent-ink);
  font-weight: 760;
}

.start-go-btn:hover {
  background: linear-gradient(135deg, #fb923c, #fbbf24);
}

.xreal-btn {
  border-color: #9a5a22;
  background: #2a1a0f;
  color: #ffe0bd;
}

.xreal-btn:hover {
  border-color: var(--accent);
  background: #3a2414;
}

.hud {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 4;
  display: block;
  pointer-events: none;
}

.toolbar,
.debug {
  pointer-events: auto;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  width: auto;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms linear;
}

.hud.controls-hidden .toolbar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
}

.toolbar label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  color: #c8d8e8;
  font-size: 13px;
}

.hud-switch {
  position: relative;
  border-left: 0 !important;
}

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

.switch-ui {
  position: relative;
  width: 38px;
  height: 22px;
  min-width: 38px;
  border: 1px solid #555;
  border-radius: 999px;
  background: #333;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ccc;
  transition: transform 0.15s ease, background 0.15s ease;
}

.hud-switch input:checked + .switch-ui {
  border-color: var(--accent);
  background: #8a3d12;
}

.hud-switch input:checked + .switch-ui::after {
  transform: translateX(16px);
  background: #fff;
}

.hud-switch input:disabled + .switch-ui {
  opacity: 0.45;
}

input[type="range"] {
  width: 112px;
  accent-color: var(--accent);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.debug {
  min-width: 184px;
  margin-top: 8px;
  padding: 10px 12px;
  font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: inline-block;
}

#fullscreen-btn {
  margin-left: auto;
}

#settings-dialog {
  z-index: 25;
}

.settings-panel {
  width: min(90vw, 500px);
  max-height: min(90vh, 600px);
  overflow-y: auto;
}

.settings-panel h2 {
  margin: 0 0 14px;
  text-align: center;
  font-size: 20px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.settings-list label > select,
.settings-list label > input[type="range"] {
  flex: 1;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

#settings-close {
  display: block;
  margin: 18px auto 0;
}

#about-dialog {
  z-index: 30;
}

.about-panel {
  width: min(90vw, 560px);
  max-height: min(90vh, 680px);
  overflow-y: auto;
  text-align: left;
}

.about-panel h2 {
  margin: 0 0 16px;
  font-size: 22px;
  text-align: left;
}

.about-panel h3 {
  margin: 18px 0 6px;
  color: #fbbf24;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.about-panel p {
  margin: 0 0 8px;
  color: #c8d8e8;
  font-size: 14px;
  line-height: 1.6;
}

.about-panel a {
  color: #fb923c;
}

.about-list {
  margin: 4px 0 0;
  padding-left: 18px;
  color: #c8d8e8;
  font-size: 13px;
  line-height: 1.7;
}

.about-list li + li {
  margin-top: 6px;
}

#about-close {
  display: block;
  margin: 22px auto 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.status,
.error {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 5;
  width: fit-content;
  max-width: calc(100vw - 28px);
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.error {
  border-color: rgba(255, 91, 110, 0.55);
  color: #ffd7dc;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .hud {
    left: 8px;
    right: 8px;
    top: 8px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar label,
  .toolbar button {
    width: 100%;
  }

  input[type="range"] {
    width: 100%;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  #start-overlay {
    padding-top: 8px;
    --start-edge-padding: 16px;
    --start-card-gutter: 32px;
  }

  .site-nav,
  #footer-container,
  .start-footer {
    display: none;
  }

  .start-header {
    padding: 10px 20px;
  }

  .start-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
  }

  .start-desc,
  .start-cam-hint,
  .start-notes {
    display: none;
  }

  .start-body {
    gap: 10px;
    padding: 10px 20px;
  }
}
