:root {
  /* Soft-moe palette aligned with character art plates */
  --orange: #ff9a62;
  --orange-soft: #ffb38a;
  --orange-glow: #ffd0a8;
  --purple: #9b7dff;
  --purple-soft: #c4b0ff;
  --purple-deep: #5a478a;
  --bg: #1a1430;
  --bg-card: #2a2148;
  --bg-elevated: #352a58;
  --cream: #fff6ec;
  --lavender: #e8dffc;
  --text: #fff8f2;
  --text-muted: #d4c4ef;
  --pink: #ffb3c9;
  --gold: #ffe0a3;
  --radius: 28px;
  --shadow: 0 14px 42px rgba(123, 90, 200, 0.28);
  --font: "Nunito", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 60% at 15% 0%, rgba(255, 176, 138, 0.22), transparent 55%),
    radial-gradient(ellipse 80% 55% at 90% 15%, rgba(180, 150, 255, 0.28), transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(255, 179, 201, 0.14), transparent 55%),
    linear-gradient(180deg, #231a3d 0%, #1a1430 45%, #241838 100%);
  z-index: 0;
}

.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.star {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--lavender);
  border-radius: 50%;
  opacity: 0.55;
  box-shadow: 0 0 6px rgba(232, 223, 252, 0.5);
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.4); }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* Header */
.brand {
  text-align: center;
  margin-bottom: 28px;
  padding-top: 12px;
}
.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(255, 179, 138, 0.22), rgba(180, 150, 255, 0.28));
  border: 1px solid rgba(255, 208, 168, 0.4);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.85rem;
  color: var(--cream);
  margin-bottom: 14px;
}
.brand h1 {
  font-size: clamp(1.55rem, 5vw, 1.95rem);
  font-weight: 800;
  background: linear-gradient(120deg, var(--orange), var(--orange-glow) 40%, var(--purple-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.02em;
  line-height: 1.35;
}
.brand p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 8px;
}

/* Cards */
.card {
  background:
    linear-gradient(165deg, rgba(255, 246, 236, 0.06), transparent 40%),
    linear-gradient(160deg, #322656, #2a2148 55%, #3a2d5c);
  border: 1px solid rgba(196, 176, 255, 0.28);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 246, 236, 0.12);
  animation: fadeUp 0.45s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

/* Start screen */
.hero-art {
  width: 168px;
  height: auto;
  aspect-ratio: 3 / 4;
  margin: 0 auto 20px;
  display: block;
  filter: drop-shadow(0 10px 24px rgba(180, 150, 255, 0.35));
  border-radius: 22px;
  object-fit: cover;
  object-position: center center;
  background: transparent;
}
.start-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--orange-soft);
}
.start-desc {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}
.feature-list {
  list-style: none;
  margin-bottom: 28px;
}
.feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: rgba(196, 176, 255, 0.12);
  border-radius: 16px;
  border: 1px solid rgba(196, 176, 255, 0.18);
  font-size: 0.92rem;
  color: var(--text-muted);
}
.feature-list li span { font-size: 1.2rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, #ff9a62, #ffb38a 40%, #b89cff);
  color: #2a1a40;
  box-shadow: 0 8px 24px rgba(255, 154, 98, 0.32);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  background: rgba(123, 47, 247, 0.2);
  color: var(--text);
  border: 1px solid rgba(155, 92, 255, 0.4);
  margin-top: 10px;
}
.btn-secondary:hover { background: rgba(123, 47, 247, 0.32); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed rgba(196, 168, 224, 0.35);
  margin-top: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Progress */
.progress-wrap {
  margin-bottom: 20px;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.progress-bar {
  height: 10px;
  background: rgba(123, 47, 247, 0.2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--orange), var(--purple));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.q-text {
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 22px;
  line-height: 1.45;
}

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

.option {
  text-align: left;
  background: rgba(255, 246, 236, 0.06);
  border: 2px solid rgba(196, 176, 255, 0.32);
  border-radius: 20px;
  padding: 14px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s, box-shadow 0.15s;
}
.option:hover {
  border-color: var(--orange-soft);
  background: rgba(255, 179, 138, 0.16);
  box-shadow: 0 6px 18px rgba(180, 150, 255, 0.18);
  transform: translateX(4px);
}
.option:focus-visible {
  outline: 2px solid var(--purple-soft);
  outline-offset: 2px;
}

/* Result */
.result-rare-banner {
  text-align: center;
  background: linear-gradient(90deg, rgba(90, 138, 74, 0.35), rgba(255, 209, 102, 0.25));
  border: 1px solid rgba(168, 212, 106, 0.45);
  border-radius: 14px;
  padding: 8px 12px;
  margin-bottom: 16px;
  font-weight: 800;
  color: var(--gold);
  font-size: 0.9rem;
  animation: pulse 1.5s ease infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.result-art {
  width: 220px;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
  border-radius: 20px;
  background: linear-gradient(180deg, #c9b8ef, #b8a4e8);
  padding: 6px;
  box-shadow: 0 12px 32px rgba(140, 110, 210, 0.35);
  filter: none;
  animation: bob 2.5s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.result-name {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 900;
  margin-bottom: 6px;
  background: linear-gradient(120deg, var(--orange-glow), var(--purple-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result-tag {
  text-align: center;
  color: var(--orange-soft);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.result-blurb {
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 22px;
  padding: 0 4px;
}

.share-box {
  background: rgba(13, 6, 24, 0.5);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(155, 92, 255, 0.2);
}
.share-box label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.share-url {
  width: 100%;
  background: rgba(123, 47, 247, 0.15);
  border: 1px solid rgba(155, 92, 255, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--gold);
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, var(--purple), var(--orange));
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.footer {
  text-align: center;
  margin-top: 28px;
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.75;
}

@media (max-width: 400px) {
  .card { padding: 22px 16px; }
  .q-text { font-size: 1.08rem; }
}

.hero-art,
.result-art {
  object-fit: cover;
  border-radius: 28px;
  border: 3px solid rgba(255, 140, 66, 0.45);
  background: #1a0f2e;
}

/* Photo booth */
body.photo-open { overflow: hidden; }

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.photo-modal.hidden { display: none !important; }

.photo-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 3, 16, 0.78);
  backdrop-filter: blur(6px);
}

.photo-sheet {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(96vh, 920px);
  overflow-y: auto;
  background: linear-gradient(165deg, #1a0f2e, #241538 60%, #12081f);
  border: 1px solid rgba(255, 140, 66, 0.35);
  border-radius: 28px 28px 0 0;
  padding: 18px 18px 28px;
  box-shadow: 0 -12px 40px rgba(123, 47, 247, 0.35);
  animation: sheetUp 0.3s ease;
}
@keyframes sheetUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.photo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.photo-head h2 {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(120deg, var(--orange-glow), var(--purple-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.photo-x {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(155, 92, 255, 0.4);
  background: rgba(123, 47, 247, 0.2);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  font-family: inherit;
}
.photo-x:hover { background: rgba(255, 107, 26, 0.25); }

.photo-hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
  line-height: 1.45;
}

.photo-error {
  background: rgba(255, 80, 80, 0.15);
  border: 1px solid rgba(255, 120, 120, 0.45);
  color: #ffb4b4;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.45;
}

.photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow: hidden;
  border: 2px solid rgba(255, 140, 66, 0.45);
  box-shadow: 0 8px 28px rgba(123, 47, 247, 0.28);
  background: #0d0618;
  margin-bottom: 14px;
}

.photo-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0; /* canvas is the visible preview with overlays */
  pointer-events: none;
}

.photo-canvas,
.photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0d0618;
}

.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.photo-actions .btn { margin-top: 0; }
.photo-actions .btn + .btn { margin-top: 10px; }

@media (min-width: 560px) {
  .photo-modal { align-items: center; padding: 24px; }
  .photo-sheet {
    border-radius: 28px;
    max-height: 90vh;
  }
}


.gender-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.gender-row .btn { margin-top: 0; }
