:root {
  --pink: #f7d9e3;
  --lilac: #e3d7f5;
  --cloud: #fbf6fb;
  --ink: #3d3450;
  --ink-soft: #6b5f80;
  --accent: #b985c9;
  --accent-dark: #8a5aa8;
  --gold: #cba135;
  --danger: #b4566d;
  --ok: #4f9d78;
  --card-w: min(78vw, 220px);
  --card-ratio: 1240 / 1748;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, var(--pink) 0%, var(--lilac) 55%, var(--cloud) 100%);
  min-height: 100vh;
  font-family: -apple-system, "Noto Sans Thai", "Helvetica Neue", sans-serif;
  color: var(--ink);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding: 0 20px 40px;
}

/* --- Top bar / credit pill --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 20px calc(10px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(251, 246, 251, .72);
  backdrop-filter: blur(10px);
}
.brand-mark { font-weight: 700; color: var(--accent-dark); letter-spacing: .02em; }
.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  background: white;
  box-shadow: 0 4px 14px rgba(138, 90, 168, .22);
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent-dark);
  cursor: pointer;
}
.credit-pill:active { transform: scale(.96); }
.credit-unit { font-weight: 500; color: var(--ink-soft); }

/* --- Screens --- */

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
  min-height: 80vh;
  animation: fadein .35s ease;
}
.screen.active { display: flex; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand { text-align: center; margin-bottom: 40px; }
.brand h1 { font-size: 2.2rem; margin: 0; letter-spacing: .02em; color: var(--accent-dark); }
.tagline { color: var(--ink-soft); margin-top: 8px; }

h2 { text-align: center; color: var(--accent-dark); margin: 8px 0 20px; }
.hint { text-align: center; color: var(--ink-soft); font-size: .95rem; margin: -8px 0 24px; }

.back-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 1rem;
  margin-bottom: 12px;
  padding: 6px 0;
  cursor: pointer;
}

/* --- Boot --- */

.boot-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 70vh;
}
.boot-brand { font-size: 2rem; color: var(--accent-dark); margin: 0; }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(138, 90, 168, .2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Tiles & status --- */

.tiles { display: flex; flex-direction: column; gap: 18px; width: 100%; }
.tile {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 22px 20px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, .6);
  box-shadow: 0 8px 24px rgba(138, 90, 168, .15);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease;
}
.tile:active { transform: scale(.97); }
.tile-icon { font-size: 1.8rem; }

.status-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.status-option {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, .55);
  font-size: 1rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.status-option.selected {
  border-color: var(--accent);
  background: rgba(255, 255, 255, .9);
  font-weight: 600;
}

/* Multi-select variant used on the intention-questions screen: same look as
   .status-option, plus a checkbox glyph since several can be selected at once. */
.question-option {
  position: relative;
  padding-left: 46px;
  line-height: 1.4;
}
.question-option::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--ink-soft);
  background: white;
  transition: background .15s ease, border-color .15s ease;
}
.question-option.selected::before {
  background: var(--accent);
  border-color: var(--accent);
}
.question-option.selected::after {
  content: "✓";
  position: absolute;
  left: 19px;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: .75rem;
  font-weight: 700;
}

/* --- Buttons --- */

.cta-btn {
  margin-top: 28px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(138, 90, 168, .35);
  transition: transform .15s ease;
}
.cta-btn:active { transform: scale(.97); }
.cta-btn:disabled { background: #d9cbe3; box-shadow: none; cursor: not-allowed; }
.cta-dev {
  background: #7a8fa6;
  box-shadow: none;
  font-size: .9rem;
  margin-top: 10px;
}
.text-btn {
  margin-top: 18px;
  background: none;
  border: none;
  color: var(--ink-soft);
  text-decoration: underline;
  font-size: .95rem;
  cursor: pointer;
}

/* --- Scattered card spread --- */

.card-scatter {
  position: relative;
  width: 100%;
  height: 420px;
  margin-top: 8px;
}
.scatter-card {
  position: absolute;
  width: 32%;
  aspect-ratio: var(--card-ratio);
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 10px 20px rgba(138, 90, 168, .32));
  transform: rotate(var(--rot));
}
.scatter-card img { width: 100%; height: 100%; object-fit: contain; display: block; }

@keyframes card-deal-in {
  from { transform: translate(150vw, -40px) rotate(35deg); opacity: 0; }
  to   { transform: translate(0, 0) rotate(var(--rot)); opacity: 1; }
}
@keyframes card-float {
  0%, 100% { transform: translateY(0) rotate(var(--rot)); }
  50%      { transform: translateY(-11px) rotate(calc(var(--rot) + 1.5deg)); }
}
@keyframes card-chosen {
  from { transform: rotate(var(--rot)) scale(1); filter: drop-shadow(0 10px 20px rgba(138,90,168,.32)); }
  to   { transform: rotate(0deg) scale(1.16); filter: drop-shadow(0 0 34px rgba(185,133,201,.95)); }
}

.scatter-card.dealing { animation: card-deal-in 1.6s cubic-bezier(.16, 1, .3, 1) both; }
.scatter-card.floating { animation: card-float 3.4s ease-in-out infinite; }
.scatter-card.chosen { animation: card-chosen .55s ease-out forwards; z-index: 5; }
.scatter-card.dismissed {
  transition: opacity .5s ease, transform .5s ease;
  opacity: 0;
  transform: translateY(30px) rotate(var(--rot)) scale(.85);
}

/* --- Eye ritual --- */

.eye-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 70vh;
}
.eye-svg { width: 220px; color: var(--accent-dark); }
.eye-caption { color: var(--ink-soft); }

/* --- Reveal: 3D flip --- */

.flip-stage { perspective: 1400px; margin-bottom: 20px; }
.flip-card {
  position: relative;
  width: var(--card-w);
  aspect-ratio: var(--card-ratio);
  transform-style: preserve-3d;
  transition: transform .9s cubic-bezier(.4, .2, .2, 1);
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
}
.flip-face img { width: 100%; height: 100%; object-fit: contain; display: block; }
.flip-front {
  transform: rotateY(180deg);
  border: 3px solid var(--gold);
  background: linear-gradient(160deg, #fdeef2, #e9d8f7);
}
.flip-front .reveal-card-img { object-fit: cover; object-position: top center; }
/* Tone wash, so the cat art still reads as part of the pastel deck */
.flip-front::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.flip-front.tone-up::after {
  background: linear-gradient(160deg, rgba(253,238,242,.4), rgba(233,216,247,.25));
  mix-blend-mode: soft-light;
}
.flip-front.tone-cau::after {
  background: linear-gradient(160deg, rgba(217,199,224,.5), rgba(183,163,196,.4));
  mix-blend-mode: multiply;
}

#reveal-name { margin: 4px 0 6px; }
.face-text {
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
  padding: 0 8px;
  margin-bottom: 20px;
}

/* --- Reading + paywall --- */

.reading-block { width: 100%; }
.reading-locked { position: relative; }
.reading-section { margin-bottom: 16px; }
.reading-section h3 {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent-dark);
  margin: 0 0 4px;
}
.reading-section p { margin: 0; line-height: 1.6; }

/* Locked paragraphs hold placeholder glyphs, never the real reading — the
   blur is presentation, not protection. */
.reading-locked:not(.unlocked) .reading-section p {
  filter: blur(4px);
  user-select: none;
  color: var(--ink-soft);
}
.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
}
.lock-copy {
  background: rgba(255, 255, 255, .9);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  margin: 0;
}
.lock-sub { color: var(--ink-soft); font-size: .85rem; margin: 0; }
.reading-locked.unlocked .lock-overlay { display: none; }

/* --- Bundles --- */

.bundle-list { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.bundle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 18px 20px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 6px 18px rgba(138, 90, 168, .16);
  cursor: pointer;
}
.bundle:active { transform: scale(.98); }
.bundle-credits { font-size: 1.05rem; font-weight: 600; }
.bundle-price { font-size: 1.05rem; font-weight: 700; color: var(--accent-dark); }
.bundle-badge {
  position: absolute;
  top: -9px;
  right: 14px;
  background: var(--gold);
  color: white;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

/* --- QR --- */

.qr-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .7);
  margin-bottom: 18px;
}
.qr-summary strong { font-size: 1.15rem; color: var(--accent-dark); }
.qr-mock {
  background: white;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(138, 90, 168, .2);
  text-align: center;
}
.qr-mock canvas { display: block; width: 240px; height: 240px; }
.qr-mode-badge {
  margin: 10px 0 0;
  font-size: .78rem;
  color: var(--danger);
  font-weight: 600;
}
.qr-ref { color: var(--ink-soft); font-size: .85rem; margin: 12px 0 4px; }
.qr-warn { color: var(--danger); font-size: .85rem; text-align: center; margin: 4px 0 10px; }
.qr-status { color: var(--ink-soft); font-weight: 600; margin: 6px 0; }
.qr-status.is-ok { color: var(--ok); }
.qr-status.is-error { color: var(--danger); }

/* --- Toast --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  max-width: min(90vw, 440px);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(61, 52, 80, .95);
  color: white;
  font-size: .92rem;
  text-align: center;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 50;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .scatter-card.dealing,
  .scatter-card.floating,
  .scatter-card.chosen { animation: none; }
  .flip-card { transition: none; }
}
