:root {
  color-scheme: dark;
  --bg: #11070c;
  --bg-deep: #0b0408;
  --velvet: #1d0c15;
  --velvet-2: #28101c;
  --ink: #faf2e8;
  --muted: #cbb7be;
  --dim: #9d828d;
  --gold: #e6bf80;
  --gold-soft: #f5d8a8;
  --rose: #eb7a9d;
  --line: #e6bf8029;
  --line-strong: #e6bf8054;
  --tactile-spring: cubic-bezier(0.22, 1.18, 0.36, 1);
  --tactile-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --tactile-press: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sans: "Geist", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 68% 36% at 50% -4%, #6a1e3c5c, transparent 70%),
    radial-gradient(circle at 86% 24%, #d89a5b21, transparent 28rem),
    radial-gradient(circle at 12% 72%, #59163245, transparent 30rem),
    linear-gradient(180deg, #160910 0%, #10060b 52%, #0c0508 100%);
  color: var(--ink);
  font: 15px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button {
  color: inherit;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
a { color: inherit; }

.shell {
  width: min(1240px, calc(100% - 40px));
  margin-inline: auto;
}

/* Topbar */
.topbar {
  min-height: 68px;
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: .16em;
  font-size: 12px;
  white-space: nowrap;
}
.brand-mark { color: var(--gold); font-size: 16px; }
.brand em {
  font-style: normal;
  letter-spacing: .04em;
  color: var(--dim);
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.top-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}
.pill-link,
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #1b0c14cc;
  color: #e4d4d9;
  text-decoration: none;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s var(--tactile-smooth), color .18s var(--tactile-smooth), background .18s var(--tactile-smooth);
}
.pill-link:hover,
.pill-btn:hover {
  border-color: var(--gold);
  color: #fff;
  background: #2b1320;
}

/* Hero */
.hero {
  padding: 44px 0 26px;
  text-align: center;
  max-width: 780px;
  margin-inline: auto;
}
.eyebrow {
  display: block;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 12px 0 16px;
  font: 700 clamp(34px, 5.4vw, 62px)/1.12 var(--serif);
  letter-spacing: -.02em;
  color: #fdf6ee;
  text-wrap: balance;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, #fcebd0 0%, #e7be7d 48%, #f089a9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-desc {
  margin: 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.75;
  text-wrap: pretty;
}

/* Controls */
.controls-bar {
  margin: 8px 0 28px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, #1d0c15d6, #14080fe0);
  display: grid;
  gap: 16px;
}
.bar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
}
.bar-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--gold);
  white-space: nowrap;
}
.mood-row,
.heat-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.mood-pill,
.heat-pill {
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #14080f;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s var(--tactile-smooth), background .18s var(--tactile-smooth), color .18s var(--tactile-smooth), transform .14s var(--tactile-press);
}
.mood-pill:active,
.heat-pill:active { transform: scale(0.965); }
.mood-pill.active {
  border-color: var(--gold);
  background: linear-gradient(135deg, #43182b, #2b131d);
  color: var(--gold-soft);
  box-shadow: inset 0 0 18px #e6bf801c;
}
.heat-pill.active {
  border-color: var(--rose);
  background: linear-gradient(135deg, #571731, #321020);
  color: #ffd4e2;
  box-shadow: inset 0 0 18px #eb7a9d24;
}

.quick-opts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid #e6bf801a;
}
.mini-field {
  display: grid;
  gap: 6px;
}
.mini-field span {
  font-size: 12px;
  font-weight: 700;
  color: #e4d1c9;
  letter-spacing: .04em;
}
.mini-field input,
.mini-field select,
.mini-field textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #10060b;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  outline: none;
  transition: border-color .18s var(--tactile-smooth), box-shadow .18s var(--tactile-smooth);
}
.mini-field input {
  height: 46px;
  padding: 0 14px;
}
.mini-field textarea {
  padding: 11px 14px;
  resize: vertical;
}
.mini-field select {
  height: auto;
  min-height: 46px;
  padding: 12px 14px;
  cursor: pointer;
}
.mini-field select option {
  background: #1a0b12;
  color: var(--ink);
}
.mini-field input::placeholder,
.mini-field textarea::placeholder { color: #7e6670; font-size: 14px; }
.mini-field input:focus,
.mini-field select:focus,
.mini-field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px #e6bf801a;
}

/* 4-Card 3D Tarot Table */
.table-stage { margin-bottom: 34px; }
.deck-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.tarot-slot {
  display: grid;
  gap: 10px;
}
.slot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.slot-meta > span {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .16em;
  color: var(--gold);
}
.lock-btn {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #190a12;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s var(--tactile-smooth), background .18s var(--tactile-smooth), color .18s var(--tactile-smooth);
}
.lock-btn[aria-pressed="true"] {
  border-color: var(--gold);
  background: #3d1828;
  color: var(--gold-soft);
}

.card-scene {
  perspective: 1200px;
  min-height: 396px;
  cursor: pointer;
  outline: none;
}
.card-scene:focus-visible .card-face {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.card-3d {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 396px;
  transform-style: preserve-3d;
  transition: transform 600ms var(--tactile-spring);
}
.card-3d.is-flipped {
  transform: rotateY(180deg);
}
.card-face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* Card Back */
.card-back {
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(circle at 50% 35%, #511a316e, transparent 62%),
    repeating-linear-gradient(45deg, #e6bf8009 0 1px, transparent 1px 16px),
    linear-gradient(155deg, #240d19, #13070d);
  box-shadow: 0 22px 54px #00000073, inset 0 0 0 8px #13070d, inset 0 0 0 9px #e6bf8033;
}
.back-ornament {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px 16px;
  border: 1px solid #e6bf803d;
  border-radius: 999px;
  width: 156px;
  height: 224px;
}
.back-ornament span {
  font: 700 24px/1 var(--serif);
  color: var(--gold);
  letter-spacing: .1em;
}
.back-ornament b {
  font: 700 17px/1.25 var(--serif);
  color: var(--ink);
}
.back-ornament small {
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.4;
}

/* Card Front */
.card-front {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  padding: 20px 18px 18px;
  border: 1px solid #e6bf8061;
  background:
    radial-gradient(circle at 85% 12%, #eb7a9d22, transparent 14rem),
    radial-gradient(circle at 12% 92%, #e6bf801a, transparent 14rem),
    linear-gradient(160deg, #28101c 0%, #170910 62%, #13070d 100%);
  box-shadow: 0 24px 60px #00000080, inset 0 1px #f8e2bd29;
}
.card-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle 220px at var(--mx, 50%) var(--my, 50%), #f5d8a82b, transparent 70%);
  transition: opacity .22s var(--tactile-smooth);
}
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-roman {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--gold);
}
.card-mood-badge {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #eb7a9d4d;
  background: #361322;
  color: #f6b6ca;
  font-size: 11px;
  white-space: nowrap;
}
.card-title {
  margin: 14px 0 4px;
  font: 700 21px/1.28 var(--serif);
  color: #fff6ec;
  text-wrap: balance;
}
.card-en {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--dim);
}
.card-body {
  margin: 12px 0 14px;
  color: #dfd0d5;
  font-size: 13.5px;
  line-height: 1.65;
  flex: 1;
  text-wrap: pretty;
}
.card-quote {
  padding: 11px 12px;
  border-radius: 12px;
  border-left: 2px solid var(--gold);
  background: #10060bc4;
  color: var(--gold-soft);
  font-size: 12.5px;
  line-height: 1.55;
  text-wrap: pretty;
}

.reroll-btn {
  min-height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #180a12;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .18s var(--tactile-smooth), color .18s var(--tactile-smooth), transform .14s var(--tactile-press);
}
.reroll-btn:active { transform: scale(0.97); }
.reroll-btn:hover { border-color: var(--gold); color: #fff; }

/* Draw bar */
.draw-bar {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s var(--tactile-press), filter .18s var(--tactile-smooth), border-color .18s var(--tactile-smooth);
}
.btn:active { transform: scale(0.965); }
.btn.primary {
  border: 0;
  background: linear-gradient(110deg, #f3d6a2 0%, #e4b26f 48%, #e982a3 100%);
  color: #190910;
  box-shadow: 0 12px 34px #d9829d2e;
}
.btn.ghost {
  background: #1c0c15e0;
  color: #f3e4d8;
}
.btn.ghost:hover { border-color: var(--gold); color: #fff; }
.draw-btn { min-width: 236px; min-height: 54px; font-size: 15px; }
.compact-btn { min-height: 42px; padding: 0 18px; font-size: 13px; }

/* Output Panels */
.output-section {
  display: grid;
  gap: 18px;
  padding-bottom: 64px;
}
.combo-banner {
  padding: 22px 26px;
  border-radius: 20px;
  border: 1px solid #e6bf8066;
  background:
    radial-gradient(circle at 86% 24%, #eb7a9d29, transparent 22rem),
    linear-gradient(135deg, #2d1120, #190a12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.combo-banner h2 {
  margin: 4px 0 6px;
  font: 700 22px/1.3 var(--serif);
}
.combo-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 13.8px;
  max-width: 680px;
}

.opener-panel,
.prompt-panel {
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(155deg, #1d0c15db, #13070de6);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 {
  margin: 4px 0 0;
  font: 700 22px/1.3 var(--serif);
}
.opener-box {
  margin: 0;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid #e6bf8045;
  border-left: 3px solid var(--gold);
  background: #0e050a;
  color: #fdf2e6;
  font-size: 15px;
  line-height: 1.75;
}
.prompt-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 14px;
}
.tab-btn {
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #12060c;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s var(--tactile-smooth), background .18s var(--tactile-smooth), color .18s var(--tactile-smooth);
}
.tab-btn.active {
  border-color: var(--gold);
  background: linear-gradient(135deg, #43182b, #28111c);
  color: var(--gold-soft);
}
.prompt-panel pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 20px 22px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0d0509;
  color: #eedfd9;
  font: 13.8px/1.78 var(--sans);
  max-height: 540px;
  overflow: auto;
}

/* Custom Card Modal */
.modal-backdrop {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #080306e6;
  backdrop-filter: blur(14px);
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(560px, 100%);
  max-height: 88dvh;
  overflow: auto;
  padding: 26px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(155deg, #250f1a, #12070d);
  box-shadow: 0 32px 96px #000c;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.modal-head h2 { margin: 4px 0 0; font: 700 22px/1.25 var(--serif); }
.close-x {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #170910;
  color: var(--muted);
  cursor: pointer;
}
.close-x:hover { border-color: var(--gold); color: #fff; }
.custom-form { display: grid; gap: 14px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.custom-list {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.custom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #11060b;
  font-size: 13px;
}
.custom-item small { color: var(--gold); margin-right: 6px; }
.del-custom {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #230d18;
  color: var(--muted);
  padding: 3px 10px;
  font-size: 11.5px;
  cursor: pointer;
}

/* Footer */
.footer {
  padding: 24px 0 42px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--dim);
  font-size: 12px;
}
.footer p { margin: 0; }

/* Age Gate */
.age-gate {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #090306ed;
  backdrop-filter: blur(18px);
}
.age-gate[hidden] { display: none; }
.gate-card {
  width: min(460px, 100%);
  padding: 34px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(circle at 80% 10%, #eb7a9d26, transparent 16rem),
    linear-gradient(155deg, #250f1a, #12070d);
  box-shadow: 0 36px 100px #000c;
  text-align: center;
}
.gate-card h1 { margin: 8px 0 12px; font: 700 32px/1.2 var(--serif); }
.gate-card p { color: var(--muted); margin: 0; }
.gate-actions { margin-top: 24px; display: flex; justify-content: center; }
.micro { margin-top: 16px !important; font-size: 12px; color: var(--dim) !important; }

/* Hover sheen only on fine pointers */
@media (hover: hover) and (pointer: fine) {
  .card-scene:hover .card-sheen { opacity: 1; }
  .btn:hover { filter: brightness(1.06); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .card-3d { transition: none !important; }
  .card-sheen { display: none; }
  * { scroll-behavior: auto !important; }
}

/* Tablet */
@media (max-width: 1120px) {
  .deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-scene, .card-3d { min-height: 356px; }
}

/* Mobile */
@media (max-width: 640px) {
  .shell { width: min(100% - 24px, 1240px); }
  .topbar { padding: 10px 0; }
  .top-links { width: 100%; justify-content: flex-start; gap: 7px; }
  .pill-link, .pill-btn { min-height: 34px; padding: 0 11px; font-size: 12px; }
  .hero { padding: 28px 0 20px; }
  .hero h1 { font-size: 32px; }
  .hero-desc { font-size: 14px; }
  .hero-desc br { display: none; }
  .controls-bar { padding: 16px; gap: 14px; }
  .bar-group { justify-content: flex-start; }
  .mood-row, .heat-row { justify-content: flex-start; }
  .quick-opts, .modal-grid { grid-template-columns: 1fr; }
  .deck-grid { grid-template-columns: 1fr; gap: 18px; }
  .card-scene, .card-3d { min-height: 336px; }
  .draw-bar { flex-direction: column; }
  .draw-bar .btn { width: 100%; }
  .combo-banner { padding: 20px 16px; }
  .opener-panel, .prompt-panel { padding: 20px 16px; }
  .compact-btn { width: 100%; }
  .prompt-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .prompt-tabs .tab-btn { width: 100%; padding: 0 8px; font-size: 12px; }
  .modal-card { padding: 20px 16px; }
  .modal-actions .btn { flex: 1 1 100%; }
  .footer { flex-direction: column; gap: 8px; }
}
