:root {
  --as-ink: #4c2d18;
  --as-focus: #176b8f;
  --as-gold: #f4bd3f;
  --as-linen: #f2e9d8;
  --as-linen-deep: #e7dac1;
  --as-warm-bad: #9a632c;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: #2e2017;
}

body {
  overflow: hidden;
}

noscript {
  display: block;
  padding: 16px;
  background: #2e2017;
  color: #fff6e6;
}

#activity-root {
  min-height: 100dvh;
}

.as-game {
  --as-apple: 56px;
  --as-gap: 8px;

  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--as-ink);
  container-type: inline-size;
  scrollbar-color: rgba(127, 77, 31, 0.55) transparent;
}

.as-game.has-crowded-basket {
  overflow: auto;
}

.as-game img {
  max-width: none;
  max-height: none;
}

.as-board {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-self: stretch;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  box-sizing: border-box;
  padding: 7px 9px 9px;
}

.as-source,
.as-basket {
  position: relative;
  min-width: 0;
}

.as-source {
  display: grid;
  min-height: calc(var(--as-apple) + 18px);
  padding: 7px 10px;
  border: 0;
  border-radius: 18px;
  background:
    radial-gradient(circle at 16% 35%, rgba(255, 255, 255, 0.64), transparent 28%),
    repeating-linear-gradient(95deg, rgba(116, 86, 53, 0.034) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #f7f0e3, var(--as-linen));
  box-shadow:
    inset 0 0 0 1px rgba(121, 88, 52, 0.13),
    0 4px 12px rgba(72, 43, 18, 0.13);
}

.as-source-fruits,
.as-basket-fruits {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--as-gap);
  min-width: 0;
  pointer-events: none;
}

.as-source-fruits {
  min-height: var(--as-apple);
  pointer-events: auto;
  touch-action: pan-y;
}

.as-source-fruits:empty::after {
  content: "";
  display: block;
  width: min(74%, 360px);
  height: 22px;
  border-radius: 50%;
  background: rgba(139, 102, 58, 0.075);
}

.as-drop-target {
  position: absolute;
  z-index: 1;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: pan-x pan-y;
}

.as-source-target {
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 18px;
}

.as-drop-target:focus-visible {
  outline: 3px solid var(--as-focus);
  outline-offset: -3px;
}

.as-source.is-over {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 249, 212, 0.9), transparent 40%),
    repeating-linear-gradient(95deg, rgba(116, 86, 53, 0.034) 0 2px, transparent 2px 7px),
    var(--as-linen);
  box-shadow:
    inset 0 0 0 3px var(--as-focus),
    0 4px 12px rgba(72, 43, 18, 0.13);
}

.as-baskets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  align-self: center;
  gap: 7px;
  min-width: 0;
  min-height: 0;
}

.as-baskets[data-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.as-basket {
  display: grid;
  place-items: center;
  min-width: 0;
}

.as-basket-clip {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(116, 73, 29, 0.7) transparent;
}

.as-basket-canvas {
  position: relative;
  width: 100%;
  min-width: 100%;
  aspect-ratio: 1672 / 669;
}

.as-game .as-basket-art {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 5px 4px rgba(71, 39, 13, 0.16));
}

.as-basket-target {
  inset: 7% 4% 6%;
  width: 92%;
  height: 87%;
  border-radius: 50%;
}

.as-basket-fruits {
  position: absolute;
  z-index: 3;
  inset: 18% 3% 35%;
  flex-wrap: nowrap;
  gap: 2px;
  min-width: max-content;
  pointer-events: none;
}

.as-basket-fruits:empty::after {
  content: "";
  display: block;
  width: 46%;
  height: 25%;
  border: 2px dashed rgba(129, 91, 45, 0.27);
  border-radius: 50%;
}

.as-basket.is-over .as-basket-art {
  filter:
    drop-shadow(0 0 9px rgba(244, 189, 63, 0.82))
    drop-shadow(0 5px 4px rgba(71, 39, 13, 0.16));
}

.as-basket.is-over .as-basket-target {
  outline: 3px solid var(--as-focus);
  outline-offset: -1px;
}

.as-apple-button {
  position: relative;
  z-index: 4;
  display: grid;
  flex: 0 0 var(--as-apple);
  width: var(--as-apple);
  height: var(--as-apple);
  min-width: var(--as-apple);
  min-height: var(--as-apple);
  place-items: center;
  padding: 1px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transition:
    transform 150ms ease,
    filter 150ms ease;
}

.as-game .as-apple {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px rgba(63, 35, 15, 0.3));
}

.as-apple-button:hover {
  filter: brightness(1.045);
  transform: translateY(-2px);
}

.as-apple-button:active {
  cursor: grabbing;
}

.as-apple-button:focus-visible {
  outline: 3px solid var(--as-focus);
  outline-offset: 1px;
}

.as-apple-button.is-selected {
  outline: 4px solid var(--as-gold);
  outline-offset: 2px;
  filter:
    brightness(1.05)
    drop-shadow(0 0 7px rgba(244, 189, 63, 0.76));
  transform: translateY(-2px) scale(1.035);
}

.as-apple-button.is-dragging {
  cursor: grabbing;
  opacity: 0.36;
}

.as-apple-button.just-placed .as-apple {
  animation: as-apple-settle 440ms cubic-bezier(0.2, 0.85, 0.25, 1.2);
}

.as-apple-button.is-demo-flying {
  position: fixed;
  z-index: 66;
  margin: 0;
  pointer-events: none;
  transition:
    left 620ms cubic-bezier(0.2, 0.75, 0.25, 1),
    top 620ms cubic-bezier(0.2, 0.75, 0.25, 1),
    transform 620ms ease;
}

.as-game.is-wrong .as-source:has(.as-apple-button),
.as-game.is-wrong.is-source-error .as-source {
  box-shadow:
    inset 0 0 0 3px var(--as-warm-bad),
    0 4px 12px rgba(72, 43, 18, 0.13);
}

.as-game.is-wrong:not(.is-source-error) .as-baskets {
  filter: drop-shadow(0 0 5px rgba(154, 99, 44, 0.52));
}

.as-game.is-correct .as-apple {
  animation: as-apple-nod 650ms ease-in-out both;
}

.as-game.is-correct .as-basket-art {
  animation: as-basket-warm 720ms ease-out both;
}

.as-drag-ghost {
  position: fixed;
  z-index: 65;
  width: var(--as-apple);
  height: var(--as-apple);
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 10px 8px rgba(55, 31, 14, 0.34));
}

.as-hand {
  position: fixed;
  z-index: 68;
  width: clamp(54px, 6.5vmin, 66px);
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(42, 24, 10, 0.25));
  transform: rotate(-8deg);
  transform-origin: 15% 9%;
}

.as-hand.is-moving {
  transition:
    left 620ms cubic-bezier(0.2, 0.75, 0.25, 1),
    top 620ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.as-game.is-demo-locked .as-apple-button,
.as-game.is-demo-locked .as-drop-target {
  pointer-events: none;
}

.as-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.as-load-error {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 20px;
  font: 600 18px/1.35 Fredoka, sans-serif;
  text-align: center;
}

@keyframes as-apple-nod {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-3px) scale(1.035);
    filter:
      drop-shadow(0 3px 3px rgba(63, 35, 15, 0.3))
      drop-shadow(0 0 8px rgba(244, 189, 63, 0.9));
  }
}

@keyframes as-apple-settle {
  0% {
    transform: translateY(-8px) scale(1.05);
  }
  70% {
    transform: translateY(2px) scale(0.99);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes as-basket-warm {
  0%,
  100% {
    filter: drop-shadow(0 5px 4px rgba(71, 39, 13, 0.16));
  }
  45% {
    filter:
      drop-shadow(0 0 10px rgba(244, 189, 63, 0.82))
      drop-shadow(0 5px 4px rgba(71, 39, 13, 0.16));
  }
}

@media (max-width: 600px) {
  .as-board {
    grid-template-rows: auto auto;
    align-content: start;
    min-height: 0;
  }

  .as-baskets,
  .as-baskets[data-count="3"] {
    grid-template-columns: minmax(0, 1fr);
    align-self: start;
  }

}

@media (max-width: 600px) and (min-height: 741px) {
  .as-baskets[data-count="2"] .as-basket-clip {
    width: min(100%, 250px);
    margin-inline: auto;
  }

  .as-baskets[data-count="3"] .as-basket-clip {
    width: min(100%, 236px);
    margin-inline: auto;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .as-game {
    --as-apple: 44px;
    --as-gap: 5px;
  }

  .as-board {
    gap: 4px;
    padding: 4px 7px 6px;
  }

  .as-source {
    min-height: 61px;
    padding: 3px 7px;
  }

  .as-baskets {
    gap: 4px;
  }

  .as-basket-fruits {
    inset: 8% 3% 20%;
  }
}

@media (max-width: 430px) and (max-height: 740px) {
  .as-game {
    --as-apple: 44px;
    --as-gap: 4px;
    overflow: hidden;
  }

  .as-board {
    grid-template-columns: minmax(56px, 64px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 4px;
    height: 100%;
    min-height: 0;
    padding: 4px;
  }

  .as-source {
    height: 100%;
    min-height: 0;
    padding: 4px;
    border-radius: 14px;
    box-sizing: border-box;
  }

  .as-source-fruits {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    min-height: 0;
    padding: 0 1px;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-width: thin;
  }

  .as-baskets,
  .as-baskets[data-count="3"] {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    align-self: stretch;
    align-items: center;
    min-height: 0;
  }

  .as-basket {
    height: 100%;
    min-height: 0;
    container-type: size;
  }

  .as-basket-clip {
    width: min(100%, 249.925cqh);
    margin-inline: auto;
    aspect-ratio: 1672 / 669;
  }

  .as-baskets[data-count="2"] .as-basket-clip {
    width: min(100%, 249.925cqh);
  }

  .as-basket-fruits {
    inset: 8% 3% 20%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .as-game *,
  .as-hand {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
