:root {
  --green: #0b5b3f;
  --green-2: #11845a;
  --cream: #fbf4e8;
  --latte: #efe0c8;
  --brown: #5a3a24;
  --ink: #2a1d14;
  --pink: #ff5c8a;
  --yellow: #ffd23f;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'M PLUS Rounded 1c', system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; animation: screenIn 0.4s ease both; }
@keyframes screenIn { from { opacity: 0; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 28px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 17px;
  transition: transform 0.12s;
}
.btn:active { transform: scale(0.95); }
.btn-main {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 0 #063a28, 0 12px 24px rgba(11, 91, 63, 0.35);
  width: min(320px, 100%);
  font-size: 19px;
  animation: pulse 2s ease-in-out infinite;
}
.btn-main:active { box-shadow: 0 2px 0 #063a28; transform: translateY(4px); }
@keyframes pulse { 50% { transform: scale(1.04); } }
.btn-sub { background: var(--green); color: #fff; width: 100%; }
.btn-ghost { background: transparent; color: var(--brown); width: 100%; text-decoration: underline; min-height: 44px; }

/* ---------- title ---------- */
#title { background: radial-gradient(120% 80% at 50% 0%, #fff8ec 0%, var(--latte) 70%, #e2c9a4 100%); }
.title-bg {
  position: absolute;
  inset: -50%;
  background: repeating-conic-gradient(from 0deg at 50% 45%, rgba(255, 255, 255, 0.35) 0 6deg, transparent 6deg 15deg);
  animation: spin 40s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.title-inner {
  position: relative;
  margin: auto;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  width: 100%;
  max-width: 440px;
}
.title-kicker {
  margin: 8px 0 0;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.06em;
}
.title-logo { margin: 0; line-height: 1.05; }
.title-logo span {
  display: block;
  font-size: 15px;
  letter-spacing: 0.4em;
  color: var(--brown);
  margin-bottom: 6px;
}
.title-logo b {
  display: block;
  font-size: clamp(40px, 12vw, 54px);
  font-weight: 800;
  color: var(--green);
  text-shadow: 3px 3px 0 #fff, 6px 6px 0 rgba(11, 91, 63, 0.18);
}
.title-lead { margin: 4px 0 10px; line-height: 1.8; font-size: 15px; color: var(--brown); }
.title-note { margin: 4px 0 0; font-size: 11px; color: #8a6d55; line-height: 1.6; }

/* ---------- mascot ---------- */
.mascot { position: relative; width: 150px; height: 190px; margin-top: 28px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-2deg); } }
.mascot-box {
  position: absolute;
  bottom: 0;
  left: 15px;
  width: 120px;
  height: 160px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 18% 22%, #e2574c 0 5px, transparent 6px),
    radial-gradient(circle at 84% 68%, #e2574c 0 4px, transparent 5px),
    radial-gradient(circle at 80% 18%, #3a9b6b 0 10px, transparent 11px),
    radial-gradient(circle at 14% 80%, #3a9b6b 0 12px, transparent 13px),
    var(--green-2);
  box-shadow: inset -10px 0 0 rgba(0, 0, 0, 0.12), 0 10px 20px rgba(0, 0, 0, 0.2);
}
.mascot-top {
  position: absolute;
  top: -14px;
  left: 0;
  right: 0;
  height: 18px;
  background: var(--green);
  border-radius: 8px 8px 2px 2px;
  transform: perspective(80px) rotateX(30deg);
}
.mascot-face {
  position: absolute;
  top: 34px;
  left: 50%;
  width: 84px;
  height: 64px;
  margin-left: -42px;
  background: #fff;
  border-radius: 50%;
}
.eye {
  position: absolute;
  top: 20px;
  width: 9px;
  height: 13px;
  background: var(--ink);
  border-radius: 50%;
  animation: blink 4s infinite;
}
.eye:nth-child(1) { left: 22px; }
.eye:nth-child(2) { right: 22px; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
.cheek { position: absolute; top: 36px; width: 12px; height: 7px; background: #ff9db5; border-radius: 50%; }
.cheek:nth-child(3) { left: 10px; }
.cheek:nth-child(4) { right: 10px; }
.mouth {
  position: absolute;
  top: 36px;
  left: 50%;
  width: 16px;
  height: 9px;
  margin-left: -8px;
  border-radius: 0 0 16px 16px;
  background: #c8404e;
}
.mascot-cup {
  position: absolute;
  bottom: 14px;
  left: 50%;
  width: 40px;
  height: 30px;
  margin-left: -22px;
  background: #fff;
  border-radius: 4px 4px 14px 14px;
}
.mascot-cup::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 6px;
  width: 10px;
  height: 12px;
  border: 4px solid #fff;
  border-left: 0;
  border-radius: 0 8px 8px 0;
}
.mascot-bubble {
  position: absolute;
  top: -26px;
  right: -46px;
  padding: 8px 14px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 18px;
  font-weight: 800;
  z-index: 2;
  animation: popIn 0.5s 0.4s cubic-bezier(0.2, 1.8, 0.4, 1) both, wiggle 3s 1s ease-in-out infinite;
}
.mascot-bubble::after {
  content: '';
  position: absolute;
  left: 10px;
  bottom: -12px;
  border: 7px solid transparent;
  border-top: 9px solid var(--ink);
  transform: rotate(20deg);
}
@keyframes popIn { from { transform: scale(0); } }
@keyframes wiggle { 0%, 80%, 100% { rotate: 0deg; } 85% { rotate: 8deg; } 90% { rotate: -8deg; } }
.steam { position: absolute; top: -10px; left: 50%; }
.steam i {
  position: absolute;
  width: 8px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  animation: steam 2.4s ease-in infinite;
}
.steam i:nth-child(1) { left: -28px; }
.steam i:nth-child(2) { left: -4px; animation-delay: 0.8s; }
.steam i:nth-child(3) { left: 20px; animation-delay: 1.6s; }
@keyframes steam { from { opacity: 0; transform: translateY(10px) scaleY(0.6); } 40% { opacity: 1; } to { opacity: 0; transform: translateY(-34px) scaleY(1.2); } }
.mascot.mini { width: 100px; height: 120px; margin: -6px auto 0; transform: scale(0.65); }

/* ---------- survey ---------- */
#survey { background: linear-gradient(180deg, #fff8ec, var(--latte)); }
.survey-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 16px 0;
}
.icon-btn { width: 44px; height: 44px; font-size: 34px; line-height: 1; color: var(--brown); display: grid; place-items: center; }
.dots { display: flex; gap: 8px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(90, 58, 36, 0.2); transition: 0.3s; }
.dots i.on { background: var(--green); transform: scale(1.2); }
.q-card { margin: auto 0; padding: 0 20px; text-align: center; }
.q-card.enter { animation: cardIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes cardIn { from { opacity: 0; transform: translateX(40px) scale(0.96); } }
.q-sub { margin: 0; color: var(--green); font-weight: 800; letter-spacing: 0.1em; font-size: 14px; }
.q-text { margin: 10px 0 28px; font-size: 26px; line-height: 1.45; white-space: pre-line; }
.q-options { display: grid; gap: 12px; max-width: 400px; margin: 0 auto; }
.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 20px;
  border-radius: 20px;
  background: #fff;
  border: 3px solid transparent;
  box-shadow: 0 4px 0 rgba(90, 58, 36, 0.15);
  font-weight: 700;
  font-size: 18px;
  text-align: left;
  animation: optIn 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
@keyframes optIn { from { opacity: 0; transform: translateY(16px); } }
.opt:active { transform: scale(0.96); }
.opt.picked { border-color: var(--green); background: #e8f6ef; transform: scale(1.03); }
.opt-icon { font-size: 28px; width: 36px; text-align: center; }
.survey-note { text-align: center; font-size: 12px; color: #8a6d55; padding: 0 16px calc(20px + var(--safe-b)); margin: 0; }

/* ---------- scan ---------- */
#scan { background: #000; }
#ar { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
#ar video { object-fit: cover; }
#fxBack { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.scan-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: calc(14px + var(--safe-t)) 16px 30px;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
  text-align: center;
  pointer-events: none;
}
.scan-top p {
  display: inline-block;
  margin: 0;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  font-weight: 700;
  font-size: 14px;
  transition: opacity 0.3s;
}
#scan.found .scan-top p { opacity: 0; }
.scan-guide {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 58vw;
  max-width: 260px;
  aspect-ratio: 2 / 3;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  animation: guide 1.6s ease-in-out infinite;
}
#scan.found .scan-guide, #scan.loading .scan-guide { opacity: 0; }
@keyframes guide { 50% { transform: translate(-50%, -50%) scale(1.05); } }
.scan-guide i { position: absolute; width: 36px; height: 36px; border: 5px solid #fff; filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.4)); }
.scan-guide i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.scan-guide i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.scan-guide i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.scan-guide i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.loader { position: absolute; inset: 0; display: none; place-items: center; z-index: 4; }
#scan.loading .loader { display: grid; }
.loader span { width: 48px; height: 48px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; animation: spin 0.9s linear infinite; }

.bubble {
  --tail-x: 50%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  max-width: min(84vw, 360px);
  padding: 16px 22px 18px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18);
  pointer-events: none;
  opacity: 0;
  will-change: transform;
}
.bubble::after {
  content: '';
  position: absolute;
  left: var(--tail-x);
  bottom: -26px;
  width: 30px;
  height: 26px;
  margin-left: -15px;
  background: inherit;
  border: 4px solid var(--ink);
  border-top: 0;
  clip-path: polygon(0 0, 100% 0, 40% 100%);
  border-radius: 0 0 6px 0;
}
.bubble::before {
  content: '';
  position: absolute;
  left: var(--tail-x);
  bottom: -4px;
  width: 22px;
  height: 8px;
  margin-left: -11px;
  background: inherit;
  z-index: 1;
}
.bubble.show { opacity: 1; }
.bubble.show .bubble-text, .bubble.show .bubble-name { animation: bubblePop 0.55s cubic-bezier(0.2, 2, 0.4, 1) both; }
.bubble.show { animation: bubbleIn 0.55s cubic-bezier(0.2, 2, 0.4, 1) both; }
@keyframes bubbleIn { from { opacity: 0; scale: 0.2; } 60% { opacity: 1; } }
@keyframes bubblePop { from { transform: scale(0.6); } }
.bubble-name {
  position: absolute;
  top: -14px;
  left: 18px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.bubble-text {
  margin: 4px 0 0;
  font-size: clamp(17px, 5vw, 21px);
  font-weight: 800;
  line-height: 1.5;
  white-space: pre-line;
  min-height: 3em;
}
.bubble-text .ghost { color: transparent; }
.bubble.fx-love { background: #fff0f5; border-color: #e23b6d; }
.bubble.fx-love::after { border-color: #e23b6d; }
.bubble.fx-love .bubble-name { background: #e23b6d; }
.bubble.fx-happy { background: #fffbe6; border-color: #e0a100; }
.bubble.fx-happy::after { border-color: #e0a100; }
.bubble.fx-happy .bubble-name { background: #e0a100; }
.bubble.fx-calm { background: #f3fbf6; border-color: var(--green); border-radius: 40px; }
.bubble.fx-calm::after { border-color: var(--green); }
.bubble.fx-cheer { border-width: 5px; transform-origin: center; }
.bubble.fx-cheer.show .bubble-text { animation: bubblePop 0.55s cubic-bezier(0.2, 2, 0.4, 1) both, shake 0.5s 0.5s 2; }
.bubble.fx-cheer .bubble-text { font-size: clamp(19px, 5.6vw, 24px); }
@keyframes shake { 25% { transform: translateX(-3px) rotate(-1deg); } 75% { transform: translateX(3px) rotate(1deg); } }

.scan-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  display: flex;
  gap: 12px;
  padding: 40px 16px calc(18px + var(--safe-b));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
}
.btn-like {
  flex: 1.4;
  background: #fff;
  color: #e23b6d;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}
.btn-like .heart { font-size: 22px; transition: transform 0.2s; }
.btn-like.liked { background: #ff5c8a; color: #fff; }
.btn-like.pop .heart { animation: heartPop 0.5s cubic-bezier(0.2, 2.2, 0.4, 1); }
@keyframes heartPop { 40% { transform: scale(1.8); } }
.btn-like .count {
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(226, 59, 109, 0.12);
  font-size: 14px;
}
.btn-like.liked .count { background: rgba(255, 255, 255, 0.3); }
.btn-end { flex: 1; background: var(--green); color: #fff; box-shadow: 0 5px 0 #063a28; }

/* ---------- result ---------- */
#result { background: radial-gradient(120% 70% at 50% 0%, #fff8ec, var(--latte)); overflow-y: auto; }
.result-inner {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: calc(28px + var(--safe-t)) 16px calc(28px + var(--safe-b));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.result-lead { margin: 0; font-weight: 800; color: var(--green); }
.result-bubble {
  position: relative;
  width: 100%;
  margin-top: 6px;
  padding: 30px 24px 22px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 32px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
  text-align: center;
}
.result-bubble.show { animation: bubbleIn 0.6s cubic-bezier(0.2, 2, 0.4, 1) both; }
.result-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -24px;
  margin-left: -14px;
  width: 28px;
  height: 24px;
  background: inherit;
  border: 4px solid var(--ink);
  border-top: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.result-bubble.fx-love { background: #fff0f5; border-color: #e23b6d; }
.result-bubble.fx-love::after { border-color: #e23b6d; }
.result-bubble.fx-happy { background: #fffbe6; border-color: #e0a100; }
.result-bubble.fx-happy::after { border-color: #e0a100; }
.result-bubble.fx-calm { background: #f3fbf6; border-color: var(--green); }
.result-bubble.fx-calm::after { border-color: var(--green); }
.result-text { margin: 0; font-size: clamp(18px, 5.2vw, 24px); font-weight: 800; line-height: 1.6; white-space: pre-line; }
.result-name { margin: 12px 0 0; font-size: 13px; color: #8a6d55; font-weight: 700; }
.btn-x { width: 100%; background: #000; color: #fff; box-shadow: 0 5px 0 #444; }
.btn-x svg { width: 20px; height: 20px; }
.liked-wrap { width: 100%; }
.liked-title { margin: 6px 0 8px; font-weight: 800; color: #e23b6d; font-size: 14px; }
.liked-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.liked-list li {
  padding: 12px 16px;
  border-radius: 16px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
}
.result-actions { width: 100%; display: grid; gap: 6px; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .title-bg, .btn-main, .mascot, .scan-guide { animation: none; }
}
