:root {
  color-scheme: dark;
  --ink: #fbf7ff;
  --muted: #c8bfdd;
  --gold: #e8c77d;
  --violet: #8e70dc;
  --deep: #090619;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background-color: #0b1b3b;
  background-image: linear-gradient(rgba(4,14,38,.18), rgba(5,10,28,.5)), url('angelic-background.webp?v=6');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(3,13,37,.18) 20%, rgba(2,7,22,.58) 100%);
}
.stars, .stars::before, .stars::after {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image: radial-gradient(#fff 1px, transparent 1.5px);
  background-size: 83px 83px;
  opacity: .18;
}
.stars::before { transform: translate(31px, 17px); background-size: 127px 127px; opacity: .45; }
.stars::after { transform: translate(9px, 48px); background-size: 173px 173px; opacity: .52; }
.app {
  position: relative;
  z-index: 1;
  width: min(100%, 1040px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) clamp(18px, 5vw, 56px) max(24px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}
header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.eyebrow { margin: 0 0 3px; color: var(--gold); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.45rem, 4vw, 2rem); font-weight: 500; letter-spacing: .02em; }
.sound {
  width: 44px; height: 44px; border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.14); font-size: 1.2rem; cursor: pointer;
}
.sound[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.reading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; padding: 16px 0 10px; }
.guidance { margin: 0 0 14px; color: var(--muted); font-family: Georgia, serif; font-style: italic; text-align: center; font-size: clamp(.98rem, 2vw, 1.1rem); }
.card-stage { position: relative; width: min(68vw, 298px); aspect-ratio: 2 / 3; perspective: 1400px; }
.card {
  position: absolute; inset: 0; transition: transform .35s ease;
  filter: drop-shadow(0 24px 32px rgba(0,0,0,.55));
  cursor: pointer;
}
.card:focus-visible { outline:3px solid #fff; outline-offset:5px; border-radius:18px; }
.card.is-revealed { transform: none; }
.card.is-loading { transform: scale(.98); }
.card.is-shuffling { animation: shuffle .68s ease-in-out; }
.card-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 18px; overflow: hidden; }
.card-back {
  display: block;
  opacity: 0;
  z-index: 0;
  transition: opacity .32s ease;
  background: #120b34;
  border: 1px solid #e8c77d;
}
.card-back img { display:block; width:100%; height:100%; object-fit:cover; }
.card-front { z-index:1; opacity:1; transition:opacity .32s ease; transform: none; background: #1a123f; border: 1px solid rgba(232,199,125,.7); }
.card.show-back .card-back { opacity:1; z-index:2; }
.card.show-back .card-front { opacity:0; }
.card-front img { display: block; width: 100%; height: 100%; object-fit: cover; image-rendering:auto; }
.echo { position: absolute; inset: 2%; border-radius: 18px; background: #120c31; border: 1px solid rgba(232,199,125,.35); transition: transform .45s ease; }
.echo-left { transform: rotate(-5deg) translate(-10px, 5px); }
.echo-right { transform: rotate(5deg) translate(10px, 5px); }
.card-stage.shuffling .echo-left { animation: echoLeft .68s ease; }
.card-stage.shuffling .echo-right { animation: echoRight .68s ease; }
.card-name { min-height: 1.5em; margin: 12px 0 0; color: var(--gold); font: 500 1.05rem Georgia, serif; letter-spacing: .04em; }
.tap-hint { margin:2px 0 0; color:#ddd5ed; font-size:.75rem; letter-spacing:.04em; }
.controls { display: flex; justify-content: center; gap: 14px; }
.button {
  position: relative; isolation: isolate; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; border-radius: 999px; padding: 5px 22px; border: 1px solid transparent;
  font: 700 .93rem/1 Inter, sans-serif; letter-spacing: .025em; cursor: pointer;
  transition: transform .2s ease, filter .2s ease, box-shadow .25s ease, border-color .25s ease;
}
.button::before {
  content: ""; position: absolute; z-index: -1; inset: 1px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 20%, rgba(255,255,255,.42) 48%, transparent 72%);
  transform: translateX(-130%); transition: transform .55s ease;
}
.button:hover::before { transform: translateX(130%); }
.button:hover { transform: translateY(-2px); filter: brightness(1.08); }
.button:active { transform: scale(.97); }
.button:focus-visible, .sound:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.primary {
  color: #251638; border-color: rgba(255,247,210,.88);
  background: linear-gradient(135deg, #fff9e6 0%, #efd995 46%, #d6a94e 100%);
  box-shadow: 0 10px 32px rgba(220,179,86,.28), inset 0 1px 0 rgba(255,255,255,.9), inset 0 -2px 5px rgba(118,72,18,.16);
}
.secondary {
  color: #fff9ed; border-color: rgba(240,211,142,.62);
  background: linear-gradient(145deg, rgba(89,67,139,.84), rgba(30,26,75,.9));
  box-shadow: 0 10px 30px rgba(11,7,35,.34), inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 22px rgba(189,154,255,.12);
  backdrop-filter: blur(10px);
}
.button-icon {
  width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 50%;
  font-family: Georgia, serif; font-size: 1.22rem; line-height: 1;
  border: 1px solid rgba(255,255,255,.65); background: rgba(255,255,255,.18);
  box-shadow: inset 0 0 12px rgba(255,255,255,.3), 0 0 14px rgba(246,218,151,.25);
  text-shadow: 0 0 10px rgba(255,255,255,.95);
}
.primary .button-icon { color: #fff8dd; border-color: rgba(112,70,15,.26); background: linear-gradient(145deg,#e4bf6a,#ad762c); }
.secondary .button-icon { color: #f6d98f; }
.button-label { white-space: nowrap; }
.deck-status { margin: 14px 0 0; color: #9d93b6; text-align: center; font-size: .78rem; }
.fortune-modal[hidden] { display:none; }
.fortune-modal { position:fixed; inset:0; z-index:20; display:grid; place-items:center; padding:22px; }
.fortune-backdrop { position:absolute; inset:0; background:rgba(4,7,22,.78); backdrop-filter:blur(12px); }
.fortune-panel { position:relative; width:min(92vw,480px); padding:36px 30px 30px; border:1px solid rgba(232,199,125,.75); border-radius:26px; background:linear-gradient(160deg,rgba(35,20,75,.98),rgba(10,17,46,.98)); box-shadow:0 26px 80px rgba(0,0,0,.55),inset 0 0 50px rgba(164,120,229,.12); text-align:center; animation:fortuneIn .32s ease-out; }
.fortune-panel::before { content:""; position:absolute; inset:8px; border:1px solid rgba(232,199,125,.22); border-radius:19px; pointer-events:none; }
.fortune-close { position:absolute; top:12px; right:14px; width:40px; height:40px; border:0; border-radius:50%; background:rgba(255,255,255,.08); color:#fff; font-size:1.7rem; cursor:pointer; }
.fortune-star { display:block; color:var(--gold); font-size:2.3rem; text-shadow:0 0 24px #dfc4ff; }
.fortune-label { margin:8px 0 12px; color:var(--gold); font-size:.7rem; letter-spacing:.22em; }
.fortune-panel h2 { margin:0 0 18px; font:500 clamp(1.5rem,5vw,2rem) Georgia,serif; color:#fff7dc; }
.fortune-text { margin:0 auto 26px; max-width:38ch; color:#f4efff; font:italic 1.08rem/1.65 Georgia,serif; }
.fortune-done { min-height:48px; padding:0 24px; border:0; border-radius:999px; color:#171024; background:linear-gradient(135deg,#f5dfa1,#d8ad58); font-weight:700; cursor:pointer; }
@keyframes fortuneIn { from { opacity:0; transform:translateY(16px) scale(.97); } to { opacity:1; transform:none; } }
@keyframes shuffle { 0%,100% { transform: translateX(0) rotate(0); } 35% { transform: translateX(-50px) rotate(-7deg); } 70% { transform: translateX(50px) rotate(7deg); } }
@keyframes echoLeft { 50% { transform: rotate(-11deg) translate(-34px, 4px); } }
@keyframes echoRight { 50% { transform: rotate(11deg) translate(34px, 4px); } }
@media (min-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .card-stage { width: min(34vh, 310px); }
  .reading { padding-top: 10px; }
  .controls { padding-top: 4px; }
  .button { min-width: 180px; }
}
@media (max-height: 720px) { .card-stage { width: min(50vw, 230px); } .guidance { margin-bottom: 8px; } .reading { padding: 8px 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

.guide-content { position:relative; z-index:1; width:min(100% - 36px, 820px); margin:24px auto 48px; padding:clamp(22px,4vw,40px); border:1px solid rgba(232,199,125,.3); border-radius:20px; background:rgba(8,17,43,.95); color:#f4efff; font-size:1rem; line-height:1.75; overflow-wrap:anywhere; }
.guide-content h1 { font-size:clamp(1.8rem,5vw,2.5rem); line-height:1.2; margin:28px 0 18px; }
.guide-content h2 { color:#f4dfa8; font:500 1.55rem/1.3 Georgia,serif; margin:32px 0 14px; }
.guide-content h3 { font-size:1.12rem; line-height:1.4; margin:24px 0 8px; color:#fff2ce; }
.guide-content p { margin:0 0 18px; }
.guide-content a { color:#f6da94; text-underline-offset:4px; }
.guide-content a:focus-visible { outline:2px solid white; outline-offset:4px; }
.guide-content li { margin-bottom:10px; }
.card-directory { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 24px; padding-left:20px; }
.message-directory article { border-top:1px solid rgba(232,199,125,.18); padding:4px 0 12px; scroll-margin-top:24px; }
.guide-return { margin-top:32px !important; }
.guide-return a { text-decoration:none; }
@media(max-width:520px) { .card-directory { grid-template-columns:1fr; } }

.analytics-footer { position:relative; z-index:1; text-align:center; padding:0 20px 28px; }
.analytics-footer button { padding:12px; border:0; background:transparent; color:#f6da94; font:inherit; font-size:.9rem; text-decoration:underline; cursor:pointer; }
.analytics-panel { position:fixed; z-index:30; bottom:16px; left:50%; transform:translateX(-50%); width:min(660px,calc(100% - 24px)); max-height:80vh; overflow:auto; padding:22px; border:1px solid #c6a969; border-radius:18px; background:#11172e; color:#f4efff; box-shadow:0 12px 55px #0009; font:1rem/1.55 system-ui,sans-serif; }
.analytics-panel[hidden], .analytics-panel [hidden] { display:none; }
.analytics-panel h2 { margin:0 0 10px; color:#f4dfa8; font:1.4rem Georgia,serif; }
.analytics-panel p { margin:0 0 12px; }
.analytics-panel a { color:#f6da94; text-underline-offset:3px; }
.analytics-actions { display:flex; flex-wrap:wrap; gap:10px; }
.analytics-actions button { flex:1 1 160px; min-height:44px; border:1px solid #dcc17f; border-radius:10px; padding:10px 14px; background:#252540; color:#fff4d6; font:600 1rem/1.3 system-ui,sans-serif; cursor:pointer; }
.analytics-actions button:hover { background:#383652; }
.analytics-panel :focus-visible, .analytics-footer :focus-visible { outline:2px solid white; outline-offset:3px; }

.header-actions { display:flex; align-items:center; gap:12px; flex-wrap:wrap; justify-content:flex-end; }
.about-link { color:var(--gold); font-size:1rem; padding:12px 4px; text-underline-offset:5px; }
.about-link:focus-visible { outline:2px solid white; outline-offset:4px; }
.support-note { margin-top:32px; padding-top:4px; border-top:1px solid rgba(232,199,125,.3); }
