:root {
  --ink: #1a2744;
  --paper: #fff6e8;
  --paper-2: #ffe8c2;
  --cream: #fffdf8;
  --mango: #f5b942;
  --mango-deep: #e39a18;
  --teal: #1aa88f;
  --teal-deep: #0e7f6c;
  --coral: #ff6a54;
  --sky: #5ec4f2;
  --leaf: #3fa66a;
  --lilac: #8b7cf0;
  --shadow: 5px 5px 0 var(--ink);
  --radius: 22px;
  --line: 3px;
  --font-display: "Baloo 2", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
  --max: 1120px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, #ffe8b8 0 90px, transparent 91px),
    radial-gradient(circle at 88% 12%, #c8f3ea 0 70px, transparent 71px),
    radial-gradient(circle at 80% 88%, #ffd4cc 0 110px, transparent 111px),
    var(--paper);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.55;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--teal-deep);
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

p {
  margin: 0 0 1rem;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 20;
  background: var(--cream);
  padding: 0.4rem 0.7rem;
  border: var(--line) solid var(--ink);
}

.wrap {
  width: min(var(--max), calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 246, 232, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: var(--line) solid var(--ink);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  background: var(--mango);
}

.nav-links {
  display: flex;
  gap: 1.1rem;
  margin-left: auto;
  align-items: center;
}

.nav-links a {
  color: inherit;
  text-decoration: none;
  font-weight: 800;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
  background: var(--cream);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 6px 6px 0 var(--ink);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn-mango { background: var(--mango); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-coral { background: var(--coral); color: #fff; }
.btn-sky { background: var(--sky); }
.btn-ghost { box-shadow: none; background: transparent; }

.menu-toggle {
  display: none;
  margin-left: auto;
}

.eyebrow {
  display: inline-block;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--sky);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  margin-bottom: 0.85rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 2.5rem;
  align-items: center;
  padding: 3.2rem 0 2.2rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 4.1rem);
}

.hero p {
  font-size: 1.15rem;
  max-width: 38rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.4rem;
}

.hero-card {
  background: var(--cream);
  border: var(--line) solid var(--ink);
  border-radius: 32px;
  box-shadow: 10px 10px 0 var(--ink);
  overflow: hidden;
}

.hero-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.section {
  padding: 3.4rem 0;
}

.section h2 {
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
}

.split {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 2rem;
  align-items: center;
}

.split img {
  border: var(--line) solid var(--ink);
  border-radius: 28px;
  box-shadow: var(--shadow);
  background: var(--cream);
}

.games {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.game-card {
  background: var(--cream);
  border: var(--line) solid var(--ink);
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-bottom: var(--line) solid var(--ink);
}

.game-card div {
  padding: 0.9rem 1rem 1.1rem;
}

.game-card h3 {
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
}

.game-card p {
  margin: 0;
  font-size: 0.95rem;
}

.game-card:nth-child(1) { background: #fff3c2; }
.game-card:nth-child(2) { background: #d8f6ef; }
.game-card:nth-child(3) { background: #ffe1da; }
.game-card:nth-child(4) { background: #d9f1ff; }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.step {
  background: var(--cream);
  border: var(--line) solid var(--ink);
  border-radius: 24px;
  padding: 1.2rem 1.2rem 1.4rem;
  box-shadow: var(--shadow);
}

.step span {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px solid var(--ink);
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 0.7rem;
  background: var(--mango);
}

.step:nth-child(2) span { background: var(--teal); color: #fff; }
.step:nth-child(3) span { background: var(--coral); color: #fff; }

.cta-band {
  background: var(--mango);
  border: var(--line) solid var(--ink);
  border-radius: 32px;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  box-shadow: 8px 8px 0 var(--ink);
}

.cta-band img {
  width: 110px;
}

.site-footer {
  border-top: var(--line) solid var(--ink);
  padding: 1.4rem 0 2rem;
  margin-top: 2rem;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.4rem;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}

.foot a {
  color: inherit;
  font-weight: 800;
}

/* App shell */
.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  padding: 1.2rem 0 2.4rem;
}

.hub-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.stars-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--mango);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-weight: 800;
}

.wallet-chip {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.85rem;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
}

.studio {
  display: grid;
  grid-template-columns: 220px minmax(220px, 1fr) minmax(280px, 1.1fr);
  gap: 0.9rem;
  align-items: start;
}

.panel {
  background: var(--cream);
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 0.8rem;
}

.panel h2,
.panel h3 {
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
}

.toolbox {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.block {
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.45rem 0.65rem;
  font-weight: 800;
  color: #fff;
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.block small {
  opacity: 0.85;
  font-weight: 700;
}

.b-teal { background: var(--teal); }
.b-mango { background: var(--mango-deep); color: var(--ink); }
.b-coral { background: var(--coral); }
.b-sky { background: var(--sky); color: var(--ink); }
.b-leaf { background: var(--leaf); }
.b-lilac { background: var(--lilac); }

.stack {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stack .block {
  cursor: default;
}

.stack .nest {
  margin: 0.35rem 0 0.1rem 1rem;
  padding: 0.35rem;
  border: 2px dashed rgba(255,255,255,0.55);
  border-radius: 12px;
  min-height: 42px;
}

.stack-empty {
  color: #5b6780;
  font-weight: 700;
  padding: 1rem 0.4rem;
}

.stage-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.maze {
  display: grid;
  gap: 3px;
  background: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  width: min(100%, 420px);
  margin: 0 auto;
}

.cell {
  aspect-ratio: 1;
  background: #ffe29a;
  position: relative;
}

.cell.wall { background: #147a6a; }
.cell.goal { background: #ff8a74; }
.cell.start { background: #8ee0ff; }

.actor {
  position: absolute;
  inset: 4%;
  background: center / contain no-repeat;
}

.actor::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  right: 2px;
  top: 50%;
  margin-top: -7px;
  border-left-color: var(--ink);
}

.actor[data-dir="0"]::after {
  right: auto;
  left: 50%;
  top: 2px;
  margin: 0 0 0 -7px;
  border-left-color: transparent;
  border-bottom-color: var(--ink);
}

.actor[data-dir="2"]::after {
  right: auto;
  left: 50%;
  top: auto;
  bottom: 2px;
  margin: 0 0 0 -7px;
  border-left-color: transparent;
  border-top-color: var(--ink);
}

.actor[data-dir="3"]::after {
  right: auto;
  left: 2px;
  border-left-color: transparent;
  border-right-color: var(--ink);
}

.status {
  min-height: 1.4rem;
  font-weight: 800;
  margin-top: 0.6rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 39, 68, 0.45);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 1rem;
}

.overlay[hidden] { display: none; }

.modal {
  width: min(420px, 100%);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 28px;
  box-shadow: 10px 10px 0 var(--ink);
  padding: 1.2rem;
  text-align: center;
}

.modal img {
  width: 160px;
  margin: 0 auto 0.6rem;
}

.puzzle-board {
  display: grid;
  gap: 6px;
  width: min(100%, 420px);
  margin: 0 auto;
  justify-content: center;
}

.puzzle-slot,
.puzzle-piece {
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #ffe9c8;
  overflow: hidden;
}

.puzzle-piece {
  cursor: grab;
}

.puzzle-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0.8rem;
  justify-content: center;
}

.puzzle-tray .puzzle-piece {
  width: 88px;
}

.turtle-wrap {
  width: min(100%, 420px);
  margin: 0 auto;
  border: 3px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.bird-grid {
  display: grid;
  gap: 3px;
  background: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px;
  width: min(100%, 520px);
  margin: 0 auto;
}

.bird-cell { aspect-ratio: 1; background: #ccefff; }
.bird-cell.cloud { background: #9aa6c2; }
.bird-cell.nest { background: #ffb14a; }
.bird-cell.star { background: #ff8a74; }

.level-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.4rem 0 0.8rem;
}

.level-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--cream);
  font-weight: 800;
  cursor: pointer;
}

.level-dot.done { background: var(--leaf); color: #fff; }
.level-dot.current { background: var(--mango); }

.note {
  background: #d9f1ff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 0.8rem 1rem;
  font-weight: 700;
}

.error-page {
  min-height: 70vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem 0;
}

.error-page img { width: 220px; margin: 0 auto 1rem; }

@media (max-width: 980px) {
  .hero, .split, .games, .steps, .studio {
    grid-template-columns: 1fr;
  }
  .games { grid-template-columns: 1fr 1fr; }
  .cta-band { flex-direction: column; text-align: center; }
}

@media (max-width: 720px) {
  .menu-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: var(--line) solid var(--ink);
    padding: 0.8rem 1rem 1rem;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-links.open { display: flex; }
  .hero { padding-top: 1.6rem; }
  .games { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .actor { transition: none; }
}
