/* Sky Island reward mode — same chunky Soft Emoji UI as Word Hunt */

.isl {
  --ink: #263238;
  --white: #ffffff;
  --yellow: #ffd54f;
  --blue: #1e88e5;
  --green: #43a047;
  --orange: #ff9800;
  --purple: #8e24aa;
  --outline: 5px;
  --ease-pop: cubic-bezier(0.34, 1.4, 0.64, 1);
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  color: var(--white);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  background: #8fd3ff;
}

.isl[hidden],
.isl [hidden] {
  display: none !important;
}

.isl button {
  font-family: inherit;
  cursor: pointer;
}

.isl-stage {
  position: absolute;
  inset: 0;
}

.isl-stage canvas {
  touch-action: none;
}

/* ── Top bar ── */
.isl-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: max(0.8rem, env(safe-area-inset-top)) 0.85rem 0.4rem;
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
}

.isl-top > * {
  pointer-events: auto;
}

.isl.is-busy .isl-top {
  opacity: 0;
  transform: translateY(-120%);
  pointer-events: none;
}

.isl.is-busy .isl-top > * {
  pointer-events: none;
}

.isl-pill,
.isl-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 3.1rem;
  border: var(--outline) solid var(--white);
  color: var(--white);
  font-weight: 800;
  font-size: clamp(1rem, 3.6vw, 1.2rem);
  box-shadow: 0 6px 0 rgba(38, 50, 56, 0.2);
}

.isl-pill:active,
.isl-round:active {
  transform: translateY(3px) scale(0.95);
  box-shadow: 0 2px 0 rgba(38, 50, 56, 0.2);
}

.isl-back {
  padding: 0.3rem 1.1rem 0.3rem 0.85rem;
  border-radius: 999px;
  background: var(--orange);
}

.isl-round {
  width: 3.1rem;
  padding: 0;
  border-radius: 999px;
  background: var(--purple);
  font-size: 1.45rem;
}

.isl-grow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.6rem;
  padding: 0.2rem 0.85rem;
  border-radius: 999px;
  background: rgba(38, 50, 56, 0.35);
  border: 4px solid rgba(255, 255, 255, 0.85);
  font-weight: 700;
  font-size: 0.95rem;
  pointer-events: none;
  white-space: nowrap;
}

.isl-grow__dots {
  display: inline-flex;
  gap: 0.22rem;
}

.isl-grow__dots i {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid var(--white);
}

.isl-grow__dots i.on {
  background: var(--yellow);
}

@media (max-width: 420px) {
  .isl-back span,
  .isl-grow__label {
    display: none;
  }
  .isl-back {
    width: 3.1rem;
    padding: 0;
  }
}

/* ── Banner ── */
.isl-banner {
  position: absolute;
  top: calc(max(0.8rem, env(safe-area-inset-top)) + 3.9rem);
  left: 50%;
  z-index: 12;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 1.3rem 0.6rem;
  border-radius: 1.3rem;
  background: var(--blue);
  border: var(--outline) solid var(--white);
  box-shadow: 0 7px 0 rgba(38, 50, 56, 0.2);
  text-align: center;
  pointer-events: none;
}

.isl.is-busy .isl-banner {
  top: calc(max(0.8rem, env(safe-area-inset-top)) + 0.2rem);
}

.isl-banner__text {
  font-weight: 800;
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  line-height: 1.15;
  text-shadow: 0 2px 0 rgba(38, 50, 56, 0.2);
}

.isl-banner__sub {
  font-weight: 700;
  font-size: clamp(0.9rem, 3.4vw, 1.05rem);
  opacity: 0.95;
}

.isl-banner.is-pop {
  animation: isl-pop-down 0.5s var(--ease-pop) both;
}

/* ── Spelling reveal ── */
.isl-spell {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(6.8rem + env(safe-area-inset-bottom));
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.isl-spell__row {
  display: flex;
  gap: clamp(0.2rem, 1.2vw, 0.4rem);
  justify-content: center;
  flex-wrap: nowrap;
  padding: 0 0.5rem;
}

.isl-letter {
  display: grid;
  place-items: center;
  width: clamp(2.3rem, 9.5vw, 4rem);
  height: clamp(2.6rem, 10.5vw, 4.4rem);
  border-radius: 0.8rem;
  background: #fff8e7;
  border: 4px solid var(--ink);
  box-shadow:
    0 0 0 4px var(--white),
    0 8px 0 4px rgba(38, 50, 56, 0.2);
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(1.5rem, 6.5vw, 2.7rem);
  animation: isl-letter-in 0.45s var(--ease-pop) both;
}

.isl-spell.is-done .isl-letter {
  background: var(--yellow);
  animation: isl-letter-wave 0.6s ease both;
}

.isl-spell.is-done .isl-letter:nth-child(2) { animation-delay: 0.05s; }
.isl-spell.is-done .isl-letter:nth-child(3) { animation-delay: 0.1s; }
.isl-spell.is-done .isl-letter:nth-child(4) { animation-delay: 0.15s; }
.isl-spell.is-done .isl-letter:nth-child(5) { animation-delay: 0.2s; }
.isl-spell.is-done .isl-letter:nth-child(6) { animation-delay: 0.25s; }
.isl-spell.is-done .isl-letter:nth-child(7) { animation-delay: 0.3s; }
.isl-spell.is-done .isl-letter:nth-child(8) { animation-delay: 0.35s; }
.isl-spell.is-done .isl-letter:nth-child(9) { animation-delay: 0.4s; }
.isl-spell.is-done .isl-letter:nth-child(10) { animation-delay: 0.45s; }

.isl-new {
  padding: 0.15rem 0.8rem;
  border-radius: 999px;
  background: #e53935;
  border: 4px solid var(--white);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 0 rgba(38, 50, 56, 0.2);
  animation: isl-new-wiggle 0.9s ease-in-out infinite;
}

/* ── Tap hint over the crate ── */
.isl-hint {
  position: fixed;
  z-index: 13;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -100%);
  pointer-events: none;
}

.isl-hint__hand {
  font-size: 3rem;
  line-height: 1;
  transform: rotate(180deg);
  animation: isl-hand 0.7s ease-in-out infinite;
  filter: drop-shadow(0 4px 0 rgba(38, 50, 56, 0.2));
}

.isl-hint__text {
  order: -1;
  margin-bottom: 0.2rem;
  padding: 0.2rem 0.9rem;
  border-radius: 999px;
  background: var(--green);
  border: 4px solid var(--white);
  font-weight: 800;
  font-size: 1.35rem;
  box-shadow: 0 5px 0 rgba(38, 50, 56, 0.2);
}

/* ── Tap-an-item word bubble ── */
.isl-bubble {
  position: fixed;
  z-index: 13;
  display: flex;
  gap: 0.1rem;
  transform: translate(-50%, -100%);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--white);
  border: 4px solid var(--ink);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  pointer-events: none;
  box-shadow: 0 5px 0 rgba(38, 50, 56, 0.2);
}

.isl-bubble.is-pop {
  animation: isl-bubble 1.8s ease both;
}

.isl-bubble span {
  display: inline-block;
  animation: isl-letter-in 0.35s var(--ease-pop) both;
}

/* ── Pick cards ── */
.isl-cards {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(38, 50, 56, 0.35);
}

.isl-cards__title {
  margin: 0;
  font-weight: 800;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  text-shadow: 0 3px 0 rgba(38, 50, 56, 0.3);
  animation: isl-pop-down 0.5s var(--ease-pop) both;
}

.isl-cards__row {
  display: flex;
  gap: clamp(0.5rem, 2.5vw, 1.2rem);
  justify-content: center;
  width: 100%;
}

.isl-card {
  width: clamp(6.2rem, 28vw, 10rem);
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 0;
  background: none;
  perspective: 800px;
  opacity: 0;
  transform: translateY(40vh) scale(0.6);
  transition:
    transform 0.55s var(--ease-pop),
    opacity 0.3s ease;
}

.isl-card.is-in {
  opacity: 1;
  transform: none;
}

.isl-card__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease-pop);
}

.isl-card.is-flipped .isl-card__inner {
  transform: rotateY(180deg);
}

.isl-card__back,
.isl-card__front {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 1.1rem;
  border: var(--outline) solid var(--white);
  box-shadow: 0 8px 0 rgba(38, 50, 56, 0.25);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.isl-card__back b {
  font-size: 3.5rem;
  font-weight: 800;
  text-shadow: 0 4px 0 rgba(38, 50, 56, 0.25);
}

.isl-card__front {
  transform: rotateY(180deg);
  background: #fff8e7;
  color: var(--ink);
  gap: 0.1rem;
  padding: 0.4rem;
}

.isl-card.rarity-1 .isl-card__front {
  background: linear-gradient(180deg, #e8f5e9, #fff8e7);
}

.isl-card.rarity-2 .isl-card__front {
  background: linear-gradient(180deg, #bbdefb, #fff8e7);
}

.isl-card.rarity-3 .isl-card__front {
  background: linear-gradient(180deg, #e1bee7, #fff8e7);
}

.isl-card.rarity-3.is-flipped .isl-card__front {
  box-shadow:
    0 0 24px 6px rgba(255, 235, 59, 0.8),
    0 8px 0 rgba(38, 50, 56, 0.25);
}

.isl-card__front img {
  width: 88%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 4px 0 rgba(38, 50, 56, 0.12));
}

.isl-card__name {
  font-weight: 800;
  font-size: clamp(0.85rem, 3.6vw, 1.25rem);
  letter-spacing: 0.03em;
}

.isl-card__stars {
  color: #f9a825;
  font-size: clamp(0.8rem, 3vw, 1rem);
  -webkit-text-stroke: 1px #e65100;
}

.isl-card__new {
  position: absolute;
  top: 0.35rem;
  right: -1.8rem;
  width: 6rem;
  padding: 0.1rem 0;
  transform: rotate(35deg);
  background: #e53935;
  color: var(--white);
  font-weight: 800;
  font-size: 0.75rem;
  text-align: center;
}

.isl-card.is-chosen {
  transform: translateY(-1.2rem) scale(1.12);
}

.isl-card.is-chosen .isl-card__front {
  border-color: var(--yellow);
  box-shadow:
    0 0 0 5px var(--white),
    0 0 30px 10px rgba(255, 235, 59, 0.9);
}

.isl-card.is-gone {
  opacity: 0;
  transform: translateY(30vh) scale(0.5) rotate(-12deg);
}

/* ── Big continue button ── */
.isl-go {
  position: absolute;
  left: 50%;
  bottom: calc(1.6rem + env(safe-area-inset-bottom));
  z-index: 16;
  transform: translateX(-50%);
  min-width: 10rem;
  min-height: 3.8rem;
  padding: 0.5rem 2rem;
  border-radius: 999px;
  background: var(--yellow);
  border: var(--outline) solid var(--white);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.6rem;
  box-shadow: 0 8px 0 rgba(38, 50, 56, 0.25);
}

.isl-go.is-pop {
  animation: isl-go-in 0.5s var(--ease-pop) both;
}

.isl-go:active {
  transform: translateX(-50%) translateY(4px);
  box-shadow: 0 4px 0 rgba(38, 50, 56, 0.25);
}

/* ── Bottom: pocket + crate button ── */
.isl-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.6rem;
  padding: 0 0.8rem calc(0.8rem + env(safe-area-inset-bottom));
  pointer-events: none;
}

.isl-bottom > * {
  pointer-events: auto;
}

.isl.is-busy .isl-bottom {
  opacity: 0;
  pointer-events: none;
}

.isl.is-busy .isl-bottom > * {
  pointer-events: none;
}

.isl-pocket {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  max-width: 100%;
}

.isl-pocket:empty {
  display: none;
}

.isl-pocket__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 4.6rem;
  padding: 0.2rem 0.2rem 0.3rem;
  border-radius: 1rem;
  background: #fff8e7;
  border: 4px solid var(--white);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.72rem;
  box-shadow: 0 5px 0 rgba(38, 50, 56, 0.2);
}

.isl-pocket__item img {
  width: 3.4rem;
  height: 3.4rem;
  object-fit: contain;
}

.isl-pocket__item.is-active {
  background: var(--yellow);
  transform: translateY(-0.4rem);
  animation: isl-bob 1s ease-in-out infinite;
}

.isl-crate-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 3.8rem;
  padding: 0.4rem 1.4rem 0.4rem 1rem;
  border-radius: 999px;
  background: linear-gradient(160deg, #66bb6a, #2e7d32);
  border: var(--outline) solid var(--white);
  color: var(--white);
  font-weight: 800;
  font-size: 1.35rem;
  box-shadow: 0 7px 0 rgba(38, 50, 56, 0.25);
  animation: isl-crate-bounce 1.2s ease-in-out infinite;
}

.isl-crate-btn__icon {
  font-size: 1.9rem;
}

.isl-crate-btn b {
  position: absolute;
  top: -0.6rem;
  right: -0.4rem;
  display: grid;
  place-items: center;
  min-width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: #e53935;
  border: 3px solid var(--white);
  font-size: 0.95rem;
}

/* ── Flash ── */
.isl-flash {
  position: absolute;
  inset: 0;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
}

.isl-flash.is-on {
  animation: isl-flash 0.55s ease-out both;
}

/* ── Collection book ── */
.isl-book {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 0.8rem 1rem;
  background: rgba(38, 50, 56, 0.45);
}

.isl-book__card {
  display: flex;
  flex-direction: column;
  width: min(40rem, 100%);
  max-height: 100%;
  border-radius: 1.5rem;
  background: #fff8e7;
  border: var(--outline) solid var(--white);
  box-shadow: 0 12px 0 rgba(38, 50, 56, 0.25);
  color: var(--ink);
  overflow: hidden;
  animation: isl-pop-down 0.45s var(--ease-pop) both;
}

.isl-book__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.7rem 0.7rem 1.1rem;
  background: var(--purple);
  color: var(--white);
}

.isl-book__head h2 {
  margin: 0;
  flex: 1;
  font-size: 1.4rem;
  font-weight: 800;
}

.isl-book__count {
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  font-weight: 800;
}

.isl-book__close {
  width: 2.6rem;
  min-height: 2.6rem;
  background: var(--orange);
  font-size: 1.5rem;
}

.isl-book__body {
  overflow-y: auto;
  padding: 0.6rem 0.9rem 1rem;
  touch-action: pan-y;
}

.isl-book__zone h3 {
  margin: 0.6rem 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 800;
}

.isl-book__zone h3 small {
  font-size: 0.85rem;
  font-weight: 700;
  color: #78909c;
}

.isl-book__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr));
  gap: 0.5rem;
}

.isl-book__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem;
  border-radius: 0.9rem;
  background: #eceff1;
  border: 3px solid #cfd8dc;
  font-weight: 800;
  font-size: 0.78rem;
  color: #90a4ae;
}

.isl-book__cell img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: brightness(0) opacity(0.22);
}

.isl-book__cell.is-got {
  background: var(--white);
  border-color: #a5d6a7;
  color: var(--ink);
  cursor: pointer;
}

.isl-book__cell.is-got img {
  filter: none;
}

.isl-book__zone.is-locked .isl-book__cell {
  opacity: 0.55;
}

/* ── Keyframes ── */
@keyframes isl-pop-down {
  from { opacity: 0; transform: translateX(var(--tx, -50%)) translateY(-16px) scale(0.8); }
  to { opacity: 1; transform: translateX(var(--tx, -50%)) translateY(0) scale(1); }
}

.isl-cards__title,
.isl-book__card {
  --tx: 0;
}

@keyframes isl-letter-in {
  0% { opacity: 0; transform: translateY(-40px) scale(0.3) rotate(-20deg); }
  100% { opacity: 1; transform: none; }
}

@keyframes isl-letter-wave {
  0%, 100% { transform: none; }
  40% { transform: translateY(-14px) scale(1.12); }
}

@keyframes isl-new-wiggle {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.1); }
}

@keyframes isl-hand {
  0%, 100% { transform: rotate(180deg) translateY(0); }
  50% { transform: rotate(180deg) translateY(-14px); }
}

@keyframes isl-bubble {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -110%) scale(1.05); }
  20% { transform: translate(-50%, -100%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -130%); }
}

@keyframes isl-go-in {
  from { opacity: 0; transform: translateX(-50%) translateY(30px) scale(0.7); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes isl-bob {
  0%, 100% { transform: translateY(-0.4rem); }
  50% { transform: translateY(-0.7rem); }
}

@keyframes isl-crate-bounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-6px) rotate(-3deg); }
  40% { transform: translateY(0) rotate(3deg); }
  60% { transform: translateY(-3px) rotate(0); }
}

@keyframes isl-flash {
  0% { opacity: var(--flash, 0.95); }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .isl-crate-btn,
  .isl-new,
  .isl-hint__hand,
  .isl-pocket__item.is-active {
    animation: none;
  }
}

/* ── Opening sequence extras ── */
.isl-banner.is-upgrade {
  background: linear-gradient(120deg, #ef5350, #ffa726, #fdd835, #66bb6a, #42a5f5, #ab47bc);
  background-size: 300% 100%;
  animation:
    isl-pop-down 0.5s var(--ease-pop) both,
    isl-rainbow-slide 1.2s linear infinite;
}

.isl-banner.is-upgrade .isl-banner__text {
  font-size: clamp(1.6rem, 7vw, 2.3rem);
  letter-spacing: 0.04em;
}

.isl-card.is-charging .isl-card__inner {
  animation: isl-card-charge 0.18s ease-in-out infinite;
}

.isl-card.is-charging .isl-card__back {
  box-shadow:
    0 0 0 4px #fff59d,
    0 0 34px 12px rgba(255, 235, 59, 0.95),
    0 8px 0 rgba(38, 50, 56, 0.25);
}

@keyframes isl-card-charge {
  0%, 100% { transform: rotate(-3deg) scale(1.03); }
  50% { transform: rotate(3deg) scale(1.08); }
}

@keyframes isl-rainbow-slide {
  from { background-position: 0% 50%; }
  to { background-position: 300% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .isl-card.is-charging .isl-card__inner,
  .isl-banner.is-upgrade {
    animation: none;
  }
}
