:root {
  --bg: #2B1055;
  --bg-deep: #1E0A3F;
  --board: #15103A;
  --cell: #33306F;
  --path: #4B47A6;
  --rc: #8F8BDB;
  --rd: #4F4B9E;
  --d: #1E6B24;
  --bw: 4px;
  --rock: #FFE7C2;
  --ink: #FFF7EC;
  --muted: #CDBDEA;
  --shadow: #170733;
  --c: #FF5C8A;
  --pad: 10px;
  --gap: 8px;
  --display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(60rem 40rem at 78% 18%, rgba(255, 92, 138, .16), transparent 60%),
    radial-gradient(50rem 36rem at 10% 90%, rgba(71, 184, 255, .12), transparent 60%),
    var(--bg);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

a { color: inherit; }

:focus-visible {
  outline: 3px solid #FFB020;
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
}

.brand img { display: block; height: 88px; width: auto; }

.lang {
  font: 700 .9rem/1 var(--body);
  color: var(--ink);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
}

.lang:hover { background: rgba(255, 255, 255, .14); }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  align-items: center;
  gap: clamp(32px, 6vw, 88px);
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 48px) 24px clamp(56px, 8vw, 96px);
  min-height: calc(100svh - 80px);
}

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.5rem, 8vw, 6.75rem);
  line-height: .9;
  letter-spacing: -.02em;
  color: var(--ink);
  text-shadow: 0 .06em 0 var(--shadow);
}

.hero h1 {
  margin: .5em 0 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  line-height: 1.15;
  color: var(--rock);
}

.lede {
  margin: 1rem 0 0;
  max-width: 36ch;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.4vw, 1.2rem);
}

.stores {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 2rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 172px;
  padding: 10px 18px 10px 14px;
  background: #000;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 12px;
  text-align: left;
  user-select: none;
}

.badge svg { width: 26px; height: 26px; flex: none; }

.badge-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.badge-text small { font-size: .72rem; opacity: .85; }
.badge-text b { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }

/* ---------- Playable board ---------- */

.play {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 440px);
  margin-bottom: 14px;
}

.stat {
  flex: 1 1 0;
  justify-content: space-between;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .07);
  border-radius: 12px;
  font-size: .9rem;
  color: var(--muted);
}

.stat strong {
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink);
  min-width: 1.6ch;
  display: inline-block;
}

.stat#scoreStat strong { color: #FFE629; }
.stat.bump strong { animation: bump .35s ease; }
.stat.warn { animation: warn .4s ease; }

.restart {
  margin-top: 6px;
  font: 600 .9rem/1 var(--body);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 10px 4px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.restart:hover { color: var(--ink); }

.board {
  position: relative;
  width: min(100%, 440px);
  aspect-ratio: 1;
  padding: var(--pad);
  background: var(--board);
  border-radius: 24px;
  box-shadow: 0 12px 0 var(--shadow), 0 34px 70px rgba(10, 0, 30, .5);
  user-select: none;
  -webkit-user-select: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: var(--gap);
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

.cell {
  position: relative;
  border-radius: 23%;
  background: var(--cell);
  transition: background-color .15s ease;
}

.cell.path { background: var(--path); }

.cell.block {
  --fill: var(--c);
  --edge: var(--d);
  background: var(--fill);
  border: var(--bw) solid var(--edge);
  transition: background-color .3s ease;
}

.cell.rock {
  --fill: var(--rc);
  --edge: var(--rd);
  background: var(--fill);
  border: var(--bw) solid var(--edge);
}

/* Neighbouring blocks merge into one piece, like in the game:
   a bridge fills the gap, with no seam where it meets the tile. */
.cell.jr::after,
.cell.jd::before {
  content: "";
  position: absolute;
  z-index: 1;
  background: var(--fill);
  pointer-events: none;
}

.cell.jr::after {
  left: calc(100% - 1px);
  top: 24%;
  height: 52%;
  width: calc(2 * var(--bw) + var(--gap) + 2px);
  border-top: var(--bw) solid var(--edge);
  border-bottom: var(--bw) solid var(--edge);
}

.cell.jd::before {
  top: calc(100% - 1px);
  left: 24%;
  width: 52%;
  height: calc(2 * var(--bw) + var(--gap) + 2px);
  border-left: var(--bw) solid var(--edge);
  border-right: var(--bw) solid var(--edge);
}

.cell.pop { animation: pop .42s ease-in forwards; z-index: 1; }

.line {
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  width: calc(100% - 2 * var(--pad));
  height: calc(100% - 2 * var(--pad));
  pointer-events: none;
  overflow: visible;
}

.line polyline {
  fill: none;
  stroke: rgba(255, 255, 255, .9);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line circle { fill: rgba(255, 255, 255, .9); }

.finger {
  position: absolute;
  left: 0;
  top: 0;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  border: 3px solid #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s ease, opacity .25s ease, scale .15s ease;
  z-index: 3;
}

.finger.show { opacity: 1; }
.finger.press { scale: .8; }

.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 3px;
  background: var(--c);
  pointer-events: none;
  z-index: 2;
  animation: spark .7s cubic-bezier(.2, .7, .3, 1) forwards;
}

.float {
  position: absolute;
  left: 50%;
  top: 46%;
  translate: -50% -50%;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  color: var(--ink);
  text-shadow: 0 4px 0 var(--shadow);
  white-space: nowrap;
  pointer-events: none;
  z-index: 4;
  animation: float 1.2s ease-out forwards;
}

.float.big { font-size: clamp(2rem, 8vw, 3.2rem); color: var(--rock); }
.float.bad { color: #FF8FA8; }

.hint {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: .95rem;
  text-align: center;
}

/* ---------- How to play ---------- */

.how {
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(48px, 7vw, 88px) 24px;
}

.how h2,
.cta-line {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  line-height: 1.05;
}

.steps {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(24px, 4vw, 56px);
}

.num {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--t);
  color: var(--shadow);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.6rem;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .2), inset 0 4px 0 rgba(255, 255, 255, .3);
}

.steps h3 {
  margin: 1rem 0 .3rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.6rem;
  line-height: 1.1;
}

.steps p {
  margin: 0;
  max-width: 34ch;
  color: var(--muted);
}

/* ---------- CTA + footer ---------- */

.cta {
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(48px, 7vw, 80px) 24px clamp(64px, 9vw, 112px);
  text-align: center;
}

.cta-line { max-width: 20ch; margin: 0 auto; }
.cta .stores { justify-content: center; }

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  color: var(--muted);
  font-size: .9rem;
}

.foot a { text-underline-offset: 3px; }
.foot a:hover { color: var(--ink); }

/* ---------- Privacy page ---------- */

.doc {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) 24px clamp(64px, 9vw, 112px);
}

.doc h1 {
  margin: 0 0 .3em;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 1.05;
}

.doc h2 {
  margin: 2.2em 0 .5em;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.15;
}

.doc p,
.doc li { color: #E9DEFA; }
.doc .meta { color: var(--muted); font-size: .95rem; }
.doc a { color: var(--rock); text-underline-offset: 3px; }

/* ---------- Animations ---------- */

@keyframes pop {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.18); filter: brightness(1.5); }
  100% { transform: scale(.15); opacity: 0; }
}

@keyframes spark {
  0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(.3); opacity: 0; }
}

@keyframes float {
  0% { opacity: 0; transform: translateY(14px) scale(.8); }
  18% { opacity: 1; transform: translateY(0) scale(1.06); }
  30% { transform: translateY(0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-28px); }
}

@keyframes bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes warn {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); background: rgba(255, 92, 138, .35); }
  75% { transform: translateX(5px); }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
    text-align: center;
  }
  .hero-copy { display: contents; }
  .wordmark { order: 1; }
  .hero h1 { order: 2; margin-top: .35em; }
  .play { order: 3; margin-top: 28px; }
  .lede { order: 4; margin-top: 28px; }
  .hero .stores { order: 5; margin-top: 20px; }
  .lede { margin-left: auto; margin-right: auto; }
  .hero .stores { justify-content: center; }
  .steps { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 420px) {
  :root { --pad: 8px; --gap: 6px; --bw: 3px; }
  .top { padding: 8px 18px; }
  .brand img { height: 68px; }
  .hero, .how, .cta { padding-left: 18px; padding-right: 18px; }
  .badge { min-width: 0; flex: 1 1 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Demo finish overlay ---------- */

.win {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 24px;
  background: rgba(21, 16, 58, .92);
  text-align: center;
  animation: winIn .45s cubic-bezier(.2, 1.3, .4, 1);
}

.win[hidden] { display: none; }

.win-card { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 320px; }

.win h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  line-height: 1;
  color: #FFE629;
  text-shadow: 0 4px 0 var(--shadow);
}

.win-score { margin: 0; color: var(--muted); }
.win-score strong { margin-left: 6px; font-family: var(--display); font-size: 1.8rem; color: var(--ink); }
.win-sub { margin: 0; color: var(--muted); font-size: .98rem; line-height: 1.4; }

.win-btn {
  margin-top: 6px;
  font: 800 1.15rem/1 var(--display);
  color: #15103A;
  background: #22C7E0;
  border: 0;
  border-radius: 999px;
  padding: 14px 30px;
  cursor: pointer;
}

.win-btn:hover { filter: brightness(1.08); }

@keyframes winIn {
  from { opacity: 0; transform: scale(.92); }
}
