:root {
  color-scheme: dark;
  --ink: #fff8ec;
  --muted: rgba(255, 248, 236, 0.74);
  --panel: rgba(18, 17, 24, 0.72);
  --panel-strong: rgba(18, 17, 24, 0.88);
  --line: rgba(255, 255, 255, 0.18);
  --rose: #ff4f79;
  --gold: #ffcb54;
  --mint: #54e0bc;
  --sky: #65c8ff;
}

* {
  box-sizing: border-box;
}

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

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 203, 84, 0.14), transparent 24%),
    linear-gradient(145deg, #16151d, #0d1013 58%, #171216);
  color: var(--ink);
  isolation: isolate;
}

@supports (height: 100svh) {
  .app-shell {
    height: 100svh;
    min-height: 100svh;
  }
}

@supports (height: 100dvh) {
  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
  }
}

.camera-backdrop,
.camera,
.cake3d,
.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-backdrop {
  object-fit: cover;
  background: #090a0f;
  filter: blur(18px) saturate(1.08) brightness(0.72);
  transform: scaleX(-1) scale(1.08);
  opacity: 0;
  transition: opacity 360ms ease;
  z-index: 0;
}

.camera {
  object-fit: contain;
  background: transparent;
  transform: scaleX(-1);
  opacity: 0;
  transition: opacity 360ms ease;
  z-index: 1;
}

@media (max-width: 680px), (orientation: portrait) {
  .camera {
    object-fit: contain;
  }
}

.camera-backdrop.is-live,
.camera.is-live {
  opacity: 1;
}

.cake3d {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

.cake3d.is-live {
  opacity: 1;
}

.scene {
  z-index: 4;
  touch-action: none;
}

.app-shell::after {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.28), transparent 24%, transparent 72%, rgba(0, 0, 0, 0.22)),
    radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.34) 100%);
}

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

.status-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.status-pill,
.tracking-pill,
.ghost-btn,
.icon-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.22);
}

.status-pill {
  max-width: min(70vw, 520px);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 760;
  line-height: 1.2;
}

.tracking-pill {
  width: fit-content;
  max-width: min(72vw, 420px);
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn,
.ghost-btn,
.primary-btn {
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

.icon-btn {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.ghost-btn {
  min-width: 72px;
  height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 740;
}

.icon-btn:hover,
.ghost-btn:hover,
.primary-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.34);
}

.icon-btn:active,
.ghost-btn:active,
.primary-btn:active {
  transform: translateY(1px) scale(0.98);
}

.permission-panel {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(16, 15, 22, 0.34), rgba(16, 15, 22, 0.86)),
    url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,.09)' stroke-width='1'%3E%3Cpath d='M20 30h80M20 60h80M20 90h80M30 20v80M60 20v80M90 20v80'/%3E%3C/g%3E%3C/svg%3E");
}

.permission-panel.is-hidden {
  display: none;
}

.permission-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.cake-mark {
  position: relative;
  width: 86px;
  height: 78px;
  margin: 0 auto 16px;
}

.cake-mark::before,
.cake-mark::after {
  position: absolute;
  left: 50%;
  content: "";
  transform: translateX(-50%);
}

.cake-mark::before {
  bottom: 0;
  width: 82px;
  height: 42px;
  border-radius: 8px 8px 18px 18px;
  background: linear-gradient(180deg, #ffe0b0 0 34%, #ff7b91 34% 100%);
  box-shadow: inset 0 -8px 0 rgba(174, 48, 68, 0.24);
}

.cake-mark::after {
  top: 0;
  width: 16px;
  height: 48px;
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, #fff7df 0 8px, #61d3ff 8px 15px);
}

.cake-mark span {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 18px;
  height: 26px;
  border-radius: 60% 60% 50% 50%;
  background: radial-gradient(circle at 48% 30%, #fffdf0 0 12%, #ffdf55 14% 34%, #ff7838 70%);
  filter: drop-shadow(0 0 12px rgba(255, 196, 66, 0.8));
  transform: translateX(-50%);
}

.permission-card h1 {
  margin: 0 0 10px;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
}

.permission-card p {
  margin: 0 auto 20px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.instruction-list {
  display: grid;
  gap: 10px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.instruction-list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 248, 236, 0.88);
  font-size: 14px;
  line-height: 1.35;
}

.instruction-list span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #ff8f47);
  color: #191018;
  font-size: 13px;
  font-weight: 860;
}

.permission-card small {
  display: block;
  min-height: 18px;
  margin-top: 14px;
  color: rgba(255, 248, 236, 0.58);
  font-size: 12px;
  line-height: 1.45;
}

.primary-btn {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rose), #ff8f47 54%, var(--gold));
  color: #191018;
  font-size: 17px;
  font-weight: 840;
  box-shadow: 0 16px 34px rgba(255, 101, 79, 0.24);
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 7;
  width: max-content;
  max-width: min(86vw, 520px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 680px) {
  .hud {
    gap: 8px;
  }

  .status-pill {
    padding: 9px 12px;
    font-size: 14px;
  }

  .tracking-pill {
    display: none;
  }

  .ghost-btn {
    min-width: 60px;
    padding: 0 12px;
  }

  .icon-btn,
  .ghost-btn {
    height: 42px;
  }

  .icon-btn {
    width: 42px;
  }

  .permission-card {
    padding: 24px 20px;
  }

  .permission-card h1 {
    font-size: 34px;
  }

  .permission-card p {
    font-size: 15px;
  }

  .instruction-list li {
    min-height: 42px;
    font-size: 13px;
  }
}
