:root {
  --bg-1: #0e1512;
  --bg-2: #1a2a20;
  --panel: #efe5cf;
  --accent: #e5b54d;
  --ink: #1b1d14;
  --grass: #3f7f4a;
  --grass-deep: #2e5f39;
  --mowed: #9bd6a5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Impact", "Gill Sans", sans-serif;
  color: #f6f2e8;
  background: radial-gradient(1200px 600px at 10% -10%, #244f3c 0%, transparent 60%),
    radial-gradient(900px 500px at 120% 0%, #16302a 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  display: flex;
  align-items: center;
  justify-content: center;
}

.wrap {
  width: min(1100px, 95vw);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand .title {
  font-size: clamp(20px, 4vw, 34px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand .subtitle {
  font-size: 14px;
  color: #d7cdb7;
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 14px;
}

.stat {
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.progress-wrap {
  display: grid;
  gap: 6px;
}

.upgrades-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-family: "Comic Sans MS", "Comic Neue", cursive;
  font-size: 13px;
  color: #f2d24c;
  text-shadow:
    -1px -1px 0 #111,
    1px -1px 0 #111,
    -1px 1px 0 #111,
    1px 1px 0 #111;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.progress-label {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d9d1bd;
}

.progress-bar {
  width: 100%;
  height: 14px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7bd389, #b7e4a6);
  border-radius: 999px;
  transition: width 120ms ease;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
}

.cash {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  font-family: "Comic Sans MS", "Comic Neue", cursive;
  font-size: 18px;
  color: #9fe7a5;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.04em;
}

.cash-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(35, 80, 50, 0.6);
  border: 1px solid rgba(159, 231, 165, 0.4);
  text-align: center;
  line-height: 20px;
  font-weight: 700;
}

.stage {
  position: relative;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.2));
  border-radius: 18px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

#game {
  width: 100%;
  height: 640px;
  max-height: 70vh;
  min-height: 520px;
  display: block;
  background: radial-gradient(800px 500px at 50% 0%, #315b3d 0%, #203525 60%, #16261c 100%);
  border-radius: 14px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 10, 0.6);
  backdrop-filter: blur(4px);
  gap: 12px;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 200ms ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.game-title {
  font-family: "Comic Sans MS", "Comic Neue", cursive;
  font-size: clamp(26px, 5vw, 36px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f7f3e6;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.game-tagline {
  font-family: "Comic Sans MS", "Comic Neue", cursive;
  font-size: clamp(14px, 3vw, 18px);
  color: #efe6d0;
  margin-top: -6px;
  text-align: center;
}

.game-subtitle {
  font-family: "Comic Sans MS", "Comic Neue", cursive;
  font-size: clamp(14px, 3vw, 18px);
  color: #efe6d0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  margin-top: -4px;
}

.warning {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255, 107, 107, 0.9);
  color: #1b0c0c;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: 2px solid rgba(92, 18, 18, 0.6);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  animation: warning-pulse 0.6s infinite;
}

.warning.hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes warning-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.06);
    filter: brightness(1.2);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.win-flash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f7f3e6;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.4);
  background: rgba(10, 16, 12, 0.45);
  animation: win-flash 0.35s infinite;
  pointer-events: none;
}

.win-flash.score-count {
  color: #9fe76b;
  text-shadow: 0 0 18px rgba(159, 231, 107, 0.55);
}

.win-flash.final-win {
  font-size: clamp(40px, 9vw, 110px);
  letter-spacing: 0.18em;
  color: #f7f3e6;
  text-shadow: 0 0 28px rgba(255, 255, 255, 0.55);
}

.win-screen {
  background: #000;
}

.win-screen .hud,
.win-screen .topbar,
.win-screen .help,
.win-screen canvas,
.win-screen .overlay {
  display: none;
}

.win-screen .win-flash {
  position: fixed;
  inset: 0;
  background: #000;
}

.win-flash.hidden {
  opacity: 0;
  pointer-events: none;
  animation: none;
  display: none;
}

@keyframes win-flash {
  0% {
    opacity: 0.2;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 0.2;
    transform: scale(1);
  }
}

.panel {
  background: var(--panel);
  color: var(--ink);
  padding: 20px 26px;
  border-radius: 18px;
  text-align: center;
  min-width: min(360px, 90vw);
  border: 2px solid #c6b28a;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
  animation: float-in 420ms ease-out;
}

.panel-title {
  font-size: 24px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-body {
  margin-top: 8px;
  font-size: 14px;
}

.difficulty {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
}


.diff-button {
  border: none;
  background: var(--accent);
  color: #3b2d0f;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.diff-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.difficulty label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.upgrade-list {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.panel-hint {
  color: #4b422f;
  font-size: 12px;
}

.controls-diagram {
  margin-top: 10px;
  display: block;
  gap: 6px;
  justify-content: center;
  text-transform: uppercase;
  padding: 8px 0 4px;
}

.key-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 4px 0;
}

.key {
  min-width: 36px;
  padding: 8px 12px;
  background: #1b1f1a;
  border: 2px solid #5dd693;
  border-radius: 6px;
  font-weight: 800;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 11px;
  color: #e2ffef;
  box-shadow: 0 0 10px rgba(93, 214, 147, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.4);
  display: inline-block;
  line-height: 1;
}

.key.cap {
  min-width: auto;
  font-weight: 700;
  background: #2a322b;
  border-color: #e2b647;
  color: #ffe7b0;
  box-shadow: 0 0 10px rgba(226, 182, 71, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.4);
}

.legend {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 12px;
}

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

.legend-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 4px;
}

.legend-icon.rabbit {
  background: transparent;
  border: none;
  background-image: url("Rabbit-sit.png");
  background-size: cover;
  background-position: center;
}

.legend-icon.tree {
  background: transparent;
  border: none;
  background-image: url("TreeLawn.png");
  background-size: cover;
  background-position: center;
}

.legend-icon.rock {
  background: transparent;
  border: none;
  background-image: url("RockLawn1.png");
  background-size: cover;
  background-position: center;
}

.legend-icon.shed {
  background: transparent;
  border: none;
  background-image: url("Shed.png");
  background-size: cover;
  background-position: center;
}

.legend-icon.snake {
  background: transparent;
  border: none;
  background-image: url("SnakePos1.png");
  background-size: cover;
  background-position: center;
}


.is-hidden {
  display: none;
}

.panel-actions {
  margin-top: 16px;
}

button {
  border: none;
  background: var(--accent);
  color: #3b2d0f;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.help {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: #d9d1bd;
  justify-content: center;
}

@keyframes float-in {
  from {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 700px) {
  .hud {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats {
    flex-wrap: wrap;
  }

  #game {
    min-height: 420px;
  }
}
