@font-face { font-family: Fredoka; src: url("fonts/Fredoka.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }
:root { --ink: #402817; --paper: #ffefd3; --border: #54341d; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; display: grid; place-items: center; color: var(--ink); background: radial-gradient(ellipse at top, #ffefd0, #ffe0ac 80%); font: 500 1.1rem/1.3 Fredoka, sans-serif; }
button,input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible,input:focus-visible { outline: 4px solid #245ca0; outline-offset: 3px; }
.game { width: min(100%, 75rem); padding: clamp(.65rem, 2vw, 1.6rem); }
.topbar,.tools,.console,form { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: .5rem; padding: 0 .15rem .8rem; }
h1 { font-size: clamp(1.75rem,4.5vw,3rem); line-height: 1; margin: 0; font-weight: 700; letter-spacing: -.04em; color: #673212; }
.tools { gap: .65rem; }
#score,#sound { border: 2px solid var(--border); border-radius: .65rem; padding: .38rem .8rem; background: #fff9e6; font-weight: 600; font-size: 1rem; }
#score span { color: #995006; } #sound { min-height: 44px; } #sound[aria-pressed=true] { background: #dff0b9; }
.cabinet { overflow: hidden; border: 4px solid var(--border); border-radius: 1.1rem; box-shadow: 0 6px 0 #b6844c; background: var(--paper); }
.field { position: relative; isolation: isolate; container-type: size; overflow: hidden; height: clamp(25rem, 56vh, 37rem); background: #bcce4a url("art/meadow.jpg") center 56% / cover no-repeat; }
.question { position: absolute; z-index: 2; top: 5%; left: 50%; transform: translateX(-50%); text-align: center; width: max-content; max-width: 95%; }
h2 { margin: 0 auto; width: max-content; padding: .03em .4em .1em; line-height: 1.05; font-size: clamp(2.8rem, 6.7vw, 5rem); border: 3px solid var(--border); border-radius: .7rem; background: #fff6da; box-shadow: 0 4px 0 #613a23; font-variant-numeric: tabular-nums; }
#prompt { display: inline-block; margin: .55rem 0 0; background: #fff8df; border: 2px solid var(--border); border-radius: .55rem; padding: .2rem .7rem; font-size: clamp(1rem,2vw,1.35rem); }
#verdict { margin: 0; }
#verdict:not(:empty) {
  display: table; margin: .48rem auto 0; padding: .06em .42em .12em;
  font-size: clamp(1.7rem,5vw,3.6rem); font-weight: 700; line-height: 1.06;
  letter-spacing: .015em; white-space: nowrap;
  border: 3px solid #3f291b; border-radius: .28em;
  color: #fff9dc; background: #2d6037;
  box-shadow: inset 0 0 0 2px #d9eaa1, 0 4px 0 #49331d;
}
#verdict[data-result="miss"]:not(:empty) { background: #863b31; box-shadow: inset 0 0 0 2px #ffcf99, 0 4px 0 #49331d; }
#verdict:not(:empty) + #prompt { display: none; }
.actor { position: absolute; width: 23%; left: 1%; bottom: 9%; z-index: 2; pointer-events: none; }
.fox { display: block; width: 100%; }
.actor.whimpering .fox { visibility: hidden; }
.actor.whimpering::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: url("art/fox-whimper.webp") 0 0 / 300% 100% no-repeat;
  transform-origin: 62% 96%;
  animation: whimper-poses 1.2s step-end both, whimper-shiver 1.2s ease-in-out both;
}
@keyframes whimper-poses {
  0%, 100% { background-position-x: 0%; }
  18%, 60%, 82% { background-position-x: 50%; }
  36%, 70% { background-position-x: 100%; }
}
@keyframes whimper-shiver {
  0%, 30%, 60%, 90%, 100% { transform: none; }
  44%, 73% { transform: rotate(-1.1deg) scaleY(.985); }
}
@media (prefers-reduced-motion: reduce) {
  .actor.whimpering::after { animation: none; }
}
.actor.carry { left: auto; right: .4%; }
#leaper { position: absolute; top: 0; left: 0; width: 28%; aspect-ratio: 1; z-index: 3; pointer-events: none; background: url("art/fox-pounce.webp") 0 0 / 300% 200% no-repeat; }
.actor.gathering { z-index: 1; }
.actor.gathering ~ #apples { z-index: 2; }
.apple.aimed { outline: 3px solid #fff5b8; outline-offset: 1px; background: #fff4b12e; box-shadow: 0 0 0 5px #885c21b0; }
#basket-fruit { position: absolute; left: 30%; width: 34%; bottom: 62%; height: 29%; display: flex; align-content: end; align-items: end; flex-wrap: wrap-reverse; justify-content: center; }
#basket-fruit img { width: var(--fruit-width,32%); max-height: 70%; object-fit: contain; }
#apples { position: absolute; left: 24%; right: 24%; top: 57%; transform: translateY(-25%); display: grid; grid-template-columns: repeat(var(--cols,5), minmax(0, 1fr)); gap: clamp(1px,.7vw,10px); justify-items: center; align-items: end; }
.apple { display: grid; place-items: center; width: 100%; max-width: 6.35rem; height: clamp(3.4rem,7.1vw,5.5rem); position: relative; background: transparent; border: 0; padding: .05rem; border-radius: .45rem; -webkit-tap-highlight-color: transparent; }
.apple img { width: 100%; height: 100%; min-height: 0; object-fit: contain; filter: drop-shadow(0 3px 0 #53400f77); }
.apple[aria-pressed=true] img { opacity: .6; }
.apple[aria-pressed=true]::before,.apple[aria-pressed=true]::after { content: ""; width: 83%; max-width: 4.75rem; height: .37rem; position: absolute; z-index: 1; background: #432718; border-radius: .4rem; box-shadow: 0 0 0 1.5px #fff3ca; transform: rotate(45deg); }
.apple[aria-pressed=true]::after { transform: rotate(-45deg); }
.apple.gone { visibility: hidden; }
.note { position: absolute; right: 2%; top: 45%; margin: 0; padding: .25em .5em; border: 2px solid #724820; border-radius: .3rem; background: #ffe69c; color: #472c15; font-size: clamp(1rem,2vw,1.5rem); font-weight: 600; box-shadow: 2px 3px 0 #59401d70; }
.note span:first-child { color: #70460d; }
@media (min-width: 681px) {
  .note { top: 30%; }
  .field:has(.apple:nth-child(6)) h2 { font-size: clamp(2.8rem,min(6.7vw,15cqh),5rem); }
  .field:has(.apple:nth-child(6)) #verdict:not(:empty) { font-size: clamp(1.7rem,min(5vw,10cqh),3.6rem); }
}
#cutin {
  position: absolute; inset: 0; z-index: 5; isolation: isolate; overflow: hidden;
  container-type: size; display: grid; grid-template-columns: minmax(0,1fr); place-items: center;
  background: rgb(49 21 20 / 84%);
  animation: cutin-reveal 160ms cubic-bezier(.12,.79,.2,1) both;
}
.cutin-panel {
  width: min(100%, 250cqh); display: grid; grid-template-columns: minmax(0,1fr); place-items: end center;
  position: relative;
  box-shadow: 0 -3px #552520, 0 3px #552520, 0 7px 16px #29131180;
}
.cutin-art {
  grid-area: 1 / 1; width: 100%; aspect-ratio: 1983 / 793;
  /* Keep the fox at its painted size and center it by fitting the surrounding speed lines. */
  border-image: url("art/apple-dash-cutin.webp") 240 548 260 710 fill / 31.84% 31.82% 31.21% 31.62% / 0 stretch;
}
.move-banner {
  grid-area: 1 / 1; z-index: 1; margin: 0 .5rem clamp(.7rem,2vh,1.25rem);
  padding: .14em .8em .2em; text-align: center; color: #502014;
  background: linear-gradient(100deg,#ffcf65,#fff4cc 24%,#fff4cc 82%,#ffdb77);
  border: 3px solid #5c2417; box-shadow: 4px 4px 0 #762b1c, inset 0 0 0 2px #fff9d6;
  font-size: clamp(1.4rem,3.2vw,2.5rem); font-style: italic; line-height: 1.1;
  transform: skewX(-7deg); animation: cutin-banner 160ms 65ms ease-out both;
}
@keyframes cutin-reveal {
  from { clip-path: polygon(0 0,18% 0,0 100%,0 100%); }
  to { clip-path: polygon(0 0,119% 0,100% 100%,0 100%); }
}
@keyframes cutin-banner {
  from { transform: translateY(100%) skewX(-12deg); opacity: 0; }
  to { transform: translateY(0) skewX(-7deg); opacity: 1; }
}
@container (max-aspect-ratio: 1 / 1) {
  .cutin-panel { box-shadow: none; }
  .cutin-art { box-shadow: 0 -3px #552520, 0 3px #552520; }
  .move-banner { position: absolute; top: 100%; justify-self: center; margin: .8rem .5rem 0; white-space: nowrap; }
}
.flying-apple { position: absolute; z-index: 4; pointer-events: none; object-fit: contain; }
.console { border-top: 4px solid var(--border); background: linear-gradient(#fff8df,#ffe9bd); padding: clamp(.8rem,2vw,1.5rem); justify-content: space-between; gap: 1rem; }
.message p { margin: 0; }
#hint { font-size: clamp(1.05rem,2vw,1.4rem); font-weight: 600; }
#feedback:not(:empty) { font-size: 1.05rem; margin-top: .25rem; color: #594319; }
form { gap: .6rem; }
label { font-weight: 600; }
input { text-align: center; width: 4rem; height: 3rem; background: #fffdf2; border: 2px solid var(--border); border-radius: .55rem; font-weight: 600; font-size: 1.6rem; appearance: textfield; }
input::-webkit-inner-spin-button { -webkit-appearance: none; }
input:disabled { color: var(--ink); opacity: 1; }
.primary { min-width: 5.4rem; min-height: 3rem; padding: .4rem .9rem; border: 2px solid #364823; border-radius: .6rem; background: #4e712d; color: white; font-weight: 600; font-size: 1.25rem; box-shadow: 0 3px 0 #34451f; }
.primary:disabled { opacity: .65; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.lab-link { display: inline-block; padding: .75rem .25rem .35rem; font-size: 1rem; color: var(--ink); text-underline-offset: .18em; }
@media(max-width: 680px) {
  .console { flex-direction: column; gap: .65rem; text-align: center; }
  .field { height: clamp(23rem,59svh,31rem); }
  .actor { width: 24%; bottom: 2%; } .actor.carry { right: .5%; }
  #apples { left: 9%; right: 9%; top: 48%; transform: none; }
  .apple { height: clamp(2.8rem,10vw,4.1rem); min-height: 44px; }
  .note { top:auto; right:29%; bottom:2%; }
  .question { top: 4%; }
}
@media(max-width: 410px) { .tools { gap: .3rem; } #score,#sound { padding: .3rem .45rem; } .game { padding: .45rem; } }
@media(prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration: .001ms !important; } }
