/*
  VOICE: a late-night card table, playful and a little flashy.
  IDEA: the page is a casino table. Prompts are dealt on playing cards, progress is a stack of chips,
        and the Long Shot ladder is a lit-up marquee.
  COLOUR: deep felt green, gold trim, chip red, ivory card faces with near-black ink.
  TYPE: Bungee for marquee numbers and titles, Figtree for reading.
  LAYOUT: one column. The marquee sits on top, chips under it, then the dealt card.
*/
:root {
  --felt: #0c6b45;
  --felt-deep: #053421;
  --felt-edge: #021a10;
  --gold: #f5c542;
  --gold-deep: #b8860b;
  --gold-soft: #ffe8a3;
  --red: #e0233c;
  --red-deep: #9e0f24;
  --ivory: #fffaf0;
  --ink: #17140f;
  --ink-soft: #5d5648;
  --text: #fff8e6;
  --muted: #bfe3cf;
  --win: #11a868;
  --radius: 18px;
  --display: "Bungee", "Arial Black", Impact, sans-serif;
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; color: var(--text); }
html {
  background: var(--felt-deep);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100vh; min-height: 100dvh; display: flex;
  overscroll-behavior-y: none;
  /* Keep clear of the notch, the Dynamic Island and the home bar. */
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); flex-direction: column; align-items: center; overflow-x: clip;
}
/* iPhone Safari ignores background-attachment: fixed, so the felt lives on a fixed layer. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(255, 236, 170, .16), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 40%, var(--felt) 0%, var(--felt-deep) 70%, var(--felt-edge) 100%);
}
/* fine felt grain */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .12;
  background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, .35) 0 1px, transparent 1px 4px);
}
[hidden] { display: none !important; }
a { color: var(--red-deep); font-weight: 600; }

/* ---------- header ---------- */
.top {
  position: relative; width: 100%; max-width: 580px; padding: calc(16px + env(safe-area-inset-top)) 20px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.75rem; letter-spacing: .5px;
  color: var(--gold); text-shadow: 0 2px 0 var(--gold-deep), 0 0 18px rgba(245, 197, 66, .45);
}
.logo span { color: var(--red); text-shadow: 0 2px 0 var(--red-deep), 0 0 14px rgba(224, 35, 60, .5); }
.meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 700; }
.streak {
  padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, .3);
  border: 1px solid rgba(245, 197, 66, .4);
}
.streak b { color: var(--gold); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-weight: 800; font-size: 1rem;
  background: var(--ivory); color: var(--ink); border: 3px dashed var(--red);
  box-shadow: 0 2px 0 var(--red-deep);
}

main { position: relative; width: 100%; max-width: 580px; padding: 4px 18px 32px; }

/* ---------- Long Shot marquee ---------- */
.climb {
  position: relative; margin-bottom: 16px; padding: 22px 18px 14px; border-radius: var(--radius);
  background: linear-gradient(160deg, #b0122c, #6d0a1b 75%);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 3px var(--gold-deep), 0 10px 30px rgba(0, 0, 0, .45), inset 0 0 30px rgba(0, 0, 0, .35);
}
/* marquee bulbs */
.climb::before, .climb::after {
  content: ""; position: absolute; left: 14px; right: 14px; height: 8px;
  background: radial-gradient(circle, var(--gold-soft) 0 2.5px, rgba(255, 232, 163, .35) 3.5px, transparent 4.5px) 0 0 / 18px 8px repeat-x;
  filter: drop-shadow(0 0 3px var(--gold));
}
.climb::before { top: 6px; }
.climb::after { bottom: 4px; }
.climb-now { display: flex; align-items: center; gap: 12px; }
.climb-icon {
  font-size: 1.9rem; width: 54px; height: 54px; flex: none; display: grid; place-items: center;
  background: var(--ivory); border-radius: 12px; border: 2px solid var(--gold);
  box-shadow: 0 3px 0 var(--gold-deep);
}
.climb-text { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.climb-text small { color: var(--gold-soft); font-size: .78rem; font-weight: 600; opacity: .9; }
.climb-text b { font-family: var(--display); font-weight: 400; font-size: 1.15rem; color: #fff; }
.climb-odds { color: var(--gold); font-size: .95rem; font-weight: 800; }
.climb-score { text-align: right; }
.climb-score b {
  display: block; font-family: var(--display); font-weight: 400; font-size: 1.9rem; line-height: 1;
  color: var(--gold); text-shadow: 0 2px 0 var(--gold-deep);
}
.climb-score small { color: var(--gold-soft); font-size: .75rem; }
.climb-track {
  position: relative; height: 12px; border-radius: 6px; margin: 14px 0 8px;
  background: rgba(0, 0, 0, .45); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .6);
}
.climb-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-soft));
  box-shadow: 0 0 14px rgba(245, 197, 66, .8);
  transition: width .9s cubic-bezier(.2, .8, .2, 1);
}
.rung {
  position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%;
  background: #4d0a16; border: 2px solid rgba(255, 232, 163, .4); transform: translate(-50%, -50%);
}
.rung.on { background: #fff; border-color: var(--gold); box-shadow: 0 0 8px var(--gold); }
.climb-next { margin: 0; color: #ffd9de; font-size: .86rem; }
.climb-next b { color: #fff; }
.climb.level-up { animation: marquee-flash 1.2s ease; }
@keyframes marquee-flash {
  0%, 100% { filter: none; }
  25%, 65% { filter: brightness(1.35) saturate(1.2); }
  45% { filter: brightness(1.05); }
}

/* ---------- progress chips ---------- */
.progress { list-style: none; display: flex; gap: 8px; justify-content: center; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.progress li {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; color: var(--ivory);
  background: radial-gradient(circle, #1d4d37 0 52%, transparent 53%), #0e2c20;
  border: 4px dashed rgba(255, 250, 240, .35);
}
.progress li.done { background: radial-gradient(circle, var(--ivory) 0 52%, transparent 53%), var(--red); border-color: rgba(255, 255, 255, .85); }
.progress li.current {
  background: radial-gradient(circle, var(--gold-soft) 0 52%, transparent 53%), var(--gold-deep);
  border-color: #fff; color: var(--ink); transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .4), 0 0 16px rgba(245, 197, 66, .6);
}

/* ---------- the dealt card ---------- */
.card {
  position: relative; background: var(--ivory); color: var(--ink);
  border-radius: var(--radius); padding: 30px 26px 26px;
  box-shadow: 0 1px 0 #fff inset, 0 18px 40px rgba(0, 0, 0, .5), 0 0 0 1px rgba(0, 0, 0, .1);
}
/* corner pips, like a playing card */
.card::before, .card::after {
  position: absolute; font-family: var(--display); font-size: 1.05rem; line-height: 1; color: var(--red);
  content: "%";
}
.card::before { top: 12px; left: 14px; }
.card::after { bottom: 12px; right: 14px; transform: rotate(180deg); }
.q-count { color: var(--red); margin: 0 0 6px; font-size: .85rem; font-weight: 800; }
.q-text { margin: 0 0 18px; font-size: 1.4rem; line-height: 1.3; font-weight: 800; text-wrap: balance; }

.guess-display {
  text-align: center; font-family: var(--display); font-size: clamp(3rem, 14vw, 4rem); line-height: 1.1;
  color: var(--red); text-shadow: 0 3px 0 rgba(158, 15, 36, .25);
}
.guess-display span { font-size: .6em; margin-left: 2px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 14px; margin: 10px 0 18px;
  border-radius: 7px; background: linear-gradient(90deg, #dfe9e3, #c8d8ce); outline-offset: 4px;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .15);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 34px; height: 34px; border-radius: 50%; cursor: grab;
  background: radial-gradient(circle, var(--ivory) 0 40%, transparent 42%), var(--red);
  border: 4px dashed #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
}
input[type="range"]::-moz-range-thumb {
  width: 30px; height: 30px; border-radius: 50%; cursor: grab;
  background: radial-gradient(circle, var(--ivory) 0 40%, transparent 42%), var(--red);
  border: 4px dashed #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
}
.fine-tune { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.fine-tune input {
  width: 90px; text-align: center; font-size: 1.15rem; font-weight: 700; padding: 10px;
  background: #fff; color: var(--ink); border: 2px solid #d9cfb8; border-radius: 12px;
}
.nudge {
  width: 48px; border-radius: 12px; border: 2px solid #d9cfb8; cursor: pointer;
  background: #fff; color: var(--ink); font-size: 1.4rem; font-weight: 700;
}
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.primary {
  display: block; width: 100%; padding: 15px; border-radius: 14px; cursor: pointer;
  font-family: var(--display); font-weight: 400; font-size: 1.1rem; letter-spacing: .5px;
  color: var(--ink); background: linear-gradient(180deg, var(--gold-soft), var(--gold) 45%, #e0a91c);
  border: 0; box-shadow: 0 4px 0 var(--gold-deep), 0 8px 18px rgba(184, 134, 11, .35);
  transition: transform .08s ease, box-shadow .08s ease;
}
@media (hover: hover) { .primary:hover { filter: brightness(1.05); } }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-deep); }

/* ---------- reveal ---------- */
.bar { position: relative; height: 16px; border-radius: 8px; margin: 34px 0 20px; background: #e6ddc8; box-shadow: inset 0 2px 3px rgba(0, 0, 0, .15); }
.bar-gap { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(224, 35, 60, .35) 0 6px, rgba(224, 35, 60, .18) 6px 12px); border-radius: 8px; }
.marker { position: absolute; top: -7px; width: 6px; height: 30px; border-radius: 3px; transform: translateX(-3px); }
.marker span { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: .78rem; font-weight: 800; white-space: nowrap; }
.marker.guess { background: var(--red); }
.marker.guess span { color: var(--red); }
.marker.answer { background: var(--win); }
.marker.answer span { color: var(--win); top: 32px; }
.result-line { font-size: 1.05rem; margin: 24px 0 8px; }
.pts { color: #fff; background: var(--win); padding: 1px 8px; border-radius: 999px; margin-left: 4px; font-weight: 800; }
.fact { margin: 8px 0; line-height: 1.5; }
.source { color: var(--ink-soft); font-size: .9rem; margin: 0 0 18px; }

/* ---------- summary ---------- */
.card h2, .card h3 { font-family: var(--display); font-weight: 400; margin: 0 0 6px; }
.card h2 { font-size: 1.4rem; color: var(--red); }
.card h3 { font-size: 1.05rem; margin-top: 24px; }
.big-score { font-family: var(--display); font-size: clamp(3rem, 15vw, 4.2rem); margin: 4px 0 2px; line-height: 1; }
.big-score small { font-size: 1.3rem; color: var(--ink-soft); }
.s-reached { color: var(--win); font-weight: 800; margin: 6px 0 4px; }
.emoji-row { font-size: 1.8rem; letter-spacing: 4px; margin: 6px 0 18px; }
.share-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.share-net {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 6px; border-radius: 12px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: .95rem; color: #fff; border: 0; box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
.share-net span { font-weight: 900; }
.sx span { font-size: 1.2rem; }
.share-net:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.sx { background: #000; }
.sfb { background: #1877f2; }
@media (hover: hover) { .share-net:hover { filter: brightness(1.1); } }
.toast { min-height: 1.2em; color: var(--win); font-weight: 700; text-align: center; margin: 8px 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 18px 0; text-align: center; }
.stats div { background: #f3ecdc; border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font-family: var(--display); font-weight: 400; font-size: 1.4rem; color: var(--red); }
.stats span { font-size: .75rem; color: var(--ink-soft); font-weight: 600; }

.ladder { list-style: none; padding: 0; margin: 8px 0 18px; display: flex; flex-direction: column-reverse; gap: 6px; }
.ladder li {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  background: #f1ead9; color: #8f8674; font-size: .92rem; border: 2px solid transparent;
}
.ladder li .l-icon { font-size: 1.3rem; width: 28px; text-align: center; filter: grayscale(1); opacity: .45; }
.ladder li .l-name { flex: 1; }
.ladder li .l-at { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.ladder li.reached { background: #e4f4ea; color: var(--ink); }
.ladder li.reached .l-icon { filter: none; opacity: 1; }
.ladder li.top {
  background: linear-gradient(90deg, #fff3c4, #ffe28a); border-color: var(--gold-deep); color: var(--ink); font-weight: 800;
  box-shadow: 0 0 0 3px rgba(245, 197, 66, .35);
}

.answer-list { padding-left: 20px; line-height: 1.45; }
.answer-list li { margin-bottom: 12px; }
.answer-list .al-q { display: block; font-weight: 600; }
.answer-list .al-a { color: var(--ink-soft); font-size: .9rem; }
.next-in { text-align: center; color: var(--ink-soft); margin-bottom: 0; }
.next-in b { font-family: var(--display); font-weight: 400; color: var(--ink); }

/* ---------- help dialog ---------- */
dialog {
  background: var(--ivory); color: var(--ink); border: 3px solid var(--gold);
  border-radius: var(--radius); max-width: 430px; padding: 26px;
  box-shadow: 0 0 0 3px var(--gold-deep), 0 20px 60px rgba(0, 0, 0, .6);
}
dialog h2 { font-family: var(--display); font-weight: 400; color: var(--red); margin-top: 0; }
dialog::backdrop { background: rgba(2, 20, 12, .75); }
.tiers { width: 100%; border-collapse: collapse; margin: 10px 0; }
.tiers td, .tiers th { padding: 7px 4px; border-bottom: 1px solid #e4dac4; text-align: left; }
.tiers td:last-child, .tiers th:last-child { text-align: right; font-weight: 800; }
.small { font-size: .92rem; color: var(--ink-soft); }
.link-btn {
  display: block; margin: 14px auto 0; background: none; border: 0; padding: 10px;
  color: var(--ink-soft); font-size: .85rem; text-decoration: underline; cursor: pointer;
}

/* ---------- score pop-up ---------- */
.pop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; cursor: pointer;
  background: radial-gradient(circle at 50% 45%, rgba(0, 0, 0, .25), rgba(2, 20, 12, .8));
}
.pop-card {
  min-width: 250px; max-width: 88vw; padding: 28px 30px 26px; border-radius: 24px; text-align: center;
  background: var(--ivory); color: var(--ink);
  border: 4px solid var(--tier, var(--gold));
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .15), 0 0 50px var(--tier-glow, transparent), 0 20px 50px rgba(0, 0, 0, .5);
}
.pop-emoji { font-size: 4.2rem; line-height: 1; }
.pop-label { font-family: var(--display); font-size: 1.9rem; margin-top: 10px; color: var(--tier, var(--ink)); }
.pop-points { font-size: 1.25rem; font-weight: 800; margin-top: 2px; }
.pop-level {
  margin-top: 14px; padding: 9px 12px; border-radius: 12px; font-size: .95rem; font-weight: 800;
  background: linear-gradient(90deg, #fff3c4, #ffe28a); color: var(--ink); border: 2px solid var(--gold-deep);
}
.t100 { --tier: #11a868; --tier-glow: rgba(245, 197, 66, .95); animation: bigpop .7s cubic-bezier(.2, 1.6, .4, 1); }
.t85 { --tier: #1f9d55; --tier-glow: rgba(17, 168, 104, .7); animation: pop .5s cubic-bezier(.2, 1.5, .4, 1); }
.t60 { --tier: #c99400; --tier-glow: rgba(245, 197, 66, .6); animation: pop .45s ease-out; }
.t30 { --tier: #e46a12; --tier-glow: rgba(228, 106, 18, .5); animation: slide .45s ease-out; }
.t10 { --tier: #e0233c; --tier-glow: rgba(224, 35, 60, .5); animation: wobble .6s ease; }
.t0 { --tier: #6b6658; animation: shake .5s ease; }
@keyframes bigpop { 0% { transform: scale(.2) rotate(-12deg); opacity: 0; } 60% { transform: scale(1.15) rotate(3deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slide { 0% { transform: translateY(40px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 50% { transform: rotate(5deg); } 75% { transform: rotate(-3deg); } }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* falling poker chips */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 16px; height: 16px; border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, .9);
  animation: fall 1.6s ease-in forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .85; } }

@media (max-width: 420px) {
  .card { padding: 28px 18px 22px; }
  .q-text { font-size: 1.2rem; }
  .progress li { width: 34px; height: 34px; border-width: 3px; font-size: .9rem; }
  .climb-text b { font-size: 1rem; }
  .climb-score b { font-size: 1.5rem; }
  .logo { font-size: 1.45rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pop-card, .climb.level-up { animation: none !important; }
  .confetti { display: none; }
  .climb-fill, .primary { transition: none; }
}

/* the prompt itself reads as plain, bold text, not marquee lettering */
.card h2.q-text { font-family: inherit; font-weight: 800; color: var(--ink); font-size: 1.4rem; margin: 0 0 18px; }
@media (max-width: 420px) { .card h2.q-text { font-size: 1.2rem; } }
.card { padding-top: 38px; }

/* ---------- poker chips, one colour per score tier ---------- */
.c100 { --c: #e8b31a; --cd: #8a6a06; --ci: #fff3c4; }  /* gold: exact */
.c85 { --c: #12a05c; --cd: #0a5c35; --ci: #d9f7e7; }   /* green */
.c60 { --c: #1f5fd6; --cd: #123a85; --ci: #dfe8ff; }   /* blue */
.c30 { --c: #ef6c13; --cd: #93400a; --ci: #ffe6d2; }   /* orange */
.c10 { --c: #d81f3a; --cd: #7e0f20; --ci: #ffdbe0; }   /* red */
.c0 { --c: #6f6a5f; --cd: #3a3731; --ci: #ece8df; }    /* grey: miss */

.chip {
  position: relative; border-radius: 50%; display: grid; place-items: center;
  background: repeating-conic-gradient(from 6deg, #fff 0 14deg, var(--c) 14deg 45deg);
  box-shadow: 0 4px 0 var(--cd), 0 8px 16px rgba(0, 0, 0, .35);
}
.chip::before {
  content: ""; position: absolute; inset: 16%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .35), transparent 55%), var(--c);
  border: 2px dashed rgba(255, 255, 255, .75);
}
.chip > b, .progress li.chip { position: relative; }
.chip.big { width: 132px; height: 132px; }
.chip.big > b {
  font-family: var(--display); font-weight: 400; font-size: 2.2rem; color: #fff;
  text-shadow: 0 2px 0 var(--cd), 0 0 10px rgba(0, 0, 0, .25);
}
/* small chips in the progress row */
.progress li.chip {
  border: 0; color: #fff; font-family: var(--display); font-weight: 400; font-size: .72rem;
  text-shadow: 0 1px 0 var(--cd);
  background: repeating-conic-gradient(from 6deg, #fff 0 14deg, var(--c) 14deg 45deg);
  box-shadow: inset 0 0 0 6px transparent, 0 3px 0 var(--cd), 0 5px 10px rgba(0, 0, 0, .35);
}
.progress li.chip::before {
  content: ""; position: absolute; inset: 18%; border-radius: 50%; background: var(--c);
  border: 1px dashed rgba(255, 255, 255, .8); z-index: -1;
}
.progress li.chip { isolation: isolate; }

/* pop-up stage: spinning chip with a burst of light behind it */
.pop-emoji { display: none; }
.pop-stage { position: relative; width: 132px; height: 132px; margin: 0 auto; }
.pop-stage .chip.big { position: absolute; inset: 0; }
.rays {
  position: absolute; inset: -70px; border-radius: 50%; opacity: 0;
  background: repeating-conic-gradient(var(--tier-glow, transparent) 0 8deg, transparent 8deg 24deg);
  mask: radial-gradient(circle, #000 25%, transparent 70%);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%);
}
.t100 .rays, .t85 .rays, .t60 .rays { opacity: 1; animation: spin 6s linear infinite; }
.t100 .chip.big { animation: chip-flip 1s cubic-bezier(.2, .9, .3, 1.2); }
.t85 .chip.big, .t60 .chip.big { animation: chip-flip .8s cubic-bezier(.2, .9, .3, 1.15); }
.t30 .chip.big { animation: chip-drop .6s cubic-bezier(.3, 1.4, .5, 1); }
.t10 .chip.big { animation: chip-roll .8s ease-out; }
.t0 .chip.big { animation: chip-thud .7s ease-out; filter: saturate(.6); }
.pop-card.t100 { background: radial-gradient(circle at 50% 25%, #fff6cf, var(--ivory) 60%); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes chip-flip {
  0% { transform: perspective(500px) rotateY(0) scale(.2); opacity: 0; }
  60% { transform: perspective(500px) rotateY(660deg) scale(1.15); opacity: 1; }
  100% { transform: perspective(500px) rotateY(720deg) scale(1); }
}
@keyframes chip-drop { 0% { transform: translateY(-120px) scale(.8); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes chip-roll { 0% { transform: translateX(-160px) rotate(-360deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes chip-thud {
  0% { transform: translateY(-80px); opacity: 0; } 50% { transform: translateY(0) scaleY(.85); opacity: 1; }
  70% { transform: translateX(-6px); } 85% { transform: translateX(6px); } 100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chip.big, .rays { animation: none !important; }
}
.chip.mini { display: inline-block; width: 20px; height: 20px; vertical-align: -4px; box-shadow: 0 2px 0 var(--cd); }
.chip.mini::before { border-width: 1px; }

/* ---------- shot clock ---------- */
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.q-head .q-count { margin: 0; }
.shot-clock {
  display: flex; align-items: baseline; gap: 2px; padding: 4px 12px; border-radius: 999px;
  background: var(--ink); color: var(--gold); font-weight: 800;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.shot-clock b { font-family: var(--display); font-weight: 400; font-size: 1.2rem; min-width: 1.6em; text-align: right; font-variant-numeric: tabular-nums; }
.shot-clock small { font-size: .8rem; }
.clock-icon { margin-right: 4px; font-size: .95rem; }
.shot-clock.hurry { background: var(--red); color: #fff; animation: tick-pulse 1s ease-in-out infinite; }
.clock-track { height: 6px; border-radius: 3px; background: #e9e1cd; margin: 0 0 14px; overflow: hidden; }
.clock-bar { height: 100%; width: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
.clock-bar.hurry { background: var(--red); }
@keyframes tick-pulse { 50% { transform: scale(1.08); } }
.pop-time {
  display: inline-block; margin: 12px 0 0; padding: 4px 12px; border-radius: 999px;
  background: var(--ink); color: var(--gold); font-weight: 800; font-size: .9rem;
}

/* ---------- chip row on the score screen ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 20px; }
.chip.med { width: 46px; height: 46px; }
.chip.med > b {
  position: relative; font-family: var(--display); font-weight: 400; font-size: .78rem; color: #fff;
  text-shadow: 0 1px 0 var(--cd);
}
@media (max-width: 400px) { .chip.med { width: 40px; height: 40px; } .chip-row { gap: 6px; } }
@media (prefers-reduced-motion: reduce) { .shot-clock.hurry { animation: none; } }

/* ---------- header buttons ---------- */
.top { gap: 10px; }
.menu-btn { border-style: solid; font-size: 1.1rem; line-height: 1; flex: none; }
.logo { flex: 1; }
.logo-btn { all: unset; cursor: pointer; }
.logo-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; border-radius: 6px; }

/* ---------- menu drawer ---------- */
dialog.menu {
  margin: 0 auto 0 0; height: 100%; max-height: 100%; width: min(320px, 86vw); max-width: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #0a4d32, var(--felt-deep)); color: var(--text);
  border: 0; border-right: 3px solid var(--gold); box-shadow: 10px 0 40px rgba(0, 0, 0, .5);
}
dialog.menu[open] { animation: slide-in .25s ease-out; }
@keyframes slide-in { from { transform: translateX(-100%); } to { transform: none; } }
.menu-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.small-logo { font-family: var(--display); font-size: 1.35rem; color: var(--gold); }
.small-logo span { color: var(--red); }
.menu-head form { margin: 0; }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-list button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid rgba(245, 197, 66, .25); background: rgba(0, 0, 0, .25);
  color: var(--text); font: inherit; font-weight: 700; font-size: 1.02rem; text-align: left; cursor: pointer;
}
@media (hover: hover) { .menu-list button:hover { background: rgba(245, 197, 66, .15); border-color: var(--gold); } }
.menu-list a.menu-tip {
  display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 10px 14px; border-radius: 12px;
  border: 1px dashed rgba(245, 197, 66, .45); color: var(--gold); font-weight: 700; text-decoration: none;
}
.tip-line { text-align: center; color: var(--ink-soft); font-size: .92rem; margin: 6px 0 0; }
.menu-list span { width: 26px; text-align: center; font-size: 1.2rem; }
.menu-list em {
  margin-left: auto; font-style: normal; font-size: .78rem; padding: 2px 8px; border-radius: 999px;
  background: var(--gold); color: var(--ink);
}

/* ---------- mode bar above a non-daily round ---------- */
.mode-bar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
  padding: 8px 14px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid rgba(245, 197, 66, .35);
  font-weight: 800; color: var(--gold-soft);
}
.link-btn.inline { margin: 0; padding: 4px 8px; color: var(--gold); display: inline; }

/* ---------- shared page bits ---------- */
.page h2 { font-size: 1.5rem; }
.lede { color: var(--ink-soft); margin: 4px 0 16px; line-height: 1.45; }
.center { text-align: center; }
.empty { color: var(--ink-soft); padding: 14px 0; }
.secondary {
  display: block; width: 100%; padding: 12px; border-radius: 12px; cursor: pointer; margin-top: 10px;
  font: inherit; font-weight: 800; color: var(--ink); background: #fff; border: 2px solid #d9cfb8;
}
@media (hover: hover) { .secondary:hover { border-color: var(--gold-deep); } }
.after-actions { margin: 6px 0 4px; }
.after-actions .primary { margin-top: 10px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

/* tiles used by the archive and packs */
.tile-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.tile {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; min-height: 62px;
  border-radius: 14px; border: 2px solid #e6dcc5; background: #fff; cursor: pointer; text-align: left;
  font: inherit; color: var(--ink);
}
@media (hover: hover) { .tile:hover { border-color: var(--gold-deep); box-shadow: 0 4px 12px rgba(0, 0, 0, .08); } }
.tile-icon { flex: none; width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.7rem; }
.tile-body { flex: 1; display: flex; flex-direction: column; }
.tile-body b { font-size: 1.02rem; }
.tile-sub { color: var(--ink-soft); font-size: .86rem; }
.tile-status { font-size: .8rem; font-weight: 800; color: var(--ink-soft); text-align: right; max-width: 45%; }
.tile.played .tile-status { color: var(--win); }
.tile.partial .tile-status { color: #c97a00; }
.chip.unplayed { opacity: .55; }

/* paywall */
.paywall-hero { display: grid; place-items: center; padding: 8px 0 14px; }
.paywall-hero .chip.big > b { font-size: 3rem; }
.perks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.perks li { padding: 10px 14px 10px 40px; border-radius: 12px; background: #f3ecdc; position: relative; font-weight: 600; }
.perks li::before { content: "✔"; position: absolute; left: 14px; color: var(--win); font-weight: 800; }
.as-link { text-align: center; text-decoration: none; }

/* profile */
.profile-head { display: flex; gap: 18px; align-items: center; margin-bottom: 8px; }
.avatar { flex: none; width: 96px; height: 96px; }
.avatar > b { font-size: 2.2rem; }
.profile-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.profile-fields label { font-weight: 800; font-size: .9rem; }
.profile-fields input {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 2px solid #d9cfb8; background: #fff; color: var(--ink);
}
.chip-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.chip.mid-pick { width: 34px; height: 34px; border: 0; cursor: pointer; padding: 0; }
.chip.mid-pick.picked { outline: 3px solid var(--ink); outline-offset: 2px; }
.history { list-style: none; padding: 0; margin: 6px 0 12px; display: grid; gap: 6px; }
.history li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #f3ecdc; }
.h-num { font-family: var(--display); color: var(--red); width: 2.6em; }
.h-chips { flex: 1; display: flex; gap: 3px; flex-wrap: wrap; }
.h-score { font-weight: 800; white-space: nowrap; }

/* settings */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid #e6dcc5; }
.setting > div { display: flex; flex-direction: column; gap: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 56px; height: 32px; border-radius: 999px; cursor: pointer;
  background: #cfc6b2; position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); transition: transform .2s;
}
.switch:checked { background: var(--win); }
.switch:checked::after { transform: translateX(24px); }
.danger-btn {
  margin-top: 8px; padding: 12px 16px; border-radius: 12px; cursor: pointer; font: inherit; font-weight: 800;
  background: #fff; color: var(--red-deep); border: 2px solid var(--red);
}
@media (hover: hover) { .danger-btn:hover { background: #fff0f2; } }

/* Animations setting off */
body.no-motion *, body.no-motion *::before, body.no-motion *::after { animation: none !important; transition: none !important; }
body.no-motion .confetti { display: none; }

/* ---------- start screen ---------- */
.start { display: flex; flex-direction: column; gap: 18px; padding-top: 6px; }
.start-hero {
  position: relative; text-align: center; padding: 26px 22px 22px; border-radius: 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 232, 163, .22), transparent 65%), linear-gradient(170deg, #b0122c, #6d0a1b 80%);
  border: 3px solid var(--gold); box-shadow: 0 0 0 3px var(--gold-deep), 0 18px 40px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.start-hero::before, .start-hero::after {
  content: ""; position: absolute; left: 16px; right: 16px; height: 8px;
  background: radial-gradient(circle, var(--gold-soft) 0 2.5px, rgba(255, 232, 163, .35) 3.5px, transparent 4.5px) 0 0 / 18px 8px repeat-x;
  filter: drop-shadow(0 0 3px var(--gold));
}
.start-hero::before { top: 8px; }
.start-hero::after { bottom: 8px; }
.start-hello { margin: 0; color: var(--gold-soft); font-weight: 700; }
.start-title {
  margin: 4px 0 2px; font-family: var(--display); font-weight: 400; font-size: clamp(2.2rem, 10vw, 3rem); line-height: 1.05;
  color: var(--gold); text-shadow: 0 3px 0 var(--gold-deep), 0 0 22px rgba(245, 197, 66, .5);
}
.start-date { margin: 0 0 16px; color: #ffd9de; }
.start-rules { list-style: none; padding: 0; margin: 16px 0 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.start-rules li {
  padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, .3); border: 1px solid rgba(245, 197, 66, .4);
  color: #fff; font-size: .9rem;
}
.start-rules b { color: var(--gold); }
.start-btn { font-size: 1.35rem; padding: 18px; }
.start-btn.pulse { animation: start-pulse 1.6s ease-in-out infinite; }
@keyframes start-pulse {
  0%, 100% { box-shadow: 0 4px 0 var(--gold-deep), 0 0 0 0 rgba(245, 197, 66, .6); }
  50% { box-shadow: 0 4px 0 var(--gold-deep), 0 0 0 12px rgba(245, 197, 66, 0); }
}
.start-sub { margin: 12px 0 0; color: #fff; font-weight: 600; }
.start-sub:empty { display: none; }
.start-help {
  margin: 12px auto 0; padding: 6px 10px; background: none; border: 0; cursor: pointer;
  color: var(--gold-soft); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}
.start-more { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.start-more button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; border-radius: 16px; cursor: pointer;
  background: var(--ivory); color: var(--ink); border: 2px solid var(--gold); font: inherit; font-weight: 800;
  box-shadow: 0 4px 0 var(--gold-deep);
}
.start-more button span { font-size: 1.5rem; }
.start-more button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-deep); }

/* ---------- online account + leaderboard ---------- */
.account { margin: 16px 0 8px; padding: 14px; border-radius: 14px; background: #f3ecdc; }
.account h3 { margin-top: 0 !important; }
.acct-row { display: flex; gap: 8px; flex-wrap: wrap; }
.acct-row input { flex: 1 1 180px; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 2px solid #d9cfb8; background: #fff; }
.inline-btn { width: auto; margin: 0; padding: 10px 14px; }
.acct-msg { min-height: 1em; margin: 6px 0 0; font-weight: 700; color: var(--win); }
.board { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.board li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: #f3ecdc; }
.board li.me { background: linear-gradient(90deg, #fff3c4, #ffe28a); font-weight: 800; }
.b-rank { font-family: var(--display); color: var(--red); width: 1.8em; }
.b-name { flex: 1; }
.b-score { font-family: var(--display); }

/* ---------- chip tray: stacks grow with points ---------- */
.tray {
  margin: 0 0 16px; padding: 10px 12px 8px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .28), rgba(0, 0, 0, .42));
  border: 1px solid rgba(245, 197, 66, .35); box-shadow: inset 0 2px 8px rgba(0, 0, 0, .4);
}
.stacks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tower {
  position: relative; width: 100%; height: 74px;
  border-bottom: 3px solid rgba(245, 197, 66, .5); border-radius: 0 0 4px 4px;
}
/* side view of a poker chip: striped edge, darker rim underneath */
.schip {
  position: absolute; left: 50%; width: min(40px, 92%); height: 9px; transform: translateX(-50%);
  border-radius: 5px / 4px;
  background: repeating-linear-gradient(90deg, var(--c) 0 6px, #fff 6px 9px);
  box-shadow: 0 2px 0 var(--cd), inset 0 2px 0 rgba(255, 255, 255, .35), inset 0 -2px 0 rgba(0, 0, 0, .2);
}
.schip.ghost { background: none; border: 2px dashed rgba(255, 250, 240, .3); box-shadow: none; }
.schip.drop { animation: stack-drop .38s cubic-bezier(.4, 0, .9, .6) both; }
@keyframes stack-drop {
  0% { transform: translate(-50%, -90px); opacity: 0; }
  70% { opacity: 1; }
  85% { transform: translate(-50%, 2px); }
  100% { transform: translate(-50%, 0); }
}
.stack.full .tower::after {
  content: ""; position: absolute; inset: -6px 10% 0; border-radius: 10px;
  box-shadow: 0 0 18px rgba(245, 197, 66, .7); pointer-events: none;
}
.stack.current .tower { border-bottom-color: var(--gold); }
.stack.current .tower::before {
  content: "?"; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  font-family: var(--display); color: var(--gold); font-size: 1.2rem; animation: bob 1.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, -6px); } }
.stack-label { font-size: .75rem; font-weight: 800; color: var(--muted); }
.stack.done .stack-label { color: #fff; }
.stack.current .stack-label { color: var(--gold); }
.tray-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: .8rem; color: var(--muted); font-weight: 700; }
.tray-foot b { color: var(--gold); }
@media (prefers-reduced-motion: reduce) { .schip.drop, .stack.current .tower::before { animation: none; } }

/* chips falling from the top of the screen onto their stack */
.tray { position: relative; z-index: 2; }
.schip.fall {
  animation: chip-fall .68s both;
  will-change: transform;
}
@keyframes chip-fall {
  0% { transform: translate(calc(-50% + var(--dx, 0px)), var(--fall, -400px)) rotate(var(--spin, 0deg)); opacity: 1; animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
  72% { transform: translate(-50%, 0) rotate(0deg); animation-timing-function: cubic-bezier(0, .55, .45, 1); }
  84% { transform: translate(-50%, -7px) scaleX(1.02); animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
  100% { transform: translate(-50%, 0); }
}

/* Archive lock (part of Unlimited) */
.lock-banner {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
  background: linear-gradient(135deg, #fff6d8, #f6e3a6); border: 2px solid var(--gold-deep);
  border-radius: 14px; padding: 12px 14px; margin: 0 0 12px;
}
.lock-banner .lock-icon { font-size: 1.8rem; }
.lock-banner p { margin: 0; font-size: .92rem; }
.lock-banner button { grid-column: 1 / -1; }
.tile.locked { opacity: .72; }
.tile.locked .tile-status { color: var(--gold-deep); }
.arch-lock { font-style: normal; font-size: .75em; }

/* ---------- iPhone and touch ---------- */
/* No double-tap zoom on buttons, so quick taps on − and + register every time. */
button, a, label, input[type="range"], .tile, .pop { touch-action: manipulation; }
button, .chip, .pop, .logo, .guess-display, .stacks { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* The slider follows a finger anywhere along it (handled in app.js). */
input[type="range"] { touch-action: none; }
.nudge { min-height: 48px; }
/* Inputs at 16px or more so Safari doesn't zoom in when they get focus. */
input, select, textarea { font-size: max(16px, 1em); }
.pop { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
dialog:not(.menu) { max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
/* Small iPhones (SE, mini): keep the logo clear of the puzzle number. */
@media (max-width: 360px) {
  .top { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .logo { font-size: 1.2rem; }
}
