/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden {
  display: none !important;
}

:root {
  --sky-top: #0d1b3e;
  --sky-mid: #1a56a0;
  --sky-bottom: #3a86c8;
  --hud-bg: rgba(8, 18, 40, 0.88);
  --hud-border: rgba(100, 180, 255, 0.2);
  --text-light: #e8f4ff;
  --text-muted: rgba(200, 230, 255, 0.6);
  --meter-bg: rgba(5, 20, 60, 0.85);
  --meter-water: #1e88e5;
  --meter-water-bright: #64b5f6;
  --font-main: 'Nunito', 'Comic Sans MS', cursive, sans-serif;
  --zone-border-open: rgba(80, 255, 180, 0.7);
  --zone-border-hint: rgba(255, 220, 80, 0.9);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--sky-top);
  font-family: var(--font-main);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ═══════════════════════════════════════════════════════════════
   GAME CONTAINER
═══════════════════════════════════════════════════════════════ */
#game-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.scene-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.scene-screen.hidden {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════
   SCENE 1 — INTRO
═══════════════════════════════════════════════════════════════ */
#scene1-screen {
  background: linear-gradient(180deg, #0a1628 0%, #1a4a8a 55%, #2d6cb5 100%);
}

#scene1-title {
  text-align: center;
  padding: 28px 20px 0;
  z-index: 2;
}

#scene1-title h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(100, 200, 255, 0.8), 0 4px 20px rgba(0,0,0,0.5);
}

#scene1-title p {
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  color: rgba(180, 220, 255, 0.8);
  margin-top: 6px;
  font-weight: 600;
}

#scene1-sky {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#scene1-rain-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

#scene1-ground {
  height: clamp(70px, 16vh, 130px);
  background: linear-gradient(180deg, #78909c 0%, #546e7a 40%, #455a64 100%);
  position: relative;
  border-top: 3px solid #90a4ae;
  overflow: hidden;
  flex-shrink: 0;
}

#scene1-cement-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.scene1-crack {
  position: absolute;
  left: 15%;
  top: 0;
  width: 2px;
  height: 0;
  background: rgba(0, 0, 0, 0.35);
  animation: crackGrow 2.5s ease-in-out infinite alternate;
}

@keyframes crackGrow {
  from { height: 0; opacity: 0.3; }
  to   { height: 80%; opacity: 0.7; }
}

#continue-button {
  position: absolute;
  bottom: clamp(100px, 20vh, 160px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-family: var(--font-main);
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 50px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  z-index: 10;
  animation: buttonPulse 2s ease-in-out infinite;
}

#continue-button:hover, #continue-button:active {
  background: rgba(255, 255, 255, 0.28);
  transform: translateX(-50%) scale(1.05);
}

#continue-button.hidden { display: none; }

@keyframes buttonPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
  50%       { box-shadow: 0 0 0 12px rgba(255,255,255,0); }
}

/* ═══════════════════════════════════════════════════════════════
   CLOUDS
═══════════════════════════════════════════════════════════════ */
.cloud {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.cloud-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(100, 160, 240, 0.35));
}

#cloud-s1-a {
  width: clamp(120px, 20vw, 200px);
  height: clamp(60px, 10vw, 100px);
  top: 12%;
  animation: cloudDrift 14s linear infinite;
}

#cloud-s1-b {
  width: clamp(90px, 15vw, 160px);
  height: clamp(48px, 8vw, 80px);
  top: 22%;
  animation: cloudDrift 20s linear infinite;
  animation-delay: -8s;
  opacity: 0.85;
}

#cloud-s1-c {
  width: clamp(70px, 12vw, 130px);
  height: clamp(38px, 6vw, 65px);
  top: 8%;
  animation: cloudDrift 26s linear infinite;
  animation-delay: -14s;
  opacity: 0.7;
}

@keyframes cloudDrift {
  from { transform: translateX(-220px); }
  to   { transform: translateX(110vw); }
}

#cloud-s2-a {
  width: clamp(100px, 16vw, 180px);
  height: clamp(50px, 8vw, 90px);
  top: 8px;
  animation: cloudDrift 18s linear infinite;
}

#cloud-s2-b {
  width: clamp(80px, 13vw, 140px);
  height: clamp(40px, 6.5vw, 70px);
  top: 14px;
  animation: cloudDrift 24s linear infinite;
  animation-delay: -10s;
  opacity: 0.8;
}

.scene1-raindrop {
  position: absolute;
  top: 0;
  width: 2px;
  height: 18px;
  background: linear-gradient(180deg, transparent, #63b3ed, #90cdf4);
  border-radius: 2px;
  animation: scene1RainFall linear forwards;
  opacity: 0.7;
}

@keyframes scene1RainFall {
  from { transform: translateY(0); opacity: 0.8; }
  to   { transform: translateY(100vh); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   SCENE 2 — HUD
═══════════════════════════════════════════════════════════════ */
#scene2-screen {
  background: linear-gradient(180deg, #0a1628 0%, #0d2040 100%);
}

#game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  height: clamp(52px, 8vh, 68px);
  background: var(--hud-bg);
  border-bottom: 1px solid var(--hud-border);
  flex-shrink: 0;
  backdrop-filter: blur(10px);
}

#timer-block, #score-block {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 80px;
}

#timer-icon, #score-icon { font-size: 1.15rem; }

#timer-value, #score-value {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 900;
  color: #fff;
  transition: color 0.4s;
  min-width: 2.5ch;
  text-align: center;
}

#timer-unit, #score-unit {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

#timer-value.timer-warning {
  color: #ff6b35;
  animation: timerWarningPulse 0.5s ease-in-out infinite alternate;
}

@keyframes timerWarningPulse {
  from { text-shadow: none; }
  to   { text-shadow: 0 0 14px rgba(255, 107, 53, 0.9); }
}

#instruction-text {
  flex: 1;
  text-align: center;
  font-size: clamp(0.62rem, 1.8vw, 0.88rem);
  font-weight: 700;
  color: rgba(160, 210, 255, 0.85);
  line-height: 1.3;
  padding: 0 8px;
}

/* ═══════════════════════════════════════════════════════════════
   GAME AREA LAYOUT
═══════════════════════════════════════════════════════════════ */
#game-area {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

#sky-and-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

#sky-area {
  flex: 1;
  min-height: clamp(120px, 20vh, 220px);
  background: linear-gradient(180deg, #0a1628 0%, #1a3a6e 60%, #1f4a8a 100%);
  position: relative;
  border-bottom: 1px solid rgba(100, 160, 255, 0.15);
  overflow: hidden;
}


#rain-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   GROUND CROSS-SECTION — the unified slice view
═══════════════════════════════════════════════════════════════ */
#ground-cross-section {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  overflow: visible;
}

/* Left column: layer name labels */
#layer-label-column {
  width: clamp(80px, 11vw, 130px);
  flex-shrink: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(8, 18, 40, 0.95) 0%, rgba(5, 12, 30, 0.98) 100%);
  border-right: 2px solid rgba(100, 160, 255, 0.18);
}


.layer-row-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-size: clamp(0.48rem, 1.1vw, 0.7rem);
  font-weight: 800;
  color: rgba(180, 220, 255, 0.72);
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.15;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.layer-row-label:last-child {
  border-bottom: none;
}

/* Right section: the grid + overlays */
#ground-grid-wrapper {
  flex: 1;
  aspect-ratio: 3;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════
   SHARED CROSS-SECTION GRID — rows = layers, cols = zones
═══════════════════════════════════════════════════════════════ */
#ground-grid {
  width: 100%;
  aspect-ratio: 3;
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 0;
}

/* ═══════════════════════════════════════════════════════════════
   INDIVIDUAL CELLS  (layer × zone intersection)
═══════════════════════════════════════════════════════════════ */
.zone-cell {
  position: relative;
  border-right: 1px solid rgba(0, 0, 0, 0.22);
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  overflow: hidden;
  transition: background-color 0.45s ease;
}

/* No right border on last column */
.zone-cell:nth-child(18n) { border-right: none; }

/* No bottom border on last row */
.zone-cell.zone-cell-layer-5 { border-bottom: none; }

/* Subtle texture overlays per layer */
.zone-cell-layer-0 {
  background-image: repeating-linear-gradient(
    90deg, rgba(0,0,0,0.07) 0px, rgba(0,0,0,0.07) 2px,
    transparent 2px, transparent 16px
  );
}
.zone-cell-layer-1 {
  background-image: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.06) 2px, transparent 2px);
  background-size: 12px 12px;
}
.zone-cell-layer-2 {
  background-image: radial-gradient(circle at 70% 60%, rgba(0,0,0,0.1) 2px, transparent 2px);
  background-size: 9px 9px;
}
.zone-cell-layer-3 {
  background-image: repeating-linear-gradient(
    45deg, rgba(0,0,0,0.06) 0px, rgba(0,0,0,0.06) 1px,
    transparent 1px, transparent 9px
  );
}
.zone-cell-layer-4 {
  background-image: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.09) 1px, transparent 1px);
  background-size: 7px 7px;
}
.zone-cell-layer-5 {
  background-image: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 50%);
}

.zone-cell.dug {
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.8), inset 2px 2px 6px rgba(0, 0, 0, 0.6);
}

/* Shake animation on cells */
.cell-shaking {
  animation: cellShake 0.08s ease-in-out 5;
}

@keyframes cellShake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════════
   STONE OBSTRUCTION
═══════════════════════════════════════════════════════════════ */
.stone-block {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.stone-shape {
  width: 65%;
  height: 55%;
  background: radial-gradient(ellipse at 35% 35%, #b0bec5 0%, #78909c 45%, #546e7a 100%);
  border-radius: 42% 58% 55% 45% / 40% 45% 55% 60%;
  position: relative;
  box-shadow: inset -3px -3px 6px rgba(0,0,0,0.3), inset 2px 2px 4px rgba(255,255,255,0.15),
              2px 3px 8px rgba(0,0,0,0.4);
}

.stone-shape::before {
  content: '';
  position: absolute;
  width: 35%;
  height: 2px;
  background: rgba(255,255,255,0.22);
  top: 28%;
  left: 12%;
  border-radius: 2px;
  transform: rotate(-15deg);
}

.stone-shape::after {
  content: '';
  position: absolute;
  width: 22%;
  height: 2px;
  background: rgba(0,0,0,0.2);
  top: 55%;
  left: 45%;
  border-radius: 2px;
  transform: rotate(10deg);
}

/* ═══════════════════════════════════════════════════════════════
   ZONE CLICK OVERLAYS — transparent columns over the grid
═══════════════════════════════════════════════════════════════ */
#zone-overlay-row {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  z-index: 10;
  pointer-events: auto;
}

.zone-click-overlay {
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s, box-shadow 0.3s;
}

.zone-click-overlay:last-child {
  border-right: none;
}

.zone-click-overlay:hover {
  background: rgba(140, 210, 255, 0.06);
  box-shadow: inset 1px 0 0 rgba(140, 210, 255, 0.15), inset -1px 0 0 rgba(140, 210, 255, 0.15);
}

.zone-click-overlay:active {
  background: rgba(100, 200, 255, 0.14);
}

.zone-click-overlay.zone-column-open {
  background: rgba(80, 255, 180, 0.06);
  box-shadow: inset 0 0 0 2px rgba(80, 255, 180, 0.55);
}

.zone-click-overlay.zone-with-sprout {
  box-shadow: inset 0 0 0 2px rgba(76, 175, 80, 0.6);
}

.zone-click-overlay.lateral-dig-hint {
  background: rgba(255, 220, 80, 0.1);
  box-shadow: inset 0 0 0 2px rgba(255, 220, 80, 0.75);
  animation: hintPulse 0.5s ease-in-out 4;
}

@keyframes hintPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(255, 220, 80, 0.5); }
  50%       { box-shadow: inset 0 0 0 3px rgba(255, 220, 80, 0.9), 0 0 18px rgba(255, 220, 80, 0.3); }
}

/* ═══════════════════════════════════════════════════════════════
   DEPTH INDICATOR  (inside overlay, at bottom)
═══════════════════════════════════════════════════════════════ */
.depth-indicator {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 18, 40, 0.88);
  color: rgba(160, 210, 255, 0.9);
  font-size: clamp(0.4rem, 0.9vw, 0.58rem);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid rgba(100, 160, 255, 0.25);
  pointer-events: none;
  z-index: 12;
}

/* ═══════════════════════════════════════════════════════════════
   SPROUT  (inside overlay, at top)
═══════════════════════════════════════════════════════════════ */
.zone-sprout {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(22px, 4vw, 40px);
  height: clamp(22px, 4vw, 40px);
  z-index: 12;
  pointer-events: none;
}

.zone-sprout.hidden { display: none; }

.zone-sprout.sprouting {
  animation: sproutPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sproutPop {
  from { transform: translateX(-50%) scale(0) rotate(-10deg); opacity: 0; }
  to   { transform: translateX(-50%) scale(1) rotate(0deg);  opacity: 1; }
}

.sprout-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ═══════════════════════════════════════════════════════════════
   RAINDROP
═══════════════════════════════════════════════════════════════ */
.raindrop {
  position: absolute;
  width: 12px;
  height: 22px;
  background: linear-gradient(180deg, #64b5f6 0%, #1e88e5 60%, #1565c0 100%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform: rotate(180deg);
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 0 10px rgba(30, 136, 229, 0.6), 0 0 24px rgba(30, 136, 229, 0.2);
  will-change: top;
}

/* ═══════════════════════════════════════════════════════════════
   DIG PARTICLES
═══════════════════════════════════════════════════════════════ */
.dig-particle {
  position: absolute;
  width: clamp(3px, 1vw, 6px);
  height: clamp(3px, 1vw, 6px);
  border-radius: 50%;
  pointer-events: none;
  z-index: 15;
  animation: particleBurst 0.5s ease-out forwards;
}

@keyframes particleBurst {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to   { transform: translate(var(--particle-x), var(--particle-y)) scale(0.2); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   WATER TRICKLE
═══════════════════════════════════════════════════════════════ */
.water-trickle-anim {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  background: linear-gradient(180deg, #64b5f6, #1e88e5);
  border-radius: 3px;
  pointer-events: none;
  z-index: 14;
  animation: trickleDown 1s ease-in forwards;
}

@keyframes trickleDown {
  from { height: 0;    top: 0; opacity: 0.9; }
  to   { height: 100%; top: 0; opacity: 0.2; }
}

/* ═══════════════════════════════════════════════════════════════
   MISSED SPLASH
═══════════════════════════════════════════════════════════════ */
.missed-splash-anim {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 10px;
  background: rgba(100, 181, 246, 0.55);
  border-radius: 50%;
  pointer-events: none;
  z-index: 14;
  animation: splashSpread 0.85s ease-out forwards;
}

@keyframes splashSpread {
  from { transform: translateX(-50%) scale(0.5); opacity: 0.9; }
  to   { transform: translateX(-50%) scale(3.5); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   STONE FEEDBACK BUBBLE
═══════════════════════════════════════════════════════════════ */
.stone-feedback-bubble {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 30, 0.92);
  color: #ffcc80;
  font-family: var(--font-main);
  font-size: clamp(0.55rem, 1.4vw, 0.76rem);
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 200, 80, 0.4);
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  animation: bubbleFadeUp 1.6s ease-out forwards;
}

@keyframes bubbleFadeUp {
  0%   { opacity: 0; transform: translateX(-50%) translateY(0); }
  15%  { opacity: 1; }
  80%  { opacity: 1; transform: translateX(-50%) translateY(-14px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ═══════════════════════════════════════════════════════════════
   GROUNDWATER METER
═══════════════════════════════════════════════════════════════ */
#groundwater-meter-container {
  width: clamp(60px, 9vw, 90px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 10px;
  background: linear-gradient(180deg, rgba(5,15,40,0.9) 0%, rgba(5,20,55,0.95) 100%);
  border-left: 1px solid rgba(100, 160, 255, 0.15);
  flex-shrink: 0;
  gap: 8px;
}

#groundwater-meter-label {
  font-size: clamp(0.5rem, 1.2vw, 0.68rem);
  font-weight: 800;
  color: rgba(160, 210, 255, 0.8);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

#groundwater-meter-well {
  flex: 1;
  width: clamp(32px, 5vw, 50px);
  background: rgba(5, 20, 60, 0.8);
  border: 2px solid rgba(30, 136, 229, 0.4);
  border-radius: 8px 8px 4px 4px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 100, 0.4), 0 0 20px rgba(30, 136, 229, 0.1);
}

#groundwater-meter-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(180deg, var(--meter-water-bright) 0%, var(--meter-water) 60%, #0d47a1 100%);
  transition: height 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-radius: 0 0 2px 2px;
}

#groundwater-meter-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px 2px 0 0;
}

#groundwater-wave {
  position: absolute;
  bottom: 0;
  left: -50%;
  width: 200%;
  height: 8px;
  background: rgba(100, 181, 246, 0.4);
  border-radius: 50%;
  animation: waveSurface 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes waveSurface {
  0%, 100% { transform: translateX(0) scaleY(1); }
  50%       { transform: translateX(8%) scaleY(1.5); }
}

#groundwater-meter-percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(0.5rem, 1.3vw, 0.72rem);
  font-weight: 900;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 2;
}

#groundwater-meter-bottom-label {
  font-size: clamp(0.45rem, 1vw, 0.58rem);
  font-weight: 700;
  color: rgba(130, 165, 200, 0.6);
  text-align: center;
  letter-spacing: 0.03em;
}

/* ═══════════════════════════════════════════════════════════════
   WIN / LOSE OVERLAY
═══════════════════════════════════════════════════════════════ */
#overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: overlayFadeIn 0.5s ease-out forwards;
}

#overlay-screen.hidden { display: none; }

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.win-overlay {
  background: radial-gradient(ellipse at 50% 40%, rgba(27, 94, 32, 0.97) 0%, rgba(10, 40, 12, 0.99) 100%);
}

.lose-overlay {
  background: radial-gradient(ellipse at 50% 40%, rgba(74, 32, 0, 0.97) 0%, rgba(30, 12, 0, 0.99) 100%);
}

#overlay-content {
  text-align: center;
  padding: 40px 32px;
  max-width: 480px;
  width: 90%;
}

#overlay-icon {
  font-size: clamp(3.5rem, 10vw, 5.5rem);
  display: block;
  margin-bottom: 16px;
  animation: iconBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

@keyframes iconBounce {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

#overlay-title {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 900;
  color: #fff;
  margin-bottom: 14px;
  line-height: 1.2;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.win-overlay  #overlay-title { color: #b9f6ca; }
.lose-overlay #overlay-title { color: #ffe0b2; }

#overlay-message {
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.55;
  margin-bottom: 28px;
}

#overlay-action-button {
  font-family: var(--font-main);
  font-size: clamp(1rem, 3vw, 1.25rem);
  font-weight: 800;
  padding: 14px 40px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.02em;
}

.win-overlay #overlay-action-button {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  color: #fff;
  box-shadow: 0 6px 24px rgba(76, 175, 80, 0.5);
}

.lose-overlay #overlay-action-button {
  background: linear-gradient(135deg, #ff8f00, #e65100);
  color: #fff;
  box-shadow: 0 6px 24px rgba(255, 143, 0, 0.5);
}

#overlay-action-button:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 10px 32px rgba(0,0,0,0.3);
}

#overlay-action-button:active { transform: scale(0.96); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */
@media (max-height: 600px) {
  #game-hud  { height: 46px; }
  #sky-area  { height: 55px; }
  #layer-label-column { width: 70px; }
}

@media (max-width: 500px) {
  #instruction-text { display: none; }
  #groundwater-meter-container { width: 54px; }
  #layer-label-column { width: 60px; }
  .layer-row-label { font-size: 0.42rem; padding-right: 6px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #sky-area  { height: 48px; }
  #game-hud  { height: 40px; }
  #layer-label-column { width: 65px; }
}
