* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Courier New", monospace;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
  color: #fff;
}

#hud {
  width: 800px;
  max-width: 100%;
  background: #222;
  padding: 10px 16px;
  border: 3px solid #555;
  margin-bottom: 8px;
  font-size: 13px;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

.level-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  min-width: 140px;
}

.xp-bar {
  display: inline-block;
  width: 70px;
  height: 10px;
  background: #111;
  border: 1px solid #555;
  vertical-align: middle;
}

#xp-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(#ffd700, #ff9900);
  transition: width 0.3s;
}

.xp-text {
  font-size: 10px;
  color: #aaa;
  min-width: 48px;
}

#message {
  color: #ffd700;
  flex: 1;
  font-size: 12px;
}

.crop-wrap {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
}

.crop-timer {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: bold;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}

.crop-timer.ready {
  color: #ffd700;
  background: rgba(0, 0, 0, 0.8);
}

.crop-timer.urgent {
  color: #ff6633;
  animation: timer-blink 0.5s ease-in-out infinite alternate;
}

@keyframes timer-blink {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

.seed-catalog {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.seed-card {
  flex: 1;
  min-width: 108px;
  background: #333;
  border: 2px solid #555;
  padding: 6px;
  cursor: pointer;
  text-align: left;
}

.seed-card.selected {
  border-color: #ffd700;
  box-shadow: 0 0 6px #ffd70066;
}

.seed-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.seed-card.rarity-common { border-left: 4px solid #aaa; }
.seed-card.rarity-standard { border-left: 4px solid #00a800; }
.seed-card.rarity-rare { border-left: 4px solid #6a5acd; }
.seed-card.rarity-legendary { border-left: 4px solid #ffd700; }

.seed-name {
  font-weight: bold;
  font-size: 11px;
}

.seed-rarity {
  font-size: 9px;
  opacity: 0.75;
  text-transform: uppercase;
}

.seed-lock {
  font-size: 9px;
  color: #ff9966;
  min-height: 12px;
  margin-top: 2px;
}

.seed-stats {
  font-size: 9px;
  margin: 3px 0 5px;
  line-height: 1.35;
}

.seed-buy {
  font-family: inherit;
  font-size: 10px;
  padding: 3px 6px;
  background: #00a800;
  color: #fff;
  border: 2px solid #006800;
  cursor: pointer;
  width: 100%;
}

.seed-buy:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.seed-bag {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 10px;
  color: #ccc;
}

.bag-item {
  background: #2a2a2a;
  padding: 2px 6px;
  border: 1px solid #444;
  cursor: pointer;
}

.bag-item.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.bag-item.has-seeds {
  color: #fff;
  border-color: #666;
}

.bag-item.active {
  border-color: #ffd700;
  color: #ffd700;
}

#game {
  position: relative;
  width: 800px;
  max-width: 100%;
  height: 360px;
  overflow: hidden;
  border: 4px solid #333;
  image-rendering: pixelated;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sky {
  background: linear-gradient(#6eb5ff 0%, #5c94fc 55%, #e8c872 55%);
}

.bg-hills {
  bottom: 96px;
  top: auto;
  height: 100px;
}

.dune {
  position: absolute;
  bottom: 0;
  border-radius: 50% 50% 0 0;
  background: #d4a843;
}

.dune-far {
  width: 220px;
  height: 55px;
  left: 80px;
  background: #c9983a;
}

.dune-near {
  width: 160px;
  height: 40px;
  right: 60px;
  background: #e0b850;
}

.cloud {
  position: absolute;
  background: #fff;
  height: 16px;
  border-radius: 8px;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.c1 { width: 64px; top: 36px; left: 120px; }
.c1::before { width: 28px; height: 28px; top: -14px; left: 8px; }
.c1::after { width: 22px; height: 22px; top: -10px; left: 30px; }

.c2 { width: 80px; top: 64px; left: 420px; }
.c2::before { width: 32px; height: 32px; top: -16px; left: 12px; }
.c2::after { width: 26px; height: 26px; top: -12px; left: 40px; }

.c3 { width: 56px; top: 28px; right: 80px; }
.c3::before { width: 24px; height: 24px; top: -12px; left: 6px; }
.c3::after { width: 20px; height: 20px; top: -8px; left: 26px; }

#world {
  position: absolute;
  inset: 0;
}

#ground {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-size: cover;
  background-repeat: no-repeat;
}

.shop-building {
  position: absolute;
  bottom: 96px;
  left: 24px;
  width: 72px;
  height: 80px;
  z-index: 2;
}

.shop-roof {
  position: absolute;
  top: 0;
  left: -4px;
  width: 80px;
  height: 28px;
  background: #c45c2a;
  border: 2px solid #8b3a1a;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
}

.shop-wall {
  position: absolute;
  bottom: 0;
  left: 4px;
  width: 64px;
  height: 52px;
  background: #e8c090;
  border: 2px solid #b08050;
}

.shop-sign {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: bold;
  color: #5c3317;
  background: #fff;
  padding: 2px 4px;
  border: 1px solid #333;
}

.shop-door {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 28px;
  background: #5c3317;
  border: 2px solid #3d2010;
  border-radius: 10px 10px 0 0;
}

.plot {
  position: absolute;
  bottom: 96px;
  width: 48px;
  height: 20px;
  cursor: pointer;
  z-index: 5;
}

.plot-soil {
  width: 100%;
  height: 100%;
  background: #8b5a2b;
  border: 2px solid #5c3a18;
  border-radius: 4px 4px 0 0;
  box-shadow: inset 0 -4px 0 #6b4220;
  transition: filter 0.15s;
}

.plot:hover .plot-soil {
  filter: brightness(1.15);
}

.plot.empty .plot-soil {
  background: #9a6530;
}

.plot.ready .plot-soil {
  box-shadow: inset 0 -4px 0 #6b4220, 0 0 8px #ffd700;
}

.plot.urgent .plot-soil {
  animation: urgent-soil 0.5s ease-in-out infinite alternate;
}

@keyframes urgent-soil {
  from { box-shadow: inset 0 -4px 0 #6b4220, 0 0 4px #ff6600; }
  to { box-shadow: inset 0 -4px 0 #6b4220, 0 0 12px #ff3300; }
}

.plot.wilted .plot-soil {
  background: #4a3520;
  box-shadow: inset 0 -4px 0 #3a2818;
}

.crop {
  position: relative;
  pointer-events: none;
}

.cactus {
  position: relative;
}

.cactus.stage-0 {
  width: 6px;
  height: 6px;
  background: #8b4513;
  border-radius: 50%;
}

.cactus.stage-1 {
  width: 8px;
  height: 20px;
  background: #2d8a2d;
  border-radius: 3px 3px 0 0;
}

.cactus.stage-2 {
  width: 12px;
  height: 36px;
  background: #228b22;
  border-radius: 4px;
}

.cactus.stage-2::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 5px;
  background: inherit;
  left: -8px;
  top: 12px;
  border-radius: 2px;
}

.cactus.stage-3 {
  width: 16px;
  height: 52px;
  background: #1a7a1a;
  border-radius: 5px;
}

.cactus.stage-3::before,
.cactus.stage-3::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 7px;
  background: inherit;
  border-radius: 2px;
}

.cactus.stage-3::before { left: -10px; top: 16px; }
.cactus.stage-3::after { right: -10px; top: 28px; }

.cactus.dead {
  width: 14px;
  height: 28px;
  background: #5a4a3a;
  border-radius: 3px;
  transform: rotate(15deg);
  opacity: 0.8;
}

.cactus.dead::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 4px;
  background: #5a4a3a;
  left: -6px;
  top: 8px;
  transform: rotate(-30deg);
}

/* Varieties */
.cactus.type-prickly.stage-1,
.cactus.type-prickly.stage-2,
.cactus.type-prickly.stage-3 { background: #5a9f5a; }
.cactus.type-prickly.stage-3 { height: 44px; width: 14px; }

.cactus.type-barrel.stage-1,
.cactus.type-barrel.stage-2,
.cactus.type-barrel.stage-3 { background: #228b22; }

.cactus.type-saguaro.stage-1,
.cactus.type-saguaro.stage-2,
.cactus.type-saguaro.stage-3 { background: #2a7a4a; }
.cactus.type-saguaro.stage-3 { height: 68px; width: 12px; }
.cactus.type-saguaro.stage-3::before { left: -12px; top: 20px; width: 14px; }
.cactus.type-saguaro.stage-3::after { right: -12px; top: 32px; width: 14px; }

.cactus.type-golden.stage-1,
.cactus.type-golden.stage-2,
.cactus.type-golden.stage-3 { background: #daa520; }
.cactus.type-golden.stage-3 { height: 58px; width: 18px; }

.cactus.type-moon.stage-1 { background: #e74c3c; border-radius: 50%; width: 12px; height: 12px; }
.cactus.type-moon.stage-2 { background: #e74c3c; width: 16px; height: 16px; border-radius: 50%; }
.cactus.type-moon.stage-3 {
  background: #e74c3c;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 28px 0 -4px #2ecc40;
}
.cactus.type-moon.stage-3::before,
.cactus.type-moon.stage-3::after { display: none; }

.cactus.type-ghost.stage-1,
.cactus.type-ghost.stage-2,
.cactus.type-ghost.stage-3 {
  background: rgba(200, 220, 255, 0.75);
  box-shadow: 0 0 6px rgba(180, 200, 255, 0.8);
}
.cactus.type-ghost.stage-3 { height: 56px; width: 16px; }

.cactus.type-crystal.stage-1,
.cactus.type-crystal.stage-2,
.cactus.type-crystal.stage-3 { background: #5bc0de; }
.cactus.type-crystal.stage-3 { height: 64px; width: 20px; }

.plot.ready .cactus {
  animation: glow 0.7s ease-in-out infinite alternate;
  pointer-events: auto;
  cursor: pointer;
}

.plot.urgent.ready .cactus.type-crystal {
  animation: glow-urgent 0.4s ease-in-out infinite alternate;
}

@keyframes glow {
  from { filter: drop-shadow(0 0 2px #ffd700); }
  to { filter: drop-shadow(0 0 10px #ffd700); }
}

@keyframes glow-urgent {
  from { filter: drop-shadow(0 0 4px #ff6600); }
  to { filter: drop-shadow(0 0 14px #ff3300); }
}

@keyframes glow-crystal {
  from { filter: drop-shadow(0 0 2px #5bc0de); }
  to { filter: drop-shadow(0 0 12px #fff); }
}

.plot.ready:not(.urgent) .cactus.type-crystal {
  animation: glow-crystal 0.7s ease-in-out infinite alternate;
}
