:root {
  --ink: #11110f;
  --paper: #f7f0e6;
  --pink: #f3a4b7;
  --pink-deep: #c52f58;
  --blue: #315fd1;
  --yellow: #ffd34e;
  --card-width: min(36vh, 332px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  color: inherit;
  font: inherit;
}

.home-link {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  z-index: 20;
  display: inline-flex;
  min-height: 42px;
  padding: 9px 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.home-link:hover {
  background: var(--ink);
  color: var(--paper);
}

.home-link:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.app {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  outline: none;
  cursor: pointer;
  isolation: isolate;
}

.app::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 12% 16%, rgb(243 164 183 / 16%) 0 2px, transparent 3px),
    radial-gradient(circle at 84% 28%, rgb(49 95 209 / 12%) 0 2px, transparent 3px),
    radial-gradient(circle at 24% 83%, rgb(255 211 78 / 18%) 0 2px, transparent 3px),
    linear-gradient(115deg, #fbf7f0, var(--paper) 48%, #f5ecdf);
  background-size: 180px 180px, 230px 230px, 270px 270px, auto;
  content: "";
}

.screen {
  display: none;
  width: 100%;
  min-height: 100svh;
}

.screen.is-active {
  display: flex;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.intro {
  align-items: center;
  flex-direction: column;
  justify-content: space-between;
  padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  text-align: center;
}

.intro h1 {
  margin: 12px 0 0;
  max-width: 820px;
  font-size: clamp(31px, 4.6vw, 72px);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.intro-visual {
  position: relative;
  display: grid;
  width: min(47vh, 530px, 84vw);
  margin: clamp(16px, 3vh, 36px) 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: transform 300ms ease;
}

.intro-visual:hover {
  transform: rotate(-1deg) scale(1.015);
}

.intro-visual:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 8px;
}

.intro-visual img {
  display: block;
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.spark {
  position: absolute;
  color: var(--yellow);
  font-size: clamp(22px, 3vw, 42px);
  line-height: 1;
  animation: twinkle 1.8s ease-in-out infinite alternate;
}

.spark-one {
  top: 8%;
  left: -8%;
  color: var(--blue);
}

.spark-two {
  top: 31%;
  right: -9%;
  animation-delay: -0.7s;
}

.spark-three {
  right: 3%;
  bottom: 4%;
  color: var(--pink-deep);
  animation-delay: -1.2s;
}

.intro-copy p {
  margin: 0;
  font-size: clamp(16px, 1.55vw, 22px);
  letter-spacing: -0.025em;
  line-height: 1.18;
}

.intro-copy .intro-note {
  margin-top: 8px;
  font-size: clamp(12px, 1.1vw, 15px);
  line-height: 1.3;
}

.tap-hint {
  display: inline-block;
  margin-top: 15px;
  border-bottom: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: breathe 1.4s ease-in-out infinite alternate;
}

.reading {
  position: relative;
  align-items: center;
  flex-direction: column;
  min-height: 100svh;
  padding: max(18px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  text-align: center;
}

.reading-header {
  position: relative;
  z-index: 3;
  min-height: 118px;
}

.reading h2 {
  margin: 9px auto 0;
  font-size: clamp(20px, 2.2vw, 33px);
  font-weight: 400;
  letter-spacing: -0.04em;
  line-height: 1.02;
  transition: opacity 200ms ease, transform 200ms ease;
}

.prediction {
  display: none;
  width: min(780px, 91vw);
  margin: 9px auto 0;
  font-family: Didot, "Bodoni MT", Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 2.1vw, 31px);
  font-style: italic;
  line-height: 1.06;
}

.card-stage {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  place-items: center;
  width: min(660px, 100%);
  min-height: 430px;
  padding: 9px 0 14px;
}

.card-stage::before,
.card-stage::after {
  position: absolute;
  z-index: 1;
  width: calc(var(--card-width) * 1.12);
  aspect-ratio: 0.67;
  border: 3px solid rgb(255 91 159 / 70%);
  border-radius: 20px;
  opacity: 0;
  content: "";
  pointer-events: none;
}

.card-stage::after {
  border-color: rgb(49 95 209 / 56%);
}

.tarot-card {
  position: relative;
  z-index: 2;
  width: var(--card-width);
  aspect-ratio: 0.67;
  transform: rotate(-0.6deg);
}

.card-shadow {
  position: absolute;
  inset: 13px -13px -13px 13px;
  border: 2px solid var(--ink);
  border-radius: 14px 19px 12px 16px;
  background: var(--pink-deep);
}

.card-face {
  position: relative;
  display: grid;
  grid-template-rows: 13% 1fr 19%;
  width: 100%;
  height: 100%;
  padding: 10px 12px 12px;
  border: 3px solid var(--ink);
  border-radius: 13px 18px 12px 16px;
  background: var(--pink);
  box-shadow: inset 0 0 0 5px rgb(255 255 255 / 10%);
}

.card-face::after {
  position: absolute;
  inset: 8px;
  border: 1.5px solid var(--ink);
  border-radius: 7px 12px 8px 11px;
  content: "";
  pointer-events: none;
}

.artist,
.art-title {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 3px 10px;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: clamp(11px, 1.4vh, 15px);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.05;
  text-transform: uppercase;
}

.art-title {
  border-top: 2px solid var(--ink);
  font-size: clamp(10px, 1.25vh, 13px);
  letter-spacing: 0.08em;
}

.art-frame {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: #efe9df;
}

.art-frame img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #eee8df;
}

.art-frame.is-diptych {
  grid-template-rows: 1fr 1fr;
  gap: 3px;
  background: var(--ink);
}

.art-frame.is-diptych img {
  min-height: 0;
}

.aura {
  position: absolute;
  z-index: 1;
  width: calc(var(--card-width) * 1.8);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0;
  background:
    repeating-conic-gradient(from 0deg, rgb(255 255 255 / 0%) 0deg 7deg, rgb(255 255 255 / 42%) 8deg 9deg, rgb(255 255 255 / 0%) 10deg 18deg),
    radial-gradient(circle, rgb(255 255 255 / 95%) 0 6%, rgb(255 187 226 / 78%) 18%, rgb(122 182 255 / 43%) 38%, transparent 67%);
  filter: blur(1px);
  transform: scale(0.55) rotate(0deg);
  pointer-events: none;
}

.reading.is-result .aura {
  opacity: 1;
  animation: reveal-aura 900ms cubic-bezier(0.22, 1, 0.36, 1) both, aura-turn 16s linear 900ms infinite;
}

.reading.is-result .tarot-card {
  animation: reveal-card 920ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.reading.is-result .card-stage::before {
  animation: impact-ring 920ms 70ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.reading.is-result .card-stage::after {
  animation: impact-ring 1050ms 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.reading.is-result h2 {
  font-weight: 700;
}

.reading.is-result .prediction {
  display: block;
  animation: prediction-in 650ms 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.actions {
  position: relative;
  z-index: 4;
  display: flex;
  visibility: hidden;
  gap: 9px;
  justify-content: center;
  min-height: 42px;
  opacity: 0;
  transform: translateY(16px);
}

.actions.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 700ms ease, transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.action-button {
  min-height: 42px;
  padding: 10px 19px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.action-button.primary,
.action-button:hover {
  background: var(--ink);
  color: var(--paper);
}

.action-button:hover {
  transform: translateY(-2px);
}

.action-button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.share-status {
  position: absolute;
  top: -24px;
  left: 50%;
  width: 260px;
  margin: 0;
  color: var(--pink-deep);
  font-size: 12px;
  transform: translateX(-50%);
}

.stop-hint {
  margin: 8px 0 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.reading.is-result .stop-hint {
  visibility: hidden;
}

@keyframes twinkle {
  to { transform: rotate(18deg) scale(1.3); }
}

@keyframes breathe {
  to { opacity: 0.42; }
}

@keyframes reveal-card {
  0% {
    filter: brightness(2.2) saturate(0.6);
    transform: translateY(26px) scale(0.78) rotate(-8deg);
  }
  42% {
    filter: brightness(1.18) saturate(1.25);
    transform: translateY(-12px) scale(1.09) rotate(2.4deg);
  }
  68% {
    filter: brightness(1) saturate(1);
    transform: translateY(4px) scale(0.975) rotate(-1.4deg);
  }
  84% {
    transform: translateY(-2px) scale(1.015) rotate(-0.2deg);
  }
  100% {
    filter: brightness(1) saturate(1);
    transform: translateY(0) scale(1) rotate(-0.6deg);
  }
}

@keyframes impact-ring {
  0% {
    opacity: 0;
    transform: scale(0.78);
  }
  18% {
    opacity: 0.88;
  }
  100% {
    opacity: 0;
    transform: scale(1.62);
  }
}

@keyframes reveal-aura {
  from { opacity: 0; transform: scale(0.45) rotate(-25deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes aura-turn {
  to { transform: scale(1) rotate(360deg); }
}

@keyframes prediction-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  :root {
    --card-width: min(34.5vh, 278px, 69vw);
  }

  .intro {
    padding-inline: 18px;
  }

  .intro h1 {
    max-width: 360px;
  }

  .intro-visual {
    width: min(43vh, 82vw);
    margin-block: 12px;
  }

  .reading {
    padding-inline: 12px;
  }

  .reading-header {
    min-height: 116px;
  }

  .reading h2 {
    max-width: 370px;
  }

  .prediction {
    max-width: 430px;
    font-size: clamp(17px, 5vw, 23px);
  }

  .card-stage {
    min-height: 388px;
    padding-top: 0;
  }

  .actions {
    width: 100%;
    gap: 7px;
  }

  .action-button {
    flex: 1;
    max-width: 220px;
    padding-inline: 10px;
    font-size: 12px;
  }

}

@media (max-height: 720px) and (min-width: 700px) {
  :root { --card-width: 260px; }
  .reading-header { min-height: 94px; }
  .card-stage { min-height: 390px; }
  .prediction { font-size: 21px; }
}

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