/* ============================================================
   TWILIGHT GROVE — Snake in het schemerbos
   ============================================================ */

:root {
  --amber:   #ffb938;
  --gold:    #ffd97a;
  --leaf:    #7ee04c;
  --leaf-dk: #2f7a1d;
  --night:   #131b2a;
  --dusk-1:  #2b1a33;
  --dusk-2:  #6b2d3e;
  --dusk-3:  #c75b39;
  --cream:   #fff3d6;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--night);
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

/* ============ STAGE & PARALLAX LAYERS ============ */

#stage {
  position: fixed; inset: 0;
  perspective: 1100px;
  perspective-origin: 50% 42%;
  overflow: hidden;
}

.layer {
  position: absolute;
  inset: -6% -8%;            /* bleed zodat parallax-randen nooit zichtbaar worden */
  background-size: cover;
  background-position: 50% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  will-change: transform;
}

#sky {
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(255,150,60,.55) 0%, rgba(255,150,60,0) 55%),
    linear-gradient(180deg, #1a1430 0%, #3c1f3a 38%, #7a3046 66%, #c4593a 100%);
}

#back-trees {
  background-image: url("../assets/img/parallax-forest-back-trees.png");
  filter: blur(3px) brightness(.92) saturate(1.15);
  opacity: .95;
}

#mid-trees {
  background-image: url("../assets/img/parallax-forest-middle-trees.png");
  filter: blur(2px) brightness(.85);
}

#lights {
  background-image: url("../assets/img/parallax-forest-lights.png");
  mix-blend-mode: screen;
  filter: blur(4px);
  animation: god-rays 9s ease-in-out infinite;
}

@keyframes god-rays {
  0%, 100% { opacity: .55; }
  50%      { opacity: .95; }
}

#fireflies { background: none; }

/* alleen de onderste strook stamvoeten + grond als depth-of-field voorgrond,
   zodat de bomen het speelveld niet blokkeren */
#front-trees {
  inset: auto -10% -3% -10%;
  height: 30%;
  background-image: url("../assets/img/parallax-forest-front-trees.png");
  background-size: 115% auto;
  background-position: 50% 78%;
  filter: blur(6px) brightness(.35) saturate(.8);
  opacity: .85;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 45%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 45%);
}

#vignette {
  inset: 0;
  background:
    radial-gradient(115% 95% at 50% 45%, transparent 55%, rgba(8,6,20,.78) 100%);
}

#flash {
  inset: 0;
  background: radial-gradient(60% 60% at 50% 48%, rgba(255,235,160,.9), rgba(255,180,80,.35) 60%, transparent 100%);
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity .35s ease-out;
}
#flash.bang { transition: none; opacity: .7; }
#flash.red  { background: radial-gradient(70% 70% at 50% 48%, rgba(255,60,40,.85), transparent 100%); }

/* ============ BOARD (3D) ============ */

#board-pivot {
  position: absolute;
  left: 50%; top: 53%;
  width: min(85vw, 146vh);
  aspect-ratio: 1176 / 728;
  margin-left: calc(min(85vw, 146vh) / -2);
  transform: translateY(-50%);
  transform-style: preserve-3d;
  will-change: transform;
}

#board-shake { width: 100%; height: 100%; will-change: transform; }

#board-frame {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 18px;
  box-shadow:
    0 45px 90px -20px rgba(0,0,0,.75),
    0 0 0 3px rgba(255,185,56,.28),
    0 0 60px rgba(255,150,50,.18),
    inset 0 0 80px rgba(0,0,0,.55);
  overflow: hidden;
}

#board, #fx {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#fx { pointer-events: none; }

/* ============ HUD ============ */

#hud {
  position: absolute;
  top: max(14px, 2vh);
  left: 50%; transform: translateX(-50%);
  display: flex; gap: 18px; align-items: stretch;
  z-index: 30;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.6));
}

.hud-box {
  background: linear-gradient(180deg, rgba(34,24,46,.88), rgba(16,12,28,.88));
  border: 2px solid rgba(255,185,56,.4);
  border-radius: 14px;
  padding: 7px 20px 9px;
  min-width: 110px;
  text-align: center;
  backdrop-filter: blur(4px);
}

.hud-label {
  display: block;
  font-size: 12px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold); opacity: .85;
}
.hud-label b { color: #fff; }

.hud-value {
  display: block;
  font-family: "Luckiest Guy", cursive;
  font-size: 30px; line-height: 1.05;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(120,60,10,.8), 0 0 18px rgba(255,190,80,.5);
}

#hud-score .hud-value { color: var(--gold); }
.hud-value.pop { animation: score-pop .35s cubic-bezier(.2,2.6,.4,1); }
@keyframes score-pop { 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

#combo-bar {
  width: 130px; height: 8px;
  margin-top: 7px;
  background: rgba(255,255,255,.12);
  border-radius: 99px;
  overflow: hidden;
}
#combo-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--amber), #ff5e3a);
  border-radius: 99px;
}

#mute-btn {
  position: absolute; top: max(14px, 2vh); right: 18px;
  z-index: 40;
  width: 48px; height: 48px;
  font-size: 22px;
  background: linear-gradient(180deg, rgba(34,24,46,.9), rgba(16,12,28,.9));
  border: 2px solid rgba(255,185,56,.4);
  border-radius: 14px;
  color: var(--cream);
  cursor: pointer;
  transition: transform .15s;
}
#mute-btn:hover { transform: scale(1.1); }
#mute-btn.muted { opacity: .5; }

/* ============ SCREENS ============ */

.screen {
  position: absolute; inset: 0;
  z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  background: radial-gradient(80% 80% at 50% 45%, rgba(12,8,24,.55), rgba(8,5,18,.82));
  backdrop-filter: blur(3px);
  opacity: 1;
  transition: opacity .45s ease;
}
.screen.hidden { opacity: 0; pointer-events: none; }
.hidden { opacity: 0; pointer-events: none; }

.title {
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(56px, 11vw, 128px);
  line-height: .82;
  text-align: center;
  color: var(--gold);
  letter-spacing: .02em;
  text-shadow:
    0 1px 0 #b06a14, 0 2px 0 #a05e10, 0 3px 0 #90520c,
    0 4px 0 #7a4408, 0 6px 0 #5e3306, 0 8px 0 #422104,
    0 12px 24px rgba(0,0,0,.7),
    0 0 50px rgba(255,190,80,.45);
  animation: title-float 4.5s ease-in-out infinite;
}
.title span { display: block; }
.title .title-grove {
  color: var(--leaf);
  font-size: 1.22em;
  text-shadow:
    0 1px 0 #2a6e18, 0 2px 0 #256114, 0 3px 0 #1f5410,
    0 4px 0 #19460c, 0 6px 0 #123708, 0 8px 0 #0c2805,
    0 12px 24px rgba(0,0,0,.7),
    0 0 50px rgba(126,224,76,.4);
}
@keyframes title-float {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50%      { transform: translateY(-12px) rotate(1.2deg); }
}

.subtitle {
  color: var(--cream);
  font-weight: 500;
  font-size: clamp(14px, 1.8vw, 20px);
  letter-spacing: .28em;
  text-transform: uppercase;
  opacity: .8;
  margin-bottom: 10px;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}

.big-btn {
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(24px, 3vw, 34px);
  padding: 16px 54px 12px;
  color: #2d1500;
  background: linear-gradient(180deg, #ffe18a, var(--amber) 55%, #f08c1e);
  border: none;
  border-radius: 99px;
  cursor: pointer;
  box-shadow:
    0 6px 0 #a35410,
    0 14px 30px rgba(0,0,0,.55),
    0 0 40px rgba(255,185,56,.35),
    inset 0 2px 2px rgba(255,255,255,.7);
  transition: transform .12s, box-shadow .12s;
}
.big-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 9px 0 #a35410,
    0 18px 36px rgba(0,0,0,.55),
    0 0 60px rgba(255,185,56,.55),
    inset 0 2px 2px rgba(255,255,255,.7);
}
.big-btn:active { transform: translateY(2px) scale(.98); box-shadow: 0 3px 0 #a35410, 0 8px 18px rgba(0,0,0,.5); }

.howto {
  color: var(--cream); opacity: .65;
  font-size: 14px; font-weight: 500;
  letter-spacing: .05em;
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
}

.credits {
  position: absolute;
  bottom: 16px; left: 0; right: 0;
  text-align: center;
  font-size: 11.5px;
  color: rgba(255,243,214,.45);
  letter-spacing: .04em;
}

/* game over */
.go-title {
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(44px, 8vw, 92px);
  color: #ff6a4d;
  text-shadow:
    0 2px 0 #8c2310, 0 4px 0 #6e1a0a, 0 6px 0 #511106,
    0 10px 22px rgba(0,0,0,.75), 0 0 45px rgba(255,90,60,.4);
}
.go-title.small { font-size: clamp(36px, 6vw, 64px); color: var(--gold);
  text-shadow: 0 2px 0 #a05e10, 0 4px 0 #7a4408, 0 10px 22px rgba(0,0,0,.75); }

.go-stats { display: flex; gap: 46px; margin: 6px 0 8px; }
.go-stats > div { text-align: center; }
.go-label {
  display: block; font-size: 13px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold); opacity: .85;
}
.go-value {
  font-family: "Luckiest Guy", cursive;
  font-size: 56px; color: var(--cream);
  text-shadow: 0 3px 0 rgba(120,60,10,.8), 0 0 22px rgba(255,190,80,.45);
}

#new-record {
  font-family: "Luckiest Guy", cursive;
  font-size: 26px;
  color: var(--leaf);
  text-shadow: 0 2px 0 #1f5410, 0 0 24px rgba(126,224,76,.6);
  animation: record-blink .7s steps(2) infinite;
}
@keyframes record-blink { 50% { opacity: .35; } }

@media (max-width: 700px) {
  .hud-box { min-width: 86px; padding: 5px 12px 7px; }
  .hud-value { font-size: 22px; }
  #combo-bar { width: 86px; }
}

/* Lage schermen (telefoon liggend): compacte HUD en een iets kleiner, lager bord,
   anders vallen de scorevakken over de bovenste rij van het speelveld */
@media (max-height: 500px) {
  #hud { top: 6px; gap: 10px; }
  .hud-box { min-width: 0; padding: 3px 12px 5px; border-radius: 10px; }
  .hud-label { font-size: 10px; }
  .hud-value { font-size: 18px; }
  #combo-bar { width: 80px; margin-top: 4px; }
  #mute-btn { top: 6px; width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
  #board-pivot {
    top: 58%;
    width: min(85vw, 118vh);
    margin-left: calc(min(85vw, 118vh) / -2);
  }
}
