:root {
  --gold: #e8c87a;
  --gold-dim: rgba(212, 175, 55, 0.55);
  --ink: #0b0e1c;
  --panel: rgba(16, 19, 40, 0.72);
  --text: #e9e4f4;
  --muted: #9d95b8;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --font-ui: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, #2b2a63 0%, transparent 60%),
    radial-gradient(900px 600px at 12% 108%, #3a1f5f 0%, transparent 55%),
    linear-gradient(180deg, #080a16 0%, #0b0e1c 55%, #070812 100%);
  user-select: none;
  -webkit-user-select: none;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  box-shadow: inset 0 0 260px 70px rgba(0, 0, 0, 0.55);
}

#bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 42% at 50% -2%, rgba(130, 100, 255, 0.18), transparent 70%),
    radial-gradient(40% 30% at 12% 100%, rgba(232, 200, 122, 0.08), transparent 70%);
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0.6;
  animation: twinkle 3.6s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 0.85; transform: scale(1.1); }
}

.top {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  text-align: center;
  pointer-events: none;
}

.top h1 {
  font-size: clamp(22px, 3.4vw, 34px);
  font-family: var(--font-display);
  letter-spacing: 0.24em;
  font-weight: 600;
  background: linear-gradient(180deg, #fff4d2 0%, #e8c87a 48%, #b07f2c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(232, 200, 122, 0.32));
  background-size: 220% 220%;
  animation: titleShine 7s ease-in-out infinite;
}

@keyframes titleShine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.top h1 span {
  display: block;
  font-size: 0.42em;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.46em;
  color: #b7add3;
  -webkit-text-fill-color: #b7add3;
  opacity: 0.85;
  margin-top: 4px;
}

.intro-card h2,
.reading-panel h2,
.archive-head h2,
.settings-panel h2 {
  font-family: var(--font-display);
  letter-spacing: 0.16em;
}

.rc-name {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
}

.top .sub {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.35em;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 5;
}

#scene {
  position: absolute;
  inset: 0;
  perspective: 1500px;
  perspective-origin: 50% 40%;
}

#tilt {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: rotateX(11deg);
}

#wheel {
  position: absolute;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

.wheel-card {
  position: absolute;
  left: calc(var(--cw) / -2);
  top: calc(var(--ch) / -2);
  width: var(--cw);
  height: var(--ch);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 6%, rgba(232, 200, 122, 0.16), transparent 55%),
    conic-gradient(from 210deg at 50% 50%, rgba(232, 200, 122, 0.10), transparent 26%, rgba(120, 90, 220, 0.14) 56%, transparent 82%, rgba(232, 200, 122, 0.10)),
    linear-gradient(155deg, #1a2244 0%, #2a1d4f 52%, #130f28 100%);
  border: 1px solid var(--gold-dim);
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.025),
    inset 0 0 22px rgba(0, 0, 0, 0.65),
    0 8px 26px rgba(0, 0, 0, 0.55);
  will-change: transform, opacity;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.wheel-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 175, 55, 0.32);
  border-radius: 6px;
}

.wheel-card .moon {
  font-size: calc(var(--cw) * 0.46);
  line-height: 1;
  color: rgba(232, 205, 130, 0.92);
  text-shadow: 0 0 20px rgba(235, 195, 90, 0.55);
  transform: translateY(-6%);
}

.wheel-card::after {
  content: "";
  position: absolute;
  bottom: 9%;
  width: 5px;
  height: 5px;
  background: rgba(232, 200, 122, 0.55);
  transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(232, 200, 122, 0.5);
}

.wheel-card.active {
  border-color: #f4d47c;
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.05),
    inset 0 0 26px rgba(0, 0, 0, 0.55),
    0 0 34px rgba(244, 212, 124, 0.55);
}

/* 摄像头小窗 */
#camera {
  position: absolute;
  left: 20px;
  bottom: 160px;
  width: 248px;
  height: 186px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(232, 200, 122, 0.45);
  background: #05060d;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  z-index: 12;
}

#video,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.cam-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 8px;
  font-size: 11px;
  color: #c8c0de;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  text-align: center;
}

.gesture-readout {
  position: absolute;
  right: 8px;
  bottom: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #f4d47c;
  background: rgba(5, 6, 13, 0.72);
  border: 1px solid rgba(232, 200, 122, 0.35);
  pointer-events: none;
  z-index: 2;
}

/* 三牌阵 */
#spread {
  position: absolute;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  display: flex;
  gap: 22px;
  z-index: 11;
}

.slot {
  width: 112px;
  text-align: center;
}

.slot-label {
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--gold);
  opacity: 0.85;
  margin-bottom: 8px;
}

.slot-card {
  width: 112px;
  height: 176px;
  border-radius: 9px;
  border: 1px dashed rgba(232, 200, 122, 0.28);
  background: rgba(255, 255, 255, 0.025);
  position: relative;
  perspective: 900px;
}

.spread-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.25, 0.75, 0.2, 1);
}

.spread-card:hover {
  filter: brightness(1.07) drop-shadow(0 0 18px rgba(232, 200, 122, 0.22));
}

.spread-card.revealed {
  transform: rotateY(180deg);
}

.spread-face {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.spread-face.back {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(155deg, #1a2244 0%, #2a1d4f 52%, #130f28 100%);
  border: 1px solid var(--gold-dim);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.025), inset 0 0 18px rgba(0, 0, 0, 0.6);
}

.spread-face.back::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(212, 175, 55, 0.32);
  border-radius: 6px;
}

.spread-face.back .moon {
  font-size: 46px;
  color: rgba(232, 205, 130, 0.92);
  text-shadow: 0 0 18px rgba(235, 195, 90, 0.55);
}

.spread-face.front {
  transform: rotateY(180deg);
  padding: 0;
  overflow: hidden;
  background: #0b0e1c;
  border: 1px solid rgba(232, 200, 122, 0.55);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.03), 0 10px 26px rgba(0, 0, 0, 0.45);
}

.spread-face.front.reversed-card {
  transform: rotateY(180deg);
}

.card-art,
.card-art .card-svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 9px;
}

.card-art .card-svg {
  filter: saturate(1.06) contrast(1.02);
}

/* HUD 状态 */
#hud {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(12, 14, 30, 0.66);
  border: 1px solid rgba(232, 200, 122, 0.28);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}

#gestureIcon {
  font-size: 20px;
}

#statusText {
  font-size: 13px;
  color: #d9d2ef;
  letter-spacing: 0.04em;
}

.hold-ring {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: conic-gradient(#e8c87a 0deg, rgba(255, 255, 255, 0.06) 0deg);
  opacity: 0;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.hold-ring::after {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #0c0e1e;
}

/* 解读面板 */
#reading {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 6, 13, 0.78);
  backdrop-filter: blur(10px);
}

.reading-panel {
  width: min(760px, 94vw);
  max-height: 88vh;
  overflow: auto;
  padding: 26px 28px;
  border-radius: 18px;
  background: linear-gradient(170deg, #151936 0%, #0d1026 100%);
  border: 1px solid rgba(232, 200, 122, 0.4);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.reading-panel h2 {
  text-align: center;
  letter-spacing: 0.2em;
  color: var(--gold);
  font-size: 20px;
  margin-bottom: 18px;
}

.reading-question {
  margin: -8px 0 16px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.06em;
  color: #cfc7e6;
}

.reading-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.reading-card {
  padding: 14px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(232, 200, 122, 0.22);
}

.rc-pos {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--gold);
  opacity: 0.9;
}

.rc-art {
  width: 84px;
  margin: 8px auto;
  aspect-ratio: 240 / 384;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.rc-art .card-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.rc-name {
  font-size: 16px;
  font-weight: 700;
  margin: 6px 0 2px;
}

.rc-en {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rc-ori {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10px;
  border-radius: 999px;
  background: rgba(232, 200, 122, 0.16);
  color: var(--gold);
}

.rc-ori.reversed {
  background: rgba(180, 120, 90, 0.22);
  color: #e0a184;
}

.reading-card p {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.65;
  color: #c9c2e2;
}

.reading-sum {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.8;
  color: #e6e0f5;
  background: rgba(232, 200, 122, 0.08);
  border-left: 3px solid var(--gold);
}

.spread-insight {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(120, 90, 220, 0.10), rgba(232, 200, 122, 0.05));
  border: 1px solid rgba(232, 200, 122, 0.18);
}

.si-head {
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--gold);
  opacity: 0.85;
}

.si-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.si-chips span {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  color: #efe3c4;
  background: rgba(232, 200, 122, 0.12);
  border: 1px solid rgba(232, 200, 122, 0.25);
}

.spread-insight p {
  font-size: 12.5px;
  line-height: 1.7;
  color: #cdc6e6;
}

.reading-disclaimer {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.8;
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.thinking i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.3;
  animation: think 1.1s infinite ease-in-out;
}

.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }

@keyframes think {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

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

.reading-ai-cta {
  margin-top: 16px;
  text-align: center;
}

.reading-ai-cta button {
  min-width: 220px;
}

/* 按钮 */
button {
  cursor: pointer;
  border: 1px solid rgba(232, 200, 122, 0.5);
  background: rgba(20, 23, 48, 0.8);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 0.04em;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  background: rgba(42, 36, 78, 0.9);
  box-shadow: 0 0 18px rgba(232, 200, 122, 0.25);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.primary {
  background: linear-gradient(160deg, #c9a24b, #e8c87a);
  color: #211a0c;
  border-color: #f0d998;
  font-weight: 700;
}

.intro-actions button {
  min-width: 128px;
}

/* 介绍弹层 */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(5, 6, 13, 0.72);
  backdrop-filter: blur(8px);
  transition: opacity 0.4s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.intro-card {
  width: min(430px, 92vw);
  max-height: 92vh;
  overflow: auto;
  padding: 30px 30px 22px;
  border-radius: 20px;
  background: linear-gradient(170deg, #171b3b 0%, #0c0f24 100%);
  border: 1px solid rgba(232, 200, 122, 0.45);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.intro-card h2 {
  font-size: 28px;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(232, 200, 122, 0.4);
}

.intro-flow {
  margin: 20px 0;
  font-size: 14px;
  line-height: 2.15;
  color: #d8d1ec;
}

.intro-question {
  width: 100%;
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid rgba(232, 200, 122, 0.4);
  background: #12152e;
  color: var(--text);
  font-size: 14px;
  text-align: center;
}

.intro-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 16px;
}

.deck-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.deck-pick select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(232, 200, 122, 0.4);
  background: #12152e;
  color: var(--text);
  font-size: 13px;
}

.note {
  margin-top: 14px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #8c85a8;
}

.note code {
  color: #e0c27c;
}

/* 底部控制条 */
.controls {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 35;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px 16px 0 0;
  background: rgba(10, 12, 26, 0.78);
  border: 1px solid rgba(232, 200, 122, 0.24);
  border-bottom: none;
  backdrop-filter: blur(8px);
}

.controls button {
  padding: 7px 12px;
  font-size: 12.5px;
}

.mode-tag {
  align-self: center;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 4px;
}

.hidden {
  display: none !important;
}

@media (max-width: 620px) {
  #spread {
    gap: 12px;
    bottom: 178px;
  }
  #hud {
    bottom: 108px;
  }
  .slot,
  .slot-card {
    width: 92px;
  }
  .slot-card {
    height: 146px;
  }
  #camera {
    width: 150px;
    height: 112px;
    bottom: 310px;
  }
  .controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  .reading-grid {
    grid-template-columns: 1fr;
  }
}

/* 顶部工具条 */
.topbar {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 36;
  display: flex;
  gap: 8px;
}

.topbar button {
  padding: 8px 13px;
  font-size: 13px;
  background: rgba(16, 19, 40, 0.72);
  backdrop-filter: blur(6px);
}

.topbar button.chip {
  border-radius: 999px;
}

.topbar button.chip.active {
  background: linear-gradient(160deg, #c9a24b, #e8c87a);
  color: #211a0c;
  border-color: #f0d998;
}

/* 牌库 */
.archive-panel {
  width: min(1120px, 96vw);
  height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(170deg, #151936 0%, #0d1026 100%);
  border: 1px solid rgba(232, 200, 122, 0.4);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.archive-head h2 {
  font-size: 20px;
  letter-spacing: 0.18em;
  color: var(--gold);
}

.archive-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.archive-tools input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(232, 200, 122, 0.4);
  background: #12152e;
  color: var(--text);
  font-size: 13px;
}

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

.filters button {
  padding: 6px 11px;
  font-size: 12px;
}

.filters button.on {
  background: rgba(232, 200, 122, 0.18);
  border-color: var(--gold);
  color: var(--gold);
}

.archive-grid {
  flex: 1;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding: 4px 4px 18px;
  align-content: start;
}

.arc-card {
  aspect-ratio: 5 / 8;
  perspective: 900px;
  cursor: pointer;
}

.arc-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.25, 0.75, 0.2, 1);
}

.arc-card.open .arc-inner {
  transform: rotateY(180deg);
}

.arc-face {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.arc-face.back {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(155deg, #1a2244 0%, #2a1d4f 52%, #130f28 100%);
  border: 1px solid var(--gold-dim);
}

.arc-face.back span {
  font-size: 38px;
  color: rgba(232, 205, 130, 0.92);
  text-shadow: 0 0 16px rgba(235, 195, 90, 0.55);
}

.arc-face.front {
  transform: rotateY(180deg);
  position: relative;
  padding: 0;
  overflow: hidden;
  background: #0b0e1c;
  border: 1px solid rgba(232, 200, 122, 0.5);
}

.arc-face.front .card-art {
  position: absolute;
  inset: 0;
}

.arc-meaning {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 48%;
  overflow: auto;
  padding: 14px 7px 7px;
  font-size: 8.6px;
  line-height: 1.45;
  color: #efe7d2;
  background: linear-gradient(transparent, rgba(6, 8, 20, 0.92) 32%);
  z-index: 2;
}

.arc-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 14px;
}

/* AI 设置 */
.settings-panel {
  width: min(430px, 92vw);
  padding: 24px 26px;
  border-radius: 18px;
  background: linear-gradient(170deg, #171b3b 0%, #0c0f24 100%);
  border: 1px solid rgba(232, 200, 122, 0.45);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.settings-panel h2 {
  font-size: 20px;
  letter-spacing: 0.16em;
  color: var(--gold);
  margin-bottom: 16px;
  text-align: center;
}

.settings-panel label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.settings-panel input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(232, 200, 122, 0.4);
  background: #12152e;
  color: var(--text);
  font-size: 13px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.ai-status {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow: auto;
}

.ai-status.ok {
  color: #9be0a8;
}

.ai-status.err {
  color: #e0a184;
}

/* 解读面板里的 AI 区块 */
.ai-section {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.ai-question {
  flex: 1;
  padding: 10px 13px;
  border-radius: 999px;
  border: 1px solid rgba(232, 200, 122, 0.4);
  background: #12152e;
  color: var(--text);
  font-size: 13px;
}

.ai-result {
  margin-top: 16px;
  padding: 15px 17px;
  border-radius: 12px;
  background: rgba(232, 200, 122, 0.07);
  border: 1px solid rgba(232, 200, 122, 0.24);
  font-size: 13.5px;
  line-height: 1.85;
  color: #e6e0f5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 46vh;
  overflow: auto;
}

.ai-result.loading {
  color: var(--gold);
}

/* AI 多轮对话 */
.chat {
  margin-top: 18px;
  border-top: 1px solid rgba(232, 200, 122, 0.18);
  padding-top: 14px;
}

.chat-log {
  max-height: 42vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
}

.chat-msg {
  display: flex;
}

.chat-msg.user {
  justify-content: flex-end;
}

.chat-msg .bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user .bubble {
  background: rgba(232, 200, 122, 0.16);
  color: #f3edff;
  border: 1px solid rgba(232, 200, 122, 0.28);
  white-space: pre-wrap;
}

.chat-msg.ai .bubble {
  background: rgba(255, 255, 255, 0.05);
  color: #e6e0f5;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-msg.ai .bubble.loading {
  color: var(--gold);
}

.chat-msg.ai .bubble h3,
.chat-msg.ai .bubble h4 {
  margin: 8px 0 4px;
  color: var(--gold);
  font-size: 14px;
}

.chat-msg.ai .bubble p {
  margin: 5px 0;
}

.chat-msg.ai .bubble ul,
.chat-msg.ai .bubble ol {
  margin: 6px 0 6px 18px;
}

.chat-msg.ai .bubble li {
  margin: 3px 0;
}

.chat-msg.ai .bubble blockquote {
  margin: 6px 0;
  padding: 4px 10px;
  border-left: 3px solid var(--gold);
  color: #c9c2e2;
}

.chat-msg.ai .bubble code {
  background: rgba(232, 200, 122, 0.12);
  border-radius: 4px;
  padding: 0 4px;
}

.chat-msg.ai .bubble pre {
  background: #0a0c1c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
  margin: 8px 0;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.chat-input-row .ai-question {
  flex: 1;
}

@media (max-width: 620px) {
  .topbar {
    top: 88px;
    right: 10px;
    left: auto;
    bottom: auto;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .archive-panel {
    height: 92vh;
    padding: 14px;
  }
  .archive-grid {
    grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  }
}

/* ---------- 可读性 / 无障碍 / 小屏细化 ---------- */
#reading,
#reading *,
.chat-log,
.chat-log * {
  user-select: text;
  -webkit-user-select: text;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .star {
    animation: none !important;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 380px) {
  #camera {
    width: 118px;
    height: 88px;
    left: 10px;
    bottom: 300px;
  }
  .slot,
  .slot-card {
    width: 80px;
  }
  .slot-card {
    height: 128px;
  }
  #spread {
    gap: 8px;
  }
  .controls button {
    padding: 7px 10px;
    font-size: 12px;
  }
  .topbar button {
    padding: 6px 9px;
    font-size: 12px;
  }
}

/* ---------- 每日一牌 ---------- */
.daily-panel {
  width: min(660px, 92vw);
  padding: 24px 26px;
  border-radius: 20px;
  background: linear-gradient(170deg, #171b3b 0%, #0c0f24 100%);
  border: 1px solid rgba(232, 200, 122, 0.45);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.daily-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.daily-kicker {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--gold);
  opacity: 0.85;
}

#btnCloseDaily {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 8px;
}

#btnCloseDaily:hover {
  background: none;
  box-shadow: none;
  transform: none;
  color: var(--gold);
}

.daily-body {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-top: 18px;
}

.daily-card {
  width: 180px;
  flex: none;
  aspect-ratio: 240 / 384;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}

.daily-card .card-svg,
.hc-art .card-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.daily-info {
  flex: 1;
  min-width: 0;
}

.daily-info h2 {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.daily-orientation {
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: #e0a184;
}

.daily-meaning {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.8;
  color: #d9d2ef;
}

.daily-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.daily-meta span {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  color: #efe3c4;
  background: rgba(232, 200, 122, 0.12);
  border: 1px solid rgba(232, 200, 122, 0.25);
}

.daily-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- 牌记 ---------- */
.history-panel {
  width: min(960px, 96vw);
  height: auto;
  max-height: 90vh;
}

.history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.history-stats span {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: #cfc7e6;
  background: rgba(232, 200, 122, 0.1);
  border: 1px solid rgba(232, 200, 122, 0.22);
}

.history-list {
  flex: 1;
  overflow: auto;
  margin-top: 14px;
  padding-right: 4px;
}

.history-item {
  margin-bottom: 10px;
  border: 1px solid rgba(232, 200, 122, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.history-item summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.history-item summary::-webkit-details-marker {
  display: none;
}

.h-date {
  font-size: 11px;
  color: var(--muted);
}

.h-q {
  flex: 1;
  min-width: 120px;
  font-size: 13px;
  color: #e6e0f5;
}

.h-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.h-card {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #efe3c4;
  background: rgba(232, 200, 122, 0.12);
}

.h-card.rev {
  color: #e0a184;
  background: rgba(180, 120, 90, 0.2);
}

.history-detail {
  padding: 4px 14px 16px;
  border-top: 1px solid rgba(232, 200, 122, 0.12);
}

.history-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.history-card {
  text-align: center;
}

.hc-art {
  aspect-ratio: 240 / 384;
  border-radius: 9px;
  overflow: hidden;
}

.hc-name {
  margin-top: 6px;
  font-size: 12px;
  color: var(--gold);
}

.history-card p {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.55;
  color: #c9c2e2;
}

.history-insight {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: rgba(232, 200, 122, 0.06);
  font-size: 12.5px;
  line-height: 1.7;
  color: #e6e0f5;
}

.history-ai {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.75;
  color: #d9d2ef;
}

.history-noai {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- 隐私 ---------- */
.privacy-panel p {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.8;
  color: #c9c2e2;
}

.privacy-panel p:first-of-type {
  margin-top: 16px;
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--gold);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  background: none;
  box-shadow: none;
  transform: none;
}

@media (max-width: 620px) {
  .daily-body {
    flex-direction: column;
  }
  .daily-card {
    width: 150px;
  }
  .history-cards {
    grid-template-columns: 1fr;
  }
}
