:root {
  --bg: #0d0b08;
  --surface: #17130d;
  --gold: #d4a437;
  --gold-bright: #f0c75e;
  --gold-dim: #8a6d24;
  --text: #f5efe2;
  --text-dim: #b3a688;
  --radius: 18px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  background: radial-gradient(1200px 800px at 50% -10%, #241c0f 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  overflow: hidden;
}

/* ---------- Top bar ---------- */

.topbar {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 20px 10px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-mark {
  color: var(--gold-bright);
  font-size: 1.1rem;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(120deg, var(--gold-bright), var(--gold) 55%, var(--gold-dim));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---------- Stage ---------- */

.stage {
  width: 100%;
  max-width: 720px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 0 14px 16px;
  min-height: 0;
}

.camera-frame {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(212, 164, 55, 0.25);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

video, canvas#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Mirror like a selfie camera */
  transform: scaleX(-1);
}

canvas#overlay {
  pointer-events: none;
}

/* ---------- Panels (start / loading / error) ---------- */

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(13, 11, 8, 0.92), rgba(13, 11, 8, 0.97));
  backdrop-filter: blur(6px);
  z-index: 5;
  padding: 24px;
  text-align: center;
}

.panel-inner {
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.panel-icon {
  font-size: 2.4rem;
}

.panel h1 {
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.panel p {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.5;
}

.privacy-note {
  color: var(--text-dim);
  opacity: 0.7;
  font-size: 0.72rem;
}

.btn-gold {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 13px 34px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #241a05;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 60%, #b8892b);
  box-shadow: 0 6px 22px rgba(212, 164, 55, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(212, 164, 55, 0.45);
}

.btn-gold:active {
  transform: translateY(0);
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(212, 164, 55, 0.2);
  border-top-color: var(--gold-bright);
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Face hint ---------- */

.hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 11, 8, 0.75);
  border: 1px solid rgba(212, 164, 55, 0.35);
  color: var(--text);
  font-size: 0.82rem;
  padding: 8px 16px;
  border-radius: 999px;
  z-index: 4;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

/* ---------- Necklace selector ---------- */

.selector {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.model-btn {
  appearance: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 8px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid rgba(212, 164, 55, 0.18);
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.model-btn img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.model-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(212, 164, 55, 0.45);
}

.model-btn.active {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(212, 164, 55, 0.14), rgba(212, 164, 55, 0.04));
  color: var(--gold-bright);
  box-shadow: 0 0 0 1px rgba(212, 164, 55, 0.35), 0 6px 18px rgba(0, 0, 0, 0.4);
}

/* ---------- Tuning panel ---------- */

.tune-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(212, 164, 55, 0.4);
  background: rgba(13, 11, 8, 0.75);
  color: var(--gold-bright);
  font-size: 1.2rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.tune-panel {
  position: absolute;
  top: 60px;
  right: 12px;
  z-index: 6;
  width: 230px;
  max-height: calc(100% - 80px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 14px;
  background: rgba(13, 11, 8, 0.85);
  border: 1px solid rgba(212, 164, 55, 0.35);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tune-toggle-2 {
  right: 60px;
}

.tune-panel-left {
  right: auto;
  left: 12px;
}

.tune-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.apply-all {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--gold-bright);
  cursor: pointer;
}

.apply-all input {
  accent-color: var(--gold);
}

.tune-panel h2 {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
  font-weight: 600;
}

.tune-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.tune-panel label b {
  color: var(--text);
  font-weight: 600;
}

.tune-panel input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.btn-copy {
  appearance: none;
  border: 1px solid rgba(212, 164, 55, 0.45);
  background: rgba(212, 164, 55, 0.12);
  color: var(--gold-bright);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-copy:hover {
  background: rgba(212, 164, 55, 0.22);
}

#valuesOut {
  font-size: 0.66rem;
  line-height: 1.45;
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  padding: 8px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  user-select: all;
}

.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .model-btn img {
    width: 46px;
    height: 46px;
  }

  .model-btn {
    padding: 8px 10px 6px;
  }
}
