/* ============================================================
   Jump Jump - pastel isometric mini game
   ============================================================ */

:root {
  --sky-top: #a9dcff;
  --sky-mid: #cfeaff;
  --sky-low: #ffeef4;
  --coral: #ff7a9c;
  --coral-deep: #e05377;
  --amber: #ffb86b;
  --mint: #4fe0a4;
  --ink: #4a3b5c;
  --ink-soft: #7d6b9a;
  --white-glass: rgba(255, 255, 255, 0.72);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Nunito", "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-low) 100%);
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-root { position: fixed; inset: 0; z-index: 0; }
#scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* When a modal/overlay is open, the game canvas below must never receive
   pointer input - the overlay layer is the only interactive surface. */
body.modal-open #scene { pointer-events: none; }

/* ---------- background flourishes ---------- */
.sun {
  position: fixed;
  top: 5vh;
  right: 6vw;
  width: 15vmin;
  height: 15vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 214, 0.95) 0%, rgba(255, 236, 180, 0.55) 45%, rgba(255, 236, 180, 0) 72%);
  pointer-events: none;
  z-index: 1;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at 50% 45%, rgba(255,255,255,0) 55%, rgba(120, 90, 140, 0.10) 100%);
}

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; }

.panel {
  position: absolute;
  min-width: 86px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--white-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(74, 59, 92, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.panel-label { font-size: 11px; letter-spacing: 0.16em; font-weight: 800; color: var(--ink-soft); }
.panel-value { font-size: 28px; font-weight: 800; line-height: 1.1; font-family: "Baloo 2", sans-serif; }
.top-left { top: calc(env(safe-area-inset-top, 0px) + 14px); left: 14px; }
.top-right { top: calc(env(safe-area-inset-top, 0px) + 14px); right: 14px; }

/* ---------- power bar ---------- */
#power-wrap {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.power-label { font-size: 11px; letter-spacing: 0.22em; font-weight: 800; color: rgba(74,59,92,0.6); }
.power-track {
  width: min(240px, 60vw);
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.85);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(74, 59, 92, 0.15);
}
.power-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4fe0a4, #ffd166, #ff7a9c);
  transition: width 0.06s linear;
  box-shadow: 0 0 12px rgba(255, 122, 156, 0.5);
}
#power-track.full { animation: powerPulse 0.5s ease-in-out infinite; }
@keyframes powerPulse {
  0%, 100% { box-shadow: inset 0 2px 4px rgba(74,59,92,0.15), 0 0 0 rgba(255,122,156,0); }
  50% { box-shadow: inset 0 2px 4px rgba(74,59,92,0.15), 0 0 18px rgba(255,122,156,0.9); }
}
.power-pct { font-size: 12px; font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- hint ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(74, 59, 92, 0.12);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.25s ease;
  animation: hintFloat 2.4s ease-in-out infinite;
}
@keyframes hintFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

/* ---------- popup ---------- */
.popup {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  pointer-events: none;
}
.popup.perfect {
  font-size: clamp(34px, 8vw, 64px);
  background: linear-gradient(180deg, #ffd166, #ff9f43);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 rgba(255, 255, 255, 0.8)) drop-shadow(0 8px 18px rgba(255, 159, 67, 0.45));
}
.popup .popup-sub { display: block; font-family: "Nunito", sans-serif; font-size: 18px; font-weight: 800; color: #fff; filter: none; margin-top: -6px; }

.popup.perfect .popup-sub { color: #ff9f43; }

/* ---------- overlays & modals ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(74, 59, 92, 0.18), rgba(74, 59, 92, 0.45));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }

.modal {
  max-width: min(88vw, 400px);
  width: 100%;
  text-align: center;
  padding: 36px 30px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 24px 60px rgba(74, 59, 92, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.9);
  animation: popIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  0% { transform: scale(0.7) translateY(30px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.title {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: clamp(56px, 14vw, 84px);
  line-height: 1;
  background: linear-gradient(180deg, #ff8fab, var(--coral-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 rgba(255, 255, 255, 0.9)) drop-shadow(0 10px 22px rgba(224, 83, 119, 0.35));
  letter-spacing: 0.01em;
}
.float { animation: floaty 3s ease-in-out infinite; }
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.subtitle {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 12px 0 18px;
  line-height: 1.45;
}

.best-line {
  display: inline-block;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink-soft);
  background: rgba(255, 215, 166, 0.4);
  padding: 6px 16px;
  border-radius: 999px;
  margin: 4px auto 16px;
}
.best-line span { color: #e05377; font-family: "Baloo 2", sans-serif; font-size: 18px; }

.key-hint-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 22px;
}
.key-chip {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid rgba(74, 59, 92, 0.14);
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(74, 59, 92, 0.1);
}

.btn {
  font-family: "Baloo 2", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  padding: 12px 52px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(180deg, #ff8fab, var(--coral-deep));
  box-shadow: 0 8px 0 #c24368, 0 14px 26px rgba(224, 83, 119, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #c24368, 0 6px 12px rgba(224, 83, 119, 0.4); }

.over-title {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: clamp(40px, 10vw, 58px);
  line-height: 1;
  color: #4a3b5c;
  margin-bottom: 14px;
}
.score-line { font-family: "Baloo 2", sans-serif; font-size: 54px; font-weight: 800; color: var(--coral-deep); line-height: 1; }
.score-line span { font-size: 54px; }
.record-badge {
  display: inline-block;
  margin: 14px 0 8px;
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fff;
  background: linear-gradient(90deg, #ffd166, #ff9f43);
  box-shadow: 0 4px 14px rgba(255, 159, 67, 0.5);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- animations for popup show ---------- */
.popup.show-perfect { animation: perfectPop 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
@keyframes perfectPop {
  0% { transform: translateX(-50%) scale(0.3); opacity: 0; }
  18% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  30% { transform: translateX(-50%) scale(1); }
  80% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.9); opacity: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .panel { min-width: 72px; padding: 6px 10px; }
  .panel-value { font-size: 22px; }
  .hint { font-size: 12px; white-space: normal; width: max-content; max-width: 74vw; text-align: center; }
}

.hidden { display: none !important; }
