:root {
  --bg: #14112a;
  --bg-2: #1f1a3d;
  --panel: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.12);
  --text: #ece8ff;
  --muted: #a9a2cf;
  --gold: #e5c07b;
  --accent: #9b7cf6;
  --error: #ff8f8f;
  --card-w: 150px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, var(--bg-2), var(--bg) 70%);
  background-color: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.8;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 32px 16px 48px; }

/* ---- ヘッダー ---- */
.hero { text-align: center; margin-bottom: 28px; }
.hero-sub { color: var(--gold); letter-spacing: 0.2em; font-size: 0.8rem; margin: 0; }
.hero h1 { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 2.4rem; margin: 4px 0 12px; letter-spacing: 0.1em; }
.hero-lead { color: var(--muted); font-size: 0.92rem; margin: 0; }

/* ---- 入力フォーム ---- */
.ask { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.ask-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
textarea {
  width: 100%; resize: vertical; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--text);
  font: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ask-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 12px; }
.count { color: var(--muted); font-size: 0.8rem; }
button {
  border: 0; border-radius: 999px; padding: 12px 28px; font: inherit; font-weight: bold; cursor: pointer;
  background: linear-gradient(135deg, var(--gold), #c79a4a); color: #2a1f05;
}
button:disabled { opacity: 0.5; cursor: wait; }
.error { color: var(--error); margin: 12px 0 0; font-size: 0.9rem; }

/* ---- カード ---- */
.result { margin-top: 32px; }
.spread { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.slot { width: var(--card-w); text-align: center; }
.slot-label { color: var(--gold); font-size: 0.85rem; margin-bottom: 6px; letter-spacing: 0.1em; }

.card { width: var(--card-w); aspect-ratio: 2 / 3.3; perspective: 900px; }
.card-inner { position: relative; width: 100%; height: 100%; transition: transform 0.8s ease; transform-style: preserve-3d; }
.card.open .card-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: 12px; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px;
  border: 2px solid var(--gold);
}
.back {
  background:
    repeating-linear-gradient(45deg, rgba(229, 192, 123, 0.15) 0 6px, transparent 6px 12px),
    #2b2257;
}
.back::after { content: "✶"; color: var(--gold); font-size: 2rem; }
.front { background: linear-gradient(180deg, #fbf5e6, #efe2c3); color: #2d2447; transform: rotateY(180deg); }
.front .no { font-family: serif; font-size: 0.85rem; }
.front .symbol { font-size: 2.6rem; line-height: 1.3; margin: 8px 0; }
.front .name { font-weight: bold; font-size: 1rem; }
.front .en { font-size: 0.7rem; color: #6b5f8c; }
.card.reversed .front .art { transform: rotate(180deg); }
.orientation { font-size: 0.8rem; margin-top: 6px; color: var(--muted); }
.orientation.rev { color: #f3a6c0; }

.card-text { font-size: 0.85rem; text-align: left; margin-top: 8px; opacity: 0; transition: opacity 0.6s ease 0.4s; }
.slot.open .card-text { opacity: 1; }
.card-text .kw { color: var(--gold); font-weight: bold; }

/* ---- 総合メッセージ・分析 ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-top: 24px; }
.panel h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; margin: 0 0 8px; font-size: 1.3rem; color: var(--gold); }
.message p { margin: 0 0 10px; }
.lucky { margin: 12px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 0.9rem; }

.analysis summary { cursor: pointer; font-weight: bold; }
.analysis h3 { font-size: 0.9rem; margin: 18px 0 6px; color: var(--muted); font-weight: normal; }
.analysis code { background: rgba(0, 0, 0, 0.3); padding: 1px 6px; border-radius: 4px; font-size: 0.8rem; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 48px; align-items: center; gap: 8px; font-size: 0.8rem; margin: 3px 0; }
.bar { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar-row.top .bar > span { background: var(--gold); }
.note { font-size: 0.8rem; color: var(--muted); margin: 4px 0 0; }
.demo { color: #f3a6c0; }

.foot { text-align: center; color: var(--muted); font-size: 0.75rem; margin-top: 40px; }

@media (max-width: 520px) {
  :root { --card-w: 30vw; }
  .spread { gap: 8px; flex-wrap: nowrap; }
  .front .symbol { font-size: 1.8rem; }
  .front .name { font-size: 0.85rem; }
  .card-text { font-size: 0.78rem; }
  .hero h1 { font-size: 1.9rem; }
}
