/* Jelly splash screen. Self-contained; everything is scoped under #splash. */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 100dvh;
  box-sizing: border-box;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(60vmax 60vmax at 50% 108%, rgba(255, 90, 40, 0.75), transparent 70%),
    radial-gradient(40vmax 40vmax at 12% 18%, rgba(255, 238, 150, 0.55), transparent 70%),
    radial-gradient(34vmax 34vmax at 90% 30%, rgba(255, 150, 120, 0.4), transparent 70%),
    linear-gradient(180deg, #ffd466 0%, #ff9f3d 48%, #e0552f 100%);
  color: #1a2e0c;
  font-family: 'Bungee', 'Russo One', system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  opacity: 1;
}

#splash .sp-tag {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  margin: 0;
  text-align: center;
  font: 15px/1.3 'Russo One', system-ui, sans-serif;
  color: rgba(26, 46, 12, 0.78);
  pointer-events: none;
}

/* desktop showreel: the bottom tiles take this spot */
#splash.sp-reel .sp-tag,
#splash.sp-leaving .sp-tag {
  opacity: 0;
  transition: opacity 0.3s ease;
}

html.sp-on .game-shell {
  visibility: hidden;
}

#splash.sp-fading {
  transition: opacity 0.45s ease;
  opacity: 0;
}

#splash .sp-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#splash .sp-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5dvh;
  width: 100%;
  max-height: 100%;
}

#splash .sp-title {
  --fs: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08em;
  font-size: var(--fs);
  line-height: 1;
  white-space: nowrap;
}

#splash .sp-line {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#splash .sp-cell {
  position: relative;
  display: block;
  padding: 0 0.015em;
  height: 1em;
  cursor: pointer;
}

#splash .sp-glyph {
  position: relative;
  display: block;
  height: 1em;
  line-height: 1;
  transform-origin: 50% 100%;
  will-change: transform;
  color: var(--jc);
  /* thick dark outline painted outside the fill, so the glyph keeps its volume */
  -webkit-text-stroke: 0.11em #1a2e0c;
  paint-order: stroke fill;
  text-transform: uppercase;
  filter: drop-shadow(0 0.02em 0 rgba(255, 255, 255, 0.25));
}

/* Translucent jelly body: lighter core, glossy highlight on top */
#splash .sp-glyph::before,
#splash .sp-glyph::after {
  content: attr(data-c);
  position: absolute;
  inset: 0;
  -webkit-text-stroke: 0;
  paint-order: normal;
  pointer-events: none;
}

#splash .sp-glyph::before {
  background: radial-gradient(ellipse 70% 60% at 50% 72%, rgba(255, 255, 255, 0.5), transparent 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#splash .sp-glyph::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.35) 28%, rgba(255, 255, 255, 0) 46%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#splash .sp-ball {
  width: 0.34em;
  height: 0.34em;
  margin: 0 auto;
  position: absolute;
  left: 50%;
  bottom: 0.1em;
  margin-left: -0.17em;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #fff 0 9%, rgba(255, 255, 255, 0.0) 24%),
    radial-gradient(circle at 50% 62%, rgba(255, 255, 255, 0.45), transparent 62%),
    var(--jc);
  border: 0.07em solid #1a2e0c;
  box-sizing: border-box;
  transform-origin: 50% 100%;
  will-change: transform;
}

#splash .sp-cell.sp-dot {
  width: 0.46em;
}

#splash .sp-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -0.04em;
  height: 0.12em;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(60, 20, 0, 0.5), rgba(60, 20, 0, 0) 70%);
  pointer-events: none;
  opacity: 0;
}

#splash .sp-actions {
  min-height: 3.4em;
  font-size: clamp(16px, 4.2vmin, 26px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#splash .sp-play {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #1a2e0c;
  background: linear-gradient(180deg, #fff0a0 0%, #ffcf33 55%, #f5a30f 100%);
  border: 0.16em solid #1a2e0c;
  border-radius: 999px;
  padding: 0.6em 1.9em;
  cursor: pointer;
  box-shadow: 0 0.28em 0 #1a2e0c, 0 0.5em 0.8em rgba(60, 20, 0, 0.35), inset 0 0.15em 0 rgba(255, 255, 255, 0.7);
  opacity: 0;
  transform: translateY(0.8em) scale(0.7);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.5s cubic-bezier(0.3, 1.7, 0.5, 1);
  touch-action: manipulation;
}

#splash.sp-ready .sp-play {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  animation: sp-pulse 1.6s ease-in-out 0.6s infinite;
}

#splash .sp-play:active {
  transform: translateY(0.2em) scale(0.97);
  box-shadow: 0 0.08em 0 #1a2e0c, 0 0.2em 0.5em rgba(60, 20, 0, 0.35), inset 0 0.15em 0 rgba(255, 255, 255, 0.7);
  animation: none;
}

#splash .sp-play:focus-visible {
  outline: 0.14em solid #fff;
  outline-offset: 0.16em;
}

#splash.sp-leaving .sp-play {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
  animation: none;
  transition: opacity 0.2s ease, transform 0.25s ease;
}

@keyframes sp-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Reduced motion: no physics, plain fade-in */
#splash.sp-reduced .sp-glyph,
#splash.sp-reduced .sp-ball {
  opacity: 0;
  animation: sp-fadein 0.6s ease forwards;
}

#splash.sp-reduced .sp-cell:nth-child(n) .sp-glyph,
#splash.sp-reduced .sp-cell:nth-child(n) .sp-ball {
  animation-delay: calc(var(--i, 0) * 30ms);
}

#splash.sp-reduced .sp-play {
  transition: opacity 0.4s ease;
  transform: none;
  animation: none !important;
}

@keyframes sp-fadein {
  to { opacity: 1; }
}

/* ---- Cinema mode (desktop): shrunken title + 4 showreel tiles ---- */
#splash .sp-title,
#splash .sp-actions {
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

#splash.sp-reel .sp-title {
  transform: scale(var(--ts, 1));
  transform-origin: 50% 50%;
}

#splash .sp-reel {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}

#splash.sp-reel .sp-reel {
  display: block;
}

#splash .sp-reel-tile {
  position: absolute;
  aspect-ratio: 16 / 9;
  box-sizing: border-box;
  border: 0.42vmin solid #1a2e0c;
  border-width: max(4px, 0.5vmin);
  border-radius: max(14px, 1.8vmin);
  overflow: hidden;
  background: #2a1a10;
  box-shadow: 0 0.9vmin 0 #1a2e0c, 0 1.8vmin 2.4vmin rgba(60, 20, 0, 0.45);
  opacity: 0;
  transform: rotate(var(--rot, 0deg)) scale(0);
}

#splash .sp-reel-tile canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* glossy highlight over the picture */
#splash .sp-reel-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 28%, rgba(255, 255, 255, 0) 42%);
  pointer-events: none;
}

/* jelly spring out of the tile's own corner */
#splash .sp-reel-tile.sp-in {
  opacity: 1;
  animation: sp-tile-pop 0.8s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}

#splash .sp-reel-tile.sp-out {
  opacity: 0;
  transform: rotate(var(--rot, 0deg)) scale(0.2);
  transition: opacity 0.35s ease, transform 0.4s ease;
  animation: none;
}

@keyframes sp-tile-pop {
  0% { transform: rotate(var(--rot, 0deg)) scale(0); }
  50% { transform: rotate(var(--rot, 0deg)) scale(1.12, 0.92); }
  72% { transform: rotate(var(--rot, 0deg)) scale(0.96, 1.05); }
  100% { transform: rotate(var(--rot, 0deg)) scale(1); }
}
