/* Artwork and board share one coordinate system; neither is cropped to the viewport. */
.seascape {
  container-type: size;
  background: linear-gradient(#83c9ec, #25b4d5 40%, #28bdd2);
}
.scene-frame {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.scene-ready .scene-frame {
  background-image: url('../assets/island-scene.webp');
}
.scene-frame .iceberg {
  inset: 43% 15% 19%;
}
.scene-art {
  display: none;
}
@media (max-width: 760px) {
  /* Paint behind Telegram's native controls without moving content into their safe area. */
  body.in-telegram:has(main.island-mode) {
    background:
      linear-gradient(
        to bottom,
        #c6ebfc55,
        #e3f5ff66 calc(var(--app-safe-top) + 56px),
        var(--paper) calc(var(--app-safe-top) + 170px)
      ),
      url('../assets/island-scene-compact.webp') center top / 250% auto no-repeat,
      var(--paper);
  }
  .in-telegram .island-card {
    background: transparent;
  }
  .in-telegram .island-card-top {
    background: linear-gradient(#f5fcffed, #e7f6ffed);
    border-bottom: 1px solid #ffffffa6;
  }
  .scene-frame {
    width: 100%;
    height: 100%;
  }
  .scene-ready .scene-frame {
    background-image: none;
  }
  /* Keep all three scene sections visible, including on shorter Telegram viewports. */
  .scene-art {
    display: grid;
    position: absolute;
    inset: 0;
    grid-template-rows: min(40cqw, 24cqh) minmax(0, 1fr) min(25cqw, 15cqh);
    pointer-events: none;
  }
  .scene-art > span {
    background-size: 100% auto;
    background-repeat: no-repeat;
  }
  .scene-ready .scene-art > span {
    background-image: url('../assets/island-scene-compact.webp');
  }
  .scene-art .scene-horizon {
    background-size: 100% 250%;
    background-position: center top;
  }
  .scene-art .scene-snow {
    /* The middle 35% of the source (40%–75%) stretches between unchanged caps. */
    background-size: 100% 285.714286%;
    background-position: center 61.538462%;
  }
  .scene-art .scene-shore {
    background-size: 100% 400%;
    background-position: center bottom;
  }
  .scene-frame .iceberg {
    /* Leave room for the horizon and shore without consuming short phone screens. */
    inset: min(20cqw, 12cqh) 1% max(32px, min(20cqw, 7cqh));
  }
  /* The purchase bar must fit above navigation, including Telegram safe areas. */
  main.island-mode {
    overflow: hidden;
    padding-left: 4px;
    padding-right: 4px;
  }
  #island-page {
    height: 100%;
    min-height: 0;
  }
  .game-layout {
    height: 100%;
    width: 100%;
  }
  .island-card {
    flex: 1;
    min-height: 0;
  }
  .seascape {
    flex: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: auto;
  }
  .scene-frame .board {
    gap: clamp(4px, 1cqh, 8px) 4px;
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }
  .scene-frame
    .tile:not(.selected):not(.valid-target):not(.drop-allowed):not(.drop-hover):not(.drop-invalid) {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
  }
  .scene-frame .tile.empty::after {
    position: absolute;
    left: 50%;
    bottom: 15px;
    transform: translateX(-50%);
    width: 28px;
    height: 18px;
    border-radius: 50%;
    background: #81bac321;
    box-shadow: inset 0 1px 2px #4f919824;
    font-size: 14px;
    line-height: 18px;
    color: #568895;
    opacity: 0.7;
  }
  .scene-frame .tile > .penguin-art {
    /* Fit the tight silhouette to the whole cell, reserving space for its level label. */
    width: 100%;
    height: calc(100% - 22px);
    aspect-ratio: auto;
    bottom: 22px;
  }
  .scene-frame .tile .level {
    bottom: 2px;
    font-size: 10px;
    line-height: 14px;
    padding: 0 6px;
    box-shadow: 0 2px 4px #34596b12;
  }
  .scene-frame .sea-caption {
    background: #f6fcf0c7;
    border: 0;
    left: 18%;
    right: 18%;
    min-height: 22px;
    padding: 3px 6px;
    font-size: 10px;
  }
}
