:root {
  color-scheme: dark;
  --ink: #f7f0dd;
  --muted: #bdb5d0;
  --violet: #8e6fe8;
  --violet-bright: #b79aff;
  --gold: #e3c67a;
  --surface: rgba(27, 20, 52, 0.76);
  --line: rgba(227, 198, 122, 0.2);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #0b0819; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
  background:
    radial-gradient(circle at 76% 16%, rgba(102, 67, 177, 0.24), transparent 28rem),
    radial-gradient(circle at 10% 78%, rgba(48, 102, 126, 0.15), transparent 26rem),
    linear-gradient(145deg, #0a0717 0%, #15102c 52%, #0d0920 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
}

button, input, textarea { font: inherit; }
button, .upload { -webkit-tap-highlight-color: transparent; }

.sky { position: fixed; inset: 0; pointer-events: none; }
.sky span { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: twinkle 3s ease-in-out infinite; }
.sky span:nth-child(1) { top: 11%; left: 8%; }
.sky span:nth-child(2) { top: 20%; right: 14%; animation-delay: .8s; }
.sky span:nth-child(3) { top: 64%; left: 5%; animation-delay: 1.5s; }
.sky span:nth-child(4) { top: 80%; right: 9%; animation-delay: 2.1s; }
.sky span:nth-child(5) { top: 44%; right: 3%; animation-delay: .3s; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 70px; position: relative; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--gold); font-size: .86rem; letter-spacing: .14em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 32px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; }

.intro { max-width: 780px; margin: 74px 0 42px; }
.eyebrow, .result-kicker { margin: 0 0 14px; color: var(--gold); font-size: .78rem; letter-spacing: .17em; text-transform: uppercase; }
h1, h2 { font-family: "Italiana", serif; font-weight: 400; }
h1 { margin: 0; font-size: clamp(3rem, 6.6vw, 6.3rem); line-height: .95; letter-spacing: -.025em; }
.intro-copy { max-width: 570px; margin: 24px 0 0; color: var(--muted); font-size: 1.08rem; line-height: 1.65; }

.experience { display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(340px, .94fr); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; background: rgba(13, 9, 31, .7); box-shadow: 0 28px 80px rgba(0, 0, 0, .34); backdrop-filter: blur(18px); }
.form-card { padding: clamp(28px, 5vw, 58px); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
label > span, .field-title { display: block; margin-bottom: 9px; color: #e8e1f3; font-size: .9rem; font-weight: 500; }
input, textarea { width: 100%; border: 1px solid rgba(216, 204, 245, .16); border-radius: 13px; outline: none; color: var(--ink); background: rgba(255,255,255,.045); padding: 15px 16px; transition: border-color .2s, box-shadow .2s, background .2s; }
textarea { resize: vertical; min-height: 118px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #817a96; }
input:focus, textarea:focus { border-color: var(--violet-bright); box-shadow: 0 0 0 3px rgba(142, 111, 232, .15); background: rgba(255,255,255,.06); }
.form-card > label { display: block; margin-top: 22px; position: relative; }
.form-card > label small { position: absolute; right: 10px; bottom: 9px; color: #766f8e; font-size: .74rem; }
.upload-wrap { margin-top: 22px; }
.upload { display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 12px; border: 1px dashed rgba(227,198,122,.35); border-radius: 16px; cursor: pointer; background: rgba(227,198,122,.025); transition: border-color .2s, background .2s; }
.upload:hover, .upload:focus-within { border-color: var(--gold); background: rgba(227,198,122,.055); }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-preview { display: grid; place-items: center; flex: 0 0 56px; width: 56px; height: 56px; margin: 0; border-radius: 50%; color: var(--gold); background-color: #271d46; background-position: center; background-size: cover; overflow: hidden; }
.upload-copy { min-width: 0; flex: 1; }
.upload-copy strong, .upload-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-copy strong { color: var(--ink); font-size: .92rem; font-weight: 500; }
.upload-copy small { margin-top: 5px; color: var(--muted); font-size: .76rem; }
.upload-action { margin: 0; color: var(--gold); font-size: .78rem; font-weight: 600; }
.primary-button, .download-button { width: 100%; border: 0; border-radius: 14px; cursor: pointer; color: #150e29; font-weight: 600; background: linear-gradient(110deg, #e3c67a, #f0dba1); box-shadow: 0 12px 30px rgba(227,198,122,.14); transition: transform .2s, box-shadow .2s, filter .2s; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 28px; padding: 17px 24px; }
.primary-button:hover, .download-button:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(227,198,122,.22); filter: brightness(1.04); }
.primary-button:disabled { cursor: wait; opacity: .65; transform: none; }
.privacy { margin: 14px 0 0; color: #8c849e; text-align: center; font-size: .75rem; }

.preview-panel { min-height: 600px; display: grid; place-items: center; padding: clamp(28px, 4vw, 46px); border-left: 1px solid var(--line); background: radial-gradient(circle at center, rgba(105,73,170,.18), transparent 63%), rgba(255,255,255,.018); }
.preview-copy { max-width: 300px; text-align: center; color: var(--muted); line-height: 1.65; }
.mini-orbit { display: grid; place-items: center; width: 126px; height: 126px; margin: 0 auto 24px; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); font-family: serif; font-size: 3rem; box-shadow: inset 0 0 30px rgba(142,111,232,.14), 0 0 40px rgba(142,111,232,.08); }
.loading-state, .result-state { width: 100%; text-align: center; }
.loading-state h2 { margin: 28px 0 10px; font-size: 2rem; }
.loading-state p { margin: 0; color: var(--muted); }
.orbital-loader { width: 116px; height: 116px; margin: auto; display: grid; place-items: center; border: 1px solid rgba(227,198,122,.25); border-radius: 50%; animation: breathe 1.6s ease-in-out infinite; }
.orbital-loader::before { content: ""; position: absolute; width: 90px; height: 90px; border: 1px dashed var(--violet-bright); border-radius: 50%; animation: spin 6s linear infinite; }
.orbital-loader span { color: var(--gold); font-size: 1.5rem; }
.result-state { max-width: 345px; animation: reveal .6s ease both; }
#tarot-canvas { display: block; width: min(100%, 310px); height: auto; margin: 0 auto 20px; border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.download-button { padding: 15px 20px; }
.download-button span { margin-left: 8px; font-size: 1.1rem; }
.text-button { margin-top: 13px; border: 0; cursor: pointer; color: var(--muted); background: transparent; text-decoration: underline; text-underline-offset: 4px; }

footer { display: flex; justify-content: center; gap: 16px; padding: 0 20px 32px; color: #716a84; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
footer span { color: var(--gold); }
[hidden] { display: none !important; }

@keyframes twinkle { 0%,100% { opacity: .3; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.3); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 35px rgba(142,111,232,.22); } }
@keyframes reveal { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 820px) {
  .shell { width: min(100% - 24px, 680px); padding-top: 20px; }
  .intro { margin: 50px 6px 30px; }
  h1 { font-size: clamp(2.8rem, 13vw, 4.6rem); }
  .experience { grid-template-columns: 1fr; }
  .preview-panel { min-height: 450px; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 540px) {
  .shell { width: min(100% - 16px, 480px); }
  .field-row { grid-template-columns: 1fr; gap: 20px; }
  .form-card { padding: 28px 20px; }
  .upload-action { display: none; }
  .intro-copy { font-size: 1rem; }
  footer { font-size: .65rem; gap: 8px; }
}

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