/* ═══════════════════════════════════════
   MASTER ALICE — /master-alice (loaded by that page only)
   Arched portrait under a turning luopan; credentials as a Four Pillars
   chart that becomes a timeline on phones. Brand: #07070f, gold #f0c040,
   Outfit, the 八字 mark; the Premium purple→pink only on the Day pillar
   and the closing call to action.
═══════════════════════════════════════ */
body.ma-page {
  --ma-bg: #07070f;
  --ma-tile: #0f0f1c;
  --ma-gold: #f0c040;
  --ma-gold-deep: #e08020;
  --ma-paper: #f6ecd8;
  --ma-ink: rgba(246, 236, 216, 0.7);
  --ma-mute: rgba(246, 236, 216, 0.52);
  --ma-line: rgba(240, 192, 64, 0.22);
  --ma-line-soft: rgba(240, 192, 64, 0.12);
  --ma-p1: #a855f7;
  --ma-p2: #ec4899;
  --ma-display: 'Outfit', 'Noto Sans SC', 'Noto Sans Thai', system-ui, sans-serif;
  --ma-han: 'Noto Sans SC', sans-serif;
  --ma-ease: cubic-bezier(.2, .7, .2, 1);
  background: var(--ma-bg);
}
/* The site galaxy is replaced by a hero-only backdrop that fades into the page. */
body.ma-page .site-galaxy { display: none; }
body.ma-page::before {
  content: '';
  position: absolute; top: 0; left: 0; z-index: 0;
  width: 100%; height: min(1200px, 150vh);
  pointer-events: none;
  background:
    radial-gradient(70% 55% at 72% 30%, rgba(240, 192, 64, 0.10), transparent 70%),
    radial-gradient(55% 50% at 12% 20%, rgba(168, 85, 247, 0.14), transparent 70%),
    linear-gradient(180deg, rgba(7, 7, 15, 0.5) 0%, rgba(7, 7, 15, 0.72) 45%, var(--ma-bg) 96%),
    url('/app/assets/galaxy.jpg?v=2') center 30% / cover no-repeat;
}
.ma {
  position: relative; z-index: 1; flex: 1;
  width: 100%; max-width: 1160px; margin: 0 auto;
  padding: 24px 28px 96px;
  color: var(--ma-paper);
}

/* ── Hero ─────────────────────────────── */
.ma-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  grid-template-areas: "intro gate";
  align-items: center;
  gap: 48px;
  padding: 40px 0 24px;
}
.ma-gate {
  grid-area: gate;
  position: relative; justify-self: center;
  width: 100%; max-width: 540px; aspect-ratio: 4 / 5;
  animation: maRise 1.1s var(--ma-ease) both;
}
/* Ring: a square over the top of the gate, centred on her face */
.ma-ring {
  position: absolute; left: 0; top: 0; width: 100%; height: 80%;
  animation: maTurn 240s linear infinite;
  overflow: visible;
}
.ma-ring-line { fill: none; stroke: var(--ma-gold); stroke-width: 1; opacity: 0.5; }
.ma-ring-line.faint { opacity: 0.18; }
.ma-tick { stroke: var(--ma-gold); stroke-width: 1; opacity: 0.4; }
.ma-tick.long { stroke-width: 1.6; opacity: 0.85; }
.ma-spoke { stroke: var(--ma-gold); stroke-width: 0.8; opacity: 0.16; }
.ma-branch {
  fill: var(--ma-gold); font-family: var(--ma-han); font-size: 19px; font-weight: 700;
  text-anchor: middle; dominant-baseline: central; opacity: 0.85;
}
.ma-halo {
  position: absolute; left: 10%; top: 8%; width: 80%; height: 64%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(240, 192, 64, 0.30), rgba(240, 192, 64, 0.08) 60%, transparent);
  filter: blur(6px);
}
/* Arched portrait: a doorway rising out of the luopan, fading into the page at the foot */
.ma-portrait {
  position: absolute; left: 15%; right: 15%; top: 25%; bottom: 0;
  margin: 0; padding: 9px;
  border: 1px solid rgba(240, 192, 64, 0.55);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  background: rgba(7, 7, 15, 0.55);
  -webkit-mask-image: linear-gradient(180deg, #000 66%, transparent 99%);
  mask-image: linear-gradient(180deg, #000 66%, transparent 99%);
}
.ma-portrait img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 0;
  border-radius: 999px 999px 0 0;
  box-shadow: inset 0 0 0 1px rgba(240, 192, 64, 0.3);
}
/* Seal: the 八字 mark on the app-icon tile */
.ma-seal {
  position: absolute; right: 7%; bottom: 17%;
  width: 78px; height: 78px; border-radius: 18px;
  display: grid; place-items: center;
  background:
    linear-gradient(var(--ma-tile), var(--ma-tile)) padding-box,
    linear-gradient(135deg, #fff23a, #fdc60b 28%, #f28f3f 67%, #e83e39) border-box;
  border: 1.5px solid transparent;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 30px rgba(240, 160, 64, 0.22);
  transform: rotate(-7deg);
}
.ma-mark { width: 74%; height: auto; display: block; }

.ma-intro { grid-area: intro; text-shadow: 0 2px 24px rgba(7, 7, 15, 0.6); }
.ma-intro > * { animation: maRise 0.9s var(--ma-ease) both; }
.ma-intro > :nth-child(2) { animation-delay: 0.1s; }
.ma-intro > :nth-child(3) { animation-delay: 0.18s; }
.ma-intro > :nth-child(4) { animation-delay: 0.24s; }
.ma-intro > :nth-child(5) { animation-delay: 0.34s; }
.ma-intro > :nth-child(6) { animation-delay: 0.46s; }
.ma-kicker {
  display: flex; align-items: center; gap: 14px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--ma-gold); margin: 0 0 22px;
}
.ma-kicker::before { content: ''; width: 40px; height: 1px; background: var(--ma-gold); flex: none; }
.ma-name {
  font-family: var(--ma-display); font-weight: 700;
  font-size: clamp(76px, 10.5vw, 150px); line-height: 0.88; letter-spacing: -0.045em;
  margin: 0 0 22px; color: var(--ma-paper);
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .ma-name {
    background: linear-gradient(176deg, #fffaf0 20%, #f6ecd8 52%, var(--ma-gold) 130%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
  }
}
.ma-name em {
  display: block; font-style: normal; font-weight: 500;
  font-size: 0.17em; letter-spacing: 0.5em; text-transform: uppercase;
  margin: 0 0 0.9em 0.1em;
  color: var(--ma-gold); -webkit-text-fill-color: var(--ma-gold);
}
.ma-thai { font-family: 'Noto Sans Thai', var(--ma-display); font-size: 24px; font-weight: 500; margin: 0 0 6px; color: var(--ma-paper); }
.ma-legal { font-size: 13px; color: var(--ma-mute); margin: 0 0 34px; letter-spacing: 0.02em; }
.ma-quote {
  position: relative; margin: 0 0 36px; padding: 2px 0 2px 26px;
  max-width: 540px;
  font-family: var(--ma-display); font-weight: 400; font-size: 22px; line-height: 1.5;
  color: var(--ma-paper);
}
.ma-quote::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, #fdc60b, #f28f3f 60%, #e83e39);
}
.ma-hero-cta { text-decoration: none; }

/* ── Shared ───────────────────────────── */
.ma-h2 {
  font-family: var(--ma-display); font-weight: 700; font-size: clamp(30px, 4.2vw, 48px);
  line-height: 1.08; letter-spacing: -0.025em; color: var(--ma-paper); margin: 0 0 18px;
}
.ma a:focus-visible, .ma .btn-primary:focus-visible { outline: 2px solid var(--ma-gold); outline-offset: 4px; }

/* ── Why ──────────────────────────────── */
.ma-why {
  position: relative; isolation: isolate;
  max-width: 860px; margin: 56px auto 120px; padding: 64px 0;
  text-align: center;
}
.ma-why-mark {
  position: absolute; z-index: -1; left: 50%; top: 50%;
  width: min(620px, 96%); height: auto;
  transform: translate(-50%, -50%);
  opacity: 0.07;
}
.ma-why .ma-h2::after {
  content: ''; display: block; width: 56px; height: 2px; margin: 22px auto 0; border-radius: 2px;
  background: linear-gradient(90deg, #fdc60b, #f28f3f, #e83e39);
}
.ma-lede { font-size: clamp(18px, 2.2vw, 24px); line-height: 1.65; color: var(--ma-ink); margin: 0; }

/* ── Four Pillars chart ───────────────── */
.ma-chart-wrap { margin: 0 0 120px; }
.ma-chart-intro { text-align: center; }
.ma-chart-note { max-width: 640px; margin: 0 auto 48px; color: var(--ma-ink); font-size: 16px; line-height: 1.65; }
.ma-chart {
  position: relative;
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: row-reverse; gap: 16px;
}
/* The thread that runs through the four pillars, read right to left */
.ma-chart::before {
  content: ''; position: absolute; z-index: 0; top: 72px; left: 2%; right: 2%; height: 1px;
  background: linear-gradient(270deg, transparent, var(--ma-gold) 12%, var(--ma-gold) 88%, transparent);
  opacity: 0.5;
}
.ma-chart::after {
  content: ''; position: absolute; z-index: 0; top: 68px; left: 2%;
  border: 4.5px solid transparent; border-right: 7px solid var(--ma-gold); border-left: 0;
  opacity: 0.7;
}
.ma-pillar {
  position: relative; z-index: 1;
  flex: 1; min-width: 0;
  padding: 0 0 28px;
  border: 1px solid var(--ma-line-soft); border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
}
.ma-pillar-head {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 26px 12px 22px; border-bottom: 1px solid var(--ma-line-soft);
}
.ma-han {
  display: grid; place-items: center;
  width: 92px; height: 92px; border-radius: 22px;
  font-family: var(--ma-han); font-weight: 700; font-size: 52px; line-height: 1;
  color: var(--ma-gold);
  background:
    linear-gradient(var(--ma-tile), var(--ma-tile)) padding-box,
    linear-gradient(150deg, rgba(253, 198, 11, 0.9), rgba(242, 143, 63, 0.35) 55%, rgba(240, 192, 64, 0.15)) border-box;
  border: 1px solid transparent;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.ma-pillar-name { font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ma-mute); text-align: center; }
.ma-pillar ul { list-style: none; margin: 0; padding: 24px 22px 0; display: grid; gap: 16px; }
.ma-pillar ul li { position: relative; padding-left: 16px; font-size: 14.5px; line-height: 1.55; color: var(--ma-paper); }
.ma-pillar ul li::before {
  content: ''; position: absolute; left: 0; top: 0.62em;
  width: 5px; height: 5px; transform: rotate(45deg);
  background: var(--ma-gold); opacity: 0.75;
}
.ma-n {
  font-family: var(--ma-display); font-weight: 700; font-size: 1.5em; line-height: 1;
  letter-spacing: -0.02em; color: var(--ma-gold);
}
.ma-pillar ul li.ma-brands { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 0; }
.ma-pillar ul li.ma-brands::before { display: none; }
.ma-brands i { display: none; }
.ma-brands span {
  font-size: 12.5px; font-weight: 500; line-height: 1; letter-spacing: 0.02em;
  color: var(--ma-gold);
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--ma-line); background: rgba(240, 192, 64, 0.05);
}
/* Day pillar = the self: the one place the Premium gradient appears in the chart */
.ma-pillar.is-self {
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, #110d1d, #0b0a14) padding-box,
    linear-gradient(160deg, rgba(168, 85, 247, 0.75), rgba(236, 72, 153, 0.55) 45%, rgba(240, 192, 64, 0.18)) border-box;
  box-shadow: 0 24px 60px rgba(168, 85, 247, 0.16);
}
.ma-pillar.is-self .ma-han {
  background:
    linear-gradient(var(--ma-tile), var(--ma-tile)) padding-box,
    linear-gradient(135deg, var(--ma-p1), var(--ma-p2)) border-box;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 34px rgba(236, 72, 153, 0.3);
}
.ma-pillar.is-self .ma-han { color: #f7a8d8; text-shadow: 0 0 22px rgba(236, 72, 153, 0.5); }
.ma-pillar.is-self .ma-pillar-name { color: rgba(247, 168, 216, 0.85); }

/* ── Ultimate Destiny ─────────────────── */
.ma-house {
  display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 44px; align-items: center;
  max-width: 900px; margin: 0 auto 120px; padding: 44px;
  border: 1px solid var(--ma-line-soft); border-radius: 26px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
}
.ma-house-plate {
  width: 168px; height: 168px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(closest-side, rgba(240, 192, 64, 0.10), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 0 0 1px var(--ma-line), 0 0 0 8px rgba(255, 255, 255, 0.015);
}
.ma-house-logo { width: 120px; height: auto; filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.12)); }
.ma-house .ma-h2 { font-size: clamp(26px, 3vw, 34px); }
.ma-house p { color: var(--ma-ink); font-size: 15.5px; line-height: 1.7; margin: 0; }
.ma-house .ma-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.ma-links a {
  color: var(--ma-gold); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--ma-line);
  transition: border-color .2s, background-color .2s;
}
.ma-links a:focus-visible { border-color: var(--ma-gold); background: rgba(240, 192, 64, 0.08); }
@media (hover: hover) { .ma-links a:hover { border-color: var(--ma-gold); background: rgba(240, 192, 64, 0.08); } }

/* ── Closing call to action ───────────── */
.ma-cta {
  position: relative; isolation: isolate; overflow: hidden;
  max-width: 960px; margin: 0 auto; padding: 88px 32px 92px;
  text-align: center;
  border: 1px solid transparent; border-radius: 30px;
  background:
    radial-gradient(60% 70% at 50% 110%, rgba(236, 72, 153, 0.18), transparent 70%) padding-box,
    radial-gradient(50% 60% at 50% 0%, rgba(240, 192, 64, 0.12), transparent 70%) padding-box,
    linear-gradient(#0b0a14, #0b0a14) padding-box,
    linear-gradient(135deg, rgba(240, 192, 64, 0.7), rgba(168, 85, 247, 0.5) 55%, rgba(236, 72, 153, 0.6)) border-box;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}
.ma-cta-ring {
  position: absolute; z-index: -1; left: 50%; top: 50%;
  width: 640px; height: 640px; margin: -320px 0 0 -320px;
  opacity: 0.28;
  animation: maTurn 300s linear infinite reverse;
}
.ma-cta-mark { display: block; width: 104px; height: auto; margin: 0 auto 26px; filter: drop-shadow(0 6px 24px rgba(240, 140, 60, 0.35)); }
.ma-cta-line {
  font-family: var(--ma-display); font-weight: 700;
  font-size: clamp(30px, 4.6vw, 52px); line-height: 1.1; letter-spacing: -0.025em;
  margin: 0 0 32px;
}
.ma-cta .btn-primary { text-decoration: none; font-size: 17px; padding: 18px 40px; box-shadow: 0 12px 40px rgba(240, 192, 64, 0.3); }

/* ── Motion ───────────────────────────── */
@keyframes maRise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes maTurn { to { transform: rotate(360deg); } }
html.ma-js .ma-rv { transition: opacity 0.9s var(--ma-ease), transform 0.9s var(--ma-ease); }
html.ma-js .ma-rv:not(.is-in) { opacity: 0; transform: translateY(28px); }
html.ma-js .ma-chart .ma-rv:nth-child(3) { transition-delay: 0.1s; }
html.ma-js .ma-chart .ma-rv:nth-child(2) { transition-delay: 0.2s; }
html.ma-js .ma-chart .ma-rv:nth-child(1) { transition-delay: 0.3s; }
html.ma-js .ma-chart .ma-rv:nth-child(4) { transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) {
  .ma-ring, .ma-cta-ring, .ma-gate, .ma-intro > * { animation: none; }
  html.ma-js .ma-rv { transition: none; opacity: 1; transform: none; }
}

/* ── Tablet / phone ───────────────────── */
@media (max-width: 900px) {
  .ma { padding: 12px 20px 72px; }
  .ma-hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "gate" "intro";
    gap: 0; min-height: 0; padding: 8px 0 24px;
    text-align: center;
  }
  .ma-gate { width: min(360px, 92%); }
  /* The name rises into the faded foot of the portrait */
  .ma-intro { position: relative; z-index: 2; margin-top: -48px; }
  .ma-kicker { justify-content: center; }
  .ma-kicker::after { content: ''; width: 40px; height: 1px; background: var(--ma-gold); flex: none; }
  .ma-name em { margin-left: 0.5em; }
  .ma-quote { padding: 22px 0 0; margin: 0 auto 30px; }
  .ma-quote::before { left: 50%; top: 0; bottom: auto; width: 48px; height: 2px; margin-left: -24px; background: linear-gradient(90deg, #fdc60b, #f28f3f, #e83e39); }

  .ma-why { margin: 32px auto 56px; padding: 32px 0; }
  .ma-chart-wrap { margin-bottom: 84px; }
  .ma-chart-note { margin-bottom: 32px; }

  /* Chart → vertical timeline, Year (roots) first */
  .ma-chart { flex-direction: column; gap: 14px; }
  .ma-chart::before {
    top: 24px; bottom: 24px; left: 47px; right: auto; width: 1px; height: auto;
    background: linear-gradient(180deg, transparent, var(--ma-gold) 6%, var(--ma-gold) 94%, transparent);
  }
  .ma-chart::after { top: auto; bottom: 14px; left: 43px; border: 4.5px solid transparent; border-top: 7px solid var(--ma-gold); border-bottom: 0; }
  .ma-pillar {
    display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: start;
    padding: 0; background: rgba(255, 255, 255, 0.02);
  }
  .ma-pillar-head { border-bottom: 0; padding: 20px 6px; gap: 10px; }
  .ma-han { width: 62px; height: 62px; border-radius: 16px; font-size: 34px; }
  /* the timeline passes behind the label, so the label masks it */
  .ma-pillar-name { font-size: 10px; letter-spacing: 0.12em; position: relative; padding: 3px 2px; background: #0c0c14; border-radius: 4px; }
  .ma-pillar.is-self .ma-pillar-name { background: #0f0c1a; }
  .ma-pillar ul { padding: 22px 18px 22px 2px; gap: 14px; }

  .ma-house { grid-template-columns: minmax(0, 1fr); text-align: center; gap: 22px; padding: 32px 22px; margin-bottom: 84px; }
  .ma-house-plate { margin: 0 auto; width: 140px; height: 140px; }
  .ma-house-logo { width: 104px; }
  .ma-house .ma-links { justify-content: center; }
  .ma-cta { padding: 64px 22px 68px; border-radius: 24px; }
  .ma-cta-ring { width: 520px; height: 520px; margin: -260px 0 0 -260px; }
  .ma-cta-mark { width: 84px; }
}
@media (max-width: 480px) {
  .ma { padding: 8px 16px 56px; }
  .ma-seal { width: 60px; height: 60px; border-radius: 14px; }
  .ma-branch { font-size: 23px; }
  .ma-intro { margin-top: -40px; }
  .ma-kicker { gap: 10px; letter-spacing: 0.2em; }
  .ma-kicker::before, .ma-kicker::after { width: 18px; }
  .ma-portrait { left: 12%; right: 12%; }
  .ma-name { font-size: clamp(64px, 20vw, 84px); }
  .ma-thai { font-size: 21px; }
  .ma-quote { font-size: 19px; }
  .ma-lede { font-size: 18px; }
  .ma-pillar { grid-template-columns: 84px minmax(0, 1fr); }
  .ma-chart::before { left: 41px; }
  .ma-chart::after { left: 37px; }
  .ma-han { width: 56px; height: 56px; font-size: 30px; }
  .ma-pillar ul li { font-size: 14px; }
}
