:root {
  --bg-1: #04111f;
  --bg-2: #090720;
  --bg-3: #180f32;
  --soft-line: rgba(255, 255, 255, 0.08);
  --text: #eff5ff;
  --muted: #a3b8d9;
  --gold: #e8c879;
  --cyan: #88d5ff;
  --pink: #f08dc8;
  --glass: rgba(10, 15, 42, 0.56);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  --radius-xl: 30px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(136, 213, 255, 0.12), transparent 22%),
    radial-gradient(circle at 80% 0%, rgba(240, 141, 200, 0.15), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(232, 200, 121, 0.08), transparent 30%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
}

body { overflow-x: hidden; }
button, input { font: inherit; }

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.sky, .noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.sky-a {
  background-image:
    radial-gradient(2px 2px at 15% 25%, rgba(255, 255, 255, 0.72), transparent 50%),
    radial-gradient(1.5px 1.5px at 70% 20%, rgba(255, 255, 255, 0.55), transparent 55%),
    radial-gradient(2px 2px at 50% 55%, rgba(136, 213, 255, 0.8), transparent 60%),
    radial-gradient(2px 2px at 82% 66%, rgba(240, 141, 200, 0.75), transparent 58%),
    radial-gradient(1.5px 1.5px at 30% 80%, rgba(232, 200, 121, 0.72), transparent 56%);
  animation: driftA 18s linear infinite;
}

.sky-b {
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.85), transparent 82%);
  opacity: 0.18;
}

.noise {
  background: radial-gradient(circle at center, rgba(255,255,255,0.05), transparent 70%);
  mix-blend-mode: soft-light;
}

.phone-stage, .admin-shell {
  width: min(100%, 440px);
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.page {
  display: none;
  min-height: calc(100vh - 40px);
  animation: fadeIn 0.45s ease;
}

.page.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-badge, .result-tag {
  align-self: flex-start;
  padding: 8px 12px;
  border: 1px solid rgba(232, 200, 121, 0.42);
  border-radius: 999px;
  background: rgba(232, 200, 121, 0.08);
  letter-spacing: 0.16em;
  font-size: 12px;
}

.hero-orbit {
  position: relative;
  height: 240px;
  display: grid;
  place-items: center;
}

.orbit-ring, .hero-card { position: absolute; border-radius: 50%; }
.orbit-ring { border: 1px solid rgba(136, 213, 255, 0.24); box-shadow: inset 0 0 30px rgba(136, 213, 255, 0.06), 0 0 36px rgba(240, 141, 200, 0.08); }
.ring-a { width: 230px; height: 230px; animation: spin 12s linear infinite; }
.ring-b { width: 170px; height: 170px; animation: spinReverse 9s linear infinite; }

.hero-card {
  width: 130px;
  height: 190px;
  border-radius: 24px;
  background: radial-gradient(circle at 50% 32%, rgba(232, 200, 121, 0.8), transparent 16%), linear-gradient(140deg, rgba(10, 19, 48, 0.98), rgba(29, 18, 58, 0.98));
  border: 1px solid rgba(232, 200, 121, 0.36);
  box-shadow: var(--shadow), inset 0 0 40px rgba(136, 213, 255, 0.08);
}

.hero-card::before, .hero-card::after, .tarot-card::before, .tarot-card::after, .deck-layer::before, .deck-layer::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(232, 200, 121, 0.28);
  border-radius: inherit;
}

.hero-card::after, .deck-layer::after {
  inset: 24px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 50%, rgba(136, 213, 255, 0.2), transparent 34%), radial-gradient(circle at 50% 50%, rgba(240, 141, 200, 0.13), transparent 58%);
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 34px; line-height: 1.08; }

.hero-copy, .result-opening, .panel p, .control-text, .field-label, #revealText, .draw-progress, .camera-status {
  color: var(--muted);
  line-height: 1.6;
}

.glass, .panel {
  background: var(--glass);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel { padding: 18px; }

.text-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: 15px;
  border: 1px solid rgba(136, 213, 255, 0.22);
  background: rgba(7, 12, 31, 0.66);
  color: var(--text);
  margin-bottom: 14px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.chip {
  min-height: 62px;
  padding: 12px;
  text-align: left;
  border: 1px solid rgba(136, 213, 255, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.chip.active {
  border-color: rgba(232, 200, 121, 0.42);
  background: linear-gradient(160deg, rgba(232, 200, 121, 0.18), rgba(136, 213, 255, 0.06));
  box-shadow: 0 12px 24px rgba(232, 200, 121, 0.08);
}

.chip-label { display: block; font-size: 15px; margin-bottom: 4px; }
.chip-copy { display: block; font-size: 12px; color: var(--muted); }

.primary-btn, .ghost-btn, .control-card { border: none; cursor: pointer; }

.primary-btn {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  color: #120f08;
  font-weight: 700;
  background: linear-gradient(135deg, #f4df9d, #d9a85a);
  box-shadow: 0 10px 24px rgba(232, 200, 121, 0.24);
}

.ghost-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-title { font-size: 15px; letter-spacing: 0.08em; color: var(--gold); }

.ritual-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.glow-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold), rgba(232, 200, 121, 0.15));
  box-shadow: 0 0 18px rgba(232, 200, 121, 0.72);
}

.control-cards { display: grid; gap: 10px; }

.control-card {
  padding: 16px;
  text-align: left;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid rgba(136, 213, 255, 0.16);
  color: var(--text);
}

.control-card.active {
  border-color: rgba(232, 200, 121, 0.46);
  box-shadow: inset 0 0 0 1px rgba(232, 200, 121, 0.16), 0 16px 28px rgba(0, 0, 0, 0.22);
}

.control-title { display: block; margin-bottom: 6px; font-size: 17px; }

.camera-shell {
  margin-top: 16px;
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
}

#cameraPreview, #cameraOverlay {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.camera-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  font-size: 12px;
}

.ritual-steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.step-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  font-size: 12px;
  color: var(--muted);
}

.step-pill.active { color: var(--gold); background: rgba(232, 200, 121, 0.1); }

.deck-stage {
  position: relative;
  min-height: 360px;
  display: grid;
  place-items: center;
}

.deck-aura {
  position: absolute;
  width: 270px;
  height: 270px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(136, 213, 255, 0.22), rgba(240, 141, 200, 0.08), transparent 70%);
  filter: blur(8px);
  animation: pulse 2.4s ease-in-out infinite;
}

.deck-stack {
  position: relative;
  width: 182px;
  height: 272px;
  touch-action: none;
}

.deck-layer {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(10, 20, 49, 0.98), rgba(30, 15, 54, 0.98));
  border: 1px solid rgba(232, 200, 121, 0.28);
  box-shadow: 0 18px 28px rgba(0,0,0,0.28);
  transition: transform 0.4s ease;
}

.layer-2 { transform: translateY(8px) rotate(-4deg); opacity: 0.95; }
.layer-3 { transform: translateY(14px) rotate(4deg); opacity: 0.88; }
.layer-4 { transform: translateY(20px) rotate(-2deg); opacity: 0.78; }
.deck-stack.shuffling .layer-1 { animation: toss1 0.45s ease infinite alternate; }
.deck-stack.shuffling .layer-2 { animation: toss2 0.55s ease infinite alternate; }
.deck-stack.shuffling .layer-3 { animation: toss3 0.5s ease infinite alternate; }
.deck-stack.shuffling .layer-4 { animation: toss4 0.58s ease infinite alternate; }

.shake-meter {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(88%, 320px);
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.shake-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--pink));
  transition: width 0.18s ease;
}

.spread-board { display: grid; gap: 14px; }
.spread-board.single { grid-template-columns: 1fr; }
.spread-board.trinity { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.spread-board.cross { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.tarot-slot { display: grid; gap: 8px; }
.slot-label { font-size: 12px; letter-spacing: 0.08em; color: var(--gold); text-align: center; }

.tarot-card {
  position: relative;
  aspect-ratio: 0.67;
  border-radius: 22px;
  border: 1px solid rgba(232, 200, 121, 0.3);
  background: linear-gradient(145deg, rgba(9, 17, 47, 0.98), rgba(26, 14, 52, 0.98));
  overflow: hidden;
  box-shadow: 0 16px 28px rgba(0,0,0,0.28);
  transform-style: preserve-3d;
  transition: transform 0.7s ease, box-shadow 0.4s ease;
}

.tarot-card.flipped { transform: rotateY(180deg); box-shadow: 0 0 30px rgba(232, 200, 121, 0.24); }

.tarot-face {
  position: absolute;
  inset: 0;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backface-visibility: hidden;
}

.tarot-back {
  background: radial-gradient(circle at 50% 50%, rgba(232, 200, 121, 0.16), transparent 30%), linear-gradient(145deg, rgba(9, 17, 47, 0.98), rgba(26, 14, 52, 0.98));
}

.tarot-front {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 50% 20%, rgba(136, 213, 255, 0.18), transparent 24%), linear-gradient(180deg, rgba(248, 241, 220, 0.95), rgba(221, 210, 193, 0.95));
  color: #251d14;
}

.front-mini { font-size: 11px; letter-spacing: 0.08em; color: rgba(37, 29, 20, 0.68); }
.front-title { font-size: 20px; font-weight: 700; }
.front-en { font-size: 11px; opacity: 0.65; }
.front-symbol { text-align: center; font-size: 36px; letter-spacing: 0.18em; }

.card-keywords {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-keywords span {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(37, 29, 20, 0.08);
}

.hero-result {
  background: radial-gradient(circle at top, rgba(232, 200, 121, 0.16), transparent 40%), linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border: 1px solid rgba(232, 200, 121, 0.22);
}

.result-cards { display: grid; gap: 12px; }

.result-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.result-card h3 { margin-bottom: 6px; }
.result-meta { color: var(--gold); font-size: 13px; margin-bottom: 8px; }

.mantra {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(232, 200, 121, 0.08);
  color: var(--gold);
}

.admin-body { padding: 24px 14px; }
.records-grid { display: grid; gap: 12px; margin-top: 12px; }
.admin-card ul { padding-left: 18px; color: var(--muted); }
.admin-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.admin-actions { display: flex; gap: 10px; margin-top: 14px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes spinReverse { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }
@keyframes pulse { 0%, 100% { transform: scale(0.95); opacity: 0.8; } 50% { transform: scale(1.06); opacity: 1; } }
@keyframes toss1 { from { transform: translate(-10px, -6px) rotate(-8deg); } to { transform: translate(10px, 0) rotate(8deg); } }
@keyframes toss2 { from { transform: translate(12px, 8px) rotate(6deg); } to { transform: translate(-8px, 14px) rotate(-7deg); } }
@keyframes toss3 { from { transform: translate(-14px, 16px) rotate(-7deg); } to { transform: translate(10px, 8px) rotate(5deg); } }
@keyframes toss4 { from { transform: translate(10px, 24px) rotate(4deg); } to { transform: translate(-10px, 16px) rotate(-6deg); } }
@keyframes driftA { from { transform: translateY(0); } to { transform: translateY(-18px); } }

@media (max-width: 360px) {
  h1 { font-size: 28px; }
  .option-grid { grid-template-columns: 1fr; }
  .spread-board.trinity, .spread-board.cross { grid-template-columns: 1fr 1fr; }
}
