:root {
  --bg: #111018;
  --panel: #191722;
  --panel-2: #211d2c;
  --moon: #dedbe8;
  --moon-soft: rgba(222, 219, 232, .72);
  --muted: rgba(222, 219, 232, .54);
  --line: rgba(222, 219, 232, .16);
  --gold: #c9ad72;
  --ink: #0f0e15;
  --paper: #ede7dc;
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 0%, rgba(129, 112, 158, .26), transparent 30%),
    radial-gradient(circle at 100% 72%, rgba(201, 173, 114, .11), transparent 32%),
    var(--bg);
  color: var(--moon);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  background-image:
    radial-gradient(circle, rgba(222, 219, 232, .32) 1px, transparent 1px),
    radial-gradient(circle, rgba(201, 173, 114, .2) 1px, transparent 1px);
  background-size: 86px 86px, 133px 133px;
  background-position: 12px 18px, 48px 72px;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

.app {
  position: relative;
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.screen {
  display: none;
  min-height: calc(100svh - 42px);
  animation: enter .32s ease both;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

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

.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.hero-card,
.mini-scene {
  position: relative;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card {
  height: min(54svh, 430px);
}

.hero-card img,
.mini-scene img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hero-card::after,
.mini-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(15, 14, 21, .9));
}

figcaption {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 1;
  padding: 8px 12px;
  border: 1px solid rgba(222, 219, 232, .24);
  border-radius: 999px;
  color: var(--moon);
  background: rgba(15, 14, 21, .62);
  backdrop-filter: blur(12px);
  font-size: 12px;
}

.copy-block {
  padding: 24px 2px 18px;
}

.copy-block.compact {
  padding-top: 54px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(44px, 15vw, 64px);
  line-height: 1.04;
  letter-spacing: -.08em;
}

h2 {
  margin-bottom: 16px;
  font-size: clamp(30px, 9vw, 42px);
  line-height: 1.12;
  letter-spacing: -.06em;
}

h3 {
  margin-bottom: 12px;
  font-size: 28px;
  line-height: 1.18;
  letter-spacing: -.04em;
}

.copy-block p:not(.kicker),
.draw-copy span,
.one-note p,
.prescription p {
  color: var(--moon-soft);
  font-size: 14px;
  line-height: 1.8;
}

.main-btn,
.ghost-btn {
  width: 100%;
  min-height: 58px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .02em;
}

.main-btn {
  margin-top: auto;
  color: var(--ink);
  background: linear-gradient(135deg, #f4f0e8, #cfcbe0);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .34);
}

.main-btn:disabled {
  opacity: .52;
}

.ghost-btn {
  margin-top: 12px;
  color: var(--moon);
  background: rgba(222, 219, 232, .08);
  border: 1px solid var(--line);
}

.tiny {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.back {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--moon);
  background: rgba(222, 219, 232, .08);
  font-size: 28px;
  line-height: 1;
  backdrop-filter: blur(14px);
}

.letter-box {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(222, 219, 232, .06);
}

.letter-box span {
  display: block;
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
}

textarea {
  width: 100%;
  min-height: 152px;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--moon);
  background: transparent;
  font-size: 17px;
  line-height: 1.75;
}

textarea::placeholder {
  color: rgba(222, 219, 232, .38);
}

.quick-picks {
  display: grid;
  gap: 10px;
  margin: 10px 0 18px;
}

.pick-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.pick-toolbar > span {
  color: rgba(222, 219, 232, .56);
}

.refresh-picks {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(222, 219, 232, .18);
  border-radius: 999px;
  color: var(--moon);
  background: rgba(222, 219, 232, .08);
  font-size: 12px;
  font-weight: 800;
}

.refresh-picks span {
  font-size: 14px;
  line-height: 1;
}

.refresh-picks:active {
  transform: scale(.98);
}

.pick {
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--moon-soft);
  background: rgba(222, 219, 232, .055);
  text-align: left;
  font-size: 14px;
}

.pick.selected {
  color: var(--ink);
  background: linear-gradient(135deg, #ede7dc, #cac6d9);
}

.draw-screen {
  justify-content: center;
}

.draw-copy {
  text-align: center;
}

.draw-copy p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.deck {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin: 32px 0 28px;
}

.card-back {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 222px;
  padding: 18px 8px 16px;
  border: 1px solid rgba(237, 231, 220, .5);
  border-radius: 18px;
  color: var(--moon);
  background:
    radial-gradient(circle at 50% 42%, rgba(237, 231, 220, .18), transparent 18%),
    linear-gradient(145deg, #252033, #111018);
  box-shadow: 0 18px 34px rgba(0, 0, 0, .34);
  transform: rotate(var(--rot));
  transition:
    transform .28s ease,
    box-shadow .28s ease,
    border-color .28s ease,
    background .28s ease;
}

.card-back::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(201, 173, 114, .42);
  border-radius: 13px;
}

.card-back::after {
  content: "";
  position: absolute;
  inset: 20px 20px auto;
  height: 1px;
  background: rgba(201, 173, 114, .36);
}

.card-moon {
  position: absolute;
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold);
  font-size: 34px;
  text-shadow: 0 0 24px rgba(237, 231, 220, .3);
}

.card-back strong,
.card-back small {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
}

.card-back strong {
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.card-back small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.card-back.selected {
  border-color: rgba(244, 240, 232, .92);
  background:
    radial-gradient(circle at 50% 34%, rgba(237, 231, 220, .24), transparent 24%),
    linear-gradient(145deg, #302a40, #15131d);
  box-shadow:
    0 0 0 5px rgba(222, 219, 232, .16),
    0 0 42px rgba(237, 231, 220, .22),
    0 22px 48px rgba(0, 0, 0, .48);
  transform: translateY(-10px) rotate(var(--rot)) scale(1.04);
}

.card-back.selected small {
  color: var(--moon-soft);
}

.mini-scene {
  height: 210px;
  margin-top: 54px;
}

.reading-card,
.diagnosis-poster,
.one-note {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(222, 219, 232, .06);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .24);
}

.reading-card {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 16px;
  margin: 18px 0 14px;
  padding: 14px;
}

.tarot-face {
  min-height: 164px;
  padding: 14px 10px;
  border: 1px solid rgba(201, 173, 114, .36);
  border-radius: 18px;
  background: linear-gradient(160deg, #242033, #111018);
  text-align: center;
}

.tarot-face span {
  display: block;
  margin: 8px 0 22px;
  color: var(--gold);
  font-size: 34px;
}

.tarot-face strong,
.tarot-face em {
  display: block;
}

.tarot-face strong {
  font-size: 15px;
  line-height: 1.35;
}

.tarot-face em {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

#analysis {
  margin-bottom: 0;
  color: var(--moon-soft);
  font-size: 14px;
  line-height: 1.75;
}

.one-note {
  margin-bottom: 18px;
  padding: 16px;
}

.one-note span,
.pill-label,
.doctor-order span,
.poster-top span {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .15em;
}

.one-note p {
  margin-bottom: 0;
}

.diagnosis-poster {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 20px;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 10%, rgba(201, 173, 114, .24), transparent 28%),
    linear-gradient(180deg, #f4efe6, #d8d2c6);
}

.diagnosis-poster::after {
  content: "☾";
  position: absolute;
  right: 18px;
  bottom: -18px;
  color: rgba(15, 14, 21, .07);
  font-size: 120px;
  line-height: 1;
}

.poster-top {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.poster-top b {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 7px 10px;
  border: 1px solid rgba(15, 14, 21, .18);
  border-radius: 999px;
  color: rgba(15, 14, 21, .62);
  transform: rotate(6deg);
  font-size: 12px;
}

.poster-top span,
.diagnosis-poster .pill-label {
  color: rgba(15, 14, 21, .55);
}

.diagnosis-poster h3 {
  position: relative;
  z-index: 1;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: clamp(32px, 9vw, 44px);
  line-height: 1.08;
}

.severity {
  position: relative;
  z-index: 1;
  margin-bottom: 18px;
  color: rgba(15, 14, 21, .68);
  font-size: 14px;
  line-height: 1.55;
}

.evidence-line {
  position: relative;
  z-index: 1;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 14, 21, .12);
  border-radius: 20px;
  background: rgba(255, 255, 255, .3);
}

.evidence-line b {
  display: block;
  margin-bottom: 8px;
  color: rgba(15, 14, 21, .48);
  font-size: 11px;
  letter-spacing: .12em;
}

.evidence-line span {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.65;
}

.status-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.status-grid div {
  min-height: 82px;
  padding: 12px 8px;
  border: 1px solid rgba(15, 14, 21, .12);
  border-radius: 18px;
  background: rgba(255, 255, 255, .28);
}

.status-grid span,
.doctor-order span {
  display: block;
  color: rgba(15, 14, 21, .5);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.status-grid strong {
  display: block;
  margin-top: 12px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.doctor-order {
  position: relative;
  z-index: 1;
  margin: 16px 0;
  padding: 16px;
  border-radius: 20px;
  color: var(--moon);
  background: linear-gradient(145deg, #201c2c, #111018);
}

.doctor-order p {
  margin: 8px 0 0;
  color: var(--moon);
  font-size: 17px;
  line-height: 1.65;
}

.poster-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(15, 14, 21, .12);
  font-size: 13px;
  line-height: 1.45;
}

.poster-row b {
  flex: 0 0 auto;
  color: rgba(15, 14, 21, .52);
}

.poster-row strong {
  text-align: right;
}

.poster-modal[hidden] {
  display: none;
}

.poster-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 5, 8, .72);
  backdrop-filter: blur(14px);
}

.poster-modal-card {
  position: relative;
  width: min(100%, 390px);
  max-height: 92svh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.poster-modal-card h3 {
  margin-right: 42px;
}

.poster-modal-card p {
  color: var(--moon-soft);
  font-size: 13px;
  line-height: 1.6;
}

.poster-modal-card img {
  display: block;
  width: 100%;
  margin: 14px 0;
  border-radius: 22px;
  background: var(--paper);
}

.poster-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  font-size: 24px;
}

@media (max-height: 760px) {
  .hero-card {
    height: 42svh;
  }

  h1 {
    font-size: 46px;
  }

  .copy-block {
    padding-top: 18px;
  }

  .deck {
    margin-top: 20px;
  }

  .card-back {
    min-height: 188px;
  }

  .card-moon {
    top: 34px;
  }
}
