:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eee3d2;
  background: #181512;
  --ink: #eee3d2;
  --muted: #b3a591;
  --line: #c9a77126;
  --accent: #cbaa78;
  --surface: #27211b;
  --card-width: clamp(100px, 16vw, 154px);
  --card-radius: 4px;
  -webkit-text-size-adjust: 100%;
  touch-action: pan-x pan-y;
}
* { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 50% 25%, #63462c1a, transparent 65%),
    repeating-linear-gradient(0deg, #f0d7ae03 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, #00000012 0 1px, transparent 1px 3px),
    linear-gradient(115deg, #100e0c, #201b16 45%, #151210);
  &.detail-open, &.share-open { overflow: hidden; }
}
button, a { -webkit-tap-highlight-color: transparent; touch-action: pan-x pan-y; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 8px; }
[hidden] { display: none !important; }
.reading {
  max-width: 1080px;
  margin: 0 auto;
  padding: max(27px, env(safe-area-inset-top)) max(36px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(36px, env(safe-area-inset-left));
  @media (max-width: 600px) { padding-right: max(22px, env(safe-area-inset-right)); padding-left: max(22px, env(safe-area-inset-left)); }
}
.reading-header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 21px;
  border-bottom: 1px solid var(--line);
  .wordmark {
    flex-shrink: 0;
    text-decoration: none;
    color: var(--ink);
    font: 32px/1 Georgia, "Times New Roman", serif;
    letter-spacing: -.7px;
    img { display: block; width: clamp(140px, 26vw, 200px); height: auto; }
  }
  .edition { text-align: right; font-size: 10px; letter-spacing: .8px; text-transform: uppercase; span { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; letter-spacing: .3px; text-transform: none; } }
}
.introduction {
  text-align: center;
  padding: 32px 0 14px;
  .eyebrow { text-transform: uppercase; font-size: 9px; letter-spacing: 2.3px; margin: 0 0 14px; color: var(--accent); }
  h1 { font: 400 clamp(28px, 4.4vw, 45px)/1.16 Georgia, "Times New Roman", serif; margin: 0 0 13px; letter-spacing: -1.1px; }
  > p:last-child { font-size: 12px; line-height: 1.85; color: var(--muted); margin: 0; }
  @media (max-width: 600px) { padding-top: 27px; }
}
.table {
  max-width: 830px;
  margin: 0 auto;
  text-align: center;
  .deck-area {
    display: grid;
    place-items: center;
    position: relative;
    isolation: isolate;
    padding: 25px 0 5px;
    &::before {
      content: '';
      position: absolute;
      z-index: -1;
      inset: -50px -18px -20px;
      pointer-events: none;
      background:
        radial-gradient(ellipse at 50% 48%, #d99b5142, #b87c3221 36%, transparent 70%);
    }
  }
  .deck-stack { position: relative; z-index: 1; width: 100%; min-height: 242px; display: grid; place-items: center; }
  .deck-halo {
    position: absolute;
    z-index: 0;
    top: 44%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 260px;
    height: 170px;
    border: 1px solid #d5af6926;
    border-radius: 50%;
    background:
      linear-gradient(155deg, transparent 20%, #f5cf8d08 36%, #00000014 40%, transparent 49%, #edbf7e09 65%, transparent 72%),
      radial-gradient(ellipse, #dba35c12, transparent 72%);
    box-shadow: 0 0 55px 20px #d8993c0a;
    pointer-events: none;
  }
  .deck-hint {
    position: relative;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: .5px;
    margin: 21px 0 22px;
    &.is-active { animation: deck-hint-pulse 2s ease-in-out infinite; }
    @media (prefers-reduced-motion: reduce) { &.is-active { animation: none; } }
  }
  .status {
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
    margin: 22px 0 0;
    &:not(.is-error) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  }
  .restart { position: absolute; top: 50%; left: 50%; z-index: 2; transform: translate(-50%, -50%); display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: max-content; min-height: 44px; margin: 0; padding: 12px 20px; background: var(--surface); border: 1px solid #b79869; border-radius: 30px; box-shadow: 0 4px 24px #0009; font-size: 11px; cursor: pointer; svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent); } &:hover { background: #3b3024; } }
  @media (min-width: 701px) {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    grid-template-areas: "deck spread";
    align-items: center;
    column-gap: 30px;
    padding-top: 25px;
    .deck-area { grid-area: deck; align-content: center; }
    .deck-halo { width: 280px; }
    .spread { grid-area: spread; gap: 22px; }
    .status.is-error { grid-column: 1 / -1; }
  }
}
@keyframes deck-hint-pulse {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}
.deck {
  position: relative;
  display: block;
  width: 64px;
  aspect-ratio: 7 / 12;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 1;
  &:disabled { cursor: default; }
  &::after { content: ''; position: absolute; inset: -65% -205%; z-index: 9; }
  .deck-packet { position: absolute; inset: 0; pointer-events: none; will-change: transform; filter: drop-shadow(0 12px 9px #0008) drop-shadow(0 2px 2px #0006); }
  &.complete { .deck-card::before { opacity: .5; } }
}
.deck-card {
  display: block;
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  background: white;
  box-shadow: 0 .35px 0 #9c8b73;
  pointer-events: none;
  &::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: url('./images/back.webp') center / 100% 100% no-repeat; }
}
.spread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 4vw, 36px);
  @media (max-width: 700px) { max-width: 420px; margin-inline: auto; }
  .slot {
    position: relative;
    width: 100%;
    aspect-ratio: 7 / 12;
    border: 1px solid #cbaa7840;
    background: linear-gradient(145deg, #b68c4e08, #00000014);
    box-shadow: inset 0 1px 12px #0000001a;
    border-radius: var(--card-radius);
    display: grid;
    place-items: center;
    perspective: 1000px;
    .slot-number { font: 22px Georgia, serif; color: var(--accent); }
    .slot-caption { position: absolute; bottom: 13%; font-size: 8px; letter-spacing: .5px; color: var(--muted); }
    &.occupied { border-color: transparent; > .slot-number, > .slot-caption { visibility: hidden; } }
  }
}
.chosen-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  border-radius: var(--card-radius);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  &:disabled { cursor: default; }
  &.revealed { transform: rotateY(180deg); }
  .face { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: fill; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 2px 4px #0006, 0 12px 28px #0005; }
  .front { transform: rotateY(180deg); }
  .card-fallback { display: grid; place-content: center; padding: 10px; background: var(--surface); color: var(--ink); font-size: 11px; line-height: 1.5; }
}
.flying-card { display: block; position: fixed; inset: auto; z-index: 10; pointer-events: none; border-radius: var(--card-radius); transform-origin: center; }
.interpretations {
  max-width: 648px;
  margin: 32px auto 0;
  display: grid;
  gap: 18px;
  .meaning { border-top: 1px solid var(--line); padding-top: 16px; display: grid; grid-template-columns: 27px 1fr; column-gap: 10px; .order { color: var(--accent); font: 16px Georgia, serif; padding-top: 2px; } h2 { font: 400 22px Georgia, serif; margin: 0 0 7px; } p { font-size: 12px; line-height: 1.8; color: var(--muted); margin: 0; } }
}
.reading-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  margin-top: 38px;
  padding-top: 17px;
  font-size: 9px;
  line-height: 1.7;
  color: var(--muted);
  .copyright { margin: 0; font-size: 11px; }
  @media (max-width: 600px) { flex-direction: column; text-align: center; gap: 5px; margin-top: 27px; }
}
.share-qr {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  margin-bottom: 48px;
  img { display: block; width: 168px; height: 168px; flex-shrink: 0; border-radius: 4px; filter: sepia(.3) brightness(.85); }
  > span { font-size: 11px; span { display: block; margin-top: 4px; font-size: 9px; color: var(--muted); } }
  @media (max-width: 600px) { align-self: center; margin-top: 36px; }
  @media (max-width: 360px) { flex-direction: column; text-align: center; }
}
.share-actions {
  display: flex;
  flex-direction: column;
  gap: 54px;
}
.share-moment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 12px 20px;
  border: 1px solid #b79869;
  border-radius: 4px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent); }
  &:hover { background: #3b3024; }
}
.share-dialog {
  width: min(540px, calc(100% - 28px));
  max-height: calc(100svh - 32px);
  padding: 24px;
  border: 1px solid #b7986955;
  border-radius: 12px;
  color: var(--ink);
  background: #201b16;
  box-shadow: 0 24px 80px #0009;
  overscroll-behavior: contain;
  &::backdrop { background: #0c0906c9; backdrop-filter: blur(8px); }
  .share-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  h2 { font: 400 27px/1.2 Georgia, serif; margin: 0; }
  p { color: var(--muted); font-size: 13px; line-height: 1.6; }
  label { display: block; margin: 20px 0 10px; font-size: 14px; span { margin-left: 6px; color: var(--muted); font-size: 12px; } }
  textarea { display: block; width: 100%; resize: vertical; min-height: 100px; padding: 12px; border: 1px solid #b7986966; border-radius: 5px; font-family: inherit; font-size: 16px; line-height: 1.5; color: var(--ink); background: #17130f; &:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } }
  .share-hint { margin: 8px 0; font-size: 11px; }
  .share-message { min-height: 21px; }
  .share-close { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; svg { width: 24px; height: 24px; } }
  .share-buttons { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
  .share-submit, .share-download { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 12px 18px; border: 1px solid #b79869; border-radius: 5px; font-size: 14px; text-decoration: none; cursor: pointer; }
  .share-submit { color: #201b16; background: var(--accent); &:disabled { opacity: .6; cursor: wait; } }
  .share-download { color: var(--ink); background: var(--surface); }
  @media (max-width: 400px) { padding: 18px; h2 { font-size: 23px; } }
}
.card-detail {
  width: min(100%, 540px);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0 auto;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  overflow-y: auto;
  overscroll-behavior: contain;
  &::backdrop { background: #0c0906b3; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  &[open] { animation: detail-enter 240ms ease-out; }
  .detail-header { position: sticky; top: 0; z-index: 1; padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left)); background: #201b16f5; border-bottom: 1px solid var(--line); }
  .detail-back { min-height: 44px; padding: 10px 14px; border: 1px solid #b79869; border-radius: 3px; background: var(--surface); font-size: 13px; cursor: pointer; &:hover { background: #3b3024; } }
  .detail-image { display: block; width: 100%; height: auto; aspect-ratio: 7 / 12; object-fit: contain; background: white; }
  .detail-description { padding: 25px max(24px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); background: #201b16; h2 { font: 400 30px/1.2 Georgia, serif; margin: 0 0 14px; } p { font-size: 15px; line-height: 1.8; color: var(--muted); margin: 0; } }
  @media (prefers-reduced-motion: reduce) { &[open] { animation: none; } }
}
@keyframes detail-enter { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
