:root {
  color-scheme: dark;
  --ink: #f7f0dc;
  --muted: #bdb5a4;
  --night: #080813;
  --gold: #d9ad65;
  --gold-light: #f2d59c;
  --line: rgba(217, 173, 101, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--night);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 48% 42%, rgba(72, 60, 139, 0.12), transparent 34rem),
    linear-gradient(145deg, #070710 0%, #0b0b19 55%, #080811 100%);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.2;
  background-image:
    radial-gradient(circle at 15% 18%, #f4d99e 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 11%, #f4d99e 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 83% 72%, #f4d99e 0 1px, transparent 1.5px),
    radial-gradient(circle at 26% 79%, #f4d99e 0 0.8px, transparent 1.4px);
  background-size: 17rem 19rem, 23rem 27rem, 29rem 21rem, 31rem 25rem;
}

[hidden] { display: none !important; }

button,
a { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

.ambient {
  position: fixed;
  width: 24rem;
  height: 24rem;
  pointer-events: none;
  border: 1px solid rgba(217, 173, 101, 0.12);
  border-radius: 50%;
}

.ambient::before,
.ambient::after {
  position: absolute;
  inset: 2.2rem;
  content: "";
  border: inherit;
  border-radius: inherit;
}

.ambient::after { inset: 5.2rem; }
.ambient-one { top: -13rem; left: -11rem; }
.ambient-two { right: -13rem; bottom: -14rem; }

.site-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  width: min(100% - 2rem, 78rem);
  margin: 0 auto;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  color: var(--night);
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(217, 173, 101, 0.26);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.sync-dot {
  width: 0.45rem;
  height: 0.45rem;
  background: #d2a85e;
  border-radius: 50%;
  box-shadow: 0 0 0 0.25rem rgba(210, 168, 94, 0.08);
}

.sync-status.is-online .sync-dot { background: #8fc5a4; }
.sync-status.is-offline .sync-dot { background: #ca7a6d; }

.oracle {
  padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(3rem, 7vw, 6rem);
}

.reading-panel {
  max-width: 48rem;
  margin: 0 auto;
  text-align: center;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.75rem, 6vw, 4.75rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.reading-intro {
  max-width: 52ch;
  margin: 1.15rem auto 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:active:not(:disabled) { transform: translateY(0); }

.button:focus-visible {
  outline: 3px solid rgba(242, 213, 156, 0.34);
  outline-offset: 3px;
}

.button-primary {
  color: #11111d;
  background: var(--gold-light);
  box-shadow: 0 0.8rem 2.5rem rgba(217, 173, 101, 0.13);
}

.button-primary:hover:not(:disabled) { background: #ffe5ae; }

.button-secondary {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.button-secondary:hover:not(:disabled) {
  border-color: rgba(217, 173, 101, 0.55);
  background: rgba(217, 173, 101, 0.08);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.card-counter {
  margin: 1.15rem 0 0;
  color: var(--gold-light);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.updated-at {
  margin: 0.5rem 0 0;
  color: #858090;
  font-size: 0.8rem;
}

.feedback {
  min-height: 1.4rem;
  margin: 0.5rem 0 0;
  color: #e5a89b;
  font-size: 0.85rem;
}

.cards-stage {
  position: relative;
  display: grid;
  min-height: 29rem;
  margin-top: clamp(2.5rem, 5vw, 4.5rem);
  place-items: center;
  isolation: isolate;
}

.stage-orbit {
  position: absolute;
  z-index: -1;
  width: min(72vw, 49rem);
  aspect-ratio: 1;
  border: 1px solid rgba(217, 173, 101, 0.14);
  border-radius: 50%;
}

.stage-orbit::before,
.stage-orbit::after {
  position: absolute;
  content: "";
  border-radius: 50%;
}

.stage-orbit::before {
  inset: 10%;
  border: 1px solid rgba(217, 173, 101, 0.08);
}

.stage-orbit::after {
  top: 50%;
  left: 50%;
  width: 0.45rem;
  height: 0.45rem;
  background: var(--gold);
  box-shadow:
    -20rem 0 0 -0.08rem rgba(217, 173, 101, 0.65),
    20rem 0 0 -0.08rem rgba(217, 173, 101, 0.65);
  transform: translate(-50%, -50%);
}

.empty-deck {
  display: grid;
  width: 100%;
  place-items: center;
}

.tarot-card {
  position: relative;
  width: min(62vw, 17rem);
  aspect-ratio: 0.58;
  filter: drop-shadow(0 2rem 3rem rgba(0, 0, 0, 0.42));
}

.card-face,
.drawn-card-frame {
  position: absolute;
  inset: 0;
  padding: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(242, 213, 156, 0.68);
  border-radius: 0.9rem;
  background: linear-gradient(145deg, #d8b66e, #8f6930 14%, #11111f 15% 85%, #8f6930 86%, #d8b66e);
  box-shadow:
    inset 0 0 0 0.2rem #090914,
    inset 0 0 0 0.26rem rgba(242, 213, 156, 0.38),
    0 0 0 1px rgba(0, 0, 0, 0.45);
}

.card-art-back {
  width: 100%;
  height: 100%;
  border-radius: 0.55rem;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 12%, rgba(242, 213, 156, 0.95) 12.5% 13%, transparent 13.5% 23%, rgba(217, 173, 101, 0.55) 23.5% 24%, transparent 24.5%),
    repeating-conic-gradient(from 22.5deg, rgba(217, 173, 101, 0.2) 0 1.5deg, transparent 1.5deg 22.5deg),
    radial-gradient(circle at 50% 50%, #12152c 0 48%, #090b1c 82%);
  box-shadow:
    inset 0 0 0 0.3rem #0a0b18,
    inset 0 0 0 0.36rem rgba(217, 173, 101, 0.48),
    inset 0 0 3rem rgba(0, 0, 0, 0.6);
}

.card-back-label,
.drawn-card-label {
  position: absolute;
  right: 0.9rem;
  bottom: 0.9rem;
  left: 0.9rem;
  display: flex;
  min-height: 3.75rem;
  align-items: center;
  justify-content: center;
  color: var(--gold-light);
  text-align: center;
  border: 1px solid rgba(242, 213, 156, 0.4);
  border-radius: 0.45rem;
  background: rgba(8, 8, 19, 0.93);
  backdrop-filter: blur(0.35rem);
}

.card-back-label {
  gap: 0.55rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.62rem;
  letter-spacing: 0.13em;
}

.cards-grid {
  display: grid;
  width: 100%;
  align-items: start;
  gap: clamp(1rem, 2vw, 1.6rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
}

.cards-grid[data-count="1"] { max-width: 15rem; }
.cards-grid[data-count="2"] { max-width: 31.5rem; }
.cards-grid[data-count="3"] { max-width: 48rem; }
.cards-grid[data-count="4"] { max-width: 64.5rem; }
.cards-grid[data-count="5"] { max-width: 78rem; }

.drawn-card {
  min-width: 0;
  animation: card-arrival 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.drawn-card-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 0.58;
  filter: drop-shadow(0 1.2rem 1.6rem rgba(0, 0, 0, 0.36));
}

.drawn-card-art {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(242, 213, 156, 0.3);
  border-radius: 0.52rem;
  object-fit: cover;
}

.drawn-card-label {
  min-height: 3.5rem;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.45rem;
}

.drawn-card-number {
  color: var(--gold);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.drawn-card-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  font-weight: 400;
  line-height: 1.1;
}

.drawn-card-info {
  margin: 0.8rem 0 0;
  color: var(--gold-light);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.35;
  text-align: center;
}

@keyframes card-arrival {
  from { opacity: 0; transform: translateY(1rem) rotate(-1deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.25rem 0 1.5rem;
  border-top: 1px solid var(--line);
  color: #7e7988;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.footer-star { color: var(--gold); }

@media (max-width: 780px) {
  .site-shell { width: min(100% - 1.5rem, 35rem); }
  .topbar { padding: 1rem 0; }
  .oracle { padding-top: 3rem; }
  .cards-stage { min-height: 25rem; }
  .stage-orbit { width: min(110vw, 34rem); }
  .stage-orbit::after { box-shadow: none; }
}

@media (max-width: 440px) {
  .sync-status { font-size: 0; }

  .sync-status span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .sync-dot { width: 0.55rem; height: 0.55rem; }
  .actions { display: grid; }
  .button { width: 100%; }

  .cards-grid {
    gap: 1.25rem 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cards-grid[data-count="1"] {
    width: min(100%, 15rem);
    grid-template-columns: 1fr;
  }

  .drawn-card-frame { padding: 0.35rem; border-radius: 0.65rem; }

  .drawn-card-label {
    right: 0.58rem;
    bottom: 0.58rem;
    left: 0.58rem;
    min-height: 3rem;
  }

  .drawn-card-name { font-size: 0.95rem; }
  .drawn-card-info { font-size: 0.8rem; }
  footer { flex-direction: column; gap: 0.35rem; }
}

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