/* Keep the existing game UI inside narrow and short Yandex Games iframes. */
.sugar-game-shell {
  grid-template-columns: minmax(0, 1fr);
}

.sugar-topbar,
.sugar-playfield,
.sugar-tools {
  width: 100%;
  min-width: 0;
}

@media (max-width: 920px) and (orientation: portrait) {
  .candy-holder,
  .sugar-board.is-multirow .candy-holder {
    justify-self: center;
    width: auto;
    max-width: 100%;
    height: min(100%, 270px);
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .sugar-overlay {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    touch-action: pan-y;
  }

  .sugar-overlay::-webkit-scrollbar {
    display: none;
  }

  .sugar-playfield {
    grid-template-rows: minmax(0, 1fr);
  }

  .bloom-theater {
    height: min(100%, 68dvh, 415px);
    min-height: 0;
    max-height: 100%;
  }

  .rose-progress.is-crowded {
    display: grid;
    grid-template-columns: repeat(6, 12px);
    grid-template-rows: repeat(2, 12px);
    gap: 2px;
  }

  .rose-progress.is-crowded .rose-progress-slot {
    width: 12px;
    height: 12px;
    border-width: 1px;
    box-shadow: inset 0 1px 2px rgba(20, 2, 0, 0.5);
  }

  .rose-progress.is-crowded .progress-dot {
    width: 5px;
    height: 5px;
    border-width: 0;
  }
}

@media (orientation: landscape) and (max-width: 560px) {
  .sugar-topbar {
    grid-template-columns: 41px minmax(0, auto) minmax(0, 1fr) minmax(0, auto) 41px;
    gap: 4px;
  }

  .sugar-level-badge,
  .move-pill {
    gap: 3px;
    padding-right: 5px;
    padding-left: 5px;
  }

  .sugar-level-badge span,
  .move-pill span {
    font-size: 7px;
  }

  .sugar-level-badge strong,
  .move-pill strong {
    font-size: 16px;
  }

  .rose-progress {
    gap: 3px;
  }

  .rose-progress-slot {
    width: 30px;
    height: 30px;
  }

  .rose-progress.is-many .rose-progress-slot {
    width: clamp(18px, 4vw, 24px);
    height: clamp(18px, 4vw, 24px);
  }

  .rose-progress.is-many .progress-dot {
    width: 8px;
    height: 8px;
    border-width: 1px;
  }

  .sugar-tools {
    grid-template-columns: minmax(72px, 0.4fr) minmax(0, 1fr) minmax(72px, 0.4fr);
    gap: 6px;
  }

  .sugar-tool-button {
    min-width: 0;
    padding-right: 6px;
    padding-left: 6px;
    font-size: 10px;
  }

  .goal-ribbon {
    gap: 5px;
    font-size: 10px;
  }

  .goal-candy {
    width: 36px;
  }

  .level-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (orientation: landscape) and (max-height: 360px) {
  .home-rose-wrap {
    width: 72px;
    height: 66px;
    margin-bottom: -7px;
  }

  .home-kicker {
    margin-bottom: 2px;
    font-size: 9px;
  }

  .sugar-home-card h1 {
    margin-top: 6px;
  }

  .sugar-home-card h1 span {
    font-size: 30px;
  }

  .sugar-home-card h1 strong {
    margin-top: 3px;
    font-size: 35px;
  }

  .home-subtitle {
    margin-top: 8px;
    font-size: 10px;
  }

  .home-progress {
    margin: 6px 0 -4px;
    font-size: 9px;
  }

  .play-button {
    min-width: 210px;
    min-height: 46px;
    margin-top: 6px;
    font-size: 16px;
  }

  .home-secondary-actions {
    flex-wrap: nowrap;
    gap: 5px;
    margin-top: 6px;
  }

  .home-music-button,
  .home-levels-button,
  .home-language-button {
    padding: 4px 8px;
    font-size: 9px;
  }

  .sugar-modal {
    border-width: 3px;
    border-radius: 22px;
    padding: 18px 20px 14px;
  }

  .modal-cookie {
    width: 46px;
    height: 46px;
    margin: -20px auto 6px;
    border-width: 3px;
    font-size: 20px;
  }

  .sugar-modal h2 {
    margin-top: 2px;
    font-size: 28px;
    line-height: 1.08;
  }

  .modal-kicker {
    margin-bottom: 2px;
    font-size: 9px;
  }

  .modal-actions {
    gap: 6px;
    margin-top: 10px;
  }

  .modal-primary,
  .modal-secondary,
  .modal-text {
    min-height: 40px;
    padding: 6px 10px;
    font-size: 11px;
  }

  .modal-text {
    min-height: 32px;
  }

  .win-modal {
    padding: 76px 20px 14px;
  }

  .win-rose {
    top: 0;
    width: 116px;
    height: 116px;
  }

  .win-rays {
    top: 0;
    width: 180px;
    height: 180px;
  }

  .win-stars {
    gap: 4px;
    margin-top: 5px;
  }

  .win-stars span {
    font-size: 28px;
  }

  .win-copy {
    margin-top: 4px;
    font-size: 10px;
  }

  .win-modal .modal-actions {
    grid-template-columns: 1fr 1fr;
  }

  .win-modal .modal-primary {
    grid-column: 1 / -1;
  }
}

@media (orientation: landscape) and (min-width: 561px) and (max-width: 760px) {
  .level-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (orientation: landscape) and (max-height: 290px) {
  .sugar-home-card,
  .sugar-modal {
    transform-origin: top center;
    scale: 0.86;
  }

  .win-modal {
    scale: 0.76;
  }
}

@media (orientation: landscape) and (max-height: 250px) {
  .sugar-home-card,
  .sugar-modal {
    scale: 0.72;
  }

  .win-modal {
    scale: 0.64;
  }
}
