/* Fredoka (SIL OFL 1.1, see fonts/OFL.txt), bundled so the game makes no font requests. */
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/fredoka-latin.woff2") format("woff2");
}
:root {
  --ink: #3b2340;
  --cream: #fff8ea;
  --wall: #fff1d6;
  --tomato: #ef5b4c;
  --butter: #ffcf5a;
  --mint: #8fd8c3;
  --teal: #2b857f;
  --cookie: #dfa45c;
  --choc: #5b3424;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--wall);
  overscroll-behavior: none;
}
body {
  font-family: Fredoka, "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
#game {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: pointer;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.meter { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.progress {
  display: flex; gap: 5px; padding: 5px 9px;
  background: rgba(255, 248, 234, .92);
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink);
}
.pip { width: 26px; height: 26px; display: block; }
.pip .ck { fill: rgba(59, 35, 64, .06); stroke: var(--ink); stroke-width: 2; stroke-dasharray: 3.2 2.6; }
.pip .chip { fill: rgba(59, 35, 64, .12); }
.pip.on .ck { fill: var(--cookie); stroke-dasharray: none; }
.pip.on .chip { fill: var(--choc); }
.pip.pop { animation: pop .55s cubic-bezier(.2, 1.8, .4, 1); }
.bones { display: flex; gap: 4px; padding: 3px 8px; background: rgba(255, 248, 234, .75); border-radius: 999px; }
.bone { width: 28px; height: 14px; display: block; }
.bone path, .res-bone path { fill: rgba(59, 35, 64, .1); stroke: rgba(59, 35, 64, .45); stroke-width: 1.8; stroke-dasharray: 2.5 2; }
.bone.on path, .res-bone.on path { fill: var(--cream); stroke: var(--ink); stroke-dasharray: none; }
.bone.on { animation: pop .55s cubic-bezier(.2, 1.8, .4, 1); }

.caught {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 6px;
  background: var(--butter); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink);
  font-size: 22px; font-weight: 700; line-height: 1;
}
.caught[hidden] { display: none; }
.caught svg { width: 26px; height: 26px; }
.caught.pop { animation: pop .35s cubic-bezier(.2, 1.8, .4, 1); }
.controls { display: flex; gap: 8px; }
.btn {
  position: relative; width: 48px; height: 48px; padding: 0;
  display: grid; place-items: center;
  border: 3px solid var(--ink); border-radius: 15px;
  background: var(--cream); color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer; transition: transform .08s, box-shadow .08s, background .2s;
}
.btn svg { width: 26px; height: 26px; fill: currentColor; }
.btn svg .ln { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.hint { background: var(--butter); position: relative; }
.sniff-n {
  position: absolute; right: -8px; top: -8px; min-width: 22px; height: 22px; padding: 0 5px;
  display: grid; place-items: center; font-size: 14px; line-height: 1; color: var(--cream);
  background: var(--tomato); border: 2.5px solid var(--ink); border-radius: 999px;
}
.btn.hint.invite, .btn.hint.free { animation: nudge 1.6s ease-in-out infinite; }
.btn.hint.free .sniff-n { background: var(--teal); }
.btn.hint.gain .sniff-n { animation: pop .55s cubic-bezier(.2, 1.8, .4, 1); }
.btn[hidden] { display: none; }
.btn.off { background: #ece3d4; color: rgba(59, 35, 64, .55); }
.btn.off::after {
  content: ""; position: absolute; width: 34px; height: 4px; border-radius: 2px;
  background: var(--tomato); transform: rotate(-45deg); box-shadow: 0 0 0 2px var(--cream);
}
.btn.confirm { background: var(--tomato); color: var(--cream); animation: wob .35s; }
.btn:focus-visible, .again:focus-visible { outline: 4px solid var(--teal); outline-offset: 3px; }

@media (max-width: 440px) {
  .btn { width: 42px; height: 42px; border-radius: 13px; }
  .btn svg { width: 22px; height: 22px; }
  .controls { gap: 6px; }
  .pip { width: 21px; height: 21px; }
  .progress { gap: 3px; padding: 4px 7px; }
  .bone { width: 24px; height: 12px; }
}

/* ---------- title flash ---------- */
.title {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  display: grid; place-content: center; text-align: center;
  animation: titleIn .8s cubic-bezier(.2, 1.6, .4, 1) both;
  transition: opacity .5s ease, transform .5s ease;
}
.title::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: min(620px, 92vw); height: min(300px, 50vw);
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 248, 234, .92), rgba(255, 248, 234, 0));
}
.title h1 {
  position: relative; margin: 0; font-weight: 700; line-height: .92;
  font-size: clamp(52px, 12vw, 128px); letter-spacing: .01em;
  text-shadow:
    -4px -4px 0 var(--ink), 4px -4px 0 var(--ink), -4px 4px 0 var(--ink), 4px 4px 0 var(--ink),
    0 -4px 0 var(--ink), 0 4px 0 var(--ink), -4px 0 0 var(--ink), 4px 0 0 var(--ink),
    0 11px 0 var(--ink);
}
.title .t1 { color: var(--butter); display: inline-block; transform: rotate(-4deg); }
.title .t2 { color: var(--tomato); display: inline-block; transform: rotate(3deg); }
.title p {
  position: relative; justify-self: center; margin: 16px 0 0; padding: 6px 16px;
  font-size: clamp(16px, 3.4vw, 22px); font-weight: 600;
  color: var(--cream); background: var(--ink); border-radius: 999px;
}
.title.gone { animation: none; opacity: 0; transform: scale(1.12); }

/* ---------- results ---------- */
.results {
  position: fixed; inset: 0; z-index: 4; padding: 16px;
  display: grid; place-items: end center; padding-bottom: max(5vh, 24px);
  background: linear-gradient(to top, rgba(59, 35, 64, .38), rgba(59, 35, 64, 0) 70%);
  opacity: 0; transition: opacity .35s ease;
  pointer-events: none; /* the kitchen stays playable (munch the cookies!) */
}
.results .card { pointer-events: auto; }
.results[hidden] { display: none; }
.results.show { opacity: 1; }
.card {
  width: min(360px, 100%); padding: 18px 24px 24px; text-align: center;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 28px;
  box-shadow: 0 9px 0 var(--ink);
  transform: scale(.75) rotate(-3deg);
  transition: transform .5s cubic-bezier(.2, 1.7, .4, 1);
}
.results.show .card { transform: scale(1) rotate(-1deg); }
.big-cookie { width: 74px; height: 74px; margin-top: -54px; filter: drop-shadow(0 4px 0 var(--ink)); animation: spin 6s linear infinite; }
.yum {
  margin: 2px 0 6px; font-size: 64px; line-height: 1; font-weight: 700; color: var(--tomato);
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 7px 0 var(--ink);
}
.the-end { margin: 0 0 2px; font-size: 17px; font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 18px; margin: 10px 0 4px; }
.stat { display: inline-flex; align-items: center; gap: 6px; font-size: 28px; }
.stat svg { width: 30px; height: 30px; }
.stat .res-bone { width: 32px; height: 16px; }
.best { margin: 4px 0 0; min-height: 1.2em; font-weight: 600; color: var(--teal); font-size: 18px; }
.hint-line { margin: 2px 0 0; font-size: 16px; color: rgba(59, 35, 64, .75); }
.hint-line[hidden] { display: none; }
.again {
  margin-top: 14px; display: inline-flex; align-items: center; gap: 10px;
  font: inherit; font-size: 24px; font-weight: 700; color: var(--cream);
  background: var(--tomato); border: 4px solid var(--ink); border-radius: 18px;
  padding: 12px 26px 12px 20px; box-shadow: 0 5px 0 var(--ink); cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.again svg { width: 28px; height: 28px; }
.again[hidden] { display: none; }
.again.next { margin-right: 6px; padding: 12px 18px 12px 24px; }
.again.secondary { background: var(--cream); color: var(--ink); font-size: 20px; padding: 10px 18px 10px 14px; }
.res-stars { display: flex; justify-content: center; gap: 6px; margin: 2px 0 4px; }
.res-star { width: 40px; height: 40px; fill: rgba(59, 35, 64, .1); stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.res-star.on { fill: var(--butter); animation: pop .5s cubic-bezier(.2, 1.8, .4, 1) both; }
.res-star.on:nth-child(2) { animation-delay: .25s; }
.res-star.on:nth-child(3) { animation-delay: .5s; }
.genius { margin: 0 0 6px; font-size: 17px; font-weight: 600; color: var(--tealDark, #2b857f); }
.score-line { margin: 4px 0 0; font-size: 16px; font-weight: 600; }
.btn-row { display: flex; justify-content: center; align-items: center; gap: 10px; }
.btn-row .again { margin-top: 12px; }
.again.rooms { padding: 10px 12px; }
.again.rooms svg { width: 26px; height: 26px; }

/* ---------- panels: out of sniffs, room map ---------- */
.panel-wrap { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; padding: 16px; background: rgba(59, 35, 64, .45); opacity: 0; transition: opacity .25s ease; }
.panel-wrap[hidden] { display: none; }
.panel-wrap.show { opacity: 1; }
.panel {
  width: min(380px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px 22px 22px; text-align: center;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 8px 0 var(--ink);
}
.panel h2 { margin: 0 0 4px; font-size: 30px; }
.panel-sub { margin: 4px 0 8px; font-size: 17px; }
.rooms { display: grid; gap: 8px; margin: 8px 0 4px; }
.room-card {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; text-align: left;
  font: inherit; font-size: 19px; font-weight: 600; color: var(--ink); cursor: pointer;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 8px 12px; box-shadow: 0 4px 0 var(--ink);
}
.room-card.here { background: var(--butter); }
.room-card.locked { opacity: .5; cursor: default; }
.room-card:focus-visible { outline: 4px solid var(--teal); outline-offset: 3px; }
.room-n { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--cream); font-size: 16px; }
.room-stars .star { font-size: 20px; color: rgba(59, 35, 64, .2); }
.room-stars .star.on { color: #f2a93b; }
.fade { position: fixed; inset: 0; z-index: 8; background: var(--wall); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.fade.on { opacity: 1; }
.again:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- keyboard & screen-reader layer ---------- */
#targets { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.target {
  position: absolute; left: 0; top: 0; padding: 0; margin: 0;
  border: 0; border-radius: 50%; background: transparent; pointer-events: none;
}
.target:focus { outline: none; }
.target:focus-visible { outline: 5px solid var(--teal); outline-offset: 2px; box-shadow: 0 0 0 10px rgba(255, 255, 255, .65); }
.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;
}
.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-size: 22px; background: var(--wall); }

@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes wob { 0%, 100% { transform: rotate(0); } 33% { transform: rotate(-8deg); } 66% { transform: rotate(8deg); } }
@keyframes titleIn { from { opacity: 0; transform: scale(.6) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes nudge { 0%, 100% { transform: none; } 15% { transform: rotate(-10deg) scale(1.08); } 30% { transform: rotate(10deg) scale(1.08); } 45% { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .title, .pip.pop, .bone.on, .big-cookie, .btn.confirm, .btn.hint.invite, .btn.hint.free, .res-star.on { animation: none; }
  .card, .results.show .card { transition: none; transform: none; }
}

/* ---------- Biscuit's Big Rescue ---------- */
.lvl {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px;
  background: rgba(255, 248, 234, .94); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink);
  font-weight: 700; font-size: 17px; white-space: nowrap; max-width: 52vw; overflow: hidden; text-overflow: ellipsis;
}
.lvl b { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--cream); font-size: 15px; }
.cookiebar { position: relative; width: 150px; height: 18px; border: 3px solid var(--ink); border-radius: 999px; background: rgba(255, 248, 234, .9); overflow: hidden; box-shadow: 0 3px 0 var(--ink); }
.cookiebar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--cookie); transition: width .2s; }
.cookiebar.full i { background: #7dc26a; }
.cookiebar svg { position: absolute; right: 3px; top: 1px; width: 12px; height: 12px; }
.card .why { margin: 0 0 6px; font-size: 18px; }
.card.lose .yum { color: var(--teal); }
.intro {
  position: fixed; left: 0; right: 0; top: 34%; z-index: 4; text-align: center; pointer-events: none;
  opacity: 0; transform: scale(.8); transition: opacity .25s, transform .35s cubic-bezier(.2, 1.7, .4, 1);
}
.intro.show { opacity: 1; transform: none; }
.intro small { display: inline-block; font-size: 18px; font-weight: 700; color: var(--cream); background: var(--ink); border-radius: 999px; padding: 4px 14px; }
.intro h2 {
  margin: 8px 0 0; font-size: clamp(38px, 9vw, 64px); line-height: 1; color: var(--butter);
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 7px 0 var(--ink);
}
.bars::before, .bars::after { content: ""; position: fixed; left: 0; right: 0; height: 0; background: #1d1220; z-index: 3; transition: height .35s ease; }
.bars::before { top: 0; } .bars::after { bottom: 0; }
.bars.on::before, .bars.on::after { height: 7vh; }
@media (max-width: 420px) { .cookiebar { width: 110px; } .lvl { font-size: 15px; } }
.rooms.levels { grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .rooms.levels { grid-template-columns: 1fr; } }

.intro-story { margin: 12px auto 0; max-width: min(520px, 90vw); font-size: clamp(16px, 2.4vw, 20px); font-weight: 600; color: var(--cream); background: rgba(59, 35, 64, .88); border-radius: 16px; padding: 8px 14px; }
.story-line { margin: 2px 0 8px; font-size: 16px; font-weight: 600; color: var(--choc); }
.panel-sub.mission { font-weight: 600; color: var(--teal); }
.btn.invite { animation: nudge 1.6s ease-in-out infinite; }

/* ---------- Biscuit on Ice ---------- */
html.ice, html.ice body { background: #2c3170; }
.ice .fade { background: #2c3170; }
.ice-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 6px;
  background: rgba(255, 248, 234, .94); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink);
  font-weight: 700; font-size: 16px; line-height: 1.1; white-space: nowrap;
}
.chip svg { width: 20px; height: 20px; flex: none; }
.chip.pop { animation: pop .35s cubic-bezier(.2, 1.8, .4, 1); }
.chip .par { color: #b8741d; }
.chip.over .par { color: rgba(59, 35, 64, .45); text-decoration: line-through; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; pointer-events: none;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.dock .slot { display: flex; flex-direction: column; align-items: center; }
.dock .btn { pointer-events: auto; width: 58px; height: 58px; border-radius: 50%; }
.dock .btn svg { width: 30px; height: 30px; }
.dock .btn:disabled { opacity: .45; cursor: default; }
.dock .btn.invite { background: var(--butter); }
.dock-label { display: block; font-size: 13px; font-weight: 700; color: var(--cream); text-align: center; margin-top: 4px; text-shadow: 0 2px 0 var(--ink); }
.target.dir { border-radius: 14px; }
@media (max-width: 420px) { .chip { font-size: 14px; } .dock .btn { width: 52px; height: 52px; } }
@media (prefers-reduced-motion: reduce) { .chip.pop, .btn.invite { animation: none; } }
