/* Layout: one narrow column, like a single card dealt onto a stone table. */
:root {
  --bg: #e3e7e2;
  --card: #f4f6f2;
  --ink: #1c2320;
  --muted: #56625d;
  --line: #c6cec8;
  --accent: #8b2a2c;
  --gold: #9a6a17;
  --good: #2c7448;
  --good-bg: #dcefe2;
  --bad: #a3392d;
  --bad-bg: #f5dfdb;
  --gold-soft: rgba(196, 140, 40, .32);
  --ember: 190, 110, 40;           /* r,g,b for the canvas embers */
  --ember-alpha: .28;
  --torch: rgba(214, 150, 60, .10);
  --shade: rgba(40, 32, 22, .07);
  --flame-a: #e0892a; --flame-b: #f3c552; --flame-core: #fff1c4;
  --f-display: "Grenze Gotisch", Georgia, serif;
  --f-body: "Alegreya", Georgia, "Times New Roman", serif;
  --f-label: "Alegreya Sans SC", "Alegreya Sans", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --card: #1a201d; --ink: #e6ebe5; --muted: #95a39c; --line: #2f3a35;
    --accent: #d8665f; --gold: #d9a94c; --good: #66c48c; --good-bg: #1d3426; --bad: #e57a69; --bad-bg: #3a211d; --gold-soft: rgba(217, 169, 76, .30); --ember: 240, 160, 70; --ember-alpha: .55; --torch: rgba(226, 150, 60, .13); --shade: rgba(0, 0, 0, .38); --flame-a: #e8792a; --flame-b: #f6c757; --flame-core: #fff4d2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111614; --card: #1a201d; --ink: #e6ebe5; --muted: #95a39c; --line: #2f3a35;
  --accent: #d8665f; --gold: #d9a94c; --good: #66c48c; --good-bg: #1d3426; --bad: #e57a69; --bad-bg: #3a211d; --gold-soft: rgba(217, 169, 76, .30); --ember: 240, 160, 70; --ember-alpha: .55; --torch: rgba(226, 150, 60, .13); --shade: rgba(0, 0, 0, .38); --flame-a: #e8792a; --flame-b: #f6c757; --flame-core: #fff4d2;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 18px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(20px, env(safe-area-inset-top, 0px)) 56px;
}
a { color: var(--accent); }
.wrap { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

nav.top { display: flex; justify-content: flex-end; gap: 4px; flex-wrap: wrap; font-family: var(--f-label); letter-spacing: .06em; }
nav.top a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 4px; }
nav.top a:hover { color: var(--ink); }
nav.top a[aria-current="page"] { color: var(--ink); background: var(--card); border: 1px solid var(--line); }

header.brand { display: flex; align-items: center; gap: 16px; }
.die { width: 64px; height: 64px; flex: none; color: var(--accent); }
.die text { fill: var(--ink); font-family: var(--f-label); font-weight: 700; }
.brand > div { min-width: 0; }
h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(2.2rem, 7vw, 3rem); line-height: 1; margin: 0; letter-spacing: .01em; }
h1 a { color: inherit; text-decoration: none; }
.sub { font-family: var(--f-label); color: var(--muted); font-size: .95rem; letter-spacing: .06em; margin-top: 4px; }

.pips { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.pip { height: 8px; border-radius: 2px; background: var(--line); transition: background .25s; }
.pip.now { background: var(--ink); }
.pip.ok { background: var(--good); }
.pip.no { background: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 26px 24px; display: flex; flex-direction: column; gap: 18px; }
.meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: var(--f-label); font-size: .9rem; letter-spacing: .07em; color: var(--muted); }
.meta .cat { color: var(--accent); font-weight: 700; }
.q { font-size: 1.4rem; line-height: 1.35; font-weight: 500; margin: 0; text-wrap: balance; }

.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  font: inherit; font-size: 1.05rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px;
  padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
}
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt:active:not(:disabled) { transform: translateY(1px); }
.opt:focus-visible, .btn:focus-visible, input:focus-visible, nav.top a:focus-visible, .day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt .key { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-family: var(--f-label); font-weight: 700; font-size: .9rem; color: var(--muted); }
.opt span:last-child { min-width: 0; }
.opt:disabled { cursor: default; }
.opt.right { background: var(--good-bg); border-color: var(--good); }
.opt.right .key { background: var(--good); border-color: var(--good); color: var(--card); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: var(--card); }
.opt.dim { opacity: .55; }

.lore { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.verdict { font-family: var(--f-label); font-weight: 700; letter-spacing: .06em; }
.verdict.ok { color: var(--good); } .verdict.no { color: var(--bad); }
.lore p { margin: 0; color: var(--muted); }

.btn {
  font-family: var(--f-label); font-weight: 700; font-size: 1rem; letter-spacing: .08em;
  background: var(--accent); color: var(--card); border: 0; border-radius: 5px;
  padding: 12px 20px; cursor: pointer; align-self: flex-start; text-decoration: none; display: inline-block;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
/* Google's sign-in button: white surface, Google colours in the mark only. */
.btn.google { display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #1f1f1f; border: 1px solid #747775; font-family: "Roboto", system-ui, sans-serif; font-weight: 500; letter-spacing: .01em; }

.result { align-items: center; text-align: center; }
.bigdie { width: 150px; height: 150px; color: var(--gold); }
.bigdie text { fill: var(--ink); font-family: var(--f-display); font-weight: 800; }
.rank { font-family: var(--f-display); font-size: 2.1rem; line-height: 1; margin: 0; }
.rank-note { color: var(--muted); margin: 0; max-width: 40ch; }
.grid { font-size: 1.4rem; letter-spacing: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.row.start { justify-content: flex-start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.next { font-family: var(--f-label); color: var(--muted); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.toast { font-family: var(--f-label); color: var(--good); min-height: 1.2em; font-size: .95rem; }
.share-fallback { width: 100%; font: inherit; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 5px; padding: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--f-display); font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-family: var(--f-label); font-size: .8rem; color: var(--muted); letter-spacing: .06em; }

h2 { font-family: var(--f-label); font-size: 1rem; letter-spacing: .1em; color: var(--muted); margin: 0; font-weight: 700; }
.review { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.review li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.review .mark { font-family: var(--f-label); font-weight: 700; }
.review .mark.ok { color: var(--good); } .review .mark.no { color: var(--bad); }
.review .rq { margin: 0; font-weight: 500; }
.review .ra { margin: 0; color: var(--muted); font-size: .95rem; }

.how { color: var(--muted); font-size: .95rem; margin: 0; text-align: center; }
.notice { margin: 0; color: var(--muted); }
.title { font-family: var(--f-display); font-size: 2rem; line-height: 1.05; margin: 0; text-wrap: balance; }

/* Subscribe panel */
.offer { border-color: var(--gold); }
.price { font-family: var(--f-display); font-size: 2.4rem; line-height: 1; margin: 0; }
.price small { font-family: var(--f-label); font-size: 1rem; color: var(--muted); letter-spacing: .06em; }
.perks { margin: 0; padding-left: 1.1em; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

/* Archive */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.day {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 12px 14px;
}
a.day:hover { border-color: var(--ink); }
.day b { font-family: var(--f-label); letter-spacing: .06em; }
.day span { font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.day .s-ok { color: var(--good); font-weight: 700; }
.day.locked { opacity: .7; }

/* Forms */
form.signin { display: flex; gap: 10px; flex-wrap: wrap; }
form.signin input {
  flex: 1 1 220px; min-width: 0; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 5px; padding: 11px 12px;
}
.msg { margin: 0; font-family: var(--f-label); letter-spacing: .04em; }
.msg.ok { color: var(--good); } .msg.err { color: var(--bad); }
dl.acct { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.acct dt { font-family: var(--f-label); color: var(--muted); letter-spacing: .06em; }
dl.acct dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 480px) {
  body { font-size: 17px; }
  .card { padding: 20px 16px; }
  .q { font-size: 1.25rem; }
  .stats { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
}
/* ---------- Atmosphere: torchlight and embers sit behind the page ---------- */
.torch, #embers { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.torch {
  background:
    radial-gradient(60vmax 45vmax at -8% -12%, var(--torch), transparent 70%),
    radial-gradient(60vmax 45vmax at 108% -12%, var(--torch), transparent 70%),
    radial-gradient(120vmax 80vmax at 50% 50%, transparent 55%, var(--shade) 100%);
  animation: torchlight 7s ease-in-out infinite;
}
@keyframes torchlight { 0%, 100% { opacity: 1; } 23% { opacity: .82; } 41% { opacity: .95; } 67% { opacity: .86; } }
.wrap { position: relative; z-index: 1; }

/* ---------- Header die: tumbles on every answer, lands on 20 or 1 ---------- */
.die { transition: color .3s, filter .3s; transform-origin: 50% 50%; }
.die.rolling { animation: tumble .62s cubic-bezier(.25,.7,.3,1.25); }
.die.hit { color: var(--gold); filter: drop-shadow(0 0 6px var(--gold-soft)); }
.die.miss { color: var(--bad); }
@keyframes tumble {
  0% { transform: rotate(0) scale(1); }
  35% { transform: rotate(220deg) scale(1.14) translateY(-4px); }
  70% { transform: rotate(345deg) scale(.95); }
  100% { transform: rotate(360deg) scale(1); }
}

/* ---------- Answer reactions ---------- */
.opts { position: relative; }
.opt { position: relative; overflow: hidden; }
.opt.pop::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 15%, var(--gold-soft) 50%, transparent 85%);
  animation: sweep .75s ease-out both;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.opt.pop .key { animation: keypop .5s cubic-bezier(.3,1.7,.5,1); }
@keyframes keypop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.opt.shake { animation: shake .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 15%, 85% { transform: translateX(-2px); } 30%, 70% { transform: translateX(5px); } 45%, 60% { transform: translateX(-6px); } }
.opt.glow { animation: glow 1.1s ease-out .35s 2 both; }
@keyframes glow { from { box-shadow: 0 0 0 0 var(--good); } to { box-shadow: 0 0 0 8px transparent; } }
.spark {
  position: absolute; left: var(--x); top: var(--y); width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold); pointer-events: none; z-index: 2;
  animation: spark .7s cubic-bezier(.15,.7,.35,1) both;
}
@keyframes spark {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; }
}
.lore.enter { animation: rise .4s ease-out .15s both; }
#nextBtn.enter { animation: rise .4s ease-out .3s both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Results: staged reveal ---------- */
.reveal .bigdie { animation: land 1.05s cubic-bezier(.2,.75,.25,1.15) both; }
@keyframes land {
  0% { transform: translateY(-30px) rotate(-260deg) scale(.55); opacity: 0; }
  60% { transform: translateY(4px) rotate(14deg) scale(1.05); opacity: 1; }
  80% { transform: rotate(-5deg); }
  100% { transform: none; }
}
.bigdie.landed { filter: drop-shadow(0 0 14px var(--gold-soft)); transition: filter .5s; }
.tiles { display: flex; gap: 6px; justify-content: center; perspective: 600px; }
.tile {
  width: 26px; height: 26px; border-radius: 4px; display: grid; place-items: center;
  font-family: var(--f-label); font-weight: 700; font-size: .85rem; color: var(--card);
}
.tile.ok { background: var(--good); }
.tile.no { background: var(--bad); }
.reveal .tile { animation: flip .5s cubic-bezier(.3,1.3,.5,1) calc(1.05s + var(--i, 0) * 90ms) both; }
@keyframes flip { from { transform: rotateY(90deg) scale(.8); opacity: .2; } to { transform: none; opacity: 1; } }
.rank-block { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.seal { width: 54px; height: 54px; color: var(--accent); transform: rotate(-12deg); flex: none; }
.seal .wax { fill: currentColor; }
.seal .ring { fill: none; stroke: var(--card); stroke-opacity: .5; stroke-width: 2; }
.seal .mark { fill: none; stroke: var(--card); stroke-width: 3; }
.reveal .rank-block { animation: stamp .55s cubic-bezier(.2,1.5,.4,1) 2.05s both; }
@keyframes stamp {
  0% { transform: scale(2.3) rotate(-6deg); opacity: 0; }
  60% { transform: scale(.94) rotate(1deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
.reveal.card { animation: thud .3s ease-out 2.4s; }
@keyframes thud { 40% { transform: translateY(3px); } }
.reveal .after { animation: rise .5s ease-out 2.6s both; }

/* ---------- Streak flame ---------- */
.streak {
  margin-left: auto; align-self: center; flex: none;
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--f-label); font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums;
}
.streak svg { width: var(--fs, 26px); height: calc(var(--fs, 26px) * 1.3); overflow: visible; }
.streak.t1 { --fs: 22px; } .streak.t2 { --fs: 28px; } .streak.t3 { --fs: 34px; } .streak.t4 { --fs: 40px; }
.streak .outer { fill: var(--flame-a); } .streak .inner { fill: var(--flame-b); } .streak .core { fill: var(--flame-core); }
.streak.t4 .core { fill: #cfe8ff; }
.streak .flame { transform-origin: 50% 100%; animation: flicker 1.6s ease-in-out infinite; }
.streak .inner { transform-origin: 50% 100%; animation: flicker 1.1s ease-in-out infinite reverse; }
@keyframes flicker { 0%, 100% { transform: scale(1, 1) skewX(0); } 30% { transform: scale(.96, 1.06) skewX(-3deg); } 60% { transform: scale(1.03, .95) skewX(2deg); } }
.streak.cold { color: var(--muted); }
.streak.cold svg { filter: grayscale(1); opacity: .55; }
.streak.cold .flame, .streak.cold .inner { animation: none; }
.streak.flare svg { animation: flare .9s ease-out; }
@keyframes flare { 30% { transform: scale(1.35); filter: drop-shadow(0 0 10px var(--flame-b)); } }
.badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--gold); color: var(--gold); font-family: var(--f-label); font-weight: 700; font-size: .85rem; letter-spacing: .04em;
}
.badge.new { background: var(--gold-soft); }
.badge.locked { border-color: var(--line); color: var(--muted); }

/* ---------- Moving to the next question ---------- */
#play.sizing { transition: height .32s cubic-bezier(.25,.8,.3,1); overflow: hidden; }
.q-out > * { animation: q-out .19s ease-in both; }
@keyframes q-out { to { opacity: 0; transform: translateX(-16px); } }
.q-in > :not(.opts) { animation: q-in .32s cubic-bezier(.2,.75,.3,1) both; }
.q-in > .q { animation-delay: .05s; }
.q-in .opt { animation: q-in .32s cubic-bezier(.2,.75,.3,1) both; }
.q-in .opt:nth-child(1) { animation-delay: .1s; }
.q-in .opt:nth-child(2) { animation-delay: .15s; }
.q-in .opt:nth-child(3) { animation-delay: .2s; }
.q-in .opt:nth-child(4) { animation-delay: .25s; }
@keyframes q-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@keyframes settle { from { transform: rotate(-200deg) scale(.6); } to { transform: none; } }
.bigdie.roll { animation: settle .7s cubic-bezier(.2,.8,.2,1); }

/* Footer and policy page */
.site-foot { display: flex; justify-content: center; gap: 10px; font-family: var(--f-label); letter-spacing: .06em; color: var(--muted); padding: 8px 0 4px; }
.site-foot a { color: var(--muted); text-decoration: none; padding: 4px 6px; }
.site-foot a:hover, .site-foot a:focus-visible { color: var(--ink); text-decoration: underline; }
.prose { gap: 12px; line-height: 1.6; }
.prose h2 { margin: 0; font-size: 1.7rem; color: var(--ink); letter-spacing: 0; text-transform: none; }
.prose h3 { margin: 14px 0 0; font-family: var(--f-label); letter-spacing: .04em; }
.prose p, .prose ul { margin: 0; }
.prose ul { padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.prose a { color: var(--accent); overflow-wrap: anywhere; }
.prose .meta { color: var(--muted); }
