* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Baloo 2", "Trebuchet MS", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #1b1440 0%, #3d2f8f 30%, #4f7fbf 65%, #cfe9ff 100%);
  color: #26264a;
  overflow-x: hidden;
  position: relative;
}

/* ---------- background scenery ---------- */

.mountains {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.peak {
  position: absolute;
  bottom: -10%;
  width: 0;
  height: 0;
  border-left: 220px solid transparent;
  border-right: 220px solid transparent;
  border-bottom: 320px solid #6a8fd8;
  opacity: 0.55;
  filter: drop-shadow(0 0 30px rgba(255,255,255,0.15));
}
.peak.back { border-bottom-color: #5a72c0; opacity: 0.35; }
.peak.front { border-bottom-color: #3a2f7a; opacity: 0.5; }
.peak.p1 { left: -8%; transform: scale(1.3); }
.peak.p2 { left: 28%; transform: scale(1.6); }
.peak.p3 { left: 62%; transform: scale(1.1); }
.peak.front.p1 { left: 5%; transform: scale(1.5); }
.peak.front.p2 { left: 55%; transform: scale(1.8); }

#snow {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.flake {
  position: absolute;
  top: -10px;
  color: #fff;
  opacity: 0.85;
  text-shadow: 0 0 4px rgba(255,255,255,0.6);
  animation: fall linear infinite;
}

@keyframes fall {
  to { transform: translateY(110vh) translateX(20px); }
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.9; }
}

/* ---------- layout ---------- */

#app {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 20px;
  max-width: 820px;
  width: 100%;
}

h1 {
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 3px 8px rgba(0,0,0,0.4);
  margin: 0 0 4px;
}

#level-banner {
  color: #ffe9a8;
  font-weight: 700;
  margin-bottom: 16px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ---------- hint ---------- */

#hint {
  display: inline-block;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  padding: 6px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  margin-bottom: 14px;
}

/* ---------- 3D board (real WebGL scene, rendered by game.js) ---------- */

#board-stage {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 800px;
}

#board {
  display: block;
  border-radius: 18px;
  overflow: hidden;
  line-height: 0;
  box-shadow:
    0 40px 60px -10px rgba(5, 5, 30, 0.55),
    0 0 0 6px rgba(255,255,255,0.25) inset;
}

#board canvas {
  display: block;
  width: 100%;
  height: auto;
}

#toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 15, 50, 0.85);
  color: #fff;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
}

#toast.show { opacity: 1; }

/* ---------- HUD ---------- */

#hud {
  margin-top: 26px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* ---------- D-pad ---------- */

#dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.pad-mid {
  display: flex;
  gap: 6px;
}

.pad-btn {
  font-family: inherit;
  font-size: 22px;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(160deg, #ffd76a, #e0ab1f);
  color: #2b1f5c;
  box-shadow: 0 5px 0 #a97c10, 0 8px 14px rgba(0,0,0,0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.pad-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #a97c10, 0 3px 6px rgba(0,0,0,0.25);
}

#stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

#counter, #turns {
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

#turns.low { color: #ff9a7a; }

/* ---------- win modal ---------- */

#win-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 10, 40, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}

#win-modal.hidden {
  display: none;
}

#win-card {
  background: linear-gradient(160deg, #ffffff, #eaf4ff);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  border: 4px solid #ffd76a;
}

#win-text {
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 10px;
  color: #2b1f5c;
}

#win-stars {
  font-size: 34px;
  margin-bottom: 18px;
  letter-spacing: 4px;
}

#next-btn {
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(160deg, #7c5cf0, #4a3aa8);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 5px 0 #322678, 0 8px 14px rgba(0,0,0,0.3);
}

#next-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #322678, 0 3px 6px rgba(0,0,0,0.25);
}

/* ---------- fail modal ---------- */

#fail-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 10, 40, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}

#fail-modal.hidden { display: none; }

#fail-card {
  background: linear-gradient(160deg, #ffffff, #eaf4ff);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  border: 4px solid #7fd4f0;
}

#fail-text {
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 18px;
  color: #2b1f5c;
}

#retry-btn {
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(160deg, #7fd4f0, #2f9fc9);
  color: #0f2b38;
  cursor: pointer;
  box-shadow: 0 5px 0 #1f7690, 0 8px 14px rgba(0,0,0,0.3);
}

#retry-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #1f7690, 0 3px 6px rgba(0,0,0,0.25);
}

@media (max-width: 480px) {
  .peak { border-left-width: 140px; border-right-width: 140px; border-bottom-width: 200px; }
}
