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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #07020f;
  color: #e0d8f0;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Stars background ── */
#stars {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, #1a0a30 0%, transparent 60%),
    radial-gradient(ellipse at 80% 70%, #0a1a30 0%, transparent 60%),
    #07020f;
  overflow: hidden;
  z-index: 0;
}
#stars::before, #stars::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 38% 45%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 60% 12%, rgba(255,255,255,0.7) 0%, transparent 100%),
    radial-gradient(1px 1px at 75% 55%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 28%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 5% 70%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 80%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 92% 85%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 22% 92%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 70% 88%, rgba(255,255,255,0.5) 0%, transparent 100%);
  background-size: 100% 100%;
}
#stars::after {
  background-image:
    radial-gradient(1px 1px at 30% 8%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 35%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 12% 50%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 82% 42%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 65%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 95% 60%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 8% 85%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 95%, rgba(255,255,255,0.4) 0%, transparent 100%);
}

/* ── App layout ── */
#app {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  gap: 0;
  padding: 1.2vh 1rem 0;
}

header {
  text-align: center;
  flex-shrink: 0;
  padding-bottom: 0.4vh;
}

header h1 {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: transparent;
  background: linear-gradient(135deg, #c8b8ff, #ffd700 45%, #c8b8ff);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: none;
  transition: background 2s ease;
}

header .subtitle {
  font-size: clamp(0.6rem, 1.5vw, 0.85rem);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #8878b0;
  margin-top: 0.1em;
}

/* ── Angel stage ── */
#angel-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#angel-glow {
  position: absolute;
  width: 55%;
  height: 80%;
  border-radius: 50%;
  pointer-events: none;
  transition: background 2.5s ease, box-shadow 2.5s ease;
  z-index: 0;
}

#angel {
  position: relative;
  z-index: 1;
  height: 100%;
  width: auto;
  max-height: 100%;
  filter: drop-shadow(0 0 12px rgba(180,150,255,0.3));
  animation: float 6s ease-in-out infinite;
  transition: filter 2.5s ease;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* ── Judgment panel ── */
#judgment-panel {
  flex-shrink: 0;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5vh;
  padding-bottom: 1.2vh;
}

#alignment-badge {
  font-size: clamp(0.7rem, 2vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 0.2em 1.2em;
  border-radius: 2em;
  border: 1.5px solid currentColor;
  transition: color 2.5s, border-color 2.5s, background 2.5s;
}

#score-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 90%;
}

.bar-label {
  font-size: clamp(0.55rem, 1.4vw, 0.75rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
  flex-shrink: 0;
}

.evil-lbl { color: #cc2244; }
.good-lbl { color: #aabbff; }

#score-track {
  flex: 1;
  position: relative;
  height: 8px;
  background: linear-gradient(to right, #330015, #1a1840, #3344aa);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}

#score-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 4px;
  transition: width 2s cubic-bezier(.4,0,.2,1), background 2s ease;
}

#score-pip {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  transition: left 2s cubic-bezier(.4,0,.2,1), background 2s ease, box-shadow 2s ease;
}

#score-number {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: color 2.5s ease;
}

#judgment-text {
  font-size: clamp(0.7rem, 1.8vw, 0.95rem);
  text-align: center;
  max-width: 90%;
  line-height: 1.5;
  color: #c8c0e0;
  font-style: italic;
  min-height: 2.5em;
  transition: color 2s ease;
}

#last-update-text {
  font-size: clamp(0.5rem, 1.2vw, 0.65rem);
  color: #5a5070;
  letter-spacing: 0.1em;
}

#analyzing-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.55rem, 1.3vw, 0.7rem);
  color: #8878a8;
  letter-spacing: 0.1em;
}
#analyzing-indicator.visible { display: flex; }

.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #8878a8;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.2); }
}

/* ════════════════════════════════════════
   SVG state switching via #angel classes
   ════════════════════════════════════════ */

/* Default: hide all state-specific elements */
.wing-evil, .eyes-evil, .outfit-evil, .skirt-evil,
.horns, .chains, .embers, .mouth-evil, .brow-evil { opacity: 0; }

.wing-good, .eyes-good, .outfit-good, .skirt-good,
.halo, .sparkles, .mouth-good, .blush            { opacity: 1; }

/* Transition all */
.wing-evil, .eyes-evil, .outfit-evil, .skirt-evil,
.horns, .chains, .embers, .mouth-evil, .brow-evil,
.wing-good, .eyes-good, .outfit-good, .skirt-good,
.halo, .sparkles, .mouth-good, .blush,
.aura {
  transition: opacity 2s ease;
}

/* Good state */
#angel.state-good .aura-good-el { opacity: 1; }
#angel.state-good .aura-evil-el { opacity: 0; }
#angel.state-good .wing-good    { opacity: 1; }
#angel.state-good .wing-evil    { opacity: 0; }
#angel.state-good .eyes-good    { opacity: 1; }
#angel.state-good .eyes-evil    { opacity: 0; }
#angel.state-good .outfit-good  { opacity: 1; }
#angel.state-good .outfit-evil  { opacity: 0; }
#angel.state-good .skirt-good   { opacity: 1; }
#angel.state-good .skirt-evil   { opacity: 0; }
#angel.state-good .halo         { opacity: 1; }
#angel.state-good .horns        { opacity: 0; }
#angel.state-good .chains       { opacity: 0; }
#angel.state-good .sparkles     { opacity: 1; }
#angel.state-good .embers       { opacity: 0; }
#angel.state-good .mouth-good   { opacity: 1; }
#angel.state-good .mouth-evil   { opacity: 0; }
#angel.state-good .blush        { opacity: 1; }
#angel.state-good .brow-evil    { opacity: 0; }

/* Evil state */
#angel.state-evil .aura-good-el { opacity: 0; }
#angel.state-evil .aura-evil-el { opacity: 1; }
#angel.state-evil .wing-good    { opacity: 0; }
#angel.state-evil .wing-evil    { opacity: 1; }
#angel.state-evil .eyes-good    { opacity: 0; }
#angel.state-evil .eyes-evil    { opacity: 1; }
#angel.state-evil .outfit-good  { opacity: 0; }
#angel.state-evil .outfit-evil  { opacity: 1; }
#angel.state-evil .skirt-good   { opacity: 0; }
#angel.state-evil .skirt-evil   { opacity: 1; }
#angel.state-evil .halo         { opacity: 0; }
#angel.state-evil .horns        { opacity: 1; }
#angel.state-evil .chains       { opacity: 1; }
#angel.state-evil .sparkles     { opacity: 0; }
#angel.state-evil .embers       { opacity: 1; }
#angel.state-evil .mouth-good   { opacity: 0; }
#angel.state-evil .mouth-evil   { opacity: 1; }
#angel.state-evil .blush        { opacity: 0; }
#angel.state-evil .brow-evil    { opacity: 1; }

/* ── Theme shifts per state ── */
body.theme-evil {
  background: #0d0005;
}
body.theme-good {
  background: #07020f;
}

#angel.state-evil {
  filter: drop-shadow(0 0 18px rgba(180,0,80,0.5));
  animation: float-evil 6s ease-in-out infinite;
}
@keyframes float-evil {
  0%, 100% { transform: translateY(0) rotate(-0.5deg); }
  50%       { transform: translateY(-8px) rotate(0.5deg); }
}

/* ── Ember glow animation ── */
.ember {
  animation: ember-flicker 2.5s ease-in-out infinite;
}
.ember:nth-child(2) { animation-delay: 0.4s; animation-duration: 2.1s; }
.ember:nth-child(3) { animation-delay: 0.8s; animation-duration: 3.1s; }
.ember:nth-child(4) { animation-delay: 1.2s; animation-duration: 2.7s; }
.ember:nth-child(5) { animation-delay: 0.2s; animation-duration: 2.3s; }
.ember:nth-child(6) { animation-delay: 1.6s; animation-duration: 2.9s; }

@keyframes ember-flicker {
  0%, 100% { opacity: 0.4; r: 3; }
  50%       { opacity: 1;   r: 5; }
}

/* ── Sparkle twinkle animation ── */
.sparkles path, .sparkles circle {
  animation: twinkle 3s ease-in-out infinite;
}
.sparkles path:nth-child(2) { animation-delay: 0.6s; }
.sparkles path:nth-child(3) { animation-delay: 1.2s; }
.sparkles path:nth-child(4) { animation-delay: 1.8s; }
.sparkles circle:nth-child(5) { animation-delay: 0.3s; }
.sparkles circle:nth-child(6) { animation-delay: 0.9s; }
.sparkles circle:nth-child(7) { animation-delay: 1.5s; }
.sparkles circle:nth-child(8) { animation-delay: 2.1s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.7); }
  50%       { opacity: 1;   transform: scale(1.2); }
}
