/* 摘星塔罗 · Pick a Star Tarot — one dark "universe" theme */

:root {
  color-scheme: dark;
  /* palette */
  --midnight: #1F1B42;
  --twilight: #3B3470;
  --taro: #C6B0E8;
  --sakura: #FFD4DF;
  --blush: #FF9DB0;
  --baby-blue: #A8D7F4;
  --mint: #B3E6CF;
  --butter: #FFE6A0;
  --gold: #E0B45A;
  --antique-gold: #B5832E;
  --cream: #FFF7EC;
  --cocoa: #4F3A3C;
  --moon: #DCE2EE;
  --white: #FFFFFF;
  /* surfaces + text */
  --text: var(--cream);
  --text-soft: rgba(255, 247, 236, 0.78);
  --text-dim: rgba(220, 226, 238, 0.62);
  --line: rgba(220, 226, 238, 0.16);
  --glass: linear-gradient(160deg, rgba(59, 52, 112, 0.62), rgba(31, 27, 66, 0.62));
  --glass-solid: rgba(31, 27, 66, 0.72);
  --shadow: 0 18px 50px rgba(10, 8, 30, 0.45);
  /* special finishes */
  --holo: linear-gradient(115deg, var(--blush), var(--taro), var(--baby-blue), var(--mint), var(--butter));
  --foil: linear-gradient(135deg, #FFE6A0 0%, #E0B45A 38%, #FFF1C9 55%, #E0B45A 72%, #B5832E 100%);
  /* type */
  --font-cjk-display: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-display: "Fredoka", var(--font-cjk-display);
  --font-body: "Nunito", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --card-radius: 5% / 2.92%;
}
:lang(zh-Hant) {
  --font-cjk-display: "Huninn", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --font-body: "Nunito", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "PingFang SC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
html { background: var(--midnight); }
body {
  background: var(--midnight);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.app {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.5;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
button { font: inherit; color: inherit; touch-action: manipulation; }
img { max-width: 100%; }
.ic { width: 1.1em; height: 1.1em; flex: none; fill: currentColor; }
:focus-visible { outline: 3px solid var(--butter); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
::selection { background: rgba(198, 176, 232, 0.45); }

.sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  touch-action: manipulation;
}

/* ---------- buttons ---------- */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 500 16px/1.1 var(--font-display);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, filter 0.2s ease;
}
.pill-btn:hover { transform: translateY(-2px); }
.pill-btn:active { transform: translateY(1px) scale(0.98); }
.pill-btn:disabled { opacity: 0.6; cursor: progress; transform: none; }
.pill-btn.gold {
  background: var(--foil);
  color: var(--cocoa);
  box-shadow: 0 6px 22px rgba(224, 180, 90, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.pill-btn.gold:hover { box-shadow: 0 10px 28px rgba(224, 180, 90, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.pill-btn.soft {
  background: rgba(198, 176, 232, 0.16);
  color: var(--cream);
  border-color: rgba(198, 176, 232, 0.38);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.pill-btn.soft:hover { background: rgba(198, 176, 232, 0.26); }
.pill-btn.small { min-height: 38px; padding: 0 14px 0 10px; font-size: 15px; gap: 4px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(31, 27, 66, 0.55);
  color: var(--cream);
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.icon-btn:hover { background: rgba(59, 52, 112, 0.8); }
.icon-btn .ic { width: 20px; height: 20px; }
.icon-btn.is-muted { color: var(--text-dim); }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
/* once the page scrolls, text fades out under the bar instead of colliding with its pills */
.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 -26px;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(21, 18, 46, 0.95), rgba(21, 18, 46, 0.72) 60%, rgba(21, 18, 46, 0));
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.topbar.scrolled::before { opacity: 1; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mini-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  background: rgba(31, 27, 66, 0.55);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font: 400 19px/1 var(--font-cjk-display);
  color: var(--butter);
  letter-spacing: 0.06em;
}
.mini-brand .ic { width: 18px; height: 18px; filter: drop-shadow(0 0 6px rgba(255, 230, 160, 0.7)); }
.lang {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(31, 27, 66, 0.55);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lang button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: 500 15px/1 var(--font-display);
  min-width: 40px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.lang button[lang="en"] { font-family: "Fredoka", sans-serif; font-size: 14px; }
.lang button:hover { color: var(--cream); }
.lang button[aria-pressed="true"] { background: var(--taro); color: var(--midnight); }

/* ---------- screens ---------- */
/* the screens wrapper lets taps through to the sky canvas; each screen opts back in (picking stays see-through) */
.screens { position: relative; flex: 1; display: flex; flex-direction: column; pointer-events: none; }
.screen { position: relative; z-index: 1; pointer-events: auto; }
.screen.enter { animation: fadeUp 0.55s ease both; }
.screen.leaving { opacity: 0; transform: scale(0.98); transition: opacity 0.32s ease, transform 0.32s ease; }

.footnote {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ---------- 1. home ---------- */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(64px + env(safe-area-inset-top, 0px)) 16px calc(22px + env(safe-area-inset-bottom, 0px));
}
.home-panel {
  width: 100%;
  max-width: 580px;
  padding: 28px 26px 24px;
  text-align: center;
}
.logo { display: flex; flex-direction: column; align-items: center; }
.logo-star {
  width: 44px;
  height: 44px;
  color: var(--butter);
  filter: drop-shadow(0 0 12px rgba(255, 230, 160, 0.75));
  animation: bob 4s ease-in-out infinite;
}
.logo-title { margin: 6px 0 0; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 400; }
.logo-title .brand-cjk {
  font: 400 clamp(42px, 12vw, 60px)/1.05 var(--font-cjk-display);
  letter-spacing: 0.08em;
  padding-left: 0.08em;
  background: linear-gradient(180deg, #FFF7EC 10%, #FFE6A0 55%, #E0B45A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 14px rgba(255, 157, 176, 0.35));
}
.logo-en {
  font: 500 clamp(14px, 4vw, 17px)/1.2 "Fredoka", sans-serif;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--taro);
}
.subtitle { margin: 12px auto 0; max-width: 30em; color: var(--text-soft); font-size: 15.5px; line-height: 1.6; }

.q-label {
  display: block;
  margin: 18px 4px 8px;
  text-align: left;
  font: 500 15px/1.3 var(--font-display);
  color: var(--sakura);
}
.q-box { position: relative; }
.q-box textarea {
  display: block;
  width: 100%;
  min-height: 70px;
  resize: none;
  padding: 12px 16px 24px;
  border-radius: 18px;
  border: 1px solid rgba(198, 176, 232, 0.35);
  background: rgba(20, 17, 46, 0.55);
  color: var(--cream);
  font: 500 16px/1.45 var(--font-body);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.q-box textarea::placeholder { color: rgba(220, 226, 238, 0.45); }
.q-box textarea:focus { outline: none; border-color: var(--taro); box-shadow: 0 0 0 3px rgba(198, 176, 232, 0.25); }
.q-box textarea:focus-visible { outline: none; }
.q-count { position: absolute; right: 14px; bottom: 7px; font: 500 12px/1 "Fredoka", sans-serif; color: var(--text-dim); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-align: left;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(150deg, rgba(255, 212, 223, 0.16), rgba(198, 176, 232, 0.1));
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.choice.deep { background: linear-gradient(150deg, rgba(168, 215, 244, 0.16), rgba(198, 176, 232, 0.12)); }
.choice::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--holo);
  opacity: 0;
  mix-blend-mode: soft-light;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.choice:hover { transform: translateY(-3px); border-color: rgba(255, 230, 160, 0.5); box-shadow: 0 12px 30px rgba(10, 8, 30, 0.45), 0 0 24px rgba(198, 176, 232, 0.25); }
.choice:hover::after { opacity: 0.55; }
.choice:active { transform: translateY(0) scale(0.99); }
.choice-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 230, 160, 0.16);
  color: var(--butter);
}
.choice.deep .choice-icon { background: rgba(168, 215, 244, 0.16); color: var(--baby-blue); }
.choice-icon svg { width: 26px; height: 26px; }
.choice-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.choice-title { font: 500 21px/1.15 var(--font-display); color: var(--cream); }
.choice-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-soft); }
.choice-count {
  font: 500 12.5px/1 var(--font-display);
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--butter);
  color: var(--cocoa);
}
.choice.deep .choice-count { background: var(--baby-blue); }

/* ---------- 2. picking ---------- */
.pick {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.pick-top { padding: calc(62px + env(safe-area-inset-top, 0px)) 16px 0; display: flex; justify-content: center; }
.pick-pill {
  pointer-events: auto;
  margin: 0;
  max-width: 620px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 16px;
  border-radius: 24px;
  background: rgba(31, 27, 66, 0.72);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font: 400 15.5px/1.45 var(--font-display);
  color: var(--cream);
  box-shadow: 0 8px 26px rgba(10, 8, 30, 0.35);
}
.pick-pill > .ic { color: var(--butter); }
.pick-pill .pos-name { color: var(--butter); white-space: nowrap; }
.pick-count {
  flex: none;
  margin-left: auto;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--butter);
  color: var(--cocoa);
  font: 500 14px/1 "Fredoka", sans-serif;
  white-space: nowrap;
}
.pick-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 16px calc(14px + env(safe-area-inset-bottom, 0px));
}
.pick-bottom > * { pointer-events: auto; }
.tray {
  list-style: none;
  margin: 0;
  width: 100%;
  max-width: 820px;
  padding: 12px 12px 10px;
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  gap: 8px;
  border-radius: 24px;
  background: rgba(31, 27, 66, 0.66);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 -6px 30px rgba(10, 8, 30, 0.3);
}
.tray[data-n="3"] { max-width: 380px; }
.tray-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.tray-card {
  position: relative;
  width: 100%;
  max-width: 64px;
  aspect-ratio: 7 / 12;
  border-radius: 8px;
  border: 1.5px dashed rgba(198, 176, 232, 0.45);
  display: grid;
  place-items: center;
  color: rgba(198, 176, 232, 0.5);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.tray-card .ic { width: 40%; height: auto; }
.tray-card img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 7px; display: block; animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.tray-slot.next .tray-card {
  border-color: var(--butter);
  color: var(--butter);
  box-shadow: 0 0 0 3px rgba(255, 230, 160, 0.16), 0 0 18px rgba(255, 230, 160, 0.35);
  animation: pulse 1.6s ease-in-out infinite;
}
.tray-slot.filled .tray-card { border-color: transparent; box-shadow: 0 4px 14px rgba(10, 8, 30, 0.5); }
.tray-label {
  max-width: 100%;
  font: 400 12px/1.2 var(--font-display);
  color: var(--text-soft);
  text-align: center;
  overflow-wrap: anywhere;
}
.tray-label .num { color: var(--butter); margin-right: 3px; font-family: "Fredoka", sans-serif; }
.tray.done .tray-card { animation: glowAll 1.2s ease-in-out infinite; }
.tray.done .tray-card img { animation: none; }

/* ---------- 3. reading ---------- */
.reading { padding: calc(64px + env(safe-area-inset-top, 0px)) 16px calc(28px + env(safe-area-inset-bottom, 0px)); }
.reading-wrap { max-width: 940px; margin: 0 auto; }
.reading-head { text-align: center; }
.reading-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
  font: 400 16px/1.3 var(--font-display);
  color: var(--taro);
}
.reading-meta #rSpread { color: var(--butter); }
.reading-meta .sep { color: var(--text-dim); }
.reading-q {
  margin: 10px auto 0;
  max-width: 34em;
  padding: 8px 16px;
  border-radius: 18px;
  background: rgba(255, 212, 223, 0.08);
  border: 1px solid rgba(255, 212, 223, 0.22);
  color: var(--cream);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* cards (shared by both spreads) */
.spread { --cw: clamp(150px, 16vw, 196px); margin: 22px auto 0; }
.slot { position: relative; display: flex; flex-direction: column; align-items: center; width: var(--cw); animation: dealIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; animation-delay: calc(var(--i, 0) * 90ms); }
.card3d {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 7 / 12;
  padding: 0;
  border: 0;
  border-radius: var(--card-radius);
  background: none;
  perspective: 1100px;
  cursor: pointer;
}
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.25, 0.8, 0.25, 1.05);
}
.card3d.flipped .card-inner { transform: rotateY(180deg); }
.card3d:not(.flipped):hover .card-inner { transform: translateY(-4px) rotateZ(-1deg); }
.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--card-radius);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  box-shadow: 0 10px 26px rgba(8, 6, 28, 0.55);
}
.face img { display: block; width: 100%; height: 100%; }
.face.front { transform: rotateY(180deg); }
.slot.rev .face.front img { transform: rotate(180deg); }
.face.back { box-shadow: 0 10px 26px rgba(8, 6, 28, 0.55), 0 0 18px rgba(198, 176, 232, 0.25); }
/* holographic (镭射) shimmer on Major Arcana: on flip and on hover */
.slot.major .face.front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 25%, rgba(255, 157, 176, 0.55) 38%, rgba(198, 176, 232, 0.55) 45%, rgba(168, 215, 244, 0.55) 52%, rgba(179, 230, 207, 0.55) 58%, rgba(255, 230, 160, 0.55) 65%, transparent 78%);
  background-size: 260% 100%;
  background-position: 110% 0;
  mix-blend-mode: color-dodge;
  opacity: 0;
  pointer-events: none;
}
.slot.major .card3d.shine .face.front::after,
.slot.major .card3d.flipped:hover .face.front::after { animation: holo 1.5s ease-in-out both; }
.slot.major .card3d.flipped { box-shadow: 0 0 22px rgba(198, 176, 232, 0.35); }

.spark {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  pointer-events: none;
  background: currentColor;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  animation: sparkOut 0.85s ease-out both;
  z-index: 4;
}

.slot-label {
  margin-top: 10px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.pos { display: inline-flex; align-items: center; justify-content: center; gap: 5px; font: 400 14px/1.2 var(--font-display); color: var(--taro); }
.num {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(198, 176, 232, 0.24);
  color: var(--cream);
  font: 500 12px/1 "Fredoka", sans-serif;
}
.cname { font: 400 16px/1.25 var(--font-display); color: var(--cream); overflow-wrap: anywhere; }
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font: 400 12.5px/1.45 var(--font-display);
  white-space: nowrap;
}
.badge.up { background: rgba(179, 230, 207, 0.16); color: var(--mint); border: 1px solid rgba(179, 230, 207, 0.45); }
.badge.rev { background: rgba(255, 157, 176, 0.18); color: var(--blush); border: 1px solid rgba(255, 157, 176, 0.5); }
/* before the flip the real caption is laid out but hidden, so revealing never shifts the layout */
.concealed { visibility: hidden; }
.cname.concealed { position: relative; }
.cname.concealed::after { content: attr(data-q); visibility: visible; position: absolute; inset: 0; color: var(--text-dim); }
.cross-line { display: none; }

/* 3 cards: a row */
.spread-three { display: flex; justify-content: center; gap: 30px; }

/* 10 cards, desktop: real Celtic Cross (cross + staff) */
@media (min-width: 760px) {
  /* --cw is fitted to the window by app.js (fitSpread); this is only the starting size */
  .spread-celtic { --cw: clamp(84px, 8.6vw, 112px); --ch: calc(var(--cw) * 12 / 7); --gx: calc(var(--cw) * 0.56); display: flex; justify-content: center; align-items: center; gap: calc(var(--cw) * 0.62); }
  .cc-cross {
    display: grid;
    grid-template-columns: repeat(3, var(--cw));
    grid-template-rows: var(--ch) var(--ch) auto var(--ch);
    grid-template-areas: ". p5 ." "p4 p1 p6" "p4 p1 p6" ". p3 .";
    column-gap: var(--gx);
    row-gap: 8px;
    align-items: start;
  }
  .cc-cross .slot[data-pos="1"] { grid-area: p1; }
  .cc-cross .slot[data-pos="2"] { grid-area: p1; z-index: 3; pointer-events: none; }
  .cc-cross .slot[data-pos="3"] { grid-area: p3; }
  .cc-cross .slot[data-pos="4"] { grid-area: p4; }
  .cc-cross .slot[data-pos="5"] { grid-area: p5; }
  .cc-cross .slot[data-pos="6"] { grid-area: p6; }
  .spread-celtic .slot-label { margin-top: 6px; gap: 2px; }
  .spread-celtic .pos { font-size: 13px; }
  .spread-celtic .cname { font-size: 14px; }
  .spread-celtic .badge { font-size: 11.5px; padding: 0 8px; }
  .cc-cross .slot-label { width: calc(var(--cw) + var(--gx) - 6px); }
  /* cards 5 (above) and 3 (below) keep their captions beside them, so the cross stays as short as the staff */
  .cc-cross .slot[data-pos="5"] .slot-label,
  .cc-cross .slot[data-pos="3"] .slot-label { position: absolute; left: calc(100% + 10px); top: 50%; margin: 0; align-items: flex-start; text-align: left; transform: translateY(-50%); }
  /* the crossing card lies sideways over card 1, nudged down so card 1 stays recognisable */
  .cc-cross .slot[data-pos="2"] .card3d { pointer-events: auto; transform: translateY(calc(var(--cw) * 0.3)) rotate(90deg); }
  .cc-cross .slot[data-pos="2"] .slot-label { display: none; }
  .cc-cross .slot[data-pos="1"] .cross-line { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 4px; padding-top: 5px; border-top: 1px dashed rgba(198, 176, 232, 0.3); width: 100%; }
  .cc-staff { display: flex; flex-direction: column-reverse; gap: 10px; }
  .cc-staff .slot { width: auto; flex-direction: row; align-items: center; gap: 12px; }
  .cc-staff .slot .card3d { width: var(--cw); flex: none; }
  .cc-staff .slot-label { margin-top: 0; width: 9.5em; align-items: flex-start; text-align: left; }
}

.reveal-row { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 24px; }
.tap-hint { margin: 0; font-size: 14px; color: var(--text-dim); }
.phone-note {
  margin: 18px auto 0;
  max-width: 30em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 230, 160, 0.12);
  border: 1px solid rgba(255, 230, 160, 0.35);
  color: var(--butter);
  font: 400 14px/1.4 var(--font-display);
  text-align: center;
}

/* AI reading (only when the page is served with an ai-reading endpoint) */
.ai { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ai-cta { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pill-btn.holo { background: var(--holo); color: var(--cocoa); box-shadow: 0 6px 22px rgba(198, 176, 232, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.pill-btn.holo:hover { box-shadow: 0 10px 28px rgba(198, 176, 232, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.ai-note { margin: 0; max-width: 34em; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); }
.ai-login { color: var(--sakura); }
.ai-error {
  margin: 0;
  max-width: 30em;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(255, 157, 176, 0.12);
  border: 1px solid rgba(255, 157, 176, 0.35);
  color: var(--sakura);
  font-size: 14px;
  text-align: center;
}
.ai-panel { width: 100%; padding: 4px 22px 22px; }
.ai-panel .section-title { margin: 18px 0 12px; }
.ai-text p { margin: 0 0 12px; color: var(--text-soft); font-size: 15.5px; line-height: 1.8; overflow-wrap: anywhere; }
.ai-text > :last-child { margin-bottom: 0; }
.ai-text .ai-wait { color: var(--text-dim); }
.ai-text .ai-h { margin: 22px 0 8px; display: flex; align-items: center; gap: 7px; font: 400 18px/1.35 var(--font-display); color: var(--butter); }
.ai-text .ai-h:first-child { margin-top: 4px; font-size: 20px; }
.ai-text .ai-h .ic { width: 16px; height: 16px; flex: none; }
.ai-text .ai-label { font-weight: 800; color: var(--sakura); }
.ai-text .ai-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.ai-text .ai-list li { position: relative; padding-left: 1.2em; color: var(--text-soft); font-size: 14.5px; line-height: 1.7; overflow-wrap: anywhere; }
.ai-text .ai-list li::before { content: "・"; position: absolute; left: 0; color: var(--butter); }
.ai-text .ai-sign { text-align: right; font-family: var(--font-display); color: var(--sakura); }
/* a little sparkle "types" at the end of the text while it streams in */
.ai-text.writing > :last-child::after {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 6px;
  vertical-align: -0.05em;
  background: var(--butter);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  animation: twinkle 0.9s ease-in-out infinite;
}
@keyframes twinkle { 0%, 100% { opacity: 0.35; transform: scale(0.7) rotate(0deg); } 50% { opacity: 1; transform: scale(1.1) rotate(45deg); } }

/* details */
.section-title {
  margin: 40px 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 400 23px/1.2 var(--font-display);
  color: var(--cream);
}
.section-title .ic { color: var(--butter); }
.detail-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.detail {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
}
.detail.pending { opacity: 0.7; }
.detail-thumb {
  display: block;
  width: 92px;
  aspect-ratio: 7 / 12;
  padding: 0;
  border: 0;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: none;
  box-shadow: 0 6px 16px rgba(8, 6, 28, 0.5);
}
button.detail-thumb { cursor: zoom-in; transition: transform 0.2s ease; }
button.detail-thumb:hover { transform: translateY(-2px) rotate(-1.5deg); }
.detail-thumb img { display: block; width: 100%; height: 100%; }
.detail.rev .detail-thumb img { transform: rotate(180deg); }
.detail-pos { margin: 0; display: flex; align-items: center; gap: 6px; font: 400 15px/1.3 var(--font-display); color: var(--taro); }
.detail-hint { margin: 3px 0 0; font-size: 13.5px; color: var(--text-dim); }
.detail-name { margin: 8px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font: 400 21px/1.25 var(--font-display); color: var(--cream); }
.kw { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.kw li { padding: 3px 10px; border-radius: 999px; background: rgba(168, 215, 244, 0.12); border: 1px solid rgba(168, 215, 244, 0.3); color: var(--baby-blue); font-size: 13px; line-height: 1.4; }
.meaning { margin: 10px 0 0; color: var(--text-soft); font-size: 15.5px; line-height: 1.75; }
.pending-text { margin: 10px 0 0; color: var(--text-dim); font-size: 14px; }

/* overall energy */
.energy { margin-top: 26px; padding: 4px 22px 22px; }
.energy .section-title { margin: 18px 0 14px; }
.energy-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.energy-item { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; align-items: start; }
.energy-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 230, 160, 0.14); color: var(--butter); }
.energy-icon .ic { width: 22px; height: 22px; }
.energy-item:nth-child(2) .energy-icon { background: rgba(168, 215, 244, 0.14); color: var(--baby-blue); }
.energy-item:nth-child(3) .energy-icon { background: rgba(255, 157, 176, 0.14); color: var(--blush); }
.energy-item b { display: block; font: 400 17px/1.35 var(--font-display); color: var(--butter); }
.energy-item p { margin: 3px 0 0; color: var(--text-soft); line-height: 1.65; }
.balance { margin-top: 8px; display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: rgba(255, 157, 176, 0.55); }
.balance i { display: block; height: 100%; background: var(--mint); }

.reading-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 30px; }

/* ---------- zoom modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.modal-backdrop { position: absolute; inset: 0; background: rgba(14, 11, 34, 0.74); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fadeIn 0.3s ease both; }
.modal-panel {
  position: relative;
  width: min(860px, 100%);
  max-height: 100%;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 28px;
  padding: 28px;
  border-radius: 28px;
  background: linear-gradient(160deg, #2E2862, #1F1B42 70%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: zoomIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
.modal-art img { display: block; width: 100%; border-radius: var(--card-radius); box-shadow: 0 14px 34px rgba(8, 6, 28, 0.6); }
.modal-art.rev img { transform: rotate(180deg); }
.modal-text { padding-top: 6px; }
.modal-text h2 { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font: 400 28px/1.2 var(--font-display); }
.modal-text .detail-hint { margin-top: 4px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--cocoa);
  font: 400 15px/1.35 var(--font-display);
  text-align: center;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  animation: toastIn 0.35s ease both;
}

/* ---------- phones & small tablets ---------- */
@media (max-width: 759px) {
  .spread { --cw: auto; margin-top: 10px; }
  .spread-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 480px; }
  .spread-celtic { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px 6px; }
  .cc-cross, .cc-staff { display: contents; }
  .spread .slot { width: auto; min-width: 0; }
  .slot-label { margin-top: 6px; gap: 2px; }
  .spread-three .pos { font-size: 13px; }
  .spread-three .cname { font-size: 14px; }
  .spread-celtic .slot-label { margin-top: 4px; }
  .spread-celtic .pos { flex-direction: column; gap: 1px; font-size: 10.5px; line-height: 1.15; }
  .spread-celtic .num { min-width: 16px; height: 16px; font-size: 10px; }
  .spread-celtic .cname { font-size: 11px; line-height: 1.2; }
  .spread-celtic .badge { font-size: 10px; padding: 0 6px; }
  .reveal-row { margin-top: 16px; }
  .detail { grid-template-columns: 66px minmax(0, 1fr); gap: 14px; padding: 14px; }
  .ai-panel { padding: 2px 16px 18px; }
  .ai-text p { font-size: 15px; }
  .detail-thumb { width: 66px; }
  .detail-name { font-size: 19px; }
  .modal-panel { grid-template-columns: 1fr; gap: 18px; padding: 22px 18px; }
  .modal-art { width: min(62%, 240px); margin: 0 auto; }
  .modal-text h2 { font-size: 24px; }
}
@media (max-width: 560px) {
  .choices { grid-template-columns: 1fr; gap: 10px; }
  .choice { padding: 13px 14px; }
  .home-panel { padding: 22px 18px 18px; }
  .subtitle { font-size: 14.5px; }
  .reading { padding-top: calc(58px + env(safe-area-inset-top, 0px)); }
  .reading-meta { font-size: 14px; }
  .reading-q { margin-top: 6px; padding: 5px 12px; font-size: 13.5px; line-height: 1.38; border-radius: 14px; }
  .pick-pill { font-size: 14px; padding: 8px 8px 8px 14px; }
  .tray { padding: 10px 8px 8px; gap: 6px; border-radius: 20px; }
  .tray[data-n="10"] { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 8px; }
  .tray[data-n="10"] .tray-card { max-width: 38px; }
  .tray[data-n="10"] .tray-label { font-size: 10.5px; }
  .pill-btn.small { padding: 0 12px 0 8px; }
}
@media (max-width: 370px) {
  .lang button { min-width: 34px; padding: 0 7px; }
}

/* ---------- motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.92) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-5px) rotate(6deg); } }
@keyframes pop { 0% { opacity: 0; transform: scale(0.3) rotate(-14deg); } 100% { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(255, 230, 160, 0.12), 0 0 12px rgba(255, 230, 160, 0.25); } 50% { box-shadow: 0 0 0 4px rgba(255, 230, 160, 0.22), 0 0 24px rgba(255, 230, 160, 0.5); } }
@keyframes glowAll { 0%, 100% { box-shadow: 0 0 10px rgba(198, 176, 232, 0.4); } 50% { box-shadow: 0 0 24px rgba(255, 230, 160, 0.85), 0 0 40px rgba(255, 157, 176, 0.45); } }
@keyframes dealIn { from { opacity: 0; transform: translateY(26px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes holo { 0% { opacity: 0; background-position: 110% 0; } 25% { opacity: 0.9; } 100% { opacity: 0; background-position: -10% 0; } }
@keyframes sparkOut { 0% { opacity: 1; transform: translate(0, 0) scale(0.2); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1) rotate(90deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 0.2s !important; scroll-behavior: auto !important; }
  .screen.leaving, .pill-btn:hover, .choice:hover, .card3d:not(.flipped):hover .card-inner { transform: none !important; }
  /* flip becomes a simple cross-fade */
  .card-inner, .card3d.flipped .card-inner { transform: none !important; }
  .face { transition: opacity 0.3s ease; }
  .face.front { transform: none; opacity: 0; }
  .card3d.flipped .face.front { opacity: 1; }
  .card3d.flipped .face.back { opacity: 0; }
}
