:root {
  --bg: #0b1020;
  --panel: rgba(12, 16, 32, 0.82);
  --text: #f4f6fb;
  --muted: #b7c0d4;
  --accent: #e11d2c;
  --accent-2: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #000;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
select {
  font: inherit;
}

#ar-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

#ar-container video,
#ar-container canvas {
  display: block;
  pointer-events: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(180deg, rgba(11, 16, 32, 0.92), rgba(11, 16, 32, 0.78));
  overflow: auto;
}

.overlay[hidden],
.hud[hidden],
.banner[hidden],
.identify[hidden] {
  display: none !important;
}

.identify {
  position: fixed;
  inset: 0;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: calc(80px + var(--safe-t)) 16px calc(24px + var(--safe-b));
}

.identify-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 18px 22px;
  min-width: 220px;
  text-align: center;
}

.identify-box p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.panel {
  margin: auto;
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 22px 20px 20px;
  backdrop-filter: blur(12px);
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0 0 10px;
  font-size: 1.45rem;
  line-height: 1.25;
}

.lead,
.error-body {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

select {
  width: 100%;
  margin-bottom: 16px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #121830;
  color: var(--text);
}

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

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  flex: 1 1 160px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  flex: 1 1 120px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.hud {
  position: fixed;
  top: calc(10px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  right: calc(10px + var(--safe-r));
  z-index: 15;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.hud-chip {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.8rem;
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-actions {
  pointer-events: auto;
  display: flex;
  gap: 6px;
}

.hud-actions .btn {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.8rem;
}

.banner {
  position: fixed;
  left: calc(12px + var(--safe-l));
  right: calc(12px + var(--safe-r));
  bottom: calc(12px + var(--safe-b));
  z-index: 18;
  background: #3b2a0a;
  border: 1px solid var(--warn);
  border-radius: 14px;
  padding: 12px 14px;
}

.banner p {
  margin: 0 0 10px;
  font-size: 0.9rem;
}

.code {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(225, 29, 44, 0.18);
  color: #fecaca;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@media (min-width: 720px) {
  h1,
  h2 {
    font-size: 1.7rem;
  }
}
