:root {
  color-scheme: dark;
  --bg: #14100d;
  --panel: #1e1813;
  --line: #3a2f25;
  --bone: #efe4cd;
  --bone-shade: #cbb994;
  --text: #f3ebdd;
  --muted: #a8998a;
  --ember: #c9412a;
  --gold: #e0ad4d;
  --felt: #5a1e1a;
  --radius: 18px;
  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3, .brand { font-family: var(--serif); text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); line-height: 1.2; font-weight: 500; margin: 8px 0 20px; }
h1 em { color: var(--gold); }
h2 { font-size: 1.45rem; line-height: 1.25; }
h3 { font-size: 1.05rem; color: var(--gold); margin-bottom: 4px; }
p { margin: 0 0 12px; text-wrap: pretty; }
[hidden] { display: none !important; }

.top, main { max-width: 520px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 16px; padding-bottom: 8px; }
.brand { font-size: 1.4rem; font-weight: 700; color: var(--bone); text-decoration: none; }
.year-chip { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; white-space: nowrap; }
.top-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-right .year-chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.account { flex: none; min-height: 36px; max-width: 9em; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: none; color: var(--bone); font: 600 .8rem system-ui, sans-serif; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account.in { border-color: var(--gold); color: var(--gold); }
@media (max-width: 440px) { .top-right .year-chip { font-size: .7rem; padding: 4px 8px; } .account { padding: 0 10px; } }
@media (max-width: 340px) { .top-right .year-chip { display: none; } }
/* Google draws its own button inside this box. */
.gsi { display: flex; justify-content: center; min-height: 48px; margin: 20px 0 8px; }
.account-who { display: grid; gap: 2px; margin: 12px 0 20px; }
.account-who span { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }

.view { animation: rise .45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Start screen: two doors, the felt one for shagai and the night-blue one for tarot */
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; perspective: 900px; }
.door {
  display: grid; justify-items: center; align-content: end; gap: 4px; min-height: 310px; padding: 20px 12px 22px;
  border-radius: var(--radius); border: 1px solid #7d3a2c; color: var(--text); font: inherit; text-align: center; cursor: pointer;
  background: radial-gradient(120% 90% at 50% 20%, #7a2a22, var(--felt) 55%, #3d1412);
  box-shadow: inset 0 0 0 6px #4a1915, inset 0 0 0 7px #b8863b55, 0 14px 30px #0006;
  animation: door-in .7s var(--ease) both; transition: transform .35s var(--ease), opacity .3s;
  -webkit-tap-highlight-color: transparent;
}
.door-tarot {
  border-color: #4b4380; animation-delay: .12s;
  background: radial-gradient(120% 90% at 50% 20%, #3a3170, #1f1a3d 55%, #120f24);
  box-shadow: inset 0 0 0 6px #19152f, inset 0 0 0 7px #b8863b55, 0 14px 30px #0006;
}
.door strong { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; color: var(--gold); }
.door small { color: #f3d9c0cc; font-size: .82rem; line-height: 1.35; }
.door-art { position: relative; display: grid; place-items: center; width: 100%; height: 160px; animation: bob 3.6s ease-in-out infinite alternate; }
.door-tarot .door-art { animation-delay: -1.8s; }
.door-art svg { width: 80px; rotate: -10deg; filter: drop-shadow(0 14px 10px #0008); }
.door-card {
  position: absolute; width: 58px; aspect-ratio: 5 / 7; border-radius: 7px; border: 2px solid var(--bone);
  background:
    repeating-linear-gradient(45deg, #e0ad4d33 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-45deg, #e0ad4d33 0 1px, transparent 1px 6px),
    linear-gradient(160deg, #4a3f8f, #2a2357);
  box-shadow: inset 0 0 0 1px #b8863b, 0 8px 10px #0007;
  transform-origin: 50% 160%; transition: rotate .4s var(--ease);
}
.door-card:first-child { rotate: -18deg; }
.door-card:last-child { rotate: 18deg; }
@media (hover: hover) {
  .door:hover { transform: translateY(-6px); }
  .door:hover .door-card:first-child { rotate: -28deg; }
  .door:hover .door-card:last-child { rotate: 28deg; }
}
.door:active { transform: scale(.97); }
.opening .door { opacity: 0; transform: scale(.9); }
.opening .door.chosen { opacity: 1; transform: none; animation: door-open .45s ease-in forwards; }
@keyframes door-in { from { opacity: 0; transform: translateY(40px) rotateX(-28deg); } }
@keyframes door-open { to { opacity: 0; transform: scale(1.5); filter: brightness(1.7); } }
@keyframes bob { to { transform: translateY(-9px); } }
/* The tabs belong to the shagai side; the start screen stands alone */
body:has(#start:not([hidden])) .tabs { display: none; }

/* Felt mat and bones */
.mat {
  position: relative;
  height: 250px;
  border-radius: var(--radius);
  background: radial-gradient(120% 90% at 50% 20%, #7a2a22, var(--felt) 55%, #3d1412);
  border: 1px solid #7d3a2c;
  box-shadow: inset 0 0 0 6px #4a1915, inset 0 0 0 7px #b8863b55, inset 0 30px 60px #0005;
  overflow: hidden;
  margin-bottom: 16px;
}
.mat-hint { position: absolute; inset: auto 0 16px; text-align: center; color: #f3d9c0aa; font-family: var(--serif); font-style: italic; margin: 0; transition: opacity .3s; }
.mat.thrown .mat-hint { opacity: 0; }
.bone {
  position: absolute;
  left: calc(5% + var(--col, 0) * 23.5%);
  top: 34%;
  width: 62px;
  height: 78px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 8px 6px #0007);
  will-change: transform;
}
.bone svg { width: 100%; height: 100%; transform: rotate(var(--r, 0deg)); }
.bone canvas { position: absolute; left: 50%; top: 50%; width: 132px; height: 132px; translate: -50% -50%; }
.bone[data-i="0"] { --col: 0; }
.bone[data-i="1"] { --col: 1; }
.bone[data-i="2"] { --col: 2; }
.bone[data-i="3"] { --col: 3; }
.bone span {
  position: absolute; bottom: -34px; left: 50%; translate: -50% 0;
  font-size: .78rem; color: #f6e3cf; white-space: nowrap; opacity: 0; transition: opacity .3s .1s;
}
.bone.landed span { opacity: 1; }

/* Buttons */
.btn {
  display: block; width: 100%; min-height: 52px;
  border-radius: 14px; border: 1px solid transparent;
  font: 600 1.05rem/1 system-ui, sans-serif; cursor: pointer;
  transition: transform .15s var(--ease), background .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--ember); color: #fff; box-shadow: 0 6px 20px #d4482e44; }
@media (hover: hover) { .btn.primary:hover { background: #cf4429; } }
.btn.ghost { background: transparent; color: var(--bone); border-color: var(--line); }
.btn.gold { background: var(--gold); color: #2a1c05; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
#pay-qpay > .btn { margin-top: 12px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.reveal > * { animation: rise .5s var(--ease) both; }
.reveal > :nth-child(2) { animation-delay: .08s; }
.reveal > :nth-child(3) { animation-delay: .16s; }
.reveal > :nth-child(4) { animation-delay: .24s; }
.reveal > :nth-child(5) { animation-delay: .32s; }
.reveal > :nth-child(n+6) { animation-delay: .4s; }
.faces { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.stars { color: var(--gold); letter-spacing: 3px; font-size: 1.1rem; margin: 6px 0 10px; }
.stars i { color: #6b5a48; font-style: normal; }
.advice { font-family: var(--serif); font-style: italic; color: var(--bone); border-left: 2px solid var(--ember); padding-left: 12px; }
.card .btn { margin-top: 8px; }

.teaser {
  display: block; width: 100%; text-align: left; margin-top: 16px; padding: 16px 20px;
  border-radius: var(--radius); border: 1px solid #6b4d1c; cursor: pointer;
  background: linear-gradient(135deg, #2c2110, #1e1813); color: var(--text); font: inherit;
}
.teaser span { display: block; font-size: .8rem; color: var(--gold); }
.teaser strong { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; }

/* Forms */
.form { display: grid; gap: 10px; margin-top: 0; }
.form label { font-size: .9rem; color: var(--muted); }
.form select {
  width: 100%; min-height: 52px; padding: 0 14px; border-radius: 12px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); font: inherit; font-size: 1.1rem;
}
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; color: var(--text) !important; }
.check input { width: 20px; height: 20px; accent-color: var(--ember); flex: none; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair > div { display: grid; gap: 6px; align-content: start; }

/* Results */
.sign-name { color: var(--gold); font-size: .95rem; margin-bottom: 2px; }
.section { margin-top: 16px; }
.ring {
  --p: 0;
  width: 132px; aspect-ratio: 1; border-radius: 50%; margin: 4px auto 14px;
  display: grid; place-items: center;
  background: radial-gradient(closest-side, var(--panel) 80%, transparent 81%), conic-gradient(var(--ember) calc(var(--p) * 1%), var(--line) 0);
  font: 700 2.1rem var(--serif); color: var(--bone);
}
.center { text-align: center; }
.lucky { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.lucky div { background: var(--bg); border-radius: 12px; padding: 12px; }
.lucky small { display: block; color: var(--muted); font-size: .78rem; }
.locked { position: relative; margin-top: 16px; border-radius: 14px; overflow: hidden; border: 1px solid #6b4d1c; padding: 18px; }
.locked-count { color: var(--bone); font-weight: 600; margin-bottom: 6px; }
.locked ul { list-style: none; padding: 0; margin: 0 0 14px; color: var(--muted); }
.locked li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.locked li::after { content: '🔒'; font-size: .8rem; filter: grayscale(1); opacity: .7; }
.price-note { text-align: center; color: var(--muted); font-size: .85rem; margin: 8px 0 0; }

.fine { color: var(--muted); font-size: .78rem; text-align: center; margin: 24px 0 8px; }

/* Bottom tabs */
.tabs {
  position: fixed; inset: auto 0 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #14100df2; backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  min-height: 60px; background: none; border: 0; color: var(--muted);
  font: 600 .82rem system-ui, sans-serif; padding: 0 2px; cursor: pointer; position: relative;
}
.tabs button[aria-current] { color: var(--bone); }
.tabs button[aria-current]::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--ember); border-radius: 2px; }

/* Payment sheet */
dialog {
  max-height: 92dvh; overflow-y: auto;
  width: min(480px, 100%); max-width: 100%; margin: auto auto 0; border: 0;
  border-radius: 22px 22px 0 0; background: var(--panel); color: var(--text);
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
}
dialog[open] { animation: sheet .35s var(--ease); }
@keyframes sheet { from { transform: translateY(100%); } }
dialog::backdrop { background: #000a; backdrop-filter: blur(2px); }
.close { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; background: none; border: 0; color: var(--muted); font-size: 1.7rem; cursor: pointer; }
.pay-lead { color: var(--muted); margin-top: 8px; }
.pay-rows { margin: 16px 0; display: grid; gap: 8px; }
.pay-rows div { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bg); border-radius: 12px; padding: 10px 14px; }
.pay-rows div div { display: block; padding: 0; background: none; min-width: 0; }
.pay-rows dt { color: var(--muted); font-size: .82rem; }
.pay-rows dd { margin: 0; font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.pay-rows .code dd { color: var(--gold); font-size: 1.3rem; letter-spacing: 2px; white-space: nowrap; }
.pay-rows button { flex: none; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: none; color: var(--bone); cursor: pointer; font: inherit; font-size: .85rem; }
.pay-must { color: var(--text); font-size: .95rem; margin: 12px 0 0; }
.pay-must b { color: var(--gold); }
#pay-transfer summary { cursor: pointer; color: var(--muted); padding: 12px 0; min-height: 44px; }
#pay-transfer.only summary { display: none; }
.pay-banks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.pay-banks a { display: grid; place-items: center; min-height: 48px; padding: 6px 10px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); color: var(--text); text-decoration: none; text-align: center; font-weight: 600; font-size: .92rem; }
.pay-qr { display: block; width: 200px; max-width: 60%; margin: 12px auto; border-radius: 12px; background: #fff; padding: 8px; }
.pay-hint { color: var(--muted); font-size: .85rem; text-align: center; }
.pay-status { text-align: center; color: var(--gold); min-height: 1.6em; }
.pay-status.wait::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); margin-right: 8px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); translate: -50% 20px;
  background: var(--bone); color: #1a130c; padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .25s, translate .25s var(--ease); z-index: 20; width: max-content; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; translate: -50% 0; }

@media (min-width: 720px) {
  .mat { height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* Quiz */
.quiz { margin-top: 0; }
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 28px; }
.progress { flex: 1; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 20%; background: var(--gold); border-radius: 99px; transition: width .35s var(--ease); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 12px; }
.quiz fieldset:not([hidden]) { animation: rise .35s var(--ease); }
legend { font-family: var(--serif); font-size: 1.35rem; line-height: 1.3; padding: 0; margin-bottom: 12px; text-wrap: balance; }
.form legend { font: inherit; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
input[type="text"], .quiz select {
  width: 100%; min-height: 52px; padding: 0 14px; border-radius: 12px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); font: inherit; font-size: 1.1rem;
}
.dob { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr; gap: 8px; }
.choices { display: grid; gap: 8px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choices label {
  display: flex; align-items: center; min-height: 52px; padding: 8px 16px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); font-size: 1.02rem; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choices input { position: absolute; opacity: 0; }
.choices label:has(:checked) { border-color: var(--gold); background: #2c2110; }
.choices label:has(:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; padding: 0; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }
.quiz-top .link { text-decoration: none; min-height: 28px; }
.card > .link { display: block; margin: 4px auto 0; }

/* Preparing */
.calc h2 { margin-bottom: 12px; }
.calc-line { margin: 0; padding: 8px 0 8px 28px; position: relative; color: var(--bone); animation: rise .4s var(--ease); }
.calc-line::before { content: '✓'; position: absolute; left: 4px; color: var(--gold); font-weight: 700; }

/* Reading */
.motto { margin: 16px 0; }
.motto small { color: var(--muted); display: block; margin-bottom: 6px; }
.motto .advice { margin: 0; }
.teaser-line { font-family: var(--serif); font-size: 1.1rem; color: var(--bone); margin-top: 20px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 14px; }
.key { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.key small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.35; margin-bottom: 4px; }
.key strong { display: block; font-family: var(--serif); font-size: 1.15rem; color: var(--gold); overflow-wrap: anywhere; }
.blur { filter: blur(6px); user-select: none; pointer-events: none; }
p.blur { color: var(--muted); margin-bottom: 0; }
.cal { list-style: none; padding: 0; margin: 8px 0 0; }
.cal li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.cal-head { display: flex; align-items: baseline; gap: 8px; }
.cal-head small { color: var(--muted); font-size: .8rem; }
.cal-head .stars { margin: 0 0 0 auto; font-size: .9rem; letter-spacing: 1px; }
.cal-lock { margin-left: auto; color: var(--muted); font-size: .78rem; }
.cal p { margin: 6px 0 0; }
.price-note.left { text-align: left; margin: 0; }
h3.section { margin-bottom: 0; }
.cal p.blur { white-space: nowrap; overflow: hidden; }
.cal li:has(.blur) { padding: 8px 0; }
.key:last-child:nth-child(odd) { grid-column: span 2; }
legend:focus { outline: none; }

/* Free answer, invite, sticky unlock */
button.key { font: inherit; color: inherit; text-align: left; cursor: pointer; border-color: #6b4d1c; transition: transform .15s var(--ease), border-color .15s; }
button.key:active { transform: scale(.97); }
button.key:disabled { opacity: .6; cursor: default; }
button.key span { display: block; margin-top: 6px; font-size: .78rem; font-weight: 600; color: var(--gold); }
.reveal-note { color: var(--bone); margin: 0 0 14px; }
.reveal-note p { margin-bottom: 8px; }
.sticky {
  position: fixed; inset: auto 0 calc(60px + env(safe-area-inset-bottom)); z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: #1e1813f2; backdrop-filter: blur(12px); border-top: 1px solid #6b4d1c;
  animation: rise .35s var(--ease);
}
.sticky span { font-family: var(--serif); color: var(--bone); min-width: 0; }
.sticky .btn { width: auto; min-height: 44px; padding: 0 18px; font-size: .95rem; flex: none; }
body.has-sticky { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
body.has-sticky .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
#proof { margin: 10px 0 0; }

/* From QA: narrow screens and long names */
.dob { grid-template-columns: 1.15fr 1.35fr 1fr; gap: 6px; }
.dob select { padding: 0 8px; font-size: 1rem; }
.card { overflow-wrap: anywhere; }
dialog .toast { bottom: 24px; }

/* Home hub: one card per extra hook */
.hub-title { font-size: 1.1rem; color: var(--muted); font-weight: 500; margin: 28px 0 10px; }
.hub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hub-card {
  text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font: inherit; cursor: pointer; min-height: 96px; display: grid; align-content: start; gap: 4px;
  transition: transform .15s var(--ease), border-color .15s;
}
.hub-card:active { transform: scale(.97); }
.hub-card span { font-size: .72rem; color: var(--gold); }
.hub-card strong { font-family: var(--serif); font-weight: 500; font-size: 1.05rem; line-height: 1.25; }
.hub-card small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.view > .link { display: block; min-height: 36px; text-decoration: none; }

/* Long month labels on narrow screens: the animal name gives way, the stars stay on the line */
.cal-head b { white-space: nowrap; }
.cal-head small { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
