:root {
  --bg: #120d24;
  --bg2: #241a45;
  --ink: #f6f2fc;        /* 重要な文字 */
  --text: #ddd4ef;       /* 本文 */
  --muted: #a99dc8;      /* 補足 */
  --gold: #f0cf86;
  --gold-dim: #a88b4f;
  --rose: #ff9cc2;
  --panel: rgba(255, 255, 255, 0.07);
  --line: rgba(227, 194, 122, 0.3);
  --marker: rgba(255, 156, 194, 0.35);
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(ellipse at top, var(--bg2), var(--bg) 70%) fixed;
  color: var(--text);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 500;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}
.sky {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff8, transparent),
    radial-gradient(1px 1px at 72% 12%, #fff9, transparent),
    radial-gradient(1.5px 1.5px at 40% 34%, #fff7, transparent),
    radial-gradient(1px 1px at 88% 46%, #fff8, transparent),
    radial-gradient(1px 1px at 22% 66%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 60% 78%, #fff7, transparent),
    radial-gradient(1px 1px at 8% 90%, #fff6, transparent),
    radial-gradient(1px 1px at 94% 84%, #fff8, transparent);
}

main { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 40px 16px 24px; }
.screen { display: none; text-align: center; animation: fade 0.5s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

b, strong { color: var(--ink); font-weight: 700; }
mark { background: linear-gradient(transparent 58%, var(--marker) 58%); color: var(--ink); font-weight: 700; }

.eyebrow { color: var(--gold); letter-spacing: 0.3em; font-size: 12px; margin: 0 0 4px; }
h1 { font-family: var(--serif); font-size: 42px; margin: 0 0 14px; letter-spacing: 0.08em; color: var(--gold); text-shadow: 0 0 24px rgba(240, 207, 134, 0.4); }
h2 { font-family: var(--serif); font-size: 24px; margin: 0 0 8px; color: var(--ink); }
.lead { color: var(--text); margin: 0 0 18px; font-size: 16px; }
.lead.small { font-size: 14px; margin-bottom: 12px; color: var(--muted); }
.features { list-style: none; padding: 0; margin: 0 0 26px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.features li { font-size: 12px; font-weight: 700; color: var(--gold); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; }
.q { margin: 0 0 12px; font-weight: 700; color: var(--ink); }

.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cat {
  font: inherit; font-weight: 700; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 8px; font-size: 17px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform 0.15s, background 0.15s;
}
.cat:hover, .cat:focus-visible { background: rgba(240, 207, 134, 0.14); transform: translateY(-2px); }
.cat-icon { color: var(--gold); font-size: 22px; }

/* 選んだカードの枠 */
/* 画面上部に固定して、下のカードを選んでいる間もめくれる様子が見えるようにする */
.tray-wrap {
  position: sticky; top: 0; z-index: 5; margin: 8px -16px 12px; padding: 10px 16px 12px;
  background: rgba(18, 13, 36, 0.88); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tray-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.tray-label { font-size: 12px; font-weight: 700; line-height: 1.4; color: var(--muted); }
.tray-slot.filled .tray-label { color: var(--gold); }
.tray-card { position: relative; width: 78px; aspect-ratio: 2 / 3.2; perspective: 600px; }
/* まだ選んでいない枠：点線と番号 */
.tray-card::before {
  content: attr(data-n); position: absolute; inset: 0; display: grid; place-items: center;
  border: 1.5px dashed var(--gold-dim); border-radius: 8px; color: var(--gold-dim); font-size: 18px;
}
.tray-slot.filled .tray-card::before { content: none; }
.flip-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.3, 0.7, 0.3, 1); visibility: hidden; }
.tray-slot.filled .flip-inner { visibility: visible; }
/* 弾む動きは外側に。flip-inner に transform のアニメーションを重ねると、めくりの transition が飛ばされる */
.tray-slot.filled .tray-card { animation: pop 0.35s; }
.tray-slot.flipped .flip-inner { transform: rotateY(180deg); }
.flip-back, .flip-front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-front { transform: rotateY(180deg); }
.tray-slot.flipped .flip-front .face { box-shadow: 0 0 18px rgba(255, 156, 194, 0.55); }
.tray-name { margin: 2px 0 0; font-size: 11px; line-height: 1.45; color: var(--muted); min-height: 3em; }
.tray-name b { display: block; font-size: 12px; color: var(--ink); animation: fade 0.5s; }
.tray-name .tag { margin-left: 4px; font-size: 10px; padding: 0 6px; }
.reveal { width: 100%; margin-top: 10px; animation: fade 0.4s, glow 1.6s 0.4s ease-in-out infinite; }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes glow { 50% { box-shadow: 0 0 22px rgba(240, 207, 134, 0.7); } }

/* カード裏面 */
.deck { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding-top: 12px; }
.back, .flip-back {
  aspect-ratio: 2 / 3.2; border-radius: 8px; border: none;
  background: url(img/back.svg) center / cover;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}
.back {
  position: relative; width: 100%; padding: 0; cursor: pointer;
  /* backwards: 配り終えた後は選択時の transform を効かせるため、終了状態を保持しない */
  animation: deal 0.4s backwards; animation-delay: var(--d);
  transition: transform 0.25s, box-shadow 0.25s, opacity 0.3s, filter 0.3s;
}
.back:hover { transform: translateY(-4px); }
.back.chosen {
  transform: translateY(-10px) scale(1.06); z-index: 1;
  box-shadow: 0 0 0 2px #fbe9b7, 0 0 22px rgba(242, 167, 198, 0.9);
}
.back.chosen::after {
  content: attr(data-order);
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--rose); color: #fff; font-size: 13px; font-weight: 700; line-height: 24px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.deck.done .back:not(.chosen) { opacity: 0.25; filter: grayscale(0.6); }
@keyframes deal { from { opacity: 0; transform: translateY(-20px) rotate(-6deg); } to { opacity: 1; transform: none; } }

/* ===== 結果 ===== */
#resultBody { text-align: left; }

/* ヒーロー：タイプ名と点数（いちばん大事） */
.hero { text-align: center; padding: 8px 0 24px; }
.hero-cat { display: inline-block; margin: 0 0 14px; font-size: 12px; font-weight: 700; color: var(--gold); border: 1px solid var(--line); border-radius: 999px; padding: 2px 14px; }
.hero-pre { margin: 0; font-size: 15px; color: var(--muted); }
.type-name {
  font-family: var(--serif); font-size: clamp(25px, 7vw, 32px); line-height: 1.4; margin: 4px 0 10px;
  background: linear-gradient(90deg, #ffd9e8, #f0cf86, #ffd9e8); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.type-catch { margin: 0 auto 14px; font-size: 16px; font-weight: 700; color: var(--ink); max-width: 22em; }
.rare-badge { display: inline-block; margin: 0 0 12px; font-size: 12px; font-weight: 900; color: #2a1b4d; background: linear-gradient(90deg, #ffd9e8, #f0cf86); border-radius: 999px; padding: 2px 14px; }
.score { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 4px; }
.score-label { font-size: 15px; font-weight: 700; color: var(--text); }
.score-num { font-family: "Cinzel", serif; font-size: 64px; line-height: 1; color: var(--gold); text-shadow: 0 0 24px rgba(240, 207, 134, 0.45); }
.score-unit { font-size: 18px; font-weight: 700; color: var(--gold); }
.stars { font-size: 22px; color: var(--gold); margin: 2px 0 8px; letter-spacing: 0.12em; }
.rarity { margin: 0; font-size: 14px; color: var(--muted); }
.rarity b { color: var(--rose); font-size: 16px; }

/* 共通の箱 */
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 16px; margin-bottom: 16px; }
.box h3, .section-title { font-family: var(--serif); font-size: 19px; color: var(--ink); margin: 0 0 12px; line-height: 1.5; }
.section-title { margin: 28px 0 0; text-align: center; }
.body { margin: 0; font-size: 15px; color: var(--text); line-height: 1.95; }
.body + .body { margin-top: 10px; }
.body strong { color: var(--ink); font-weight: 700; background: linear-gradient(transparent 62%, var(--marker) 62%); }
.intro { margin: 10px 0 0; font-size: 15px; line-height: 1.95; color: var(--text); }

/* メーター */
.meter + .meter { margin-top: 12px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 700; color: var(--ink); }
.meter-head b { font-family: "Cinzel", serif; font-size: 20px; color: var(--gold); }
.meter-head small { font-size: 12px; margin-left: 1px; }
.bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; width: var(--w); border-radius: 999px; background: linear-gradient(90deg, #ff9cc2, #f0cf86); animation: grow 1.2s 0.3s both; }
@keyframes grow { from { width: 0; } }

/* ズバリ！ */
.answer { border-color: var(--gold); background: rgba(240, 207, 134, 0.08); }
.qa + .qa { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.q-label { margin: 0; font-size: 13px; font-weight: 900; color: var(--gold); }
.a-text { margin: 2px 0 0; font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.7; }
.qa.ng .q-label { color: var(--rose); }

/* これからの流れ */
.tl { position: relative; padding-left: 18px; }
.tl + .tl { margin-top: 10px; }
.tl::before { content: ""; position: absolute; left: 3px; top: 8px; bottom: -14px; width: 2px; background: var(--line); }
.tl:last-child::before { bottom: auto; height: 0; }
.tl::after { content: ""; position: absolute; left: 0; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--rose); }
.tl-when { margin: 0; font-size: 13px; font-weight: 900; color: var(--gold); }
.deep { border-color: var(--rose); }

/* 有料版の需要測定枠（決済はなく、興味がある人の割合を測る）。サイトの一部として金色で見せる */
.paid { border: 1.5px solid var(--gold); background: linear-gradient(160deg, rgba(240, 207, 134, 0.12), rgba(255, 156, 194, 0.08)); text-align: center; }
.paid-label { display: inline-block; margin: 0 0 8px; font-size: 12px; font-weight: 900; color: #2a1b4d; background: linear-gradient(90deg, #ffd9e8, #f0cf86); border-radius: 999px; padding: 2px 14px; }
.paid .body { text-align: left; }
.paid .paid-btn { width: 100%; margin-top: 14px; background: var(--gold); color: #20163d; }
.paid-thanks { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); font-size: 14px; color: var(--ink); text-align: left; }

/* アフィリエイト枠（広告）。占い結果より目立たないよう、色を抑えて需要測定枠と区別する */
.pr-box { background: rgba(255, 255, 255, 0.04); border: 1px dashed rgba(185, 173, 214, 0.45); }
.pr-label { margin: 0 0 8px; font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pr-label span { font-weight: 900; border: 1px solid var(--muted); border-radius: 4px; padding: 0 5px; font-size: 10px; letter-spacing: 0.05em; }
.pr-box h3 { font-size: 16px; }
.pr-box .body { font-size: 14px; color: var(--muted); }
.pr-box .pr-btn { display: block; width: 100%; margin-top: 14px; text-align: center; text-decoration: none; font-size: 15px; border-color: var(--muted); color: var(--text); }
.pr-note { margin: 6px 0 0; font-size: 11px; color: var(--muted); text-align: center; }

/* 結果上部のシェア（タイプ名の直後がいちばんシェアされやすい） */
.hero-share { margin: 16px auto 0; padding: 10px 28px; font-size: 15px; }

/* トップ：前回の結果 */
.last-result { margin: 0 0 18px; padding: 8px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--text); }
.last-result b { color: var(--gold); }

/* カード */
.spread { display: flex; flex-direction: column; gap: 16px; margin: 14px 0 10px; }
.slot {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 16px;
  animation: fade 0.5s both; animation-delay: var(--d);
}
.pos { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--gold); display: flex; align-items: center; gap: 8px; }
.pos span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--rose); color: #fff; font-size: 12px; }
.slot-main { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center; margin-bottom: 12px; }
.cardname { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.tag { margin-left: 6px; font-size: 11px; font-weight: 700; color: #2a1b4d; background: var(--rose); border-radius: 999px; padding: 1px 8px; vertical-align: 1px; }
.catch { margin: 0; font-size: 20px; line-height: 1.5; font-weight: 900; color: var(--ink); }
.advice { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 156, 194, 0.1); font-size: 15px; color: var(--ink); }
.advice span { display: block; font-size: 12px; font-weight: 900; color: var(--rose); }
.note { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.note b { color: var(--rose); }

.slot-card { aspect-ratio: 2 / 3.2; }

.face { height: 100%; border-radius: 8px; overflow: hidden; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35); }
.face svg { display: block; width: 100%; height: 100%; }
/* 原画を金の二重枠にはめ込む */
.face.rws {
  padding: 6px; background: linear-gradient(#fffaf0, #f6e9cf);
  box-shadow: inset 0 0 0 1.5px #e0b55c, inset 0 0 0 3.5px #fffaf0, inset 0 0 0 4.2px #e0b55c, 0 3px 12px rgba(0, 0, 0, 0.35);
}
.face.rws .art { width: 100%; height: 100%; overflow: hidden; border-radius: 3px; background: #f4ecd8; }
.face.rws img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.03); /* スキャンの白い余白を切り落とす（番号と札名は残す） */
  filter: saturate(0.9) brightness(1.04);
}
.face.rev { transform: rotate(180deg); }

.rare-box { border-color: var(--rose); background: rgba(255, 156, 194, 0.1); text-align: center; }
.rare-label { margin: 0 0 4px; font-size: 13px; font-weight: 900; color: var(--rose); }
.aruaru { margin: 0; padding: 0; list-style: none; }
.aruaru li { position: relative; padding-left: 1.6em; font-size: 15px; font-weight: 700; color: var(--ink); }
.aruaru li + li { margin-top: 6px; }
.aruaru li::before { content: "✓"; position: absolute; left: 0; color: var(--rose); font-weight: 900; }
.match { text-align: center; }
.match-name { margin: 0 0 6px; font-family: var(--serif); font-size: 20px; color: var(--gold); }
.lucky-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.lucky-grid div, .lucky-action { background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 8px 12px; }
.lucky-grid span, .lucky-action span { display: block; font-size: 12px; color: var(--muted); }
.lucky-grid b { font-size: 16px; }
.lucky-action { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.btn {
  font: inherit; font-weight: 700; font-size: 16px; padding: 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--gold); background: transparent; color: var(--gold);
}
.btn.primary { background: var(--gold); color: #20163d; font-weight: 700; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn:hover { filter: brightness(1.1); }

footer { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition: none !important; }
  /* カードをめくる動きは小さく、本人の操作で起きるので、この設定でも残す（少し短めに） */
  .tray-slot .flip-inner { transition: transform 0.6s ease-out !important; }
}
