:root {
  --bg: #070412;
  --ink: #f4e7c5;
  --muted: #b7a88a;
  --gold: #d4af37;
  --gold-dim: rgba(212, 175, 55, 0.35);
  --violet: #7c4dc4;
  --panel: rgba(16, 8, 36, 0.78);
  --line: rgba(212, 175, 55, 0.28);
  --danger: #c47c7c;
  --ok: #8fbf88;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --serif: "Songti SC", "Noto Serif SC", "STSong", "Source Han Serif SC", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}
button, input, textarea, select { font-family: inherit; }
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 4, 18, 0.55);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.rings {
  width: 42px;
  height: 42px;
  position: relative;
}
.rings span {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 8s linear infinite;
}
.rings span:nth-child(2) {
  inset: 6px;
  animation-duration: 12s;
  animation-direction: reverse;
  border-color: rgba(212, 175, 55, 0.55);
  border-bottom-color: transparent;
}
.rings span:nth-child(3) {
  inset: 12px;
  animation-duration: 5s;
  border-color: rgba(232, 214, 168, 0.8);
  border-left-color: transparent;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.18em;
}
.brand small {
  display: block;
  color: var(--muted);
  letter-spacing: 0.28em;
  font-size: 10px;
  margin-top: 2px;
}
.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a {
  text-decoration: none;
  display: inline-block;
}
.nav button, .nav a, .ghost, .gold, .textbtn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.08em;
}
.nav button.active, .gold, .nav a.gold {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.15) inset;
}
.ghost:hover, .nav button:hover, .nav a:hover, .gold:hover { background: rgba(212, 175, 55, 0.08); }
.textbtn {
  border: none;
  padding: 4px 8px;
  color: var(--muted);
}
.mode-pill {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
}
main { padding: 22px 22px 80px; max-width: 1180px; margin: 0 auto; width: 100%; }
.view { display: none; }
.view.on { display: block; }
.hero {
  text-align: center;
  padding: 18px 0 28px;
}
.hero h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: 0.22em;
  margin: 0 0 10px;
}
.hero p { color: var(--muted); margin: 0 auto; max-width: 36em; line-height: 1.7; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.spread-card { cursor: pointer; transition: transform 0.2s ease, border-color 0.2s ease; }
.spread-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.spread-card h3 { margin: 0 0 6px; font-family: var(--serif); letter-spacing: 0.12em; }
.kicker { color: var(--gold); font-size: 12px; letter-spacing: 0.16em; }
.muted { color: var(--muted); line-height: 1.65; }
label { display: block; margin: 12px 0 6px; color: var(--gold); font-size: 13px; letter-spacing: 0.08em; }
input, textarea, select {
  width: 100%;
  background: rgba(7, 4, 18, 0.65);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 84px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.themes { display: flex; flex-wrap: wrap; gap: 8px; }
.themes button { opacity: 0.75; }
.themes button.active { opacity: 1; }
.draw-stage { min-height: 340px; position: relative; }
.deck-pile {
  width: 92px;
  height: 150px;
  margin: 28px auto 16px;
  position: relative;
  cursor: pointer;
}
.deck-pile .back {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}
.deck-pile.shuffling { animation: shake 0.45s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-8px) rotate(-3deg); }
  75% { transform: translateX(8px) rotate(3deg); }
}
.fan {
  position: relative;
  height: 260px;
  margin: 10px auto 0;
  max-width: 980px;
}
.fan .mini {
  position: absolute;
  left: 50%;
  top: 28px;
  width: 64px;
  height: 104px;
  transform-origin: 32px 130px;
  cursor: pointer;
  transition: transform 0.25s ease, filter 0.25s ease;
}
.fan .mini:hover { filter: brightness(1.15); }
.fan .mini.gone { opacity: 0.2; pointer-events: none; }
.tarot {
  width: 104px;
  height: 170px;
  perspective: 900px;
}
.tarot .inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(.2,.7,.2,1);
}
.tarot.flipped .inner { transform: rotateY(180deg); }
.tarot.reversed.flipped .inner { transform: rotateY(180deg) rotateZ(180deg); }
.tarot .face, .tarot .backface {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
}
.tarot .face { transform: rotateY(180deg); }
.tarot svg, .tarot img, .fan .mini svg, .deck-pile svg, .mini-card svg, .mini-card img, .lib-item .art svg, .lib-item .art img {
  width: 100%;
  height: 100%;
  display: block;
}
.rws-face {
  width: 100%;
  aspect-ratio: 2 / 3;
  height: auto;
  border-radius: 10px;
  overflow: hidden;
  background: #1a0d36;
  border: 1px solid rgba(212, 175, 55, 0.45);
  box-sizing: border-box;
}
.rws-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tarot .rws-face,
.mini-card .rws-face,
.lib-item .art .rws-face {
  height: 100%;
  aspect-ratio: auto;
}
.mini-card .rws-face { height: 144px; }
.lib-item .art { height: 168px; }
.chosen {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.slot {
  text-align: center;
  width: 104px;
}
.slot .name { font-size: 12px; color: var(--gold); margin-top: 8px; letter-spacing: 0.08em; }
.reading-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.verdict {
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 6px 12px;
  border-radius: 999px;
  letter-spacing: 0.2em;
}
.verdict.block { border-color: var(--danger); color: var(--danger); }
.verdict.care { border-color: #c4a36a; color: #c4a36a; }
.section { margin-top: 22px; }
.section h3 { font-family: var(--serif); letter-spacing: 0.14em; font-weight: 400; }
.pos {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.pos .mini-card { width: 88px; }
.actions li { margin: 8px 0; line-height: 1.7; }
.library-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.lib-item { cursor: pointer; text-align: center; }
.lib-item .art { width: 100%; max-width: 110px; margin: 0 auto; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 2, 12, 0.72);
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.on { display: flex; }
.modal .box {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #120826;
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 20px;
}
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a0d36;
  border: 1px solid var(--gold);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 30;
  display: none;
}
.toast.on { display: block; }
.progress { color: var(--gold); text-align: center; letter-spacing: 0.12em; }
.ai-box {
  white-space: pre-wrap;
  line-height: 1.75;
  min-height: 2em;
}
footer.note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0 24px;
}
.home-block { margin-bottom: 28px; }
.home-block h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: 0.16em;
  margin: 0 0 12px;
}
.oracle-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 120px;
  margin: 8px 0 18px;
}
.oracle-bowl {
  width: 220px;
  height: 220px;
  margin: 10px auto 18px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: radial-gradient(circle at 40% 30%, rgba(124,77,196,0.25), rgba(7,4,18,0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.oracle-bowl.casting { animation: shake 0.55s ease; }
.oracle-bowl .hint { color: var(--gold); letter-spacing: 0.18em; font-size: 13px; }
.oracle-rounds {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 18px;
}
.oracle-round {
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 14px;
  padding: 8px 8px 2px;
  background: rgba(16, 8, 36, 0.35);
}
.round-lab {
  text-align: center;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--gold);
}
.pebbles { gap: 16px; }
.pebble {
  width: 72px;
  height: 56px;
  border-radius: 50% 46% 50% 48%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f4e7c5;
  font-size: 13px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
  border: 1px solid rgba(244,231,197,0.35);
}
.lot-slip {
  width: 210px;
  min-height: 300px;
  background: linear-gradient(180deg, #f7ead0, #e8d3a0);
  color: #1a0d36;
  border: 1px solid #d4af37;
  border-radius: 6px 6px 18px 18px;
  padding: 22px 18px 28px;
  text-align: center;
  box-shadow: 0 16px 32px rgba(0,0,0,0.35);
  font-family: serif;
}
.lot-rank {
  letter-spacing: 0.4em;
  font-size: 13px;
  color: #7a5b12;
}
.lot-no {
  margin: 8px 0 14px;
  letter-spacing: 0.18em;
  font-size: 12px;
}
.lot-slip h4 {
  margin: 0 0 16px;
  font-size: 20px;
  letter-spacing: 0.16em;
  font-weight: 400;
}
.lot-verse {
  line-height: 1.9;
  font-size: 15px;
  margin: 0;
}
.oracle-only .tarot-only { display: none; }
.mgr-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.mgr-table-wrap { overflow-x: auto; }
.mgr-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.mgr-table th, .mgr-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
.mgr-table th { color: var(--muted); font-weight: 500; letter-spacing: 0.08em; }
.mgr-table input.mgr-limit { width: 88px; }
.mgr-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .pos { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .hero h2 { font-size: 22px; }
  .fan { height: 220px; }
  .fan .mini { width: 52px; height: 86px; transform-origin: 26px 110px; }
  .tarot { width: 88px; height: 144px; }
  .slot { width: 88px; }
}
