:root {
  --bg: #0b0714;
  --bg-card: #161022;
  --text: #f4f0ff;
  --text-dim: #9b8fb8;
  --accent: #a855f7;
  --accent2: #ec4899;
  --accent3: #38bdf8;
  --good: #4ade80;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#app { height: 100%; position: relative; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 20px calc(16px + var(--safe-bottom));
  text-align: center;
  overflow-y: auto;
}
.screen.active { display: flex; }

.hidden { display: none !important; }

/* ---------- shared ---------- */
.btn {
  border: none; cursor: pointer;
  font-size: 17px; font-weight: 700;
  padding: 15px 28px;
  border-radius: 999px;
  color: #fff;
  transition: transform .12s ease, opacity .2s;
  font-family: inherit;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 24px rgba(168, 85, 247, .45);
}
.btn-secondary { background: #2a2140; border: 1px solid #4c3a75; }
.btn-ghost { background: transparent; border: 1px solid #4c3a75; }
.btn-big { font-size: 20px; padding: 18px 44px; }

.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 14px;
  text-decoration: underline; margin-top: 14px;
  font-family: inherit;
}

.subtext { color: var(--text-dim); font-size: 13px; margin-top: 10px; }

.disclaimer {
  position: relative;
  color: #6a5f85; font-size: 11px; line-height: 1.5;
  max-width: 320px; margin-top: 22px;
}

.version-line { color: #4a4066; font-size: 11px; margin-top: 12px; letter-spacing: 1px; }
#btn-update { margin-top: 16px; font-size: 15px; padding: 12px 24px; }

/* ---------- landing ---------- */
.aura-orb {
  width: 170px; height: 170px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f0abfc, var(--accent) 45%, #4c1d95 80%);
  filter: blur(2px);
  box-shadow:
    0 0 60px 20px rgba(168, 85, 247, .5),
    0 0 120px 60px rgba(236, 72, 153, .25);
  margin-bottom: 34px;
  animation: float 5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.04); }
}
.aura-orb.pulsing { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: .8; }
}

.logo {
  font-size: 42px; font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, #f0abfc, var(--accent3));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.headline { font-size: 19px; color: var(--text-dim); margin: 10px 0 30px; }

.landing-content { display: flex; flex-direction: column; align-items: center; }
.landing-content .btn-ghost, .landing-content .btn-secondary { margin-top: 14px; }

.battle-banner {
  background: var(--bg-card);
  border: 1px solid #4c3a75;
  border-radius: var(--radius);
  padding: 16px 22px;
  margin-bottom: 24px;
  max-width: 320px;
}
.battle-banner-title { font-weight: 800; color: var(--accent3); }
.battle-banner-text { margin-top: 8px; font-size: 16px; }
.battle-banner-score { font-weight: 900; font-size: 20px; display: block; margin-top: 4px; }
.battle-banner-sub { margin-top: 8px; color: var(--text-dim); font-style: italic; }

/* ---------- camera ---------- */
#screen-camera { justify-content: space-between; padding-bottom: calc(28px + var(--safe-bottom)); }
.camera-wrap {
  position: relative;
  width: 100%; max-width: 430px;
  flex: 1; min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-top: 34px;
}
#camera-video, #preview-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
#camera-video.mirrored { transform: scaleX(-1); }

.camera-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.face-guide {
  width: 62%; aspect-ratio: 3 / 4;
  border: 2px dashed rgba(255, 255, 255, .45);
  border-radius: 50% / 42%;
}
.camera-status {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(11, 7, 20, .82);
  padding: 20px;
}
.camera-status p { color: var(--text); font-size: 15px; line-height: 1.5; }

.camera-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 26px; margin-top: 18px; width: 100%;
}
.shutter-btn {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fff; border: 5px solid rgba(255, 255, 255, .35);
  background-clip: padding-box;
  cursor: pointer;
  transition: transform .1s;
}
.shutter-btn:active { transform: scale(.9); }
.ctrl-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: #2a2140; border: 1px solid #4c3a75;
  font-size: 22px; cursor: pointer;
}
.back-btn { position: absolute; top: calc(10px + var(--safe-top)); left: 16px; margin: 0; }

/* ---------- analyzing ---------- */
.analyzing-content { display: flex; flex-direction: column; align-items: center; }
.analyzing-content h2 { margin-top: 26px; font-size: 24px; }
.analyzing-step { color: var(--text-dim); margin-top: 10px; min-height: 20px; }
.progress-track {
  width: 240px; height: 6px; border-radius: 3px;
  background: #2a2140; margin-top: 18px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .4s ease;
}

/* ---------- in-content ad box (class names intentionally not "ad-*") ---------- */
.ad-caption {
  margin-top: 28px;
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-dim);
}
.ad-box {
  position: relative;
  width: 100%; min-height: 110px; max-height: 280px;
  background: var(--bg-card);
  border: 1px solid #2a2140;
  border-radius: var(--radius);
  margin-top: 8px;
  overflow: hidden;
}
/* generous distance from action buttons above — accidental-click policy */
.result-actions + .ad-caption, .result-actions + .ad-box,
.link-btn + .ad-caption { margin-top: 30px; }
.break-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 13px;
}
.ad-box ins.adsbygoogle {
  position: relative; z-index: 1;
  display: block; width: 100%; height: 250px;
}
/* official AdSense recommendation: collapse unfilled units so the
   placeholder underneath shows cleanly */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }

/* ---------- result ---------- */
.result-content {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 380px;
  padding: 10px 0;
}
.result-kicker {
  letter-spacing: 4px; font-size: 13px; font-weight: 700;
  color: var(--text-dim);
}
.result-card {
  width: 100%; max-width: 300px;
  border-radius: var(--radius);
  margin-top: 14px;
  border: 1px solid #2a2140;
  box-shadow: 0 10px 40px rgba(168, 85, 247, .25);
}
.result-score {
  font-size: 76px; font-weight: 900; line-height: 1.1;
  margin-top: 6px;
}
.result-score .fire { font-size: 52px; }
.score-max { font-size: 26px; color: var(--text-dim); font-weight: 600; }
.archetype {
  font-size: 24px; font-weight: 800; margin-top: 4px;
  background: linear-gradient(135deg, #f0abfc, var(--accent3));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stats { width: 100%; margin-top: 26px; }
.stat-row { margin-bottom: 14px; text-align: left; }
.stat-label {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 700; letter-spacing: 2px;
  color: var(--text-dim); margin-bottom: 5px;
}
.stat-track { height: 10px; border-radius: 5px; background: #2a2140; overflow: hidden; }
.stat-fill {
  height: 100%; border-radius: 5px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .9s cubic-bezier(.2, .8, .2, 1);
}

.rarity {
  margin-top: 18px; font-size: 15px;
  color: var(--good); font-weight: 600;
}

.result-desc {
  margin-top: 12px;
  font-size: 15px; line-height: 1.55;
  color: #cfc4e8;
  max-width: 320px;
}

.footer-links {
  margin-top: 16px;
  font-size: 12px; color: #4a4066;
}
.footer-links a { color: #8a7fb0; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

.result-actions {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; margin-top: 24px;
}

/* ---------- battle ---------- */
.battle-grid {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 14px;
  width: 100%; margin-top: 26px;
}
.battle-side {
  background: var(--bg-card);
  border: 1px solid #2a2140;
  border-radius: var(--radius);
  padding: 18px 8px;
}
.battle-side.winner { border-color: var(--accent); box-shadow: 0 0 24px rgba(168, 85, 247, .35); }
.battle-name { font-size: 15px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.battle-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: cover; display: block;
  margin: 0 auto 8px;
  border: 2px solid #4c3a75;
}
.banner-avatar { width: 56px; height: 56px; margin: 10px auto 2px; border-color: var(--accent); }
.battle-score { font-size: 44px; font-weight: 900; margin-top: 4px; }
.battle-vs { font-size: 18px; font-weight: 800; color: var(--text-dim); }
.battle-winner { margin-top: 20px; font-size: 22px; font-weight: 800; }

/* ---------- calendar ---------- */
.calendar {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 8px; width: 100%; margin: 22px 0 26px;
}
.cal-day {
  background: var(--bg-card);
  border: 1px solid #2a2140;
  border-radius: 10px;
  padding: 8px 2px;
}
.cal-day.today { border-color: var(--accent); }
.cal-day-name { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }
.cal-day-score { font-size: 16px; font-weight: 800; margin-top: 3px; }
.cal-day-score.empty { color: #3a2f55; }

/* ---------- modal & toast ---------- */
.modal {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(5, 3, 10, .7);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid #4c3a75;
  border-radius: var(--radius);
  padding: 26px 22px;
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 16px;
  text-align: center;
}
.modal-card input {
  background: #0f0a1c; border: 1px solid #4c3a75; border-radius: 12px;
  padding: 13px 14px; color: var(--text); font-size: 17px; text-align: center;
  font-family: inherit; outline: none;
}
.modal-card input:focus { border-color: var(--accent); }
.install-steps { line-height: 1.9; font-size: 16px; }

.nudge {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  width: calc(100% - 40px); max-width: 360px;
  background: var(--bg-card);
  border: 1px solid #4c3a75;
  border-radius: var(--radius);
  padding: 16px;
  z-index: 35;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  animation: toast-in .3s ease;
}
.nudge-text { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.nudge-actions { display: flex; gap: 10px; justify-content: center; }
.nudge-btn { font-size: 14px; padding: 10px 22px; }

.toast {
  position: absolute; bottom: calc(30px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%);
  background: #2a2140; border: 1px solid #4c3a75;
  color: var(--text); font-size: 14px;
  padding: 12px 22px; border-radius: 999px;
  z-index: 40; white-space: nowrap;
  animation: toast-in .25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (min-width: 700px) {
  .camera-wrap { max-height: 62vh; }
}
