:root {
  --bg-top: #2b2018;
  --bg-bottom: #120d0a;
  --accent: #ff8a4c;
  --text: #f5ece2;
  --panel: #241a14;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 0%, var(--bg-top), var(--bg-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 9rem;
}

.top-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 6;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  position: relative;
}

.coin-badge { color: #ffd97a; border-color: rgba(255, 215, 120, 0.4); }
.arsenal-badge { color: #ffb199; border-color: rgba(255, 140, 100, 0.4); }

.floaty-gain {
  position: absolute;
  right: 0.4rem;
  top: -0.6rem;
  font-size: 0.8rem;
  color: #9be564;
  opacity: 0;
  pointer-events: none;
}

.floaty-gain.floating {
  animation: gain-float 0.9s ease-out forwards;
}

@keyframes gain-float {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-22px); }
}

.stage {
  width: min(760px, 94vw);
  text-align: center;
}

h1 {
  margin: 4.5rem 0 0.3rem;
  font-size: 1.7rem;
}

.hint {
  margin: 0 0 1.25rem;
  opacity: 0.7;
  font-size: 0.9rem;
}

.town {
  margin-top: 1rem;
  position: relative;
  height: 560px;
  border-radius: 18px;
  overflow: hidden;
  background-color: #4a5c30;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 220px 140px at 14% 30%, rgba(255, 255, 255, 0.06), transparent 70%),
    radial-gradient(ellipse 260px 160px at 65% 20%, rgba(90, 70, 40, 0.35), transparent 70%),
    radial-gradient(ellipse 240px 170px at 40% 65%, rgba(255, 255, 255, 0.05), transparent 70%),
    radial-gradient(ellipse 280px 190px at 85% 70%, rgba(70, 55, 30, 0.4), transparent 70%),
    radial-gradient(ellipse 300px 200px at 20% 90%, rgba(90, 70, 40, 0.3), transparent 70%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 58px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 58px),
    radial-gradient(circle at 50% 100%, rgba(0, 0, 0, 0.5), transparent 60%),
    linear-gradient(180deg, #5c6f3a 0%, #48592d 45%, #364420 80%, #2a350f 100%);
  background-blend-mode: overlay, normal, normal, normal, normal, normal, normal, normal, normal, normal;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.15s ease;
}

.town.drop-hover-all {
  box-shadow: 0 0 0 3px rgba(255, 140, 90, 0.6), 0 0 40px rgba(255, 140, 90, 0.3) inset;
}

@media (max-width: 640px) {
  .town { height: 640px; }
  h1 { margin-top: 6.5rem; }
}

.buildings-layer {
  position: absolute;
  inset: 0;
}

.townsperson {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  transition: left linear, top linear, transform 0.3s ease;
}

.townsperson svg {
  display: block;
}

.building {
  position: absolute;
  transform: translate(-50%, -100%);
  width: 92px;
  text-align: center;
  cursor: default;
  user-select: none;
  z-index: 3;
  transition: transform 0.12s ease;
}

.building.drop-hover .building-plate {
  border-color: rgba(255, 140, 90, 0.8);
  background: #40291a;
  transform: scale(1.06);
}

.building.shaking .building-plate {
  animation: building-shake 0.25s ease;
}

@keyframes building-shake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3px, 2px); }
  50%  { transform: translate(3px, -2px); }
  75%  { transform: translate(-2px, 1px); }
  100% { transform: translate(0, 0); }
}

.building-emoji {
  font-size: 2.3rem;
  line-height: 1;
  display: block;
}

.building-plate {
  margin-top: 0.2rem;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.3rem 0.4rem 0.4rem;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.building.destroyed .building-plate {
  opacity: 0.55;
}

.building-name {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 0.3rem;
  white-space: nowrap;
}

.building-hp-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.building-hp-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7fd858, #4ea832);
  transition: width 0.15s ease;
}

.building-hp-bar.repairing {
  background: linear-gradient(90deg, #ffcf5c, #ff9a4c);
}

.building-reward {
  margin-top: 0.3rem;
  font-size: 0.65rem;
  opacity: 0.6;
}

.dmg-float {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, 0);
  font-weight: 800;
  font-size: 1.1rem;
  color: #ff8a6a;
  pointer-events: none;
  opacity: 0;
}

.dmg-float.floating {
  animation: dmg-float-up 0.6s ease-out forwards;
}

@keyframes dmg-float-up {
  0%   { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -34px); }
}

.shop-button {
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff9a6c, #d9503f);
  color: #2a120c;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #7a2c1f, 0 6px 12px rgba(0, 0, 0, 0.3);
}

.shop-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #7a2c1f, 0 4px 8px rgba(0, 0, 0, 0.3);
}

.arsenal-tray {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 0.6rem;
  padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
  overflow-x: auto;
  background: linear-gradient(180deg, rgba(18, 13, 10, 0), rgba(18, 13, 10, 0.92) 35%);
  justify-content: center;
}

.weapon-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 64px;
  padding: 0.5rem 0.4rem 0.4rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease, opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.weapon-chip:hover {
  transform: translateY(-3px);
}

.weapon-chip.armed {
  border-color: rgba(255, 140, 90, 0.9);
  background: rgba(255, 140, 90, 0.18);
  box-shadow: 0 0 0 2px rgba(255, 140, 90, 0.4);
}

.weapon-chip-emoji {
  font-size: 1.7rem;
  line-height: 1;
}

.weapon-chip-name {
  font-size: 0.62rem;
  font-weight: 600;
  opacity: 0.8;
  white-space: nowrap;
}

body.aiming,
body.aiming * {
  cursor: none !important;
}

.crosshair-cursor {
  position: fixed;
  top: 0;
  left: 0;
  font-size: 2rem;
  line-height: 1;
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -50%);
  opacity: 0;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}

.crosshair-cursor.visible {
  opacity: 1;
  animation: crosshair-pulse 0.9s ease-in-out infinite;
}

@keyframes crosshair-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.12); }
}

.explosion {
  position: fixed;
  top: 0;
  left: 0;
  font-size: 2.6rem;
  pointer-events: none;
  z-index: 15;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
}

.explosion.boom {
  animation: explosion-pop 0.55s ease-out forwards;
}

@keyframes explosion-pop {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  60%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

.shop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.shop-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.shop-panel {
  width: min(440px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  background: #1c140f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.shop-header h2 { margin: 0; font-size: 1.2rem; }

.shop-close {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
}

.shop-intro {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  opacity: 0.7;
  text-align: left;
}

.shop-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.shop-item-emoji {
  font-size: 1.8rem;
  width: 2.2rem;
  text-align: center;
}

.shop-item-info { flex: 1; text-align: left; }
.shop-item-name { font-weight: 600; }
.shop-item-cost { font-size: 0.8rem; opacity: 0.7; }
.shop-item-stats { font-size: 0.75rem; opacity: 0.55; }

.shop-item-action {
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  background: #ffb199;
  color: #3a1408;
  white-space: nowrap;
}

.shop-item-action:disabled {
  background: #6b6558;
  color: #b9b3a4;
  cursor: not-allowed;
}

.shop-item-action.owned {
  background: #7fd858;
  color: #1c2a17;
  cursor: default;
}


.weapon-chip{font:inherit;color:inherit}.weapon-chip:focus-visible{outline:3px solid #ffad79;outline-offset:3px}
