:root {
  --bg: #FFE4EC;
  --surface: #FFF5F8;
  --paper: #FFFBF5;
  --line: #F2B8CB;
  --gold: #C8952E;
  --gold-soft: #E8C17A;
  --accent: #C2185B;
  --accent-dark: #8E0F42;
  --ink: #4A0F2E;
  --ink-2: #5C1A3C;
  --muted: #7E2E55;
  --display: 'Mitr', 'IBM Plex Sans Thai', sans-serif;
  --body: 'IBM Plex Sans Thai', 'Mitr', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }

.trial {
  background: var(--ink);
  color: #FFE4EC;
  font-size: 12px;
  text-align: center;
  padding: 6px 12px;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: calc(100dvh - 30px);
  display: flex;
}
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  min-width: 0;
}

/* header */
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.logo { font-family: var(--display); font-size: 26px; font-weight: 600; color: var(--accent); letter-spacing: .5px; }
.logo.small { font-size: 20px; }
.logo { text-decoration: none; border-radius: 10px; }
.logo:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.logo { display: inline-flex; align-items: center; gap: 6px; line-height: 1; }
.logo .mark { width: 1.05em; height: 1.25em; flex: none; }
.pill { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: 12px; cursor: pointer; color: var(--ink); }
.icon-btn:focus-visible, .btn:focus-visible, .link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* hero */
.hero { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.hero.compact { padding-top: 8px; }
.hero-art svg { display: block; }
h1 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 30px; line-height: 1.3; }
h2 { margin: 0; font-family: var(--display); font-weight: 500; }
.sub { margin: 0; font-size: 15px; color: var(--muted); line-height: 1.6; }
.fine { margin: 2px 0 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* fields */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 500; }
.field textarea, .field input {
  width: 100%; resize: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; font-size: 16px; line-height: 1.5;
}
.field textarea::placeholder, .field input::placeholder { color: #9A4A70; }
.field textarea:focus, .field input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-align: center; font-size: 15px; line-height: 1.7; }
.notice strong { font-family: var(--display); font-weight: 500; color: var(--accent); margin-left: 4px; }

/* buttons */
.actions { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.actions.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 0; }
.btn {
  min-height: 52px; border-radius: 16px; border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
  font-size: 15px; text-decoration: none; transition: transform .08s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; font-family: var(--display); font-size: 18px; font-weight: 500; min-height: 56px; flex-wrap: wrap; }
.btn.primary:hover { background: #AD1457; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.outline { background: transparent; border-color: var(--accent); color: var(--accent); }
.trial-price { font-family: var(--body); font-size: 12px; font-weight: 400; opacity: .9; width: 100%; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 13px; cursor: pointer; padding: 8px; }

/* shake */
.ask { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.ask-label { font-size: 13px; color: var(--muted); }
.ask-text { font-family: var(--display); font-size: 20px; overflow-wrap: anywhere; }
.ask-text.small { font-size: 18px; }
.stage { flex: 1; min-height: 300px; position: relative; display: flex; align-items: center; justify-content: center; }
.rings { position: absolute; max-width: 100%; height: auto; }
.cyl { position: relative; transform-origin: 50% 75%; transform: rotate(-12deg); }
.cyl svg { display: block; }
.cyl.shaking { animation: mj-shake .5s ease-in-out 3; }
.cyl.shaking .sticks { animation: mj-rattle .25s ease-in-out 6; }
.dropped { position: absolute; left: calc(50% + 62px); top: calc(50% + 40px); width: 60px; height: 120px; }
.dropped .spark { position: absolute; left: 0; top: -14px; animation: mj-spark 1.2s ease-out .5s infinite; }
.dropped .stick { position: absolute; left: 19px; top: 0; animation: mj-drop .8s cubic-bezier(.3,1.4,.5,1) both; }
.shake-copy { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.shake-copy h2 { font-size: 24px; }
@keyframes mj-shake { 0%{transform:rotate(-12deg)} 15%{transform:rotate(10deg)} 30%{transform:rotate(-14deg)} 45%{transform:rotate(12deg)} 60%{transform:rotate(-10deg)} 75%{transform:rotate(8deg)} 100%{transform:rotate(-12deg)} }
@keyframes mj-rattle { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes mj-drop { 0%{transform:translateY(-160px) rotate(-40deg);opacity:0} 60%{transform:translateY(8px) rotate(18deg);opacity:1} 80%{transform:translateY(-6px) rotate(12deg)} 100%{transform:translateY(0) rotate(14deg);opacity:1} }
@keyframes mj-spark { 0%{transform:scale(.3);opacity:0} 50%{opacity:1} 100%{transform:scale(1.2);opacity:0} }
/* ประกายแตกตอนได้ใบ */
.burst { position: absolute; left: calc(50% + 92px); top: calc(50% + 96px); width: 0; height: 0; pointer-events: none; }
.burst span, .burst i { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; opacity: 0; }
.burst span { background: var(--gold); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.burst i { background: #F27BA0; clip-path: path('M6 11 C1 8 0 4 2.5 2.5 C4 1.5 5.5 2.5 6 4 C6.5 2.5 8 1.5 9.5 2.5 C12 4 11 8 6 11Z'); }
.burst.go span { animation: mj-burst .9s cubic-bezier(.2,.8,.3,1) forwards; }
.burst.go i { animation: mj-burst 1.1s cubic-bezier(.2,.8,.3,1) .05s forwards; }
@keyframes mj-burst {
  0% { transform: rotate(var(--a)) translateX(0) scale(.4); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateX(78px) scale(1); opacity: 0; }
}

/* หน้าผลค่อยๆ เปิด */
.reveal .card { animation: mj-pop .55s cubic-bezier(.2,1.3,.4,1) both; }
.reveal .card .art { animation: mj-float 2.8s ease-in-out .6s infinite; }
.reveal .full { animation: mj-up .5s ease-out .25s both; }
.reveal .asked { animation: mj-up .4s ease-out both; }
@keyframes mj-pop { from { transform: scale(.85) rotate(-2deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mj-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mj-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

@media (prefers-reduced-motion: reduce) {
  .cyl.shaking, .cyl.shaking .sticks, .dropped .stick, .dropped .spark,
  .burst.go span, .burst.go i, .reveal .card, .reveal .card .art, .reveal .full, .reveal .asked { animation: none; }
}

/* result card */
.asked { padding: 0 4px; }
.card {
  background: var(--paper); border: 2px solid var(--gold); border-radius: 20px;
  padding: 18px 20px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.card-top { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-no { font-family: var(--display); font-size: 14px; color: var(--muted); }
.art { width: 168px; max-width: 60%; }
.art svg { display: block; width: 100%; height: auto; }
.card-name { font-size: 28px; line-height: 1.3; }
.card-text { margin: 0; font-size: 15px; line-height: 1.7; color: var(--ink-2); }

.chip { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.chip.l-best, .chip.strong { background: var(--accent); color: #fff; }
.chip.l-good { background: #FFE4EC; color: #A3134D; border: 1px solid var(--line); }
.chip.l-mid { background: #F3EEF6; color: #5B3F73; }
.chip.l-care { background: #FFF3DB; color: #7A5200; }

.full { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.full-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 8px; }
.full h3 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 17px; }
.trial-tag { font-size: 12px; color: var(--muted); }
.answer { margin: 0; font-size: 16px; line-height: 1.7; font-weight: 500; color: var(--ink); }
.answer-long { margin: 0; font-size: 15px; line-height: 1.75; color: var(--ink-2); }
.block { background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.block h4 { margin: 0 0 4px; font-family: var(--display); font-weight: 500; font-size: 14px; color: var(--accent); }
.block p { margin: 0; font-size: 14px; line-height: 1.65; }
.block ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.65; }
.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.block.dont h4 { color: #7A5200; }
.block.tip { background: #FFF6E3; border: 1px dashed var(--gold-soft); }
.block.tip h4 { color: #8A5A00; }
@media (max-width: 360px) { .dodont { grid-template-columns: 1fr; } }
.facts { margin: 0; display: grid; gap: 8px; }
.facts div { display: grid; grid-template-columns: 112px 1fr; gap: 8px; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-size: 14px; line-height: 1.6; }

.save-row { display: flex; justify-content: center; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* couple */
.couple-form { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.heart-sep { display: flex; justify-content: center; }
.error { margin: 0; color: #A3134D; font-size: 14px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center; z-index: 10;
}

.sheet { position: fixed; inset: 0; background: rgba(74,15,46,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.sheet-box { background: var(--paper); border-radius: 20px; padding: 16px; width: 100%; max-width: 380px; max-height: 100%; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.sheet-box h2 { font-size: 18px; text-align: center; }
.sheet-box img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; }
.sheet .btn.primary { font-size: 16px; min-height: 52px; }

@media (min-width: 600px) {
  .app { padding: 24px 0; }
  .screen { background: rgba(255,255,255,.35); border-radius: 28px; }
}
