/* === COLOR VARIABLES === */
:root {
  --hud-glow: none;
  --panel-border: 2px solid var(--brand-blue);
  --brand-blue: #2E9DF7;
  --brand-yellow: #FFC907;
  --brand-teal: #8BD1CB;
  --brand-green: #4FCB53;
  --brand-darkgreen: #159A48;
  --brand-orange: #FF902A;
  --brand-red: #F5402C;
  --brand-pinkred: #F16061;
  --bg-dark: #222520;
  --bg-medium: #383B36;
  --text-light: #F8EED3;

  /* ensure overlay/fallback tokens exist (if not already defined above) */
  --modal-overlay: rgba(0,0,0,0.6);
  --modal-card-bg: #ffffff;
  --modal-focus-ring: 4px rgba(46,157,247,0.16);
}

/* ======================================================
  STYLE SECTIONS
  - Page / container
  - HUD / header
  - Village / map
  - Controls / buttons
  - Spots / markers
  - Animations & celebration
  - Modals
  ====================================================== */

body {
  /* prefer locally installed Proxima Nova; fall back to Montserrat, Poppins, then Avenir/Georgia */
  font-family: 'Proxima Nova', 'Montserrat', 'Poppins', 'Avenir', Georgia, serif;
  background: var(--bg-dark);
  color: var(--text-light);
  text-align: center;
  margin: 0;
  padding: 0;
  letter-spacing: 0.14em;
}

.game-container {
  max-width: 400px;
  margin: 40px auto;
  padding: 10px 20px;
  background: var(--bg-medium);
  border-radius: 12px;
  box-shadow: none;
  border: var(--panel-border);
}
/* .game-container rules are defined above */

/* --- HUD / HEADER --- */
.hud {
  background: rgba(34,37,32,0.95);
  color: var(--text-light);
  padding: 16px 10px 10px 10px;
  border-radius: 10px 10px 0 0;
  border-bottom: 2px solid var(--brand-blue);
  box-shadow: none;
}

.hud h1 {
  margin: 5px 0;
  font-size: 1.7rem;
  color: var(--brand-blue);
  letter-spacing: 0.14em;
}


.hud-stats {
  display: flex;
  justify-content: space-around;
  font-size: 1.05rem;
  border-radius: 6px;
  background: rgba(46,157,247,0.08);
  border: 1.5px solid var(--brand-blue);
  box-shadow: none;
  margin-top: 8px;
  padding: 6px 0;
}

.stat span {
  font-weight: bold;
  color: var(--brand-yellow);
  text-shadow: 0 1px 2px #000;
}

.village {
  margin: 30px 0;
}

.controls {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- MAP AREA --- */
#map {
  position: relative;
  width: 100%;
  height: 250px;
  background: var(--bg-dark); /* image is rendered via <img> to avoid duplicate layers */
  border: 3px solid var(--brand-blue);
  box-shadow: none;
  border-radius: 10px;
  margin: 0 auto;
  overflow: hidden;
}

/* --- CONTROLS --- */
.controls {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ensure the map image inserted by script fills the area */
#map img#mapImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

/* Hide spots by default, show only when .spots-visible is on #map */
#map .spot {
  display: none !important;
}
#map.spots-visible .spot {
  display: flex !important;
}

/* weather overlay and rainfall visuals (not used in current UI) */

/* --- RESET BUTTON --- */
.reset {
  color: var(--brand-yellow);
  background: var(--brand-red);
  border: 2px solid var(--brand-yellow);
  font-weight: bold;
  margin-top: 10px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.reset:hover {
  background: var(--brand-pinkred);
  color: var(--brand-yellow);
}

/* --- CONTROLS BUTTONS --- */
#digBtn, #buildBtn {
  flex: 1 1 0;
  min-width: 0;
  border: 2px solid var(--brand-yellow);
  font-weight: bold;
  font-size: 1rem;
  border-radius: 8px;
  box-shadow: none;
  padding: 10px 16px;
  cursor: pointer;
  color: #fff;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
#digBtn {
  margin-right: 10px;
  background: #8B5C2A; /* brown */
}
#buildBtn {
  margin-left: 10px;
  background: var(--brand-green); /* green */
}

#digBtn:hover, #buildBtn:hover {
  color: var(--brand-yellow);
  border-color: var(--brand-yellow);
}

#digBtn:hover {
  background: #a06a32;
}

#buildBtn:hover {
  background: #3fae46;
}

/* --- DONATE BUTTON --- */
button.donate, .donate {
  background: transparent;
  color: #fff;
  border: 2px solid var(--brand-yellow);
  font-weight: bold;
  font-size: 1rem;
  border-radius: 8px;
  box-shadow: none;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

button.donate:hover, .donate:hover {
  color: var(--brand-yellow);
  border-color: var(--brand-yellow);
  background: rgba(255, 201, 7, 0.08);
}

/* === INTERACTIVE / ANIMATIONS === */
/* Pulse animation (not used) */

/* Interactive HUD pieces */
.hud .stat#fundsStat:hover,
.hud .stat#fundsStat:focus {
  transform: translateY(-3px);
  box-shadow: none;
}
/* currency-toggle (not used) */

/* Spot markers (clickable) — now icon-based using water drop.png */
.spot {
  position: absolute;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none; /* ensure no square border behind icons */
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.spot img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  pointer-events: none;
  transition: transform 0.18s ease, filter 0.18s ease;
}

/* Wet spots get a cool green glow around the icon */
.spot.wet {
  /* remove colored glow */
  box-shadow: none;
}

/* Dry spots get a warm orange/red hint */
.spot.dry {
  /* remove colored glow */
  box-shadow: none;
}

/* Toxic spots get a slight red tint and higher visual priority */
.spot.toxic {
  border-color: rgba(255,80,60,0.9);
  background: rgba(255,80,60,0.06);
  z-index: 8;
}

.spot:hover {
  transform: translateY(-6px) scale(1.18);
  z-index: 6;
}
.spot:active {
  transform: translateY(-2px) scale(1.02);
}

/* Small focus-visible ring for keyboard users */
.spot:focus-visible {
  box-shadow: none;
}

/* Larger spread glow behind each spot for more visual weight */
.spot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 160%;
  height: 160%;
  transform: translate(-50%, -50%) scale(1);
  border-radius: 50%;
  pointer-events: none;
  z-index: 2; /* sits below the icon but above the map overlay */
  transition: opacity 220ms ease, transform 220ms ease;
  opacity: 0.0;
  filter: blur(10px);
}

.spot.wet::after {
  background: none;
  opacity: 0;
}

.spot.dry::after {
  background: none;
  opacity: 0;
}

/* Intensify the glow on hover */
.spot:hover::after {
  transform: translate(-50%, -50%) scale(1.18);
  opacity: 0;
}

/* subtle overlay shimmer (no map-overlay in markup) */

/* --- ANIMATIONS & CELEBRATION --- */

/* contamination warning banner */
.contamination-warning {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  background: rgba(220,50,50,0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  z-index: 9999;
  box-shadow: none;
  pointer-events: none;
}

/* Flash red for depleted funds */
.hud .stat.flash-red {
  animation: flash-red 1s ease-in-out 2;
  /* ensure high visual priority while flashing */
  z-index: 10000;
}
@keyframes flash-red {
  0%   { background: rgba(255,60,60,0.0); color: var(--text-light); }
  40%  { background: rgba(255,60,60,0.95); color: #fff; }
  70%  { background: rgba(255,60,60,0.6); color: #fff; }
  100% { background: rgba(255,60,60,0.0); color: var(--text-light); }
}

/* Confetti celebration (shoot from bottom to top) */
.confetti-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 10000;
}
.confetti-piece {
  position: absolute;
  bottom: -8px;
  display: block;
  opacity: 0.95;
  border-radius: 2px;
  will-change: transform, opacity;
  /* animation defined below */
  animation-name: confetti-shoot;
  animation-timing-function: cubic-bezier(.2,.8,.2,1);
  animation-fill-mode: forwards;
}
@keyframes confetti-shoot {
  0% {
    transform: translateY(0) rotate(0deg) translateX(0);
    opacity: 1;
  }
  60% {
    transform: translateY(-60vh) rotate(360deg) translateX(10px);
    opacity: 1;
  }
  100% {
    transform: translateY(-120vh) rotate(720deg) translateX(-20px);
    opacity: 0;
  }
}

/* Victory overlay covering the map area */
.victory-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12000;
  background: rgba(0,0,0,0.45);
  pointer-events: auto;
}
.victory-message {
  text-align: center;
  color: #fff;
  padding: 18px 22px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  max-width: 90%;
}
.victory-message h1 {
  margin: 0 0 8px 0;
  font-size: 1.6rem;
  line-height: 1.05;
  letter-spacing: 0.06em;
}

/* disco color-changing text */
.disco-text {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  animation: disco-colors 1.6s linear infinite;
  font-weight: 900;
}
@keyframes disco-colors {
  0%   { color: #FFC907; text-shadow: 0 2px 10px rgba(255,201,7,0.2); }
  20%  { color: #2E9DF7; text-shadow: 0 2px 10px rgba(46,157,247,0.2); }
  40%  { color: #4FCB53; text-shadow: 0 2px 10px rgba(79,203,83,0.2); }
  60%  { color: #FF902A; text-shadow: 0 2px 10px rgba(255,144,42,0.2); }
  80%  { color: #F5402C; text-shadow: 0 2px 10px rgba(245,64,44,0.2); }
  100% { color: #8BD1CB; text-shadow: 0 2px 10px rgba(139,209,203,0.2); }
}

.victory-sub {
  margin: 8px 0 12px 0;
  opacity: 0.95;
  font-weight: 600;
}

.victory-restart {
  background: transparent;
  color: #fff;
  border: 2px solid #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}
.victory-restart:hover {
  background: rgba(255,255,255,0.06);
}

/* === Difficulty modal (brand-colored, accessible) === */
#difficultyModal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--modal-overlay);
  z-index: 9999;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#difficultyModal .difficulty-card {
  background: var(--bg-medium);
  border-radius: 12px;
  padding: 18px 20px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 36px rgba(2,6,23,0.18);
  color: var(--brand-muted);
  font-family: inherit;
}

#difficultyModal .difficulty-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  color: var(--brand-blue);
  font-weight: 600;
  font-family: proxima nova;
}

#difficultyModal .difficulty-card p {
  margin: 0 0 14px;
  color: var(--brand-muted);
  font-size: 0.95rem;
}

#difficultyModal .difficulty-card .emph {
  margin: 0 0 14px;
  font-weight: bold;
  color: var(--brand-yellow);
  font-size: 0.95rem;
}
/* Button row */
#difficultyModal .difficulty-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
}

/* Base button appearance */
#difficultyModal .difficulty-row button {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.96rem;
  color: #fff;
  transition: transform .08s ease, box-shadow .12s ease, opacity .12s ease;
  min-width: 0;
}

/* Brand-colored variants with subtle depth */
#difficultyModal .btn-easy {
  background: linear-gradient(180deg, var(--brand-green), var(--brand-darkgreen));
  box-shadow: 0 8px 22px rgba(11,122,43,0.12);
}
#difficultyModal .btn-hard {
  background: linear-gradient(180deg, var(--brand-orange), #8b4f00);
  box-shadow: 0 8px 22px rgba(181,106,0,0.12);
}
#difficultyModal .btn-difficult {
  background: linear-gradient(180deg, var(--brand-red), #7b1212);
  box-shadow: 0 8px 22px rgba(164,25,25,0.12);
}

/* Hover and focus states — accessible outlines */
#difficultyModal .difficulty-row button:hover {
  transform: translateY(-3px);
  filter: saturate(1.04);
}
#difficultyModal .difficulty-row button:active {
  transform: translateY(0);
}
#difficultyModal .difficulty-row button:focus {
  outline: none;
  box-shadow: 0 0 0 var(--modal-focus-ring);
  border-radius: 10px;
}

/* Disabled / aria-disabled */
#difficultyModal .difficulty-row button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ensure modal content scales nicely on small screens */
@media (max-width: 420px) {
  #difficultyModal .difficulty-card { padding: 14px; }
  #difficultyModal .difficulty-row { flex-direction: column; gap: 8px; }
}

