:root {
  color-scheme: light;
  --world-w: 1024;
  --world-h: 1792;
  --mobile-game-w: 100vw;
  --mobile-game-h: 175vw;
  --mobile-test-ad-top: calc(100vh - 76px);
  --mobile-test-ad-h: 76px;
  --desktop-game-w: min(100vw, 57.1429vh);
  --desktop-test-ad-w: clamp(104px, calc((100vw - var(--desktop-game-w)) / 2 - 18px), 160px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  position: relative;
  background: #1f6c65;
  font-family: Arial, Helvetica, sans-serif;
  touch-action: none;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: -34px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 234, 151, 0.12), transparent 28rem),
    linear-gradient(180deg, rgba(7, 24, 18, 0.36), rgba(5, 22, 18, 0.58)),
    url("./assets/optimized/backgrounds/widebg.webp") center / cover no-repeat;
  filter: blur(18px) saturate(1.08) brightness(0.62);
  transform: scale(1.04);
}

#game-shell {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
}

#game {
  position: relative;
  width: min(100vw, 57.1429vh);
  height: min(100vh, 175vw);
  max-width: 100vw;
  max-height: 100vh;
  filter: drop-shadow(0 14px 34px rgba(30, 19, 8, 0.34));
}

#game canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  touch-action: none;
}

#boot {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 22px;
  border: 2px solid rgba(91, 57, 19, 0.35);
  border-radius: 12px;
  background: #fee7b0;
  color: #5d3915;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  max-width: min(82vw, 420px);
}

body.ready #boot {
  display: none;
}

#boot.is-error {
  background: #fff2c8;
  color: #6a2a16;
}

.mobile-test-ad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 9px max(12px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid rgba(255, 239, 199, 0.35);
  background:
    linear-gradient(180deg, rgba(255, 245, 202, 0.12), rgba(17, 71, 61, 0)),
    linear-gradient(180deg, #2d8a75 0%, #185b50 100%);
  box-shadow: 0 -10px 26px rgba(20, 14, 8, 0.2);
  color: #4d2c11;
  font-weight: 800;
  pointer-events: none;
}

.mobile-test-ad__creative {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(320px, 100%);
  height: 50px;
  border: 1px solid rgba(77, 43, 18, 0.42);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff7cf 0%, #f0c56c 100%);
  box-shadow: 0 6px 18px rgba(25, 15, 6, 0.28);
}

.mobile-test-ad__tag {
  position: absolute;
  left: 8px;
  top: 5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(77, 43, 18, 0.14);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
}

.mobile-test-ad__text {
  font-size: 15px;
  line-height: 1;
}

body.is-mobile.has-mobile-test-ad #game-shell {
  inset: 0 0 auto;
  height: var(--mobile-game-h);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

body.is-mobile.has-mobile-test-ad #game {
  width: var(--mobile-game-w);
  height: var(--mobile-game-h);
  max-height: var(--mobile-game-h);
}

body.is-mobile.has-mobile-test-ad .mobile-test-ad {
  top: var(--mobile-test-ad-top);
  bottom: auto;
  display: flex;
  min-height: 76px;
  height: var(--mobile-test-ad-h);
}

body.has-desktop-test-ad .mobile-test-ad {
  left: auto;
  right: max(10px, env(safe-area-inset-right));
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  display: flex;
  width: var(--desktop-test-ad-w);
  height: min(600px, calc(100vh - 48px));
  min-height: 360px;
  padding: 0;
  border-top: 0;
  background: transparent;
  box-shadow: none;
}

body.has-desktop-test-ad .mobile-test-ad__creative {
  flex-direction: column;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-width: 0;
  border-width: 2px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 253, 220, 0.96) 0%, rgba(246, 199, 99, 0.96) 100%);
  box-shadow:
    0 10px 24px rgba(25, 15, 6, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

body.has-desktop-test-ad .mobile-test-ad__tag {
  position: static;
  font-size: 11px;
}

body.has-desktop-test-ad .mobile-test-ad__text {
  width: 100%;
  padding: 0 10px;
  font-size: 17px;
  line-height: 1.15;
  text-align: center;
}

body.platform-poki .mobile-test-ad {
  display: none !important;
}

body.platform-android #game-shell {
  display: block;
  place-items: initial;
}

body.platform-android #game {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  filter: none;
}

body.recording-finger-cursor,
body.recording-finger-cursor *,
body.recording-finger-cursor canvas {
  cursor: url("./assets/sliced/recording_finger_cursor.png") 24 10, pointer !important;
}

body.recording-finger-cursor.recording-animated-cursor,
body.recording-finger-cursor.recording-animated-cursor *,
body.recording-finger-cursor.recording-animated-cursor canvas {
  cursor: none !important;
}

.recording-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483647;
  width: 96px;
  height: 96px;
  pointer-events: none;
  opacity: 0;
  background: url("./assets/sliced/recording_finger_cursor.png") center / contain no-repeat;
  filter: drop-shadow(0 8px 10px rgba(42, 20, 6, 0.24));
  transform:
    translate3d(
      calc(var(--recording-cursor-x, 50vw) - 24px),
      calc(var(--recording-cursor-y, 50vh) - 10px),
      0
    )
    scale(1)
    rotate(0deg);
  transform-origin: 24px 10px;
  transition: opacity 90ms ease, transform 80ms ease;
  will-change: transform, opacity;
}

.recording-cursor.is-visible {
  opacity: 1;
}

.recording-cursor.is-down {
  transform:
    translate3d(
      calc(var(--recording-cursor-x, 50vw) - 24px),
      calc(var(--recording-cursor-y, 50vh) - 10px),
      0
    )
    scale(0.86)
    rotate(-7deg);
}

.recording-cursor.is-tapping {
  animation: recording-cursor-press 330ms cubic-bezier(0.2, 0.82, 0.18, 1) both;
}

.recording-cursor::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 1px;
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 214, 74, 0.86);
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.3);
}

.recording-cursor.is-tapping::after {
  animation: recording-cursor-tap 360ms ease-out both;
}

@keyframes recording-cursor-press {
  0% {
    transform:
      translate3d(
        calc(var(--recording-cursor-x, 50vw) - 24px),
        calc(var(--recording-cursor-y, 50vh) - 10px),
        0
      )
      scale(1)
      rotate(0deg);
  }
  28% {
    transform:
      translate3d(
        calc(var(--recording-cursor-x, 50vw) - 24px),
        calc(var(--recording-cursor-y, 50vh) - 10px),
        0
      )
      scale(0.82)
      rotate(-8deg);
  }
  58% {
    transform:
      translate3d(
        calc(var(--recording-cursor-x, 50vw) - 24px),
        calc(var(--recording-cursor-y, 50vh) - 10px),
        0
      )
      scale(1.07)
      rotate(3deg);
  }
  100% {
    transform:
      translate3d(
        calc(var(--recording-cursor-x, 50vw) - 24px),
        calc(var(--recording-cursor-y, 50vh) - 10px),
        0
      )
      scale(1)
      rotate(0deg);
  }
}

@keyframes recording-cursor-tap {
  0% {
    opacity: 0.95;
    transform: scale(0.24);
  }
  70% {
    opacity: 0.4;
  }
  100% {
    opacity: 0;
    transform: scale(1.85);
  }
}
