/* ============================================================
   Leap & Jump — stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
          user-select: none;
  touch-action: manipulation;
  font-family: 'Fredoka', system-ui, sans-serif;
}

body {
  background: radial-gradient(ellipse at 50% -10%,
              #5fb8ff 0%, #2a7fd6 40%, #1a4f9e 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* Decorative dotted side panels (visible only on landscape PC layout) */
body::before, body::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 20vw;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18) 0 3px, transparent 4px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.12) 0 2px, transparent 3px),
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.16) 0 2px, transparent 3px),
    radial-gradient(circle at 80% 30%, rgba(255,255,255,0.10) 0 2px, transparent 3px);
  background-size: 80px 110px, 60px 90px, 100px 130px, 70px 100px;
  opacity: 0.7;
}
body::before { left: 0; }
body::after  { right: 0; }

/* ------------------------------------------------------------
   Frame: the actual game container
   - Mobile: fills viewport
   - PC (>= 3:4 aspect): becomes a centered portrait card
   ------------------------------------------------------------ */
.frame {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  background: #1a4f9e;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}

@media (min-aspect-ratio: 3/4) {
  .frame {
    width: auto;
    height: min(96vh, 96dvh);
    aspect-ratio: 9 / 16;
    max-width: 92vw;
    border-radius: 28px;
    box-shadow:
      0 30px 80px rgba(0,0,0,0.55),
      0 0 0 6px rgba(255,255,255,0.06),
      0 0 0 7px rgba(0,0,0,0.5);
  }
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: -webkit-optimize-contrast;
}

/* ------------------------------------------------------------
   Overlays (menu / pause / game over)
   ------------------------------------------------------------ */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 8% 6%;
  background: linear-gradient(180deg, rgba(15,40,90,0.55) 0%, rgba(15,40,90,0.85) 100%);
  backdrop-filter: blur(2px);
  z-index: 5;
}
.overlay[hidden] { display: none; }

.menu-logo {
  width: min(78%, 320px);
  height: auto;
  margin-bottom: 28px;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.5));
  animation: floaty 3s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-0.5deg); }
  50%      { transform: translateY(-6px) rotate(0.5deg); }
}

.title {
  font-family: 'Lilita One', cursive;
  font-size: clamp(38px, 11vmin, 76px);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: #ffe24a;
  text-shadow:
    0 4px 0 #c87600,
    0 6px 0 #4a2a00,
    0 10px 24px rgba(0,0,0,0.5);
  transform: rotate(-3deg);
  margin-bottom: 8px;
}
.title.small { font-size: clamp(34px, 9vmin, 56px); }

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
  font-family: 'Lilita One', cursive;
  font-size: clamp(20px, 5.4vmin, 30px);
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(180deg, #ff8a3d 0%, #ff5e1f 100%);
  border: none;
  border-radius: 999px;
  padding: 16px 38px;
  cursor: pointer;
  box-shadow:
    0 4px 0 #b03b08,
    0 6px 0 #5a1d04,
    0 12px 24px rgba(0,0,0,0.4),
    inset 0 2px 0 rgba(255,255,255,0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  text-shadow: 0 2px 0 rgba(0,0,0,0.3);
}
.btn:active {
  transform: translateY(4px);
  box-shadow:
    0 0 0 #b03b08,
    0 2px 0 #5a1d04,
    0 4px 10px rgba(0,0,0,0.4),
    inset 0 2px 0 rgba(255,255,255,0.4);
}
.btn .arrow { display: inline-block; margin-left: 8px; transform: translateY(-1px); }

/* ------------------------------------------------------------
   HUD (top score pills)
   ------------------------------------------------------------ */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 4;
  font-family: 'Lilita One', cursive;
}
.pill {
  background: rgba(15,40,90,0.65);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 16px;
  padding: 8px 14px;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  letter-spacing: 0.05em;
}
.pill .label {
  display: block;
  font-size: 10px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: #b6d6ff;
  margin-bottom: 3px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.pill .val {
  font-size: 22px;
  color: #ffe24a;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}
.pill.best .val { color: #ffd166; font-size: 18px; }

.hint {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 0.4; transform: translateX(-50%) translateY(0); }
  50%     { opacity: 0.95; transform: translateX(-50%) translateY(-4px); }
}

/* ------------------------------------------------------------
   Game-over panel
   ------------------------------------------------------------ */
.panel {
  background: linear-gradient(180deg, #ffe9b8 0%, #ffc873 100%);
  color: #6b3a00;
  padding: 28px 32px 30px;
  border-radius: 26px;
  border: 4px solid #6b3a00;
  box-shadow:
    0 8px 0 #6b3a00,
    0 14px 28px rgba(0,0,0,0.45);
  max-width: 84%;
  text-align: center;
}
.panel h2 {
  font-family: 'Lilita One', cursive;
  font-size: clamp(28px, 8vmin, 44px);
  color: #d63a00;
  text-shadow: 0 3px 0 #6b3a00, 0 5px 0 rgba(0,0,0,0.15);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  transform: rotate(-2deg);
}
.panel .row {
  display: flex; justify-content: space-around;
  gap: 16px; margin: 18px 0 22px;
}
.stat {
  flex: 1;
  background: rgba(255,255,255,0.55);
  border: 3px solid #6b3a00;
  border-radius: 16px;
  padding: 10px 8px;
}
.stat .l {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: #8a4a00;
}
.stat .v {
  font-family: 'Lilita One', cursive;
  font-size: clamp(22px, 6vmin, 32px);
  color: #d63a00;
  line-height: 1.1; margin-top: 4px;
  text-shadow: 0 2px 0 rgba(255,255,255,0.6);
}
.panel .new {
  display: inline-block;
  background: #d63a00; color: #fff;
  font-family: 'Lilita One', cursive;
  font-size: 13px; padding: 4px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  letter-spacing: 0.1em;
  transform: rotate(-4deg);
  box-shadow: 0 3px 0 #6b3a00;
  animation: bounceIn 0.6s ease;
}
@keyframes bounceIn {
  0%   { transform: rotate(-4deg) scale(0.4); opacity: 0; }
  60%  { transform: rotate(-4deg) scale(1.15); opacity: 1; }
  100% { transform: rotate(-4deg) scale(1); }
}

/* Pause button */
.pause {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 50%;
  transform: translateX(50%);
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(15,40,90,0.65);
  border: 2px solid rgba(255,255,255,0.25);
  color: #fff;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  z-index: 4;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.pause.visible { display: flex; }
.pause svg { width: 16px; height: 16px; }

/* Score floaters */
.float-score {
  position: absolute;
  font-family: 'Lilita One', cursive;
  color: #ffe24a;
  font-size: 18px;
  text-shadow: 0 2px 0 #6b3a00;
  pointer-events: none;
  animation: floatUp 0.9s ease-out forwards;
  z-index: 3;
}
@keyframes floatUp {
  0%   { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  20%  { transform: translate(-50%, -8px) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -50px) scale(0.95); opacity: 0; }
}

/* Combo badge */
.combo {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  font-family: 'Lilita One', cursive;
  background: #d63a00;
  color: #fff;
  padding: 6px 16px;
  border-radius: 14px;
  box-shadow: 0 4px 0 #6b3a00, 0 6px 14px rgba(0,0,0,0.4);
  font-size: 16px;
  letter-spacing: 0.08em;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.combo.show { opacity: 1; animation: comboPop 0.3s ease; }
@keyframes comboPop {
  0%   { transform: translateX(-50%) rotate(-4deg) scale(0.5); }
  60%  { transform: translateX(-50%) rotate(-4deg) scale(1.2); }
  100% { transform: translateX(-50%) rotate(-4deg) scale(1); }
}

/* ------------------------------------------------------------
   Loading screen (covers everything until images preload)
   ------------------------------------------------------------ */
.loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: linear-gradient(180deg, #2a7fd6 0%, #1a4f9e 100%);
  z-index: 10;
  transition: opacity 0.4s ease;
}
.loader.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 56px; height: 56px;
  border: 5px solid rgba(255,255,255,0.18);
  border-top-color: #ffe24a;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 13px;
}
