* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050608;
  color: #f4f1ea;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.ar-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
  min-height: 420px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    #050608;
}

@supports (height: 100svh) {
  .ar-stage {
    height: 100svh;
  }
}

@supports (height: 100dvh) {
  .ar-stage {
    height: 100dvh;
  }
}

#cameraVideo {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

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

.status-text {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 4;
  max-width: min(360px, calc(100vw - 32px));
  padding: 9px 12px;
  border: 1px solid rgba(246, 239, 220, 0.14);
  border-radius: 8px;
  background: rgba(8, 10, 13, 0.62);
  color: rgba(244, 241, 234, 0.86);
  font-size: 13px;
  line-height: 1.45;
  backdrop-filter: blur(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-text.is-hidden {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.controls {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 10px;
  border: 1px solid rgba(246, 239, 220, 0.14);
  border-radius: 8px;
  background: rgba(8, 10, 13, 0.72);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
  transition: opacity 220ms ease, transform 220ms ease, background 220ms ease;
}

.controls.is-muted {
  opacity: 0.2;
  transform: translateX(-50%) translateY(8px);
}

.controls.is-muted:focus-within,
.controls.is-muted:hover {
  opacity: 0.92;
  transform: translateX(-50%);
}

.control-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(246, 239, 220, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #f4f1ea;
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.control-button:hover {
  border-color: rgba(246, 239, 220, 0.38);
  background: rgba(255, 255, 255, 0.12);
}

.control-button:focus-visible,
.smooth-control input:focus-visible {
  outline: 2px solid #75cce7;
  outline-offset: 2px;
}

.control-button.is-active {
  border-color: rgba(117, 204, 231, 0.68);
  background: rgba(117, 204, 231, 0.16);
  color: #dff8ff;
}

.smooth-control {
  display: grid;
  grid-template-columns: auto 116px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 4px 0 10px;
  border-left: 1px solid rgba(246, 239, 220, 0.12);
  color: rgba(244, 241, 234, 0.78);
  font-size: 13px;
  white-space: nowrap;
}

.smooth-control input {
  width: 116px;
  accent-color: #75cce7;
  cursor: pointer;
}

.error-box {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  width: min(420px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid rgba(221, 63, 55, 0.64);
  border-radius: 8px;
  background: rgba(16, 17, 20, 0.94);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.46);
  color: #f4f1ea;
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(18px);
}

.error-message {
  margin-bottom: 14px;
  color: #ffd7cf;
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 680px) {
  html,
  body {
    min-height: 100svh;
  }

  .controls {
    display: grid;
    grid-template-columns: 1.25fr 1fr 0.8fr;
    width: min(420px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    padding: 8px;
    gap: 6px;
  }

  .control-button {
    min-width: 0;
    min-height: 40px;
    padding: 0 6px;
    font-size: 12px;
    line-height: 1.1;
    white-space: normal;
  }

  .smooth-control {
    grid-column: 1 / -1;
    grid-template-columns: auto minmax(130px, 1fr);
    padding: 8px 2px 0;
    border-left: 0;
    border-top: 1px solid rgba(246, 239, 220, 0.12);
  }

  .smooth-control input {
    width: 100%;
  }

  .status-text {
    left: 12px;
    right: 12px;
    top: 12px;
    max-width: none;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  #resetButton {
    grid-column: 1 / -1;
  }
}
