:root {
  color-scheme: dark;
  --ink: #f5f2e9;
  --muted: #b9b4aa;
  --glass: rgba(13, 14, 14, 0.78);
  --line: rgba(255, 255, 255, 0.18);
  --accent: #c94c2e;
  --ok: #68d391;
  --postcard-paper: #f3eedf;
  --postcard-ink: #292922;
  --postcard-muted: #686b62;
  --postcard-celadon: #82998e;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080909;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  font: inherit;
}

.permission-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  background: linear-gradient(155deg, #bdc9c3 0%, var(--postcard-celadon) 52%, #5c7167 100%);
  opacity: 1;
  transition: opacity 300ms ease;
}

.permission-dialog.is-closing {
  opacity: 0;
  pointer-events: none;
}

.permission-dialog[hidden] {
  display: none;
}

.permission-card {
  width: min(100%, 23rem);
  padding: 1.5rem;
  border: 1px solid rgba(52, 61, 55, 0.24);
  border-radius: 1.2rem;
  background: rgba(243, 238, 223, 0.97);
  color: var(--postcard-ink);
  box-shadow: 0 1.4rem 4rem rgba(40, 48, 43, 0.3);
  text-align: center;
}

.permission-card h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.4;
}

.permission-card p {
  margin: 0.85rem 0 1.25rem;
  color: var(--postcard-muted);
  font-size: 1rem;
  line-height: 1.75;
}

.primary-button {
  width: 100%;
  min-height: 3.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 0.75rem 2rem rgba(138, 48, 30, 0.25);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.start-error {
  min-height: 1.5rem;
  margin: 0.8rem 0 0 !important;
  color: #ff9c8e;
  text-align: center;
  line-height: 1.5;
}

.ar-shell,
.ar-shell a-scene,
.ar-shell canvas {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

.ar-shell {
  display: none;
  background: #000;
}

.ar-shell.active {
  display: block;
}

.ar-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
}

.status-pill {
  width: fit-content;
  max-width: calc(100vw - 2rem);
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  font-size: 0.9rem;
  font-weight: 650;
  text-align: center;
}

.status-pill[hidden] {
  display: none;
}

.status-dot {
  width: 0.58rem;
  height: 0.58rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #ffb14a;
  box-shadow: 0 0 0 0.3rem rgba(255, 177, 74, 0.14);
}

.status-locking .status-dot {
  animation: pulse 0.8s ease-in-out infinite alternate;
}

.status-locked .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 0.3rem rgba(104, 211, 145, 0.14);
}

.status-error .status-dot {
  background: #ff6b5b;
}

.tracking-debug {
  display: none !important;
}

.tracking-debug.is-rejected {
  color: #ffb0a4;
}

.reset-reason {
  display: none !important;
}

.reset-reason[hidden] {
  display: none;
}

.aim-guide {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1.15rem);
  width: max-content;
  max-width: 88vw;
  padding: 0.55rem 0.85rem;
  transform: translate(-50%, 0.35rem);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(8, 9, 9, 0.66);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 320ms ease, transform 320ms ease, visibility 0s linear 320ms;
  backdrop-filter: blur(10px);
}

.aim-guide.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.viewfinder {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(82vw, 25rem, 55vh);
  aspect-ratio: 700 / 1036;
  transform: translate(-50%, -50%);
}

.viewfinder i {
  position: absolute;
  width: 2.4rem;
  height: 2.4rem;
  border-color: rgba(255, 255, 255, 0.82);
  border-style: solid;
}

.viewfinder i:nth-of-type(1) { left: 0; top: 0; border-width: 2px 0 0 2px; border-radius: 0.6rem 0 0; }
.viewfinder i:nth-of-type(2) { right: 0; top: 0; border-width: 2px 2px 0 0; border-radius: 0 0.6rem 0 0; }
.viewfinder i:nth-of-type(3) { right: 0; bottom: 0; border-width: 0 2px 2px 0; border-radius: 0 0 0.6rem; }
.viewfinder i:nth-of-type(4) { left: 0; bottom: 0; border-width: 0 0 2px 2px; border-radius: 0 0 0 0.6rem; }

.controls {
  position: absolute;
  left: auto;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  pointer-events: auto;
}

.controls button {
  min-height: 2.35rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  color: var(--ink);
  backdrop-filter: blur(14px);
  font-size: 0.78rem;
  font-weight: 600;
}

.controls #relock-button {
  flex: 0 0 auto;
}

@keyframes pulse {
  to { transform: scale(1.35); opacity: 0.55; }
}
