@font-face { font-family: 'Fell'; src: url('assets/fonts/im-fell-english-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Fell'; font-style: italic; src: url('assets/fonts/im-fell-english-latin-400-italic.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Fell SC'; src: url('assets/fonts/im-fell-english-sc-latin-400-normal.woff2') format('woff2'); font-display: swap; }

:root {
  --ink: #0d1524;
  --ink-2: #152036;
  --ink-3: #1f2f4e;
  --line: #3a4d74;
  --paper: #efe5cb;
  --paper-2: #c6bb9f;
  --paper-3: #8c8672;
  --gold: #f1c240;
  --red: #e45a40;
  --card-ratio: 600 / 1035;
  --serif: 'Fell', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sc: 'Fell SC', 'Fell', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 80% at 50% 38%, #1c2c4b 0%, #0d1524 58%, #070b14 100%) fixed var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 16px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 940px;
  margin: 0 auto;
  padding: max(6px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---- top bar ------------------------------------------------------------ */
#top { flex: none; display: flex; align-items: baseline; justify-content: space-between; height: 30px; }
#title { font-family: var(--sc); letter-spacing: .22em; font-size: 15px; color: var(--paper-2); }
.link { font-family: var(--sc); font-size: 13px; letter-spacing: .12em; color: var(--paper-3); padding: 4px 2px; min-width: 64px; text-align: left; }
#btn-help { text-align: right; }
.link:hover { color: var(--gold); }

/* ---- cards -------------------------------------------------------------- */
.card {
  aspect-ratio: var(--card-ratio);
  border-radius: 5.5% / 3.2%;
  background: #f3ead4;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 8px 22px rgba(0, 0, 0, .5);
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.card img.reversed { transform: rotate(180deg); }

/* Card back: the diagonal hatching of a face-down card in a notebook sketch. */
.backart {
  background:
    radial-gradient(circle at 50% 50%, #132443 0 17%, transparent 17.5%),
    repeating-linear-gradient(135deg, #2a4a7f 0 2px, #1b3260 2px 9px);
  box-shadow: inset 0 0 0 3px #efe5cb, inset 0 0 0 4px #132443, inset 0 0 0 7px #1b3260, inset 0 0 0 8px rgba(239, 229, 203, .55), 0 0 0 1px rgba(0, 0, 0, .35), 0 8px 22px rgba(0, 0, 0, .5);
}
.backart::after {
  content: '✦';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--gold);
  font-size: 150%;
  font-family: Georgia, serif;
}

/* ---- the spread --------------------------------------------------------- */
#spread {
  flex: none;
  height: clamp(86px, 15.5dvh, 176px);
  margin-top: 4px;
  display: flex; justify-content: center; gap: clamp(12px, 5vw, 34px);
}
.slot {
  height: 100%;
  aspect-ratio: var(--card-ratio);
  position: relative;
  border-radius: 5.5% / 3.2%;
  outline: 1px dashed rgba(239, 229, 203, .16);
  outline-offset: -1px;
  cursor: default;
}
.slot .card { width: 100%; height: 100%; transition: transform .25s ease, filter .4s ease, opacity .4s ease; font-size: clamp(11px, 2.4dvh, 20px); }
.slot.ready { cursor: pointer; }
.slot.ready::after {
  content: ''; position: absolute; inset: -5px; border-radius: 9% / 5.2%;
  border: 1.5px solid var(--gold); opacity: 0; pointer-events: none;
  animation: beckon 2.4s ease-in-out infinite;
}
.slot.ready:nth-child(2)::after { animation-delay: .25s; }
.slot.ready:nth-child(3)::after { animation-delay: .5s; }
.slot.ready:hover .card { transform: translateY(-5px); }
.slot.played .card { filter: saturate(.55) brightness(.55); }
.slot.skipped .card { opacity: .3; transform: rotate(7deg) translateY(4px); }
.slot.away .card { visibility: hidden; }
.slot .mark {
  position: absolute; left: 50%; bottom: -3px; transform: translate(-50%, 50%);
  font-size: 10px; color: var(--ink); background: var(--paper-2);
  width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; line-height: 1;
}
#spread.deal .slot { animation: dealIn .45s cubic-bezier(.2, .8, .2, 1) both; }
#spread.deal .slot:nth-child(2) { animation-delay: .09s; }
#spread.deal .slot:nth-child(3) { animation-delay: .18s; }
#spread.clear .slot { animation: dealOut .3s ease-in both; }
@keyframes dealIn { from { transform: translateY(-140%) rotate(-8deg); opacity: 0; } }
@keyframes dealOut { to { transform: translateY(-60%); opacity: 0; } }
@keyframes beckon { 50% { opacity: .7; } }

#mods {
  flex: none; height: 22px; margin-top: 7px;
  display: flex; justify-content: center; gap: 12px; align-items: center;
  font-size: 12.5px; font-style: italic; color: var(--gold); white-space: nowrap; overflow: hidden;
}
#mods b { font-family: var(--sc); font-style: normal; font-weight: normal; letter-spacing: .06em; }

/* ---- the stage: who you are, and the card in front of you --------------- */
#play {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr) auto auto;
  grid-template-areas: 'stage stage' 'left right' 'note note';
  column-gap: 14px;
}
#stage { grid-area: stage; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
#self { height: 90%; max-height: 520px; transition: filter .4s ease, transform .4s ease; }
#self.covered { filter: brightness(.45) saturate(.6); transform: scale(.96); }
#self.swap { animation: selfSwap .7s ease; }
@keyframes selfSwap { 0% { transform: rotateY(90deg) scale(.96); } 100% { transform: none; } }

#active {
  position: absolute; top: 50%; left: 50%; translate: -50% -50%;
  height: 100%; max-height: 578px; aspect-ratio: var(--card-ratio);
  perspective: 1200px;
  cursor: grab; touch-action: none;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  z-index: 3;
}
#active.dragging { transition: none; cursor: grabbing; }
#active.shake { animation: shake .35s ease; }
@keyframes shake { 20% { transform: translateX(-9px); } 50% { transform: translateX(8px); } 80% { transform: translateX(-4px); } }
.flipper { position: absolute; inset: 0; transform-style: preserve-3d; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); font-size: 34px; }

#redraw {
  position: absolute; z-index: 4; top: 2px; right: 0;
  font-family: var(--sc); font-size: 12.5px; letter-spacing: .06em; line-height: 1.15; text-align: center;
  color: var(--ink); background: var(--gold); padding: 7px 11px; border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
}

#toast {
  position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(310px, 92%);
  background: rgba(10, 16, 29, .94); border: 1px solid var(--gold); border-radius: 8px;
  padding: 12px 16px; text-align: center; font-style: italic; font-size: 15px; line-height: 1.3;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  animation: toastIn .25s ease both;
}
#toast b { display: block; font-family: var(--sc); font-style: normal; font-weight: normal; letter-spacing: .14em; color: var(--gold); margin-bottom: 3px; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -40%); } }

/* ---- the two interpretations ------------------------------------------- */
.choice {
  height: 5.5em;
  font-size: clamp(14px, 3.9vw, 17px); line-height: 1.22; font-style: italic;
  display: flex; flex-direction: column; gap: 2px; padding: 8px 2px 0;
  color: var(--paper); opacity: .92;
  transition: opacity .2s ease, color .2s ease, transform .2s ease;
}
.choice.left { grid-area: left; text-align: left; align-items: flex-start; }
.choice.right { grid-area: right; text-align: right; align-items: flex-end; }
.choice .arrow { font-style: normal; color: var(--gold); font-size: 13px; line-height: 1; }
.choice.on { opacity: 1; color: #fff; }
.choice.on .arrow { transform: scale(1.35); }
.choice.off { opacity: .32; }
.choice.blocked { opacity: .3; text-decoration: line-through; cursor: not-allowed; }
.choice.idle { visibility: hidden; }

#note {
  grid-area: note; height: 2.7em; font-size: 12.5px; line-height: 1.3; text-align: center; color: var(--paper-2);
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
}
#note b { font-family: var(--sc); font-weight: normal; letter-spacing: .1em; color: var(--paper); }
#note i { color: var(--gold); }
#note.prompt { font-style: italic; font-size: 15px; color: var(--paper-2); }

/* ---- who you are, and the four traits ----------------------------------- */
#status { flex: none; }
#identity { display: block; width: 100%; text-align: center; min-height: 58px; padding: 4px 0 6px; border-top: 1px solid rgba(58, 77, 116, .5); }
#identity .name { font-family: var(--sc); letter-spacing: .18em; font-size: 15px; color: var(--gold); }
#identity .rule { font-size: 13px; font-style: italic; line-height: 1.25; color: var(--paper-2); max-width: 420px; margin: 0 auto; }
#identity .rule b { font-family: var(--sc); font-style: normal; font-weight: normal; letter-spacing: .05em; color: var(--paper); }
#identity .rule.spent { text-decoration: line-through; opacity: .6; }
#identity .goal { font-size: 12.5px; line-height: 1.25; color: var(--gold); max-width: 420px; margin: 1px auto 0; }

#bars { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 440px; margin: 0 auto; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.cap { height: 13px; font-family: var(--sc); font-size: 10.5px; letter-spacing: .04em; line-height: 13px; white-space: nowrap; color: transparent; }
.cap.end { color: #9c4a3d; font-size: 9px; }
.cap.exit { color: var(--gold); }
.cap.hot { animation: hot .7s ease-in-out infinite alternate; }
.cap.end.hot { color: #ff7358; }
@keyframes hot { to { transform: scale(1.25); text-shadow: 0 0 8px currentColor; } }
.tube {
  display: flex; flex-direction: column-reverse; gap: 2px; width: 30px; padding: 3px;
  border: 1px solid var(--line); border-radius: 4px; background: rgba(0, 0, 0, .28);
  transition: border-color .3s ease;
}
.bar.touched .tube { border-color: var(--gold); }
.seg { height: 5px; border-radius: 1px; background: rgba(239, 229, 203, .09); transition: background .35s ease; }
.seg.want { background: rgba(241, 194, 64, .2); }
.seg.on { background: var(--paper); }
.seg.gain { background: var(--gold); animation: blink .55s ease-in-out infinite alternate; }
.seg.loss { background: var(--red); animation: blink .55s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .45; } }
.delta { position: absolute; top: 15px; left: calc(50% + 21px); height: 60px; display: flex; flex-direction: column; justify-content: center; font-size: 12px; line-height: 1.05; }
.delta.up { color: var(--gold); }
.delta.down { color: var(--red); }
.delta.unknown { color: var(--paper); font-size: 14px; font-style: italic; }
.label { display: flex; align-items: center; gap: 4px; font-family: var(--sc); font-size: 12px; letter-spacing: .08em; color: var(--paper-2); margin-top: 1px; }
.label svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---- overlays: intro, becoming, the reading, the web, rules ------------ */
#overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(7, 11, 20, .93);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  overflow-y: auto; overscroll-behavior: contain;
  animation: fade .3s ease both;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  min-height: 100%; max-width: 560px; margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 22px max(26px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
}
.sheet.top { justify-content: flex-start; }
.kicker { font-family: var(--sc); letter-spacing: .2em; font-size: 13px; color: var(--paper-3); }
.sheet h2 { font-weight: normal; font-size: 27px; line-height: 1.15; margin: 2px 0 0; }
.sheet h2 em { font-style: normal; font-family: var(--sc); letter-spacing: .08em; color: var(--gold); display: block; font-size: 31px; }
.sheet h3 { font-family: var(--sc); font-weight: normal; letter-spacing: .16em; font-size: 14px; color: var(--paper-3); margin: 14px 0 0; }
.sheet p { margin: 0; line-height: 1.42; font-size: 17px; max-width: 30em; }
.sheet p.soft { font-style: italic; color: var(--paper-2); }
.sheet p.small { font-size: 14.5px; color: var(--paper-2); }
.sheet .card.big { height: min(40dvh, 380px); flex: none; }
.btn {
  font-family: var(--sc); letter-spacing: .14em; font-size: 16px;
  color: var(--ink); background: var(--gold); padding: 11px 26px; border-radius: 99px; margin-top: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.btn.ghost { color: var(--paper); background: none; box-shadow: inset 0 0 0 1px var(--line); }
.btn:active { transform: translateY(1px); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.close { position: sticky; top: 0; align-self: flex-end; font-family: var(--sc); letter-spacing: .12em; font-size: 13px; color: var(--paper-2); padding: 6px 0; z-index: 2; }

.rulebox { border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; max-width: 26em; font-size: 15.5px; line-height: 1.35; font-style: italic; color: var(--paper-2); }
.rulebox b { display: block; font-family: var(--sc); font-style: normal; font-weight: normal; letter-spacing: .14em; color: var(--gold); margin-bottom: 2px; }
.exits { list-style: none; padding: 0; margin: 0; font-size: 15.5px; line-height: 1.5; }
.exits b { font-family: var(--sc); font-weight: normal; letter-spacing: .06em; color: var(--gold); }

/* becoming: the old card turns over into the new */
.turncard { height: min(38dvh, 360px); aspect-ratio: var(--card-ratio); position: relative; perspective: 1200px; flex: none; }
.turncard .flipper { transition: transform .9s cubic-bezier(.3, .7, .2, 1); }
.turncard.turned .flipper { transform: rotateY(180deg); }
.turncard .face.back { font-size: inherit; }
.reveal { opacity: 0; transform: translateY(8px); transition: opacity .5s ease .75s, transform .5s ease .75s; }
.turned ~ .reveal, .reveal.in { opacity: 1; transform: none; }

/* the reading */
.path { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.path .card { height: 56px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.fortune { text-align: left; width: 100%; max-width: 30em; }
.fortune h4 { font-family: var(--sc); font-weight: normal; letter-spacing: .14em; font-size: 14px; color: var(--gold); margin: 16px 0 4px; }
.fortune ol { list-style: none; margin: 0; padding: 0; }
.fortune li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(58, 77, 116, .35); font-size: 16px; line-height: 1.3; font-style: italic; }
.fortune li .card { width: 30px; box-shadow: none; border-radius: 2px; }
.fortune li small { display: block; font-family: var(--sc); font-style: normal; font-size: 11.5px; letter-spacing: .08em; color: var(--paper-3); }

/* the web */
.web { position: relative; width: 100%; flex: none; }
.web svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.web line { stroke: var(--line); stroke-width: 1.5; }
.web line.walked { stroke: var(--gold); stroke-width: 2; }
.node { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 5px; width: 84px; }
.node .card { height: 58px; font-size: 9px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 3px 8px rgba(0, 0, 0, .5); }
.node .card.backart { box-shadow: inset 0 0 0 1.5px #efe5cb, inset 0 0 0 2.5px #1b3260, 0 3px 8px rgba(0, 0, 0, .5); opacity: .75; }
.node span { font-family: var(--sc); font-size: 10px; letter-spacing: .04em; color: var(--paper-3); white-space: nowrap; line-height: 1; }
.node.seen span { color: var(--paper-2); }
.node.here .card { box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(241, 194, 64, .6); }
.node.here span, .node.picked span { color: var(--gold); }
.node.picked .card { outline: 1px solid var(--gold); outline-offset: 2px; }
.webinfo {
  position: sticky; bottom: 0; width: calc(100% + 44px); margin: 0 -22px -26px; padding: 12px 22px max(16px, env(safe-area-inset-bottom));
  background: rgba(10, 16, 29, .97); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 132px;
}
.webinfo .name { font-family: var(--sc); letter-spacing: .14em; color: var(--gold); font-size: 17px; }
.webinfo .keys { font-size: 13px; font-style: italic; color: var(--paper-3); }
.webinfo .rule { font-size: 14.5px; font-style: italic; color: var(--paper-2); line-height: 1.3; }
.webinfo .rule b { font-family: var(--sc); font-style: normal; font-weight: normal; color: var(--paper); letter-spacing: .05em; }
.webinfo .exits { font-size: 14.5px; line-height: 1.4; }

/* rules */
.rules { text-align: left; max-width: 30em; }
.rules p { font-size: 16px; margin: 0 0 10px; }
.rules b { font-family: var(--sc); font-weight: normal; letter-spacing: .06em; color: var(--gold); }

/* ---- wide screens: the interpretations flank the card, as in the sketch -- */
@media (min-width: 760px) {
  #play { grid-template-columns: 1fr min(36vw, 340px) 1fr; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: 'left stage right' 'note note note'; column-gap: 18px; }
  .choice { height: auto; align-self: center; font-size: 21px; padding: 12px 6px; gap: 8px; max-width: 280px; }
  .choice.left { text-align: right; align-items: flex-end; justify-self: end; }
  .choice.right { text-align: left; align-items: flex-start; justify-self: start; }
  .choice .arrow { font-size: 16px; }
  #note { font-size: 14px; }
  #identity .name { font-size: 17px; }
  #identity .rule { font-size: 15px; max-width: 560px; }
  #identity .goal { font-size: 14px; max-width: 560px; }
  #bars { max-width: 520px; }
  .tube { width: 36px; }
  .seg { height: 6px; }
  .cap { font-size: 12px; }
  .cap.end { font-size: 10px; }
  .label { font-size: 13.5px; }
  .delta { left: calc(50% + 25px); height: 68px; font-size: 13px; }
  #redraw { right: -150px; top: 0; }
  #spread { height: clamp(96px, 17dvh, 190px); }
}

@media (max-height: 620px) {
  #identity { min-height: 0; }
  #identity .rule, #identity .goal { font-size: 12px; }
  .choice { height: 5.4em; font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .slot.ready::after, .seg.gain, .seg.loss, .cap.hot { animation: none; }
}
