.tarot-page .tarot-layout {
  max-width: 75rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 4.5rem) clamp(1rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: minmax(16rem, .85fr) minmax(0, 1.35fr);
  gap: clamp(1.35rem, 5vw, 4rem);
  align-items: start;
}
.tarot-controls { min-width: 0; }
.tarot-controls > p:first-of-type { color: var(--muted); }
.tarot-controls h1 {
  margin: 0 0 1.65rem;
  font-size: clamp(2.5rem, 6vw, 4.7rem);
  line-height: .97;
  letter-spacing: -.055em;
  text-wrap: balance;
}


.tarot-page #tarot-form { gap: .55rem; margin: 0; }
.tarot-page #tarot-form > label { font-weight: 620; }
.tarot-page #tarot-form .tarot-field-help { margin: -.2rem 0 .45rem; color: var(--muted); font-size: .78rem; }
.tarot-page .tarot-actions { display: grid; gap: .55rem; margin-top: .25rem; }
.tarot-page .tarot-actions > button { width: 100%; justify-self: stretch; }
.tarot-page .tarot-actions > .tarot-secondary { border-color: #ffffff24; color: var(--muted-strong); background: #ffffff08; box-shadow: none; }
.tarot-page .tarot-actions > .tarot-secondary:hover { color: var(--paper); background: #ffffff12; box-shadow: none; }
.tarot-page #tarot-history-shortcut { margin-top: .25rem; }
.tarot-page #tarot-history-shortcut a { color: var(--teal); font-size: .84rem; }
.tarot-page :is(textarea, input, select) {
  box-sizing: border-box;
  max-width: 100%;
  border: 1px solid var(--rule);
  border-radius: .55rem;
  color: var(--paper);
  background: #0b0a10;
}
.tarot-page #tarot-form textarea { padding: .95rem 1rem; min-height: 6rem; resize: vertical; }
.tarot-page textarea::placeholder { color: #aaa3b5; }
.tarot-page #tarot-form summary { font-size: .9rem; }
.tarot-page button { justify-self: start; border-radius: .45rem; background: var(--gold); }
.tarot-page button:not(:disabled):hover { background: #ede4ff; }
.tarot-page #tarot-status { color: var(--muted-strong); min-height: 1.65rem; margin: .85rem 0; font-size: .9rem; }
.tarot-page #tarot-status:empty { display: none; }
.tarot-page #tarot-basic { color: var(--gold); background: transparent; padding: .4rem 0; font-size: .85rem; }
.tarot-page #tarot-basic:hover { background: transparent; text-decoration: underline; }

.tarot-table {
  min-width: 0;
  padding: clamp(1rem, 3vw, 2.5rem);
  border: 1px solid var(--rule);
  border-radius: 1.2rem;
  background: radial-gradient(ellipse at 50% 0%, #22192d, #100f15 68%);
  box-shadow: 0 1rem 4rem #0c081648;
}

.tarot-table h2 { margin: 0 0 1.4rem; font-size: clamp(1.7rem, 4vw, 2.7rem); }
.tarot-table article { background: transparent; border: 0; padding: 0; }
.tarot-table :is(.tarot-slots, #tarot-preview) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: clamp(.45rem, 2vw, 1rem);
  max-width: 34rem;
  margin-inline: auto;
  list-style: none;
  padding: 0;
  margin-block: 0;
}
.tarot-table #tarot-slots[hidden] { display: none; }
.tarot-table :is(.tarot-slots, #tarot-preview) li {
  display: grid;
  align-content: start;
  gap: .45rem;
  padding: 0;
  border: 0;
  background: transparent;
  min-height: 0;
  min-width: 0;
}
.tarot-table .tarot-back {
  display: grid;
  place-items: center;
  aspect-ratio: 300 / 527;
  border: 1px solid #84639b59;
  border-radius: .65rem;
  background: #241932 url("/card-art/back.png?v=cards-png") center / 100% 100% no-repeat;
}
.tarot-table #tarot-preview img {
  display: block;
  border-radius: .65rem;
  box-shadow: 0 .4rem 1rem #100b1a7a;
}
.tarot-table :is(.tarot-slots li > span:last-child, #tarot-preview .tarot-position) {
  color: var(--muted);
  font-size: clamp(.63rem, 1.7vw, .78rem);
  overflow-wrap: anywhere;
}
.tarot-table #tarot-preview strong {
  color: var(--paper);
  font: clamp(.92rem, 2.25vw, 1.28rem)/1.22 Georgia, serif;
  overflow-wrap: anywhere;
}

.tarot-table article section { margin-top: 1.55rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.tarot-table h3 { margin: 0 0 .75rem; font: normal 1.5rem/1.2 Georgia, serif; color: var(--gold); }
.tarot-table #tarot-synthesis { font: 1.24rem/1.6 Georgia, serif; margin: 0; }
.tarot-table #tarot-next { margin: 0; }
.tarot-table .note { margin: 1.35rem 0 0; color: var(--muted); font-size: .78rem; }

@media (max-width: 760px) {
  .tarot-page .tarot-layout { grid-template-columns: 1fr; gap: 1.1rem; }
  .tarot-page #tarot-form > button { justify-self: stretch; }
}

.tarot-flip { position: relative; aspect-ratio: 300 / 527; perspective: 850px; }
.tarot-turn { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .58s ease-in-out; }
.tarot-turn.is-revealed { transform: rotateY(180deg); }
.tarot-table #tarot-preview li:nth-child(2) .tarot-turn { transition-delay: .09s; }
.tarot-table #tarot-preview li:nth-child(3) .tarot-turn { transition-delay: .18s; }
.tarot-table #tarot-preview .tarot-face { position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; backface-visibility: hidden; }
.tarot-front { transform: rotateY(180deg); }
@media (prefers-reduced-motion: reduce) {
  .tarot-table #tarot-preview li .tarot-turn { transition: none; }
}

.tarot-page .tarot-profile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tarot-page .tarot-profile :is(input, select) { width: 100%; }
.tarot-page .tarot-sample ol { padding-left: 1.35rem; color: var(--muted-strong); }

@media (max-width: 760px) {
  .tarot-controls h1 { margin-bottom: 1.1rem; }
  .tarot-page #tarot-form textarea { min-height: 5rem; }
  .tarot-table h2 { margin-bottom: .85rem; }
  .tarot-table #tarot-synthesis { font-size: 1.13rem; }
}

#tarot-card-meanings { margin-top: 1.4rem; border-top: 1px solid var(--rule); }
#tarot-card-meanings summary { min-height: 44px; align-content: center; }
#tarot-meaning-list { margin: .35rem 0 0; }

/* Keep the first choice and the next action obvious on narrow screens. */
.tarot-page .tarot-controls h1 {
  max-width: 100%;
  margin-bottom: .8rem;
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  line-height: 1.08;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.tarot-page .tarot-choice > p[id$="-trial"] {
  margin: -.35rem 0 .1rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}
.tarot-page .tarot-actions { gap: .8rem; }
.tarot-page .tarot-choice { display: grid; gap: .4rem; min-width: 0; }
.tarot-page .tarot-choice > button { width: 100%; min-height: 3.1rem; }
.tarot-page .tarot-choice > .tarot-secondary { border-style: solid; }
#tarot-meaning-list dt { font-weight: 650; }
#tarot-meaning-list dd { margin: .2rem 0 .8rem; color: var(--muted); }
#tarot-meaning-list dd:last-child { margin-bottom: 0; }

#tarot-retry { background: transparent; color: var(--gold); padding-inline: 0; }

.tarot-page #tarot-slots li > .tarot-back { transition: border-color .35s, box-shadow .35s, transform .35s; }
.tarot-page.is-generating #tarot-slots li > .tarot-back { animation: card-charge 1.8s ease-in-out infinite; }
.tarot-page.is-generating #tarot-slots li:nth-child(2) > .tarot-back { animation-delay: .24s; }
.tarot-page.is-generating #tarot-slots li:nth-child(3) > .tarot-back { animation-delay: .48s; }
@keyframes card-charge { 0%,100% { border-color: #ffffff18; box-shadow: 0 0 0 #b69bff00; transform: translateY(0); } 50% { border-color: #c8b5ff88; box-shadow: 0 0 1.5rem #a994ff30; transform: translateY(-3px); } }

.tarot-table button.tarot-flip,
.tarot-table button.tarot-flip:not(:disabled):hover {
  width: 100%;
  padding: 0;
  justify-self: stretch;
  background: transparent;
  cursor: zoom-in;
}
#tarot-card-dialog {
  box-sizing: border-box;
  width: min(25rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: .85rem 1rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 1rem;
  background: var(--surface);
  color: var(--paper);
  text-align: center;
}
#tarot-card-dialog::backdrop { background: #050409db; }
#tarot-card-dialog form { display: flex; justify-content: end; }
#tarot-card-dialog button { padding: 0; min-width: 44px; font-size: 1.55rem; }
#tarot-card-dialog h2 { font-size: 1.55rem; margin: .3rem 0 .8rem; }
#tarot-card-dialog img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 64dvh;
  border-radius: .55rem;
}
