@font-face { font-family: Fredoka; font-weight: 500; font-display: swap; src: url(fonts/fredoka-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Fredoka; font-weight: 600; font-display: swap; src: url(fonts/fredoka-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Fredoka; font-weight: 700; font-display: swap; src: url(fonts/fredoka-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: 'Luckiest Guy'; font-weight: 400; font-display: swap; src: url(fonts/luckiest-guy-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: 'Gochi Hand'; font-weight: 400; font-display: swap; src: url(fonts/gochi-hand-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); }

:root {
  --sun: #FFE14D;
  --ink: #17171C;
  --ink-2: #2B2A26;
  --muted: #55534C;
  --paper: #FFFFFF;
  --sand: #F3F1EA;
  --blue: #2E5BFF;
  --orange: #FF8A3D;
  --pink: #FFB3C1;
  --display: Fredoka, "Avenir Next Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --logo: 'Luckiest Guy', 'Arial Black', system-ui, sans-serif;
  --hand: 'Gochi Hand', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--sun);
  color: var(--ink);
  font-family: var(--display);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--ink); }
a:hover { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ---------- Rotating cat scenes: polaroids pinned beside the game ---------- */
.scenes { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.polaroid {
  position: absolute;
  width: clamp(200px, 21vw, 300px);
  margin: 0;
  padding: 10px 10px 0;
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(23, 23, 28, 0.85);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--sand); }
.polaroid figcaption { font-family: var(--hand); font-size: 21px; line-height: 1.15; text-align: center; padding: 8px 4px 10px; color: var(--ink); }
.polaroid.left { left: 2.5vw; top: 17vh; transform: rotate(-6deg); }
.polaroid.right { right: 2.5vw; top: 42vh; transform: rotate(5deg); }
.polaroid.swap.left { opacity: 0; transform: rotate(-14deg) scale(0.9); }
.polaroid.swap.right { opacity: 0; transform: rotate(13deg) scale(0.9); }
.pit-slot::before { content: ""; position: absolute; inset: 0; background-image: var(--scene, none); background-size: cover; background-position: center; opacity: 0.3; transition: opacity 0.6s ease; }

/* ---------- The bouncing pit ---------- */
.pit {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}
.pit.in-slot { position: absolute; inset: 0; }
.pit-slot { display: none; }

.page {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  pointer-events: none;
}
.page > * { pointer-events: auto; }

.body {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  touch-action: manipulation;
}

.tile {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tile .ch { font-size: 34px; font-weight: 700; line-height: 1; }
.tile .v { position: absolute; right: 6px; bottom: 3px; font-family: var(--body); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.tile.pop .ch { animation: pop 0.28s ease-out; }
.tile:active { background: var(--sun); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

.sponsor { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; }
.sponsor-ball {
  width: 92px; height: 92px; border-radius: 50%;
  border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  display: grid; place-items: center; text-align: center; padding: 8px;
  color: #FFFFFF; font-weight: 700; font-size: 14px; line-height: 1.1;
}
.sponsor-tag { font-family: var(--body); font-size: 11px; font-weight: 600; color: var(--ink); background: var(--paper); border: 1px solid var(--ink); border-radius: 4px; padding: 1px 6px; }

.pet { width: 72px; height: 72px; pointer-events: auto; cursor: pointer; }
.pet img { width: 100%; height: 100%; display: block; border-radius: 50%; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); object-fit: cover; user-select: none; -webkit-user-drag: none; }

/* ---------- Header ---------- */
.top { align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.tagline { margin: 0; font-family: var(--hand); font-size: 24px; font-weight: 400; line-height: 1.1; color: var(--ink); transform: rotate(-2deg); transform-origin: left center; }
.logo { font-family: var(--logo); font-size: 46px; font-weight: 400; letter-spacing: 0.02em; line-height: 1; text-decoration: none; color: var(--ink); text-shadow: 3px 3px 0 var(--orange); }
.logo-letters { display: inline-flex; }
.logo-letters span { display: inline-block; transition: transform 0.2s ease; }
.logo-letters span:nth-child(odd) { transform: rotate(-4deg) translateY(1px); }
.logo-letters span:nth-child(even) { transform: rotate(3deg) translateY(-2px); }
.logo:hover .logo-letters span { animation: wobble 0.5s ease-in-out; }
.logo:hover .logo-letters span:nth-child(2n) { animation-delay: 0.06s; }
.logo:hover .logo-letters span:nth-child(3n) { animation-delay: 0.12s; }
@keyframes wobble { 0%, 100% { translate: 0 0; } 40% { translate: 0 -8px; } 70% { translate: 0 2px; } }
.nav { display: flex; align-items: center; gap: 12px; font-family: var(--body); font-size: 14px; font-weight: 600; }
.linkish { min-height: 44px; padding: 0 4px; background: none; border: 0; text-decoration: underline; cursor: pointer; font-family: var(--body); font-weight: 600; font-size: 14px; }

/* ---------- Game card ---------- */
.card {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.levels { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.levels label { position: relative; cursor: pointer; }
.levels input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.levels span {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper); color: var(--ink);
  font-family: var(--display); font-weight: 600; font-size: 16px;
}
.levels label.done span::after { content: "✓"; font-weight: 700; }
.levels input:checked + span { background: var(--ink); color: var(--sun); }
.levels input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 3px; }
.level-blurb { margin: 0 0 0 6px; flex: 1 1 180px; font-family: var(--body); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.how-levels { margin: 18px 0 0; font-family: var(--body); font-size: 15px; line-height: 1.5; color: var(--ink-2); text-align: center; }
.title { margin: 0; font-size: 40px; line-height: 1.1; font-weight: 700; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.target { background: var(--blue); color: #FFFFFF; border: 3px solid var(--ink); border-radius: 999px; padding: 0 20px; font-size: 44px; min-width: 1.6em; text-align: center; }
.rules { margin: 0; font-family: var(--body); font-size: 15px; line-height: 1.45; color: var(--ink-2); }

.tray {
  min-height: 68px;
  border: 2px dashed var(--ink);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.tray-empty { font-family: var(--body); font-size: 14px; color: var(--muted); padding-left: 6px; }
.mini {
  position: relative;
  width: 44px; height: 46px;
  background: var(--sun);
  border: 2px solid var(--ink);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 700;
}
.mini.new { animation: drop 0.22s ease-out; }
.mini .v { position: absolute; right: 3px; bottom: 1px; font-family: var(--body); font-size: 10px; font-weight: 600; }
@keyframes drop { from { transform: translateY(-14px) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

.keeper { display: flex; align-items: center; gap: 18px; }
.keeper-cat, .how-cat {
  position: relative;
  width: 120px;
  height: 146px;
  flex-shrink: 0;
  animation: bob 1.6s ease-in-out infinite alternate;
}
.portrait {
  position: absolute;
  left: 6px;
  top: 0;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  object-fit: cover;
  background: #E9D9B8;
}
.keeper-cat.hop { animation: hop 0.45s ease-out; }
.keeper-cat { width: 200px; }
.keeper-cat .portrait { z-index: 2; }
.keeper-cat .portrait.buddy { z-index: 1; left: 92px; top: 10px; width: 100px; height: 100px; }
.keeper-cat .sign { z-index: 3; left: 30px; width: 150px; }
@keyframes bob { from { transform: translateY(0) rotate(-2deg); } to { transform: translateY(-6px) rotate(2deg); } }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-18px) rotate(-4deg); } 100% { transform: translateY(0); } }

.sign {
  position: absolute; left: 4px; top: 90px;
  width: 112px; height: 54px;
  border: 3px solid var(--ink); border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 26px;
  background: var(--ink); color: var(--sun);
}
.sign.win, .sign-blue { background: var(--blue); color: #FFFFFF; }
.sign-white { background: var(--paper); color: var(--ink); }
.sign-yellow { background: var(--sun); color: var(--ink); }
.sign-small { font-size: 17px; }
.sign-spaced { letter-spacing: 0.14em; }

.bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 16px 18px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  background: var(--paper);
  color: var(--ink);
}
.bubble::before {
  content: "";
  position: absolute;
  left: -11px; top: 50%;
  width: 16px; height: 16px; margin-top: -8px;
  transform: rotate(45deg);
  border-left: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: inherit;
}
.bubble span { position: relative; }
.bubble .who { display: block; margin-bottom: 2px; font-family: var(--body); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; }
.bubble.tone-blue { background: var(--blue); color: #FFFFFF; }
.bubble.tone-orange { background: var(--orange); color: var(--ink); }
.bubble.tone-grey { background: var(--sand); color: var(--ink); }

.actions { display: flex; gap: 8px; }
.btn {
  min-height: 48px;
  padding: 0 18px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 14px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
}
.btn:active { transform: translate(1px, 1px); }
.btn-go { flex: 1; background: var(--ink); color: var(--sun); font-weight: 700; font-size: 20px; }
.btn-big { flex: 0 0 auto; min-height: 56px; padding: 0 40px; font-size: 22px; box-shadow: 4px 4px 0 var(--blue); }
.btn[disabled] { opacity: 0.45; cursor: default; }

.guesses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.guesses:not(:empty) { border-top: 2px solid var(--ink); padding-top: 14px; }
.guess { display: flex; align-items: center; gap: 10px; }
.guess .w { font-size: 20px; font-weight: 700; letter-spacing: 0.12em; min-width: 7.5em; overflow-wrap: anywhere; }
.guess .s { font-size: 20px; font-weight: 700; }
.chip { margin-left: auto; min-height: 34px; display: flex; align-items: center; padding: 0 14px; border-radius: 999px; border: 2px solid var(--ink); font-family: var(--body); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.up { background: var(--blue); color: #FFFFFF; }
.chip.down { background: var(--orange); color: var(--ink); }
.chip.hit { background: var(--ink); color: var(--sun); }

.end { border-top: 2px solid var(--ink); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.end p { margin: 0; }
.end-line { font-size: 22px; font-weight: 700; }
.end-examples { font-family: var(--body); font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.end-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.end-actions .btn-go { flex: 0 0 auto; padding: 0 22px; }
.next { font-family: var(--body); font-size: 14px; font-weight: 500; color: var(--ink-2); }

/* ---------- Toys + footer ---------- */
.toys { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.toy {
  min-height: 44px;
  padding: 0 18px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}
.toy[aria-pressed="true"] { background: var(--ink); color: var(--sun); }
.foot { margin-top: auto; align-self: center; text-align: center; font-family: var(--body); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.foot p { margin: 2px 0; }
.foot .small { font-size: 12px; }

/* ---------- How to play ---------- */
.how {
  width: min(940px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 28px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 8px 8px 0 var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
}
.how::backdrop { background: rgba(23, 23, 28, 0.45); }
.how-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.how h2 { margin: 0; font-family: var(--logo); font-weight: 400; font-size: 38px; letter-spacing: 0.02em; line-height: 1.1; text-shadow: 2px 2px 0 var(--orange); }
.how-sub { font-family: var(--hand); font-size: 20px; color: var(--ink-2); transform: rotate(-1.5deg); }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.how-step { background: var(--sun); border: 2px solid var(--ink); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.how-step:nth-child(2) .how-cat { animation-delay: -0.6s; }
.how-step:nth-child(3) .how-cat { animation-delay: -1.2s; }
.how-step h3 { margin: 0; font-size: 22px; line-height: 1.15; }
.how-step p { margin: 0; font-family: var(--body); font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.how-step .step-no { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.how-foot { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- Phones: the pit becomes a box under the card ---------- */
@media (max-width: 899px) {
  .scenes { display: none; }
  .page { padding: 16px 16px 24px; gap: 16px; }
  .pit-slot { display: block; position: relative; height: 380px; border: 3px solid var(--ink); border-radius: 24px; background: #FFEB85; overflow: hidden; order: 3; }
  .toys { order: 4; }
  .foot { order: 5; }
  .card { padding: 18px; gap: 14px; border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); }
  .title { font-size: 28px; gap: 10px; }
  .target { font-size: 30px; padding: 0 14px; }
  .logo { font-size: 36px; }
  .tagline { font-size: 20px; }
  .keeper-cat { width: 96px; height: 118px; }
  .keeper-cat { width: 150px; }
  .keeper-cat .portrait { left: 4px; width: 84px; height: 84px; }
  .keeper-cat .portrait.buddy { left: 70px; top: 8px; width: 76px; height: 76px; }
  .keeper-cat .sign { left: 22px; top: 72px; width: 108px; height: 44px; font-size: 22px; }
  .bubble { font-size: 16px; padding: 10px 12px; }
  .keeper { gap: 14px; }
  .tile { width: 52px; height: 52px; border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); }
  .tile .ch { font-size: 26px; }
  .tile .v { right: 4px; bottom: 2px; font-size: 10px; }
  .sponsor-ball { width: 76px; height: 76px; font-size: 12px; }
  .guess .w { font-size: 17px; min-width: 6.5em; }
  .guess .s { font-size: 17px; }
  .chip { font-size: 13px; padding: 0 10px; min-height: 30px; }
  .how { padding: 20px; }
  .how h2 { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-letters span,
  .keeper-cat, .how-cat, .mini, .tile.pop .ch { animation: none !important; }
}
