/* Stackscape website. Colors and type follow DESIGN.md ("dusk diorama"). */

@font-face { font-family: 'Fredoka'; font-weight: 400; font-display: swap; src: url('/fonts/Fredoka-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 500; font-display: swap; src: url('/fonts/Fredoka-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url('/fonts/Fredoka-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url('/fonts/Fredoka-Bold.woff2') format('woff2'); }

:root {
  --ink: #1E1B4B;
  --ink-soft: #4A4673;
  --sun: #FFC83D;
  --sun-shadow: #D99A12;
  --coral: #FF7A59;
  --mint: #3DD6A3;
  --dusk: #6B4FA0;
  --violet: #5B44B8;
  --cloud: #FFFFFF;
  --mist: #F2EFFC;
  --line: #E1DBF5;
  --sky: linear-gradient(180deg, #24215C 0%, #6B4FA0 55%, #F49A6C 100%);
  --night: #15133A;
  --radius: 24px;
  --shadow: 0 18px 40px -18px rgba(30, 27, 75, .35);
  --max: 1160px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: 'Fredoka', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--mist);
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--violet); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; border-radius: 8px; }
h1, h2, h3 { line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-weight: 700; }
h2 { font-weight: 700; font-size: clamp(34px, 5vw, 52px); }
h3 { font-weight: 600; font-size: 22px; }
p { margin: 0 0 1em; }

.skip { position: absolute; left: 16px; top: -60px; z-index: 100; background: var(--sun); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-weight: 600; }
.skip:focus { top: 16px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  --b: var(--sun); --s: var(--sun-shadow); --t: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 12px 26px;
  border: 0; border-radius: 18px;
  background: var(--b); color: var(--t);
  font: 700 19px/1.1 inherit; font-family: inherit;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 0 var(--s), 0 14px 24px -10px rgba(0, 0, 0, .35);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { color: var(--t); transform: translateY(-2px); box-shadow: 0 8px 0 var(--s), 0 18px 28px -10px rgba(0, 0, 0, .35); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--s), 0 6px 12px -8px rgba(0, 0, 0, .35); }
.btn small { display: block; font-size: 12px; font-weight: 500; opacity: .8; letter-spacing: .04em; text-transform: uppercase; }
.btn .btn-txt { text-align: left; }
.btn-ghost { --b: rgba(255, 255, 255, .12); --s: rgba(0, 0, 0, .25); --t: #fff; backdrop-filter: blur(6px); border: 1.5px solid rgba(255, 255, 255, .28); }
.btn-violet { --b: var(--violet); --s: #3E2C8A; --t: #fff; }
.btn svg { width: 26px; height: 26px; flex: none; }

/* ---------- Header ---------- */
.site-head {
  position: fixed; inset: 0 0 auto; z-index: 50;
  transition: background .3s, box-shadow .3s, backdrop-filter .3s;
}
.site-head.solid { background: rgba(21, 19, 58, .78); backdrop-filter: blur(14px) saturate(1.4); box-shadow: 0 1px 0 rgba(255, 255, 255, .08); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 700; font-size: 24px; }
.brand:hover { color: #fff; }
.brand img { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.nav { display: flex; align-items: center; gap: 6px; }
.nav a { color: rgba(255, 255, 255, .86); text-decoration: none; font-weight: 500; padding: 8px 14px; border-radius: 12px; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.nav .btn { min-height: 44px; padding: 8px 18px; font-size: 16px; margin-left: 8px; box-shadow: 0 4px 0 var(--s); }
.nav .btn:hover { color: var(--t); background: var(--b); }
@media (max-width: 820px) { .nav a:not(.btn) { display: none; } }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background: var(--sky);
  padding: 104px 0 0;
  isolation: isolate;
}
.stars { position: absolute; inset: 0 0 40%; z-index: -1; pointer-events: none; }
.stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; opacity: .8; animation: twinkle 3.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .15; } }
.sun-glow { position: absolute; z-index: -1; right: -10%; bottom: 8%; width: 70vw; max-width: 900px; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 61, .38), transparent 62%); pointer-events: none; }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 8px; margin-bottom: 22px;
  border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
  font-size: 15px; font-weight: 500;
}
.eyebrow b { background: var(--mint); color: var(--ink); border-radius: 999px; padding: 2px 10px; font-size: 13px; letter-spacing: .04em; }
.hero h1 { font-size: clamp(54px, 7.2vw, 96px); margin-bottom: 18px; text-shadow: 0 6px 30px rgba(30, 27, 75, .35); }
.hero h1 span { color: var(--sun); display: block; font-size: .5em; margin-top: .25em; line-height: 1.15; }
.hero .lead { font-size: clamp(19px, 2.1vw, 22px); color: #F2EFFC; max-width: 33ch; margin-bottom: 30px; }
.cta-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 26px; }
.hero-note { font-size: 15px; color: rgba(255, 255, 255, .78); display: flex; gap: 18px; flex-wrap: wrap; }
.hero-note span::before { content: '✓'; color: var(--sun); font-weight: 700; margin-right: 6px; }

/* The phone with the playable demo. */
.phone-stage { position: relative; display: flex; justify-content: center; padding-bottom: 54px; }
.phone {
  position: relative; width: min(330px, 82vw, calc((100svh - 150px) * .4875)); min-width: 260px; aspect-ratio: 390 / 800;
  border-radius: 52px; padding: 12px;
  background: linear-gradient(145deg, #3a3470, #15133A 60%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .14) inset, 0 50px 90px -30px rgba(10, 8, 40, .8), 0 30px 60px -40px rgba(255, 122, 89, .6);
  transform: rotate(-2deg);
  transition: transform .6s var(--ease);
}
.phone:hover { transform: rotate(0deg) translateY(-6px); }
.phone-screen { position: relative; width: 100%; height: 100%; border-radius: 41px; overflow: hidden; background: #24215C; }
.phone-screen::before { content: ''; position: absolute; z-index: 3; top: 10px; left: 50%; width: 96px; height: 28px; transform: translateX(-50%); border-radius: 20px; background: #0b0a1f; }
#game { width: 100%; height: 100%; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; text-align: center; color: #fff; }
.hud-score { position: absolute; top: 58px; left: 0; right: 0; font-size: 76px; font-weight: 700; line-height: 1; text-shadow: 0 4px 18px rgba(30, 27, 75, .45); transition: transform .18s var(--ease); }
.hud-score.pop { transform: scale(1.16); }
.hud-perfect { position: absolute; top: 146px; left: 50%; margin-left: -80px; width: 160px; padding: 4px 0; border-radius: 999px; background: rgba(30, 27, 75, .5); font-size: 19px; font-weight: 700; color: #FFA48A; letter-spacing: .06em; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s var(--ease); text-shadow: 0 2px 10px rgba(30, 27, 75, .4); }
.hud-perfect.show { opacity: 1; transform: none; }
.hud-hint { position: absolute; bottom: 30px; left: 0; right: 0; font-size: 16px; font-weight: 500; color: rgba(255, 255, 255, .92); }
.hud-hint b { display: inline-block; padding: 8px 16px; border-radius: 999px; background: rgba(30, 27, 75, .45); backdrop-filter: blur(4px); font-weight: 500; }
.hud-best { position: absolute; top: 40px; right: 26px; font-size: 13px; font-weight: 600; opacity: .85; }
.hud-over { position: absolute; left: 22px; right: 22px; bottom: 26px; transform: translateY(24px) scale(.94); opacity: 0; transition: opacity .25s, transform .3s var(--ease); background: rgba(255, 255, 255, .96); color: var(--ink); border-radius: 26px; padding: 18px 18px 20px; box-shadow: var(--shadow); }
.hud-over.show { opacity: 1; transform: none; }
.hud-over .k { font-size: 14px; color: var(--ink-soft); font-weight: 500; text-transform: uppercase; letter-spacing: .08em; }
.hud-over .v { font-size: 54px; font-weight: 700; line-height: 1.05; }
.hud-over .newbest { display: inline-block; margin: 6px 0 4px; padding: 2px 12px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .06em; }
.hud-over .again { margin-top: 12px; display: inline-block; padding: 10px 22px; border-radius: 14px; background: var(--sun); box-shadow: 0 4px 0 var(--sun-shadow); font-weight: 700; }
.demo-tag { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 14px; color: rgba(255, 255, 255, .85); font-weight: 500; }
.demo-tag kbd { font: inherit; font-weight: 600; padding: 1px 8px; border-radius: 6px; background: rgba(255, 255, 255, .16); }

/* Floating decorative blocks. */
.float-block { position: absolute; z-index: -1; opacity: .9; animation: drift 9s ease-in-out infinite; }
@keyframes drift { 50% { transform: translateY(-18px) rotate(4deg); } }
.horizon { display: block; width: 100%; height: 90px; margin-top: -1px; }

@media (max-width: 900px) {
  .hero { padding-top: 108px; text-align: center; }
  .phone { width: min(330px, 82vw); }
  .float-block { display: none; }
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .hero .lead { margin-left: auto; margin-right: auto; }
  .cta-row, .hero-note { justify-content: center; }
  .phone { transform: none; }
}
@media (max-width: 520px) {
  .cta-row .btn { width: 100%; }
}

/* ---------- Sections ---------- */
section { padding: 96px 0; position: relative; }
.section-head { text-align: center; max-width: 720px; margin: 0 auto 56px; }
.section-head p { font-size: 20px; color: var(--ink-soft); }
.kicker { display: inline-block; margin-bottom: 14px; padding: 4px 14px; border-radius: 999px; background: #E6E0FA; color: var(--violet); font-weight: 600; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .float-block, .stars i { animation: none; }
}

/* How it plays */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; counter-reset: step; }
.step { position: relative; background: var(--cloud); border-radius: var(--radius); padding: 32px 28px 30px; box-shadow: var(--shadow); }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 22px; right: 24px; font-size: 64px; font-weight: 700; line-height: 1; color: var(--mist); }
.step-art { width: 92px; height: 92px; margin-bottom: 16px; }
.step p { color: var(--ink-soft); margin: 0; }
@media (max-width: 820px) { .steps { grid-template-columns: 1fr; } }

/* Themes */
.themes-sec { background: var(--night); color: #fff; overflow: hidden; }
.themes-sec .section-head p { color: #C9C2EE; }
.themes-sec .kicker { background: rgba(255, 255, 255, .1); color: var(--sun); }
.themes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; }
.theme {
  position: relative; display: flex; flex-direction: column; text-align: left;
  border: 0; padding: 0; border-radius: 26px; overflow: hidden; cursor: pointer;
  background: #2a2560; color: #fff; font-family: inherit;
  box-shadow: 0 0 0 2px transparent, 0 20px 40px -24px rgba(0, 0, 0, .8);
  transition: transform .3s var(--ease), box-shadow .3s;
}
.theme:hover { transform: translateY(-6px); }
.theme[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--sun), 0 24px 44px -20px rgba(255, 200, 61, .45); }
.theme canvas { width: 100%; aspect-ratio: 3 / 4; }
.theme-info { padding: 14px 16px 16px; }
.theme-name { font-weight: 600; font-size: 19px; display: block; }
.theme-price { font-size: 14px; color: #C9C2EE; display: flex; align-items: center; gap: 6px; }
.theme-price .coin { width: 14px; height: 14px; border-radius: 50%; background: var(--sun); box-shadow: inset 0 -2px 0 var(--sun-shadow); }
.theme-price .free { color: var(--mint); font-weight: 600; }
.themes-foot { text-align: center; margin-top: 36px; color: #C9C2EE; }
.themes-foot a { color: var(--sun); }
@media (max-width: 1000px) { .themes { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
  .themes { grid-template-columns: repeat(5, 62%); overflow-x: auto; scroll-snap-type: x mandatory; padding: 6px 16px 20px; margin: 0 -16px; scrollbar-width: none; }
  .themes::-webkit-scrollbar { display: none; }
  .theme { scroll-snap-align: center; }
}

/* Daily Tower */
.daily-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: center; }
.daily-card {
  position: relative; max-width: 420px; margin: 0 auto; padding: 26px;
  border-radius: 32px; background: var(--sky); color: #fff; box-shadow: var(--shadow);
  transform: rotate(2deg);
}
.daily-card .row { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.daily-card .num { font-size: 15px; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.daily-card .streak { background: var(--coral); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.daily-card canvas { width: 100%; aspect-ratio: 1; margin: 6px 0; }
.daily-card .result { font-size: 26px; font-weight: 700; text-align: center; }
.share-bubble {
  position: absolute; right: -18px; bottom: -26px; transform: rotate(-4deg);
  background: #fff; color: var(--ink); border-radius: 20px 20px 4px 20px; padding: 12px 16px;
  font-weight: 500; font-size: 16px; box-shadow: var(--shadow);
}
.check-list { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 14px; }
.check-list li { display: flex; gap: 14px; align-items: flex-start; }
.check-list li::before { content: ''; flex: none; width: 28px; height: 28px; margin-top: 2px; border-radius: 9px; background: var(--mint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7' fill='none' stroke='%231E1B4B' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat; }
@media (max-width: 860px) { .daily-grid { grid-template-columns: 1fr; } .daily-card { transform: none; } .share-bubble { right: 8px; } }

/* Features */
.features-sec { background: var(--cloud); }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.feature { padding: 26px 24px; border-radius: var(--radius); background: var(--mist); transition: transform .3s var(--ease), background .3s; }
.feature:hover { transform: translateY(-4px); background: #EAE5FB; }
.feature-ico { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 16px; font-size: 28px; line-height: 1; }
.feature p { color: var(--ink-soft); font-size: 16px; margin: 0; }
.feature h3 { font-size: 20px; margin-bottom: 6px; }
@media (max-width: 1000px) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .features { grid-template-columns: 1fr; } }

/* FAQ / support */
.faq { max-width: 820px; margin: 0 auto; display: grid; gap: 14px; }
.faq details { background: var(--cloud); border-radius: 20px; box-shadow: 0 10px 30px -22px rgba(30, 27, 75, .5); }
.faq summary { list-style: none; cursor: pointer; padding: 20px 64px 20px 24px; font-weight: 600; font-size: 19px; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; position: absolute; right: 22px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 10px; background: var(--mist); display: grid; place-items: center; font-size: 22px; color: var(--violet); transition: transform .25s var(--ease); }
.faq details[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq .ans { padding: 0 24px 22px; color: var(--ink-soft); }
.faq .ans p:last-child { margin: 0; }
.support-card { margin: 40px auto 0; max-width: 820px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 26px 28px; border-radius: var(--radius); background: var(--ink); color: #fff; }
.support-card p { margin: 0; color: #C9C2EE; }
.support-card strong { display: block; color: #fff; font-size: 21px; }

/* Final call to action */
.cta-sec { background: var(--sky); color: #fff; text-align: center; overflow: hidden; padding: 110px 0 120px; }
.cta-sec h2 { font-size: clamp(38px, 6vw, 64px); }
.cta-sec p { font-size: 20px; color: #F2EFFC; max-width: 560px; margin: 0 auto 32px; }
.cta-sec .cta-row { justify-content: center; }

/* ---------- Footer ---------- */
.site-foot { background: var(--night); color: #C9C2EE; padding: 56px 0 40px; font-size: 16px; }
.foot-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 28px; }
.site-foot .brand { font-size: 21px; margin-bottom: 10px; }
.site-foot a { color: #E6E0FA; text-decoration: none; }
.site-foot a:hover { color: var(--sun); }
.foot-links { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.foot-base { margin-top: 36px; padding-top: 22px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 14px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Legal pages ---------- */
.legal-hero { background: var(--sky); color: #fff; padding: 132px 0 70px; text-align: center; position: relative; overflow: hidden; isolation: isolate; }
.legal-hero h1 { font-size: clamp(42px, 6vw, 64px); margin-bottom: 10px; }
.legal-hero p { color: #F2EFFC; margin: 0; }
.legal { padding: 0 0 96px; }
.legal-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; align-items: start; margin-top: -40px; }
.toc { position: sticky; top: 96px; background: var(--cloud); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); font-size: 15px; }
.toc strong { display: block; margin-bottom: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.toc ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--violet); text-decoration: underline; }
.doc { background: var(--cloud); border-radius: 28px; padding: 44px 48px; box-shadow: var(--shadow); font-size: 17px; }
.doc h2 { font-size: 28px; margin: 44px 0 14px; padding-top: 8px; scroll-margin-top: 96px; }
.doc h2:first-of-type { margin-top: 28px; }
.doc h3 { font-size: 20px; margin: 26px 0 8px; }
.doc ul { padding-left: 22px; margin: 0 0 1em; }
.doc li { margin-bottom: 6px; }
.doc table { width: 100%; border-collapse: collapse; margin: 8px 0 20px; font-size: 15.5px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.doc th { background: var(--mist); font-weight: 600; }
.doc .table-wrap { overflow-x: auto; }
.summary { background: var(--mist); border-radius: 20px; padding: 22px 26px; border-left: 6px solid var(--sun); }
.summary h2 { margin: 0 0 10px !important; font-size: 22px; padding: 0; }
.summary ul { margin: 0; }
.updated { display: inline-block; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .14); font-size: 15px; margin-top: 8px; }
@media (max-width: 900px) {
  .legal-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .toc { position: static; }
  .doc { padding: 28px 20px; border-radius: 22px; }
}

/* ---------- 404 ---------- */
.lost { min-height: 100vh; display: grid; place-items: center; text-align: center; background: var(--sky); color: #fff; padding: 120px 16px 60px; }
.lost h1 { font-size: clamp(80px, 18vw, 180px); margin: 0; }
.lost p { font-size: 21px; color: #F2EFFC; }
