/* Ace of Sums: one visual world, the game's own chalkboard. Slate board, oak trim, cream index-card cards, chalk handwriting.
   Layout: full-bleed board bands with a centred 1120px writing area; the playable hand is the centrepiece. */
:root {
  --slate: #1d2b25;        /* the board */
  --slate-deep: #131d18;   /* shadowed board, footer */
  --chalk: #f1ede2;        /* chalk white: headings, text */
  --chalk-dim: #b8c3b6;    /* faded chalk: secondary text */
  --chalk-yellow: #f3d36f; /* the yellow stick: accent */
  --chalk-pink: #f2a7b8;   /* the pink stick: second accent, used sparingly */
  --oak: #a7693a;          /* frame and tray */
  --oak-dark: #6e3f1d;
  --card: #fbf5e6;         /* index-card stock */
  --card-line: #d9e3ef;    /* the faint blue rule on index cards */
  --ink: #26221c;          /* pencil-dark equation ink */
  --ink-red: #b3302a;      /* card rank red */
  --good: #8fdc9b;
  --font-chalk: "Kalam", "Segoe Print", "Bradley Hand", cursive;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --step--1: clamp(0.88rem, 0.84rem + 0.2vw, 0.98rem);
  --step-0: clamp(1.05rem, 1rem + 0.25vw, 1.18rem);
  --step-1: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem);
  --step-2: clamp(1.8rem, 1.4rem + 1.6vw, 2.7rem);
  --step-3: clamp(2.8rem, 1.9rem + 4vw, 5.6rem);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--slate); color: var(--chalk);
  font: 400 var(--step-0)/1.6 var(--font-body);
  /* chalk grain: a faint noise layer over the board colour */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--chalk-yellow); text-underline-offset: 3px; }
a:hover { color: var(--chalk); }
:focus-visible { outline: 3px dashed var(--chalk-yellow); outline-offset: 3px; border-radius: 6px; }
img { max-width: 100%; height: auto; display: block; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.chalk { font-family: var(--font-chalk); font-weight: 700; letter-spacing: .01em; filter: url(#chalky); }
h1, h2, h3 { font-family: var(--font-chalk); font-weight: 700; line-height: 1.05; text-wrap: balance; margin: 0; }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0; }
.lede { font-size: var(--step-1); color: var(--chalk-dim); max-width: 34ch; line-height: 1.45; }
.sub { color: var(--chalk-dim); max-width: 60ch; }

/* ---------- nav ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--slate-deep); }
.nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: color-mix(in srgb, var(--slate-deep) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 3px solid var(--oak-dark); }
.nav .wrap { display: flex; align-items: center; gap: 20px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--chalk); text-decoration: none; font-family: var(--font-chalk); font-weight: 700; font-size: 1.35rem; margin-right: auto; }
.brand img { width: 38px; height: 38px; border-radius: 9px; }
.nav-links { display: flex; gap: 22px; }
.nav-links a { color: var(--chalk-dim); text-decoration: none; font-weight: 700; font-size: var(--step--1); }
.nav-links a:hover { color: var(--chalk); }
@media (max-width: 760px) { .nav-links { display: none; } }

/* ---------- buttons ---------- */
.store { display: inline-flex; align-items: center; gap: 12px; background: #0d0d0d; color: #fff; text-decoration: none; padding: 10px 20px 10px 16px; border-radius: 14px; border: 1px solid #3a3a3a; box-shadow: 0 4px 0 #000; }
.store svg { width: 26px; height: 26px; fill: #fff; flex: none; }
.store small { display: block; font-size: .72rem; opacity: .8; line-height: 1.1; }
.store strong { display: block; font-size: 1.15rem; line-height: 1.15; }
.store.soon { cursor: default; }
.store.soon small { color: var(--chalk-yellow); opacity: 1; }
.btn-chalk { display: inline-flex; align-items: center; gap: 8px; font: 700 1.2rem var(--font-chalk); color: var(--slate-deep); background: var(--chalk-yellow); padding: 10px 22px; border-radius: 999px; text-decoration: none; border: 0; cursor: pointer; box-shadow: 0 4px 0 #a88a2c; }
.btn-chalk:hover { color: var(--slate-deep); transform: translateY(-1px); }
.btn-chalk.ghost { background: transparent; color: var(--chalk); box-shadow: inset 0 0 0 2px var(--chalk-dim); }
.btn-chalk.small { font-size: 1rem; padding: 7px 16px; box-shadow: 0 3px 0 #a88a2c; }
.btn-chalk.ghost.small { box-shadow: inset 0 0 0 2px var(--chalk-dim); }

/* ---------- hero: the photographed board ---------- */
.hero { position: relative; background: var(--slate) url("img/board.jpg") center bottom / cover no-repeat; border-bottom: 14px solid var(--oak); box-shadow: inset 0 -2px 0 var(--oak-dark); overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 70px; background: linear-gradient(transparent, rgba(0,0,0,.25)); pointer-events: none; }
.hero .wrap { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; padding-block: 56px 70px; }
@media (max-width: 860px) { .hero .wrap { grid-template-columns: 1fr; padding-block: 36px 60px; } }
.hero h1 { font-size: var(--step-3); color: var(--chalk); text-shadow: 0 0 1px rgba(255,255,255,.4), 0 0 18px rgba(255,255,255,.08); }
.hero .lede { margin-top: 14px; color: #dfe4d8; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 28px; }
.hero .note { margin-top: 18px; font-size: var(--step--1); color: var(--chalk-dim); }
.hero-art { position: relative; display: flex; justify-content: center; align-items: flex-start; gap: 6px; min-width: 0; }
.phone { width: min(290px, 78vw); border-radius: 34px; border: 9px solid #121212; box-shadow: 0 30px 60px rgba(0,0,0,.45), 0 0 0 1px #2c2c2c; background: #000; overflow: hidden; transform: rotate(2.5deg); }
.phone img { width: 100%; aspect-ratio: 500 / 1084; object-fit: cover; }
.board-sum { flex: none; width: 130px; margin-top: 60px; transform: rotate(-4deg); }
@media (max-width: 860px) { .board-sum { width: 92px; margin-top: 30px; } .hero-art .phone { width: min(290px, 62vw); } }
.board-sum text { font-family: var(--font-chalk); font-weight: 700; fill: var(--chalk); stroke: var(--chalk); stroke-width: 1; }
.board-sum .yellow { fill: var(--chalk-yellow); stroke: var(--chalk-yellow); }
.board-sum line { stroke: var(--chalk); stroke-width: 4; stroke-linecap: round; }
@media (prefers-reduced-motion: no-preference) {
  .board-sum .w { stroke-dasharray: 220; stroke-dashoffset: 220; fill-opacity: 0; animation: write 0.9s ease-out forwards; }
  .board-sum .w2 { animation-delay: .5s; } .board-sum .w3 { animation-delay: 1s; } .board-sum .w4 { animation-delay: 1.5s; } .board-sum .w5 { animation-delay: 2s; }
  @keyframes write { 70% { stroke-dashoffset: 0; fill-opacity: 0; } 100% { stroke-dashoffset: 0; fill-opacity: 1; } }
}

/* ---------- sections ---------- */
section { padding-block: 72px; }
.section-head { display: grid; gap: 12px; margin-bottom: 34px; max-width: 760px; }
.eyebrow { font: 700 var(--step--1) var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--chalk-pink); }
.rule { border: 0; height: 14px; margin: 0; background: linear-gradient(var(--oak) 0 0) top / 100% 10px no-repeat, var(--oak-dark); }

/* ---------- index cards (shared by the demo and the explainer) ---------- */
.card {
  --w: 104px; width: var(--w); aspect-ratio: 5 / 7; position: relative; flex: none;
  background: var(--card); color: var(--ink); border-radius: 9px; border: 0;
  background-image: linear-gradient(transparent calc(100% - 1px), var(--card-line) 0); background-size: 100% 18%; background-position: 0 6%;
  box-shadow: 0 2px 0 rgba(0,0,0,.18), 0 8px 18px rgba(0,0,0,.28);
  font-family: var(--font-chalk); font-weight: 700; padding: 0;
}
.card .rank { position: absolute; left: 9%; top: 3%; font-size: calc(var(--w) * .26); line-height: 1; color: var(--ink-red); }
.card .eq { position: absolute; inset: 30% 6% 8%; display: grid; place-items: center; text-align: center; font-size: calc(var(--w) * .2); line-height: 1.1; color: var(--ink); white-space: nowrap; }
.card .eq.small { font-size: calc(var(--w) * .16); }
.card .big { position: absolute; inset: 22% 4% 6%; display: grid; place-items: center; font-size: calc(var(--w) * .48); line-height: 1; }
.card .big.red { color: var(--ink-red); } .card .big.black { color: var(--ink); }
.card .stack { display: grid; justify-items: end; gap: 0; font-size: calc(var(--w) * .19); line-height: 1.05; font-variant-numeric: tabular-nums; }
.card .stack .row { display: flex; gap: .3em; }
.card .stack .bar { width: 100%; border-top: 3px solid var(--ink); margin-top: 3px; }
.card.back { background: var(--slate-deep) center / cover no-repeat; border: 4px solid var(--card); }

/* ---------- Try a hand ---------- */
.play-band { background: linear-gradient(180deg, var(--slate-deep), var(--slate) 30%); }
.table { position: relative; background: #24372e; border-radius: 22px; border: 10px solid var(--oak); box-shadow: inset 0 0 0 2px var(--oak-dark), inset 0 0 80px rgba(0,0,0,.35), 0 20px 40px rgba(0,0,0,.35); padding: 22px clamp(12px, 3vw, 34px) 26px; }
.hud { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.moves { display: flex; align-items: baseline; gap: 10px; }
.moves b { font: 700 2.4rem/1 var(--font-chalk); color: var(--chalk); font-variant-numeric: tabular-nums; min-width: 2ch; }
.moves span { font-size: var(--step--1); letter-spacing: .12em; text-transform: uppercase; color: var(--chalk-dim); }
.moves.low b { color: var(--chalk-pink); }
.piles { display: flex; gap: clamp(14px, 4vw, 40px); justify-content: center; margin-bottom: 22px; }
.pile { --w: clamp(96px, 22vw, 132px); cursor: pointer; transition: transform .15s; }
.pile.hot { outline: 3px dashed var(--chalk-yellow); outline-offset: 5px; }
.pile .label { position: absolute; left: 0; right: 0; bottom: -28px; text-align: center; font: 700 .9rem var(--font-body); color: var(--chalk-dim); letter-spacing: .04em; }
.pile .bar { position: absolute; left: 10%; right: 10%; bottom: 6%; height: 5px; border-radius: 3px; background: rgba(0,0,0,.1); overflow: hidden; }
.pile .bar i { display: block; height: 100%; background: var(--chalk-yellow); width: 0; transition: width .3s; }
.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(8px, 2vw, 14px); min-height: 160px; margin-top: 40px; }
.hand .card { --w: clamp(78px, 19vw, 108px); cursor: grab; transition: transform .15s, box-shadow .15s, opacity .2s; touch-action: none; }
.hand .card:hover { transform: translateY(-4px); }
.hand .card.sel { transform: translateY(-10px); box-shadow: 0 0 0 4px var(--chalk-yellow), 0 14px 24px rgba(0,0,0,.4); }
.hand .card.gone { visibility: hidden; }
.card.ghost { position: fixed; z-index: 50; pointer-events: none; transform: rotate(4deg) scale(1.05); box-shadow: 0 20px 34px rgba(0,0,0,.45); }
.card.wiggle { animation: wiggle .4s; }
.pile .card.flash, .card.flash { box-shadow: 0 0 0 4px var(--chalk-pink), 0 8px 18px rgba(0,0,0,.3); }
@keyframes wiggle { 20% { transform: translateX(-7px) rotate(-3deg); } 40% { transform: translateX(7px) rotate(3deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .card.wiggle { animation: none; } }
.say { min-height: 3em; margin-top: 18px; text-align: center; font: 700 1.25rem/1.35 var(--font-chalk); color: var(--chalk); }
.say.bad { color: var(--chalk-pink); } .say.good { color: var(--good); }
.play-foot { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: center; margin-top: 18px; color: var(--chalk-dim); font-size: var(--step--1); }
.finale { position: absolute; inset: 0; border-radius: 12px; background: rgba(19, 29, 24, .93); display: grid; place-items: center; text-align: center; padding: 20px; z-index: 3; }
.finale .parade { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; margin: 0 auto 18px; }
.finale .parade .card { --w: clamp(62px, 14vw, 84px); }
.finale .parade .card .eq { font-size: calc(var(--w) * .15); inset: 32% 4% 6%; white-space: normal; }
.finale .stamp { font: 700 clamp(3rem, 10vw, 5.5rem)/1 var(--font-chalk); color: var(--chalk-yellow); transform: rotate(-7deg); filter: url(#chalky); }
.finale p { color: var(--chalk-dim); margin: 10px 0 18px; }
@media (prefers-reduced-motion: no-preference) {
  .finale .parade .card { animation: flipin .45s both; }
  .finale .stamp { animation: stamp .35s both; animation-delay: var(--d, 1.2s); }
  @keyframes flipin { from { transform: rotateY(90deg); } to { transform: none; } }
  @keyframes stamp { from { transform: rotate(-7deg) scale(2.4); opacity: 0; } to { transform: rotate(-7deg) scale(1); opacity: 1; } }
}

/* ---------- how it plays ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; counter-reset: step; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr; } }
.step { display: grid; gap: 14px; align-content: start; min-width: 0; }
.step .num { font: 700 3rem/1 var(--font-chalk); color: var(--chalk-yellow); filter: url(#chalky); }
.step .num::before { counter-increment: step; content: counter(step) "."; }
.step .cards { display: flex; gap: 10px; align-items: flex-end; min-height: 160px; }
.step .cards .card { --w: 96px; }
.step .cards .card:nth-child(2) { transform: rotate(-3deg); }
.step .cards .card:nth-child(3) { transform: rotate(4deg); }
.step .arrow { font: 700 2.2rem/1 var(--font-chalk); color: var(--chalk-dim); align-self: center; }
.step p { color: var(--chalk-dim); }
.step p b { color: var(--chalk); font-weight: 700; }

/* ---------- topics ---------- */
.topics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .topics { grid-template-columns: repeat(2, 1fr); } }
.topic { background: rgba(255,255,255,.035); border: 2px dashed rgba(241,237,226,.22); border-radius: 14px; padding: 16px 16px 14px; display: grid; gap: 6px; min-width: 0; }
.topic .name { font-weight: 700; font-size: var(--step--1); letter-spacing: .06em; text-transform: uppercase; color: var(--chalk-dim); }
.topic .ex { font: 700 clamp(1.4rem, 1.1rem + 1vw, 1.9rem)/1.15 var(--font-chalk); color: var(--chalk); white-space: nowrap; overflow-x: auto; }
.topic .ex em { font-style: normal; color: var(--chalk-yellow); }
.fifteen { margin-top: 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; color: var(--chalk-dim); }
.fifteen strong { font: 700 var(--step-2)/1 var(--font-chalk); color: var(--chalk-yellow); filter: url(#chalky); }
.sizes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.size { border-radius: 999px; padding: 8px 16px; background: var(--slate-deep); color: var(--chalk); font-weight: 700; font-size: var(--step--1); box-shadow: inset 0 0 0 2px rgba(241,237,226,.15); font-variant-numeric: tabular-nums; }
.size span { color: var(--chalk-dim); font-weight: 400; margin-left: 6px; }

/* ---------- tables gallery ---------- */
.tables { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
@media (max-width: 900px) { .tables { grid-template-columns: repeat(2, 1fr); } }
.tables figure { margin: 0; display: grid; gap: 10px; justify-items: center; min-width: 0; }
.tables .phone { width: 100%; max-width: 230px; border-width: 7px; border-radius: 26px; transform: none; }
.tables figure:nth-child(odd) .phone { transform: rotate(-1.5deg); }
.tables figure:nth-child(even) .phone { transform: rotate(1.5deg); }
.tables figcaption { text-align: center; }
.tables figcaption b { display: block; font: 700 1.35rem var(--font-chalk); }
.tables figcaption span { color: var(--chalk-dim); font-size: var(--step--1); }
.backs { display: flex; gap: 12px; margin-top: 34px; overflow-x: auto; padding: 6px 2px 14px; scrollbar-width: thin; }
.backs img { width: 74px; flex: none; border-radius: 8px; box-shadow: 0 6px 14px rgba(0,0,0,.35); }
.backs-note { color: var(--chalk-dim); font-size: var(--step--1); }

/* ---------- fair + readable ---------- */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; align-items: center; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.facts li { display: grid; grid-template-columns: 42px 1fr; gap: 14px; align-items: start; }
.facts .tick { font: 700 2rem/1 var(--font-chalk); color: var(--chalk-yellow); }
.facts b { display: block; font: 700 1.3rem/1.2 var(--font-chalk); margin-bottom: 4px; }
.facts span { color: var(--chalk-dim); }
.zoom-shot { justify-self: center; }

/* ---------- ad-free ---------- */
.price { display: grid; grid-template-columns: auto 1fr; gap: 28px 40px; align-items: center; background: var(--card); color: var(--ink); border-radius: 18px; padding: clamp(20px, 4vw, 40px); box-shadow: 0 10px 30px rgba(0,0,0,.35); background-image: linear-gradient(transparent calc(100% - 1px), var(--card-line) 0); background-size: 100% 2.1em; transform: rotate(-.6deg); }
@media (max-width: 700px) { .price { grid-template-columns: 1fr; } }
.price .tag { font: 700 clamp(3.2rem, 2.4rem + 3vw, 4.8rem)/1 var(--font-chalk); color: var(--ink-red); }
.price .tag small { display: block; font-size: 1.1rem; color: var(--ink); }
.price h3 { color: var(--ink); margin-bottom: 8px; }
.price p { color: #4b4438; }
.price ul { margin: 12px 0 0; padding-left: 1.2em; color: #4b4438; }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 10px; max-width: 820px; }
.faq details { background: rgba(255,255,255,.035); border-radius: 12px; border: 1px solid rgba(241,237,226,.12); padding: 4px 18px; }
.faq summary { cursor: pointer; font: 700 1.25rem/1.4 var(--font-chalk); padding: 12px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--chalk-yellow); font-size: 1.6rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { color: var(--chalk-dim); padding-bottom: 16px; }

/* ---------- footer ---------- */
footer { background: var(--slate-deep); border-top: 14px solid var(--oak); padding-block: 40px 50px; color: var(--chalk-dim); font-size: var(--step--1); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 18px 40px; justify-content: space-between; align-items: center; }
footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
footer a { color: var(--chalk); }
.doodle { font: 700 1.2rem var(--font-chalk); color: var(--chalk-dim); }

/* ---------- policy pages ---------- */
.doc { padding-block: 48px 70px; }
.doc .paper { background: var(--card); color: var(--ink); border-radius: 16px; padding: clamp(20px, 5vw, 52px); max-width: 820px; margin: 0 auto; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.doc h1 { font-size: var(--step-2); color: var(--ink); margin-bottom: 6px; }
.doc h2 { font-size: var(--step-1); color: var(--ink); margin: 30px 0 8px; }
.doc p, .doc li { color: #3e382f; max-width: 68ch; }
.doc p + p { margin-top: 10px; }
.doc a { color: var(--ink-red); }
.doc .meta { color: #7a7062; font-size: var(--step--1); margin-bottom: 18px; }
.doc .email { font-weight: 700; user-select: all; background: #efe6cf; padding: 2px 8px; border-radius: 6px; }
