:root {
  --pink: #ff8fc7;
  --deep-pink: #e05fa6;
  --cream: #fff6ea;
  --mint: #9fe3cf;
  --lilac: #cdb8ff;
  --ink: #4a3550;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: #cfe6ff;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- overlays (title + win) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(255, 233, 246, 0.35), rgba(180, 220, 255, 0.5));
  backdrop-filter: blur(2px);
  z-index: 10;
}

.overlay.see-through {
  background: radial-gradient(
    circle at 50% 18%,
    rgba(255, 170, 215, 0.22),
    rgba(255, 105, 180, 0.12) 45%,
    rgba(40, 10, 40, 0.08)
  );
  backdrop-filter: none;
  align-items: flex-end;
  padding-bottom: 28px;
  pointer-events: none;
}

.overlay.see-through .card {
  pointer-events: auto;
}

.card {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  padding: 26px 26px 30px;
  border-radius: 34px;
  background: var(--cream);
  border: 6px solid #fff;
  box-shadow: 0 18px 40px rgba(120, 90, 140, 0.25);
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(30px, 7vw, 52px);
  line-height: 1.05;
  letter-spacing: 1px;
  color: var(--deep-pink);
  text-shadow: 0 3px 0 #fff, 0 6px 14px rgba(224, 95, 166, 0.25);
}

h1 span {
  display: block;
  color: #7ec8ff;
  text-shadow: 0 3px 0 #fff, 0 6px 14px rgba(126, 200, 255, 0.3);
}

h2 {
  margin: 0 0 10px;
  font-size: clamp(24px, 5.5vw, 38px);
  color: var(--deep-pink);
  text-shadow: 0 3px 0 #fff;
}

.tag {
  margin: 0 0 16px;
  font-size: clamp(16px, 3.2vw, 20px);
}

.tip {
  margin: 14px 0 4px;
  font-size: 15px;
  opacity: 0.75;
}

.note {
  margin: 12px 0 0;
  font-size: 14px;
  color: #a35;
}

/* ---------- key guide ---------- */

.keys {
  display: grid;
  gap: 8px;
  margin: 0 auto;
  width: fit-content;
  text-align: left;
}

.keyrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  font-size: 20px;
  font-weight: 700;
  border-radius: 12px;
  background: #fff;
  border: 3px solid var(--lilac);
  box-shadow: 0 4px 0 var(--lilac);
}

.key.wide { min-width: 92px; font-size: 17px; }

.what { font-size: clamp(15px, 3vw, 19px); }

.touch-hint {
  margin: 12px 0 0;
  font-size: clamp(14px, 3vw, 17px);
  opacity: 0.8;
}

/* ---------- buttons ---------- */

button.big {
  margin-top: 18px;
  padding: 14px 46px;
  font: inherit;
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffa3d3, var(--deep-pink));
  box-shadow: 0 7px 0 #c14b8c, 0 12px 22px rgba(224, 95, 166, 0.35);
  transition: transform 0.08s ease;
}

button.big:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #c14b8c;
}

/* ---------- in-game hud ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#bar {
  position: absolute;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #5d4468;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

#bar-track {
  position: relative;
  width: 20px;
  height: min(320px, 45vh);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 3px solid #fff;
  box-shadow: 0 6px 14px rgba(120, 90, 140, 0.2);
  overflow: hidden;
}

#bar-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0%;
  border-radius: 999px;
  background: linear-gradient(0deg, var(--mint), #ffe28f 55%, var(--pink));
  transition: height 0.12s linear;
}

#level-tag {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 16px;
  font-weight: 700;
  padding: 9px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 5px 12px rgba(120, 90, 140, 0.22);
}

#mute {
  position: absolute;
  top: 16px;
  right: 16px;
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 9px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 5px 12px rgba(120, 90, 140, 0.22);
}

#message {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: 999px;
  font-size: clamp(17px, 3.4vw, 24px);
  font-weight: 700;
  color: var(--deep-pink);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 16px rgba(120, 90, 140, 0.2);
  opacity: 0;
  transition: opacity 0.25s ease;
  white-space: nowrap;
}

#message.show { opacity: 1; }

/* ---------- on-screen touch controls ---------- */

#touch-controls {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#hud.touch-on #touch-controls {
  display: flex;
}

/* Phones only — tablets keep the height bar. iPhone landscape is wide but short. */
@media (max-width: 767px), (max-height: 500px) {
  #hud.touch-on #bar {
    display: none;
  }
}

.touch-move {
  display: flex;
  gap: 12px;
}

#touch-controls button {
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  border: 3px solid var(--lilac);
  background: var(--cream);
  box-shadow: 0 6px 0 var(--lilac);
}

#touch-left,
#touch-right {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  font-size: 32px;
}

#touch-jump {
  min-width: 92px;
  height: 80px;
  padding: 0 22px;
  border-radius: 28px;
  font-size: 22px;
  color: #fff;
  border-color: #c14b8c;
  background: linear-gradient(180deg, #ffa3d3, var(--deep-pink));
  box-shadow: 0 6px 0 #c14b8c;
}

#touch-left.held,
#touch-right.held {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--lilac);
}

#touch-jump.held {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #c14b8c;
}

@media (orientation: landscape) and (max-height: 500px) {
  #touch-controls {
    gap: 10px;
    padding: 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .touch-move {
    gap: 8px;
  }

  #touch-left,
  #touch-right {
    width: 56px;
    height: 56px;
    font-size: 26px;
    border-radius: 16px;
  }

  #touch-jump {
    min-width: 76px;
    height: 60px;
    padding: 0 16px;
    font-size: 18px;
    border-radius: 22px;
  }
}
