html,
body {
  overscroll-behavior: none;
}

.play {
  height: 100%;
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr) 216px;
  grid-template-areas: "side stage pad";
  align-items: center;
  gap: 16px;
  padding: 92px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.guide {
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.guide img {
  width: clamp(84px, 14vh, 116px);
}

.guide .bubble {
  margin-bottom: 0;
  width: 100%;
  max-width: none;
  min-height: 96px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(17px, 2.5vh, 20px);
  line-height: 1.25;
}

.guide .bubble::after {
  left: calc(50% - 12px);
  bottom: auto;
  top: -12px;
  border: 12px solid transparent;
  border-bottom-color: var(--card);
  border-top: 0;
}

.tracker {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.basket {
  display: flex;
  gap: 6px;
}

.basket .slot {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--butter);
  display: grid;
  place-items: center;
}

.basket .slot img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  opacity: 0.28;
  filter: grayscale(1);
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.basket .slot.got {
  animation: pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.basket .slot.got img {
  opacity: 1;
  filter: none;
}

.maze-count {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.round-dots {
  display: flex;
  gap: 10px;
}

.round-dots i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lav);
}

.round-dots i.now {
  box-shadow: 0 0 0 4px var(--butter-deep);
}

.round-dots i.ok {
  background: var(--butter-deep);
}

.stage {
  grid-area: stage;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}

.maze {
  --wall: 8px;
  width: min(calc(100vh - 124px), calc(100vw - 472px));
  height: min(calc(100vh - 124px), calc(100vw - 472px));
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  flex: none;
  padding: 12px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: pointer;
}

.maze.enter-in {
  animation: pop-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.grid {
  position: relative;
  width: 100%;
  height: 100%;
}

.walls {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  z-index: 2;
  pointer-events: none;
}

.walls path {
  fill: none;
  stroke: var(--lav-deep);
  stroke-width: var(--wall);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cell {
  position: absolute;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.cell img {
  width: 76%;
  height: 76%;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px rgba(61, 58, 92, 0.2));
}

.cell.home::before,
.cell.goal::before {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 28%;
  background: var(--mint);
}

.cell.goal::before {
  background: var(--butter);
}

.cell.goal img {
  position: relative;
  animation: bob 2s ease-in-out infinite;
}

.cell.goal.reached img {
  animation: pop-in 0.4s ease reverse forwards;
}

.cell.fruit img {
  width: 64%;
  height: 64%;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.cell.fruit.got img {
  transform: scale(1.7);
  opacity: 0;
}

.cell.trail::before {
  content: "";
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--butter-deep);
  box-shadow: 0 0 0 6px rgba(247, 201, 72, 0.35);
}

.cell.trail {
  animation: pop-in 0.3s ease backwards;
}

.cell.bibo {
  z-index: 3;
  transition: transform 0.17s ease-out;
}

.bibo .nudge {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.bibo img {
  width: 86%;
  height: 86%;
  transition: transform 0.15s ease;
}

.bibo.face-left img {
  transform: scaleX(-1);
}

.bibo .nudge.bump {
  animation: bump-wall 0.22s ease;
}

@keyframes bump-wall {
  0%,
  100% {
    transform: translate(0, 0);
  }
  45% {
    transform: translate(var(--bx, 0), var(--by, 0));
  }
}

.pad {
  grid-area: pad;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.dpad {
  --key: 68px;
  display: grid;
  grid-template-columns: repeat(3, var(--key));
  grid-template-rows: repeat(3, var(--key));
  gap: 6px;
}

.arrow {
  width: var(--key);
  height: var(--key);
  border-radius: 22px;
  background: var(--card);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 #d4d2e6, 0 12px 20px rgba(61, 58, 92, 0.14);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  touch-action: manipulation;
}

.arrow:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #d4d2e6;
  background: var(--butter);
}

.arrow svg {
  width: 56%;
  height: 56%;
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arrow.up {
  grid-area: 1 / 2;
}

.arrow.left {
  grid-area: 2 / 1;
}

.arrow.left svg {
  transform: rotate(-90deg);
}

.arrow.right {
  grid-area: 2 / 3;
}

.arrow.right svg {
  transform: rotate(90deg);
}

.arrow.down {
  grid-area: 3 / 2;
}

.arrow.down svg {
  transform: rotate(180deg);
}

.hint-btn {
  min-width: 150px;
  min-height: 64px;
  padding: 0 26px;
  border-radius: 999px;
  background: var(--butter);
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 5px 0 #e0a92a;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.hint-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #e0a92a;
}

.key-tip {
  margin: 0;
  padding: 8px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink-soft);
  text-align: center;
}

.panel .btn-row .big-btn {
  min-width: 150px;
}

@media (orientation: landscape) and (max-height: 700px) {
  .key-tip {
    display: none;
  }
}

@media (orientation: portrait) {
  .play {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "side" "stage" "pad";
    gap: 12px;
    padding: 86px max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .side {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-height: 104px;
  }
  .guide {
    flex: 1;
    min-width: 0;
    flex-direction: row;
    gap: 10px;
  }
  .guide img {
    width: clamp(68px, 10vw, 96px);
    flex: none;
  }
  .guide .bubble {
    width: auto;
    flex: 1;
    min-height: 76px;
    font-size: clamp(18px, 2.5vw, 24px);
  }
  .guide .bubble::after {
    left: -12px;
    top: calc(50% - 12px);
    border: 12px solid transparent;
    border-right-color: var(--card);
    border-left: 0;
  }
  .tracker {
    width: auto;
    flex: none;
    display: grid;
    grid-template-columns: auto auto;
    justify-items: center;
    align-items: center;
    column-gap: 14px;
    row-gap: 6px;
    padding: 10px 16px;
  }
  .basket {
    grid-row: 1 / 3;
  }
  .maze {
    width: min(calc(100vw - 32px), calc(100vh - 420px));
    height: min(calc(100vw - 32px), calc(100vh - 420px));
    width: min(100cqw, 100cqh);
    height: min(100cqw, 100cqh);
  }
  .pad {
    flex-direction: row-reverse;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 clamp(4px, 3vw, 40px);
  }
  .dpad {
    --key: clamp(72px, 10.5vw, 96px);
    grid-template-rows: repeat(2, var(--key));
    gap: 8px;
  }
  .arrow.left {
    grid-area: 2 / 1;
  }
  .arrow.down {
    grid-area: 2 / 2;
  }
  .arrow.right {
    grid-area: 2 / 3;
  }
  .hint-btn {
    min-height: clamp(72px, 10.5vw, 96px);
    min-width: 180px;
    font-size: clamp(22px, 3.2vw, 30px);
  }
  .key-tip {
    display: none;
  }
}
