:root {
  --bg: #060814;
  --panel: #0e1326;
  --panel-border: #1f2a4a;
  --accent: #29ffc6;
  --accent2: #ff3fd4;
  --text: #e8ecff;
  --text-dim: #8a93b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(41, 255, 198, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(41, 255, 198, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 50% 20%, rgba(0,0,0,0.9), transparent 70%);
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 8px;
  text-align: center;
}

.logo { font-size: 28px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 32px; }
.accent { color: var(--accent); }
.tagline { color: var(--text-dim); font-size: 14px; margin-top: 4px; }

.nav-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
}
.nav-link:hover { opacity: 0.8; }

.lead.small {
  font-size: 13px;
  margin-bottom: 20px;
}
.lead.small a { color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.panel {
  background: linear-gradient(180deg, rgba(20,26,50,0.7), rgba(10,14,30,0.7));
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: 0 0 40px rgba(41,255,198,0.05);
}

.panel.hidden { display: none; }

h1 { font-size: 26px; margin-top: 0; text-align: center; }
h2 { text-align: center; }

.lead {
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
  max-width: 560px;
  margin: 0 auto 12px;
}

ul.lead {
  text-align: left;
  padding-left: 22px;
}

.disclaimer {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  border: 1px dashed var(--panel-border);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0 auto 20px;
  max-width: 560px;
}

.camera-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #000;
}

video, canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent);
  top: 0;
  opacity: 0;
  pointer-events: none;
}

.scan-line.active {
  opacity: 1;
  animation: scan 1.4s linear infinite;
}

@keyframes scan {
  0% { top: 0%; }
  50% { top: 98%; }
  100% { top: 0%; }
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn.primary {
  background: rgba(41,255,198,0.1);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn.accent-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #060814;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(41,255,198,0.25); }

.status {
  text-align: center;
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 14px;
  min-height: 20px;
}

/* Helix */
.helix-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.helix {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 90px;
  overflow: hidden;
}

.strand {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 40px;
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  transform: translateY(-50%);
  animation: helixspin 3s linear infinite;
}

.strand-b {
  border-top: 3px solid var(--accent2);
  animation-delay: -1.5s;
}

@keyframes helixspin {
  0% { transform: translateY(-50%) scaleY(1) rotateX(0deg); }
  50% { transform: translateY(-50%) scaleY(0.2) rotateX(180deg); }
  100% { transform: translateY(-50%) scaleY(1) rotateX(360deg); }
}

.helix-label { text-align: center; }
.archetype-name { font-size: 22px; font-weight: 700; color: var(--accent); }
.archetype-sub { color: var(--text-dim); font-size: 13px; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-value { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; margin-top: 4px; font-weight: 600; }
.stat-desc { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* Rankings */
.ranking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.ranking-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
}

.ranking-card h3 { margin-top: 0; font-size: 15px; }
.ranking-card ol { margin: 0; padding-left: 22px; color: var(--text-dim); font-size: 14px; }
.ranking-card li { margin-bottom: 4px; }
.ranking-card li strong { color: var(--text); }

.similar-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.similar-card h3 { margin-top: 0; font-size: 15px; }
.similar-card ul { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--text-dim); }
.similar-card li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--panel-border);
}
.similar-card li:last-child { border-bottom: none; }
.similar-card .sim-pct { color: var(--accent); font-weight: 700; }

#retry-btn { display: block; margin: 0 auto 20px; }

.share-card {
  text-align: center;
  border-top: 1px dashed var(--panel-border);
  padding-top: 16px;
}
.share-card h3 { margin-top: 0; font-size: 16px; }

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 520px;
  margin: 0 auto 16px;
  cursor: pointer;
}
.consent input { margin-top: 3px; flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--accent); }
.consent strong { color: var(--text); }

.share-actions { margin-bottom: 16px; }

.share-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.share-result.hidden { display: none; }

#share-preview {
  max-width: 280px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.share-buttons .btn.hidden { display: none; }

/* Página de arquetipos */
.archetype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.archetype-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.archetype-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.archetype-card-header h3 {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}

.archetype-pct {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.archetype-tagline {
  color: var(--accent2);
  font-size: 13px;
  font-weight: 600;
}

.archetype-lore {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.archetype-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}

.archetype-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.archetype-countries h4 {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text);
}

.archetype-countries ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-dim);
}

.archetype-countries li strong { color: var(--text); }

.archetype-topcity {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 20px;
}

footer .social-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent2);
  text-decoration: none;
  font-weight: 600;
}

footer .social-link:hover {
  text-decoration: underline;
}
