:root {
  --bg: #fff5f8; /* Soft pinkish white */
  --bg-2: #ffffff;
  --ink: #3d3d3d;
  --ink-soft: #7d7d7d;
  --primary: #ff8fb1; /* Bubbly Pink */
  --secondary: #7bc9ff; /* Sky Blue */
  --accent: #ffd93d; /* Sunshine Yellow */
  --rose: #ffafcc;
  --berry: #a2d2ff;
  --gold: #ffc300;
  --line: #ffe5ec;
  --card: rgba(255, 255, 255, 0.85);
  --shadow: 0 15px 30px -10px rgba(255, 143, 177, 0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Fredoka', 'Gothic A1', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.atmos { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.atmos .bloom { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.6; }
.bloom.a { width: 60vw; height: 60vw; background: #ffdeeb; top: -15vw; right: -10vw; }
.bloom.b { width: 50vw; height: 50vw; background: #e0f4ff; bottom: -15vw; left: -10vw; }
.bloom.c { width: 35vw; height: 35vw; background: #fff4d1; top: 35%; left: 45%; }

.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.3;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/></svg>");
  mix-blend-mode: soft-light;
}

.wrap { position: relative; z-index: 2; max-width: 1000px; margin: 0 auto; padding: 0 24px; }

header { padding: 40px 0 20px; text-align: center; }
.nav { display: flex; flex-direction: column; align-items: center; gap: 15px; }
.brand { font-size: 36px; font-weight: 700; color: var(--primary); letter-spacing: -0.02em; }
.brand b { color: var(--secondary); }
.tag { font-size: 14px; font-weight: 500; color: var(--ink-soft); letter-spacing: 0.05em; }

.hero { padding: 60px 0; text-align: center; }
.hero-grid { display: grid; grid-template-columns: 1fr; gap: 40px; }
.eyebrow { font-size: 20px; font-weight: 600; color: var(--primary); margin-bottom: 16px; display: block; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); font-weight: 700; line-height: 1.2; color: var(--ink); }
.hero h1 em { color: var(--secondary); font-style: normal; }
.h1-pre { font-size: 16px; font-weight: 500; color: var(--ink-soft); margin-bottom: 12px; display: block; }

.lede { margin-top: 24px; font-size: 18px; color: var(--ink-soft); max-width: 60ch; margin-left: auto; margin-right: auto; }
.hero-cta { margin-top: 40px; display: flex; gap: 16px; justify-content: center; }

.btn {
  cursor: pointer; border: none; font-family: inherit; font-weight: 700; font-size: 18px; padding: 18px 36px; border-radius: 99px;
  transition: 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); display: inline-flex; align-items: center; gap: 10px;
}
.btn:active { transform: scale(0.95); }
.btn-solid { background: var(--primary); color: #fff; box-shadow: 0 10px 20px -5px rgba(255, 143, 177, 0.5); }
.btn-solid:hover { transform: translateY(-5px) scale(1.05); box-shadow: 0 15px 30px -5px rgba(255, 143, 177, 0.6); }
.btn-ghost { background: #fff; color: var(--secondary); border: 3px solid var(--line); }
.btn-ghost:hover { border-color: var(--secondary); transform: translateY(-3px); }

.hero-preview { display: flex; justify-content: center; margin-top: 40px; }
.prev-card {
  background: var(--card); border: 4px solid #fff; border-radius: 40px; padding: 40px;
  box-shadow: var(--shadow); width: 100%; max-width: 400px; position: relative;
}
.prev-face { width: 90px; height: 90px; border-radius: 30px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 40px; margin: 0 auto 20px; color: #fff; transform: rotate(-5deg); }
.prev-muse-name { font-size: 2.5rem; font-weight: 700; color: var(--primary); }
.prev-muse-grp { font-size: 16px; font-weight: 600; color: var(--secondary); margin-bottom: 20px; }
.prev-pct { font-size: 3.5rem; font-weight: 800; color: var(--accent); line-height: 1; }
.prev-bar { height: 12px; background: var(--line); border-radius: 10px; overflow: hidden; margin: 20px 0; }
.prev-bar i { display: block; height: 100%; width: 95%; background: linear-gradient(90deg, var(--primary), var(--secondary)); }

section.block { padding: 80px 0; }
.secnum { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 10px; display: block; }
.sectitle { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 700; margin-bottom: 12px; }
.secdesc { font-size: 17px; color: var(--ink-soft); margin-bottom: 40px; }

.studio-grid { display: grid; grid-template-columns: 1fr; gap: 40px; }
.stage {
  position: relative; aspect-ratio: 1/1; background: #fff; border-radius: 40px; overflow: hidden;
  box-shadow: var(--shadow); border: 6px solid #fff;
}
.stage video, .stage canvas, .stage img { width: 100%; height: 100%; object-fit: cover; }
#liveVideo { transform: scaleX(-1); }

.action-zone { background: #fff; border-radius: 35px; padding: 32px; box-shadow: var(--shadow); border: 2px solid var(--line); }
.pickrow { display: flex; gap: 12px; margin-bottom: 24px; justify-content: center; }
.chip {
  cursor: pointer; padding: 12px 24px; border-radius: 20px; border: 3px solid var(--line); background: #fff;
  font-size: 16px; font-weight: 700; transition: 0.3s; color: var(--ink-soft);
}
.chip[aria-pressed="true"] { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.chip:hover { border-color: var(--secondary); }

.scan { position: absolute; inset: 0; display: none; z-index: 10; pointer-events: none; }
.scan.on { display: block; }
.scan .bar {
  position: absolute; width: 100%; height: 100px;
  background: linear-gradient(to bottom, transparent, rgba(123, 201, 255, 0.4), transparent);
  animation: scanning 1.5s ease-in-out infinite;
}
@keyframes scanning { 0% { top: -100px; } 100% { top: 100%; } }

.result-card {
  display: flex; flex-direction: column; background: #fff; border-radius: 45px; overflow: hidden; box-shadow: var(--shadow); border: 8px solid #fff;
}
.result-photo { position: relative; aspect-ratio: 1/1; overflow: hidden; }
.char-image-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 5; opacity: 0; transition: opacity 1s ease-in-out; }
.completed .char-image-overlay { opacity: 1; }

.char-card {
  width: 85%; height: 85%; background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 30px; border: 8px solid #fff; box-shadow: 0 20px 40px rgba(0,0,0,0.1);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #fff; padding: 20px;
  animation: cardBounce 1s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes cardBounce { from { transform: scale(0.8) rotate(-5deg); opacity: 0; } to { transform: scale(1) rotate(0deg); opacity: 1; } }

.char-studio { font-size: 14px; font-weight: 700; background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 10px; margin-bottom: 10px; }
.char-name-big { font-size: 2.5rem; font-weight: 800; line-height: 1.1; margin-bottom: 15px; }
.char-icon { font-size: 60px; }

.magic-overlay {
  position: absolute; inset: 0; background: linear-gradient(45deg, transparent, rgba(255,255,255,0.8), transparent);
  z-index: 10; pointer-events: none; opacity: 0; transform: translateX(-100%);
}
.transforming .magic-overlay {
  animation: magicSweep 2.5s ease-in-out infinite; opacity: 1;
}
@keyframes magicSweep { 0% { transform: translateX(-100%) skewX(-15deg); } 100% { transform: translateX(100%) skewX(-15deg); } }

.result-body { padding: 40px; text-align: center; }

/* AdSense Styling */
.ad-wrap { margin: 20px auto; min-height: 90px; text-align: center; overflow: hidden; background: rgba(255,255,255,0.3); border-radius: 20px; }
.ad-top { max-width: 728px; margin-bottom: 40px; }
.ad-post-result { max-width: 1000px; margin-top: 40px; border: 3px solid var(--line); }

.matchwith { font-size: 20px; font-weight: 600; color: var(--primary); }
.starname { font-size: clamp(2.5rem, 8vw, 4.5rem); font-weight: 800; margin: 10px 0; color: var(--ink); line-height: 1; }
.stargroup { font-size: 18px; font-weight: 600; color: var(--secondary); letter-spacing: 0.05em; }

.trait-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.trait { background: var(--bg); padding: 12px; border-radius: 15px; font-size: 13px; font-weight: 500; border: 2px solid var(--line); }
.trait b { display: block; color: var(--primary); font-size: 15px; margin-top: 4px; }

.runner { background: var(--line); padding: 8px 16px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--ink); }
.runner em { font-style: normal; color: var(--secondary); }

.tut-list { display: grid; gap: 20px; }
.tut-row {
  display: flex; align-items: center; gap: 20px; background: #fff; padding: 25px; border-radius: 30px;
  border: 4px solid var(--line); text-decoration: none; color: inherit; transition: 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.tut-row:hover { transform: scale(1.03) translateY(-5px); border-color: var(--secondary); box-shadow: var(--shadow); }
.tut-icon { font-size: 32px; }

/* QR Modal Styles */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(255, 143, 177, 0.4);
  backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 1000;
  padding: 24px;
}
.modal-backdrop.open { display: flex; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.qr-modal-box {
  background: #fff; border-radius: 40px; padding: 40px; width: 100%; max-width: 400px;
  text-align: center; position: relative; box-shadow: 0 30px 60px -12px rgba(255, 143, 177, 0.4);
  border: 4px solid #fff; transform: translateY(0); animation: slideUp 0.4s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes slideUp { from { transform: translateY(40px); } to { transform: translateY(0); } }

.modal-close {
  position: absolute; top: 20px; right: 20px; background: var(--bg); border: none;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.modal-close:hover { background: var(--line); transform: rotate(90deg); }

.qr-code-wrap {
  background: #fff; padding: 20px; border-radius: 30px; border: 3px solid var(--line);
  margin: 30px auto; width: fit-content;
}
.qr-code-wrap img { width: 200px; height: 200px; display: block; }
.qr-url { font-size: 13px; color: var(--ink-soft); word-break: break-all; margin-top: 10px; font-weight: 500; }

footer { padding: 60px 0; text-align: center; font-size: 15px; color: var(--ink-soft); font-weight: 500; }

@media (min-width: 800px) {
  .hero-grid { grid-template-columns: 1fr; }
  .studio-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .result-card { flex-direction: row; }
  .result-photo { width: 45%; height: auto; }
  .result-body { width: 55%; text-align: left; padding: 60px; }
}

.reveal { opacity: 0; transform: translateY(30px); transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.reveal.in { opacity: 1; transform: none; }
