:root {
  --olive: #676C2F;
  --moss: #4F592B;
  --forest: #5D6E40;
  --deep-brown: #40321E;
  --dark-teal: #3A4B4B;
  --charcoal-teal: #2E3838;
  --wood: #714E2B;
  --rust: #744224;
  --dark-warm-brown: #603921;
  --beige: #D6C097;
  --parchment: #D4BE97;
  --tan: #BB9860;
  --ink: #26271d;
  --cream: #eadab9;
  --ui-shadow: rgba(28, 27, 18, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--charcoal-teal);
  color: var(--cream);
  font-family: "Trebuchet MS", "Arial Narrow", Arial, sans-serif;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 420px;
  background: var(--charcoal-teal);
}

.game-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(214, 192, 151, 0.08), transparent 26%),
    var(--forest);
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  will-change: transform;

  background-color: var(--forest);
  background-image: url("../assets/environment/ground/grass-base.png");
  background-repeat: repeat;
  background-size: 512px 512px;

  transform: translate3d(0, 0, 0);
}


.world-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-layer--decor { z-index: 1; }
.world-layer--stumps { z-index: 2; }
.world-layer--trees { z-index: 3; }

.hud {
  position: fixed;
  z-index: 1000;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hud__resource-group,
.hud__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}

.resource-chip,
.hud__actions {
  border: 3px solid #222b2a;
  border-radius: 10px;
  background: linear-gradient(180deg, #394641 0%, #293331 100%);
  box-shadow:
    0 3px 0 #1e2524,
    0 7px 18px var(--ui-shadow),
    inset 0 1px 0 rgba(214, 192, 151, 0.18);
}

.resource-chip {
  min-width: 142px;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px 8px 10px;
}

.resource-chip__copy {
  display: grid;
  gap: 1px;
}

.resource-chip__label {
  color: var(--tan);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  font-weight: 800;
}

.resource-chip strong {
  color: #f1dfbb;
  font-size: 1.45rem;
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.42);
}

.resource-chip__icon {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}

.resource-chip__icon--wood::before,
.resource-chip__icon--wood::after {
  content: "";
  position: absolute;
  width: 23px;
  height: 12px;
  border: 2px solid var(--deep-brown);
  border-radius: 8px 5px 5px 8px;
  background: linear-gradient(90deg, #8b6337 0 76%, #bb9860 77% 100%);
}

.resource-chip__icon--wood::before {
  top: 5px;
  left: 4px;
  transform: rotate(28deg);
}

.resource-chip__icon--wood::after {
  left: 2px;
  bottom: 4px;
  transform: rotate(-18deg);
}

.resource-chip__icon--tree::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 1px;
  width: 20px;
  height: 27px;
  background: var(--olive);
  clip-path: polygon(50% 0, 96% 45%, 75% 45%, 100% 82%, 62% 82%, 62% 100%, 38% 100%, 38% 82%, 0 82%, 25% 45%, 4% 45%);
  outline: 2px solid var(--deep-brown);
}

.hud__actions {
  min-height: 50px;
  padding: 6px;
}

.save-status {
  min-width: 52px;
  color: #c7b68f;
  font-size: 0.72rem;
  text-align: center;
  padding-inline: 4px;
}

.game-button {
  border: 2px solid #24302a;
  border-radius: 7px;
  padding: 8px 12px;
  min-height: 34px;
  color: #f0dfbd;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #66783e, #4f592b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 0 #1f2924;
  cursor: pointer;
}

.game-button:hover {
  filter: brightness(1.08);
}

.game-button:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 0 #1f2924;
}

.game-button--danger {
  background: linear-gradient(180deg, #81502e, #603921);
}

.play-hint {
  position: fixed;
  z-index: 800;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100vw - 28px));
  padding: 8px 12px;
  border: 2px solid rgba(34, 43, 42, 0.88);
  border-radius: 8px;
  color: #e8d7b4;
  background: rgba(46, 56, 56, 0.91);
  box-shadow: 0 4px 16px rgba(26, 28, 23, 0.25);
  font-size: 0.78rem;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.play-hint.is-faded {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.play-hint__keys {
  border: 1px solid #85734f;
  border-radius: 4px;
  padding: 3px 6px;
  background: var(--deep-brown);
  color: var(--beige);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-weight: 900;
}

.ground-detail {
  position: absolute;
  transform: translate(-50%, -50%);
  opacity: 0.64;
}

.ground-detail--grass {
  width: 12px;
  height: 8px;
  border-bottom: 3px solid #485727;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
}

.ground-detail--grass::before,
.ground-detail--grass::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 9px;
  background: #52622d;
  transform-origin: bottom;
}

.ground-detail--grass::before { left: 3px; transform: rotate(-22deg); }
.ground-detail--grass::after { right: 3px; transform: rotate(24deg); }

.ground-detail--stone {
  width: 11px;
  height: 8px;
  border: 2px solid rgba(46, 56, 56, 0.7);
  border-radius: 50% 50% 44% 46%;
  background: #7e7b63;
  box-shadow: inset -2px -2px 0 rgba(46, 56, 56, 0.18);
}

.ground-detail--flower {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #d2bc7d;
  box-shadow: 4px 0 0 #d2bc7d, 2px -3px 0 #d2bc7d, 2px 3px 0 #d2bc7d;
}

.ground-detail--patch {
  width: 34px;
  height: 19px;
  border-radius: 50%;
  background: rgba(79, 89, 43, 0.20);
  transform: translate(-50%, -50%) rotate(var(--rotation, 0deg));
}

.tree {
  --tree-scale: 1;
  position: absolute;
  width: 72px;
  height: 92px;
  transform: translate(-50%, -72%) scale(var(--tree-scale));
  transform-origin: 50% 100%;
  pointer-events: none;
  will-change: transform;
}

.tree__visual {
  position: absolute;
  inset: 0;
  transform-origin: 50% 92%;
}

.tree__shadow {
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 50px;
  height: 15px;
  border-radius: 50%;
  background: rgba(37, 46, 36, 0.25);
  transform: translateX(-50%);
}

.tree__trunk {
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 15px;
  height: 37px;
  transform: translateX(-50%);
  border: 3px solid var(--deep-brown);
  border-radius: 6px 6px 4px 4px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.05), transparent 30%),
    var(--wood);
  box-shadow: inset -4px 0 0 rgba(64, 50, 30, 0.18);
}

.tree__crown {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  filter: drop-shadow(0 3px 0 rgba(64, 50, 30, 0.52));
}

.tree--pine .tree__crown {
  top: 2px;
  width: 63px;
  height: 69px;
  background:
    linear-gradient(180deg, #6f7a36 0 16%, #58652e 17% 62%, #465329 63% 100%);
  clip-path: polygon(50% 0, 80% 35%, 67% 35%, 92% 67%, 70% 67%, 100% 100%, 0 100%, 30% 67%, 8% 67%, 33% 35%, 20% 35%);
}

.tree--oak .tree__crown {
  top: 5px;
  width: 66px;
  height: 59px;
  border: 3px solid #3c4928;
  border-radius: 50% 45% 48% 44%;
  background:
    radial-gradient(circle at 34% 28%, #7a7f3c 0 22%, transparent 23%),
    radial-gradient(circle at 67% 35%, #687238 0 28%, transparent 29%),
    radial-gradient(circle at 45% 67%, #59652f 0 40%, transparent 41%),
    #58642e;
}

.tree--birch .tree__trunk {
  width: 12px;
  border-color: #4b4532;
  background:
    linear-gradient(180deg, transparent 0 20%, #5f5941 21% 26%, transparent 27% 52%, #5f5941 53% 59%, transparent 60% 100%),
    #c8b98f;
}

.tree--birch .tree__crown {
  top: 7px;
  width: 58px;
  height: 56px;
  border: 3px solid #40502a;
  border-radius: 54% 46% 50% 48%;
  background:
    radial-gradient(circle at 30% 24%, #768443 0 23%, transparent 24%),
    radial-gradient(circle at 68% 33%, #687a3d 0 28%, transparent 29%),
    radial-gradient(circle at 45% 67%, #5c6c36 0 42%, transparent 43%),
    #63743a;
}

.tree.is-targeted .tree__visual {
  filter: drop-shadow(0 0 7px rgba(214, 192, 151, 0.76));
}

.tree.is-hit .tree__visual {
  animation: tree-hit 155ms ease;
}

.tree.is-falling .tree__visual {
  animation: none;
  opacity: 0;
}

.tree__health {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: -10px;
  width: 50px;
  height: 8px;
  padding: 1px;
  transform: translateX(-50%);
  border: 2px solid #26302b;
  border-radius: 4px;
  background: #382f22;
  opacity: 0;
  transition: opacity 120ms ease;
}

.tree.is-targeted .tree__health {
  opacity: 1;
}

.tree__health-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 1px;
  background: var(--tan);
  transform-origin: left center;
}

@keyframes tree-hit {
  0% { transform: rotate(0deg); }
  30% { transform: rotate(-3deg) translateX(-2px); }
  68% { transform: rotate(3deg) translateX(2px); }
  100% { transform: rotate(0deg); }
}

@keyframes tree-fall {
  0% { transform: rotate(0deg) scale(1); opacity: 1; }
  100% { transform: rotate(0deg) scale(1); opacity: 0; }
}

.stump {
  position: absolute;
  width: 76px;
  height: 36px;
  transform: translate(-50%, -50%);
  border: none;
  background: none;
  box-shadow: none;
  pointer-events: none;
}

.stump__sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 76px;
  height: auto;
  object-fit: contain;
  transform: translateX(-50%);
  user-select: none;
  pointer-events: none;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 2px rgba(46, 56, 56, 0.28));
}

.stump::after {
  content: none;
}

.player {
  position: absolute;
  z-index: 5000;
  width: 46px;
  height: 56px;
  transform: translate(-50%, -78%);
  transform-origin: 50% 100%;
  pointer-events: none;
  will-change: left, top;
}

.player__shadow {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 34px;
  height: 10px;
  border-radius: 50%;
  background: rgba(31, 40, 31, 0.31);
  transform: translateX(-50%);
}

.player--assistant-collector {
  filter: saturate(0.9) brightness(0.94);
}

.player--assistant-collector .player__body {
  background:
    linear-gradient(90deg, transparent 0 42%, rgba(64, 50, 30, 0.4) 43% 50%, transparent 51% 100%),
    linear-gradient(180deg, #5e6c8d 0 45%, #3f4a65 46% 100%);
}

.player--assistant-collector .player__hat {
  background: #4d5e74;
}

.player--assistant-collector .player__hat::after {
  background: #3f4d61;
}

.player__carry-badge {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  min-width: 42px;
  padding: 2px 6px;
  border: 2px solid #25302d;
  border-radius: 8px;
  background: rgba(46, 56, 56, 0.96);
  color: var(--beige);
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 4px 0 rgba(31, 40, 31, 0.22), 0 0 0 1px rgba(214, 192, 151, 0.08);
  pointer-events: none;
}

.player__assistant-mark {
  position: absolute;
  z-index: 13;
  left: 50%;
  top: -38px;
  transform: translateX(-50%);
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 2px solid #25302d;
  border-radius: 999px;
  background: linear-gradient(180deg, #d7c89d 0%, #b69963 100%);
  color: #24302a;
  font-size: 0.58rem;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(31, 40, 31, 0.22);
  pointer-events: none;
}

.player__visual {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
}

.player.is-walking .player__visual {
  animation: player-bob 260ms ease-in-out infinite alternate;
}

.player__legs {
  position: absolute;
  left: 15px;
  bottom: 7px;
  width: 18px;
  height: 12px;
  border-left: 7px solid #313a34;
  border-right: 7px solid #313a34;
}

.player__body {
  position: absolute;
  left: 12px;
  bottom: 16px;
  width: 23px;
  height: 25px;
  border: 3px solid var(--deep-brown);
  border-radius: 7px 7px 5px 5px;
  background:
    linear-gradient(90deg, transparent 0 38%, rgba(64, 50, 30, 0.56) 39% 47%, transparent 48% 100%),
    linear-gradient(180deg, #9a5430 0 45%, #744224 46% 100%);
}

.player__head {
  position: absolute;
  left: 14px;
  top: 4px;
  width: 20px;
  height: 21px;
  border: 3px solid var(--deep-brown);
  border-radius: 48% 48% 44% 44%;
  background: #c99661;
}

.player__beard {
  position: absolute;
  left: 14px;
  top: 16px;
  width: 21px;
  height: 13px;
  border: 3px solid var(--deep-brown);
  border-top: 0;
  border-radius: 4px 4px 10px 10px;
  background: #653b24;
}

.player__hat {
  position: absolute;
  left: 11px;
  top: 1px;
  width: 28px;
  height: 11px;
  border: 3px solid var(--deep-brown);
  border-radius: 9px 9px 4px 4px;
  background: #88452b;
  transform: rotate(-4deg);
}

.player__hat::after {
  content: "";
  position: absolute;
  left: -5px;
  bottom: -5px;
  width: 31px;
  height: 5px;
  border: 2px solid var(--deep-brown);
  border-radius: 4px;
  background: #744224;
}

.player__arm {
  position: absolute;
  right: 5px;
  top: 25px;
  width: 16px;
  height: 7px;
  border: 2px solid var(--deep-brown);
  border-radius: 6px;
  background: #c99661;
  transform: rotate(-28deg);
  transform-origin: left center;
}

.player__axe {
  position: absolute;
  right: -6px;
  top: 18px;
  width: 24px;
  height: 29px;
  transform-origin: 7px 25px;
  transform: rotate(18deg);
}

.player__axe::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 7px;
  width: 4px;
  height: 25px;
  border: 1px solid var(--deep-brown);
  border-radius: 3px;
  background: #9b6b3b;
}

.player__axe span {
  position: absolute;
  left: 4px;
  top: 2px;
  width: 18px;
  height: 11px;
  border: 2px solid #28312f;
  border-radius: 6px 3px 5px 3px;
  background: #7c8172;
  transform: rotate(-8deg);
}

.player.is-chopping .player__axe {
  animation: axe-swing 430ms ease-in-out infinite;
}

@keyframes player-bob {
  from { transform: translateY(0); }
  to { transform: translateY(-2px); }
}

@keyframes axe-swing {
  0%, 100% { transform: rotate(24deg); }
  45% { transform: rotate(-54deg); }
  60% { transform: rotate(-48deg); }
}

.touch-controls {
  position: fixed;
  z-index: 900;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: none;
  grid-template-columns: 48px 48px 48px;
  grid-template-rows: 48px 48px 48px;
  gap: 4px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.touch-control,
.touch-controls__center {
  border: 2px solid #202a27;
  border-radius: 9px;
  background: rgba(46, 56, 56, 0.90);
  box-shadow: inset 0 1px 0 rgba(214, 192, 151, 0.16), 0 3px 0 rgba(30, 37, 36, 0.82);
}

.touch-control {
  color: var(--beige);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: none;
}

.touch-control.is-pressed {
  transform: translateY(2px);
  background: #526232;
  box-shadow: inset 0 1px 0 rgba(214, 192, 151, 0.12), 0 1px 0 rgba(30, 37, 36, 0.82);
}

.touch-control--up { grid-column: 2; grid-row: 1; }
.touch-control--left { grid-column: 1; grid-row: 2; }
.touch-controls__center { grid-column: 2; grid-row: 2; opacity: 0.62; }
.touch-control--right { grid-column: 3; grid-row: 2; }
.touch-control--down { grid-column: 2; grid-row: 3; }

.loading-screen {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(93, 110, 64, 0.92), rgba(46, 56, 56, 0.98));
  transition: opacity 220ms ease, visibility 220ms ease;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(320px, 92vw);
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px;
  border: 4px solid #24302d;
  border-radius: 14px;
  background: #34413c;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(214, 192, 151, 0.14);
  text-align: center;
}

.loading-card strong {
  color: #ead9b6;
  font-size: 1.2rem;
}

.loading-card span {
  color: #bcae8d;
  font-size: 0.8rem;
}

.loading-card__tree {
  width: 54px;
  height: 61px;
  background: var(--olive);
  clip-path: polygon(50% 0, 78% 36%, 65% 36%, 90% 69%, 70% 69%, 100% 100%, 0 100%, 30% 69%, 10% 69%, 35% 36%, 22% 36%);
  filter: drop-shadow(0 4px 0 rgba(64, 50, 30, 0.65));
  animation: loading-tree 900ms ease-in-out infinite alternate;
}

@keyframes loading-tree {
  from { transform: translateY(2px) scale(0.96); }
  to { transform: translateY(-2px) scale(1.02); }
}

@media (max-width: 720px) {
  .hud {
    align-items: stretch;
    gap: 7px;
  }

  .hud__resource-group {
    gap: 5px;
  }

  .resource-chip {
    min-width: 0;
    min-height: 54px;
    padding: 6px 8px;
    gap: 6px;
  }

  .resource-chip__icon {
    width: 27px;
    height: 27px;
    transform: scale(0.85);
  }

  .resource-chip strong {
    font-size: 1.08rem;
  }

  .resource-chip__label {
    font-size: 0.56rem;
  }

  .hud__actions {
    min-height: 54px;
    gap: 4px;
    padding: 5px;
  }

  .save-status {
    display: none;
  }

  .game-button {
    min-height: 31px;
    padding: 7px 8px;
    font-size: 0.65rem;
  }

  .play-hint {
    left: auto;
    right: 14px;
    bottom: max(22px, env(safe-area-inset-bottom));
    transform: none;
    max-width: 190px;
    font-size: 0.7rem;
  }

  .play-hint.is-faded {
    transform: translateY(8px);
  }

  .play-hint__keys {
    display: none;
  }

  .touch-controls {
    display: grid;
  }
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls {
    display: grid;
  }
}

@media (max-width: 440px) {
  .hud {
    left: 7px;
    right: 7px;
    top: max(7px, env(safe-area-inset-top));
  }

  .resource-chip {
    padding-inline: 6px;
  }

  .resource-chip__icon {
    display: none;
  }

  .hud__actions {
    border-width: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* Deeper-forest placeholder species. Kept intentionally simple so final art can replace it. */
.tree--spruce .tree__trunk {
  width: 17px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04), transparent 28%),
    #603921;
}

.tree--spruce .tree__crown {
  top: 0;
  width: 68px;
  height: 73px;
  background:
    linear-gradient(180deg, #5f713e 0 15%, #4f6035 16% 58%, #3f4f31 59% 100%);
  clip-path: polygon(50% 0, 78% 30%, 66% 30%, 91% 59%, 72% 59%, 100% 94%, 63% 88%, 63% 100%, 37% 100%, 37% 88%, 0 94%, 28% 59%, 9% 59%, 34% 30%, 22% 30%);
}

/* Tier differences are deliberately subtle. Size does most of the work; these tonal shifts
   help deeper forest feel older without drawing visible progression rings. */
.tree--tier-established .tree__crown {
  filter: drop-shadow(0 3px 0 rgba(64, 50, 30, 0.52)) brightness(0.98);
}

.tree--tier-dense .tree__crown {
  filter: drop-shadow(0 3px 0 rgba(64, 50, 30, 0.56)) brightness(0.94) saturate(0.94);
}

.tree--tier-oldGrowth .tree__crown {
  filter: drop-shadow(0 3px 0 rgba(64, 50, 30, 0.60)) brightness(0.90) saturate(0.90);
}

/* ================================================================
   V0.4 finite forest + two-character gameplay
   ================================================================ */

/* If you place your grass tile at this path, it is automatically used.
   The existing CSS texture stays underneath as a fallback. */
.world {
  background-image:
    url("../assets/environment/ground/grass-base.png"),
    radial-gradient(circle at 18px 24px, rgba(214, 192, 151, 0.07) 0 2px, transparent 3px),
    radial-gradient(circle at 58px 62px, rgba(46, 56, 56, 0.10) 0 3px, transparent 4px),
    radial-gradient(circle at 92px 18px, rgba(103, 108, 47, 0.23) 0 12px, transparent 13px),
    radial-gradient(circle at 22px 88px, rgba(79, 89, 43, 0.22) 0 16px, transparent 17px);
  background-repeat: repeat, repeat, repeat, repeat, repeat;
  background-size: 512px 512px, 112px 104px, 132px 124px, 144px 136px, 170px 164px;
}

.world-layer--decor { z-index: 1; }
.world-layer--stumps { z-index: 2; }
.world-layer--logs { z-index: 3; }
.world-layer--trees { z-index: 4; }

/* The user's first real pine asset. Other species deliberately remain CSS
   placeholders until matching sprites are created. */
.tree.tree--sprite {
  width: 112px;
  height: 124px;
  transform: translate(-50%, -88%) scale(var(--tree-scale));
}

.tree--sprite .tree__visual {
  inset: 0;
  transform-origin: 50% 100%;
}

.tree--sprite .tree__shadow {
  width: 64px;
  height: 17px;
  bottom: 0;
}

.tree__sprite {
  position: absolute;

  left: 50%;
  bottom: 0;

  width: 75px;
  height: auto;

  object-fit: contain;

  transform: translateX(-50%);

  user-select: none;
  pointer-events: none;

  image-rendering: pixelated;

  filter: drop-shadow(
    0 4px 2px rgba(46, 56, 56, 0.28)
  );
}

.tree--sprite .tree__health {
  top: -7px;
}

.log-pile {
  position: absolute;
  width: 44px;
  height: 31px;
  transform: translate(-50%, -58%);
  pointer-events: none;
  filter: drop-shadow(0 3px 1px rgba(46, 56, 56, 0.24));
}

.log-pile__logs,
.log-pile__logs::before,
.log-pile__logs::after {
  position: absolute;
  width: 30px;
  height: 12px;
  border: 2px solid var(--deep-brown);
  border-radius: 8px 5px 5px 8px;
  background: linear-gradient(90deg, #84562f 0 74%, #c49d63 75% 100%);
}

.log-pile__logs {
  left: 7px;
  top: 11px;
  transform: rotate(-3deg);
}

.log-pile__logs::before,
.log-pile__logs::after {
  content: "";
}

.log-pile__logs::before {
  left: -5px;
  top: -9px;
  transform: rotate(18deg);
}

.log-pile__logs::after {
  left: 5px;
  top: -14px;
  transform: rotate(-14deg);
}

.log-pile__amount {
  position: absolute;
  z-index: 4;
  right: -5px;
  top: -8px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid #222b2a;
  border-radius: 10px;
  background: #33413c;
  color: var(--beige);
  font-size: 0.62rem;
  font-weight: 900;
}

.depot {
  position: absolute;
  width: 146px;
  height: 104px;
  transform: translate(-50%, -50%);
  transform-origin: 50% 70%;
  pointer-events: none;
  transition: filter 150ms ease, transform 150ms ease;
}

.depot__platform {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 132px;
  height: 66px;
  transform: translateX(-50%);
  border: 4px solid #45351f;
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, transparent 0 20px, rgba(64, 50, 30, 0.2) 21px 23px),
    #9b7243;
  box-shadow: 0 7px 0 rgba(46, 56, 56, 0.18), inset 0 3px 0 rgba(214, 192, 151, 0.25);
}

.depot__logs,
.depot__logs::before,
.depot__logs::after {
  position: absolute;
  width: 50px;
  height: 17px;
  border: 3px solid var(--deep-brown);
  border-radius: 9px 6px 6px 9px;
  background: linear-gradient(90deg, #7b4d2c 0 76%, #c79e65 77% 100%);
}

.depot__logs {
  z-index: 2;
  left: 48px;
  top: 26px;
  transform: rotate(-2deg);
}

.depot__logs::before,
.depot__logs::after { content: ""; }
.depot__logs::before { left: -14px; top: 16px; transform: rotate(7deg); }
.depot__logs::after { left: 15px; top: 19px; transform: rotate(-8deg); }

.depot__label {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: -13px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 3px 7px;
  border: 2px solid #25302d;
  border-radius: 5px;
  background: rgba(46, 56, 56, 0.95);
  color: var(--beige);
  font-size: 0.57rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.depot.is-in-range {
  filter: drop-shadow(0 0 8px rgba(214, 192, 151, 0.72));
}

.depot.is-depositing {
  animation: depot-pop 320ms ease;
}

@keyframes depot-pop {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.07); }
}

.player__active-ring {
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 45px;
  height: 17px;
  transform: translateX(-50%);
  border: 2px solid rgba(214, 192, 151, 0.9);
  border-radius: 50%;
  opacity: 0;
  box-shadow: 0 0 8px rgba(214, 192, 151, 0.38);
}

.player.is-active-character .player__active-ring {
  opacity: 1;
}

.player.is-inactive-character {
  filter: saturate(0.84) brightness(0.93);
}

.player--collector .player__body {
  background:
    linear-gradient(90deg, transparent 0 42%, rgba(64, 50, 30, 0.4) 43% 50%, transparent 51% 100%),
    linear-gradient(180deg, #647645 0 45%, #4f592b 46% 100%);
}

.player--collector .player__hat {
  background: #665238;
}

.player--collector .player__hat::after {
  background: #55452f;
}

.collector__pack {
  position: absolute;
  left: 4px;
  top: 25px;
  width: 16px;
  height: 22px;
  border: 3px solid var(--deep-brown);
  border-radius: 4px;
  background: #9a7042;
  transform: rotate(4deg);
  box-shadow: inset -3px 0 0 rgba(64, 50, 30, 0.17);
}

.collector__pack::before,
.collector__pack::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 3px;
  height: 15px;
  background: var(--deep-brown);
  opacity: 0.65;
}
.collector__pack::before { left: 3px; }
.collector__pack::after { right: 3px; }

.collector__arm {
  position: absolute;
  right: 6px;
  top: 27px;
  width: 14px;
  height: 7px;
  border: 2px solid var(--deep-brown);
  border-radius: 6px;
  background: #c99661;
  transform: rotate(24deg);
}

.player.is-collecting .player__visual {
  animation: collector-pickup 160ms ease;
}

@keyframes collector-pickup {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px) scaleY(0.95); }
}

.goal-progress {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(330px, 30vw);
  min-width: 220px;
  transform: translateX(-50%);
  padding: 9px 12px 10px;
  border: 3px solid #222b2a;
  border-radius: 10px;
  background: linear-gradient(180deg, #394641 0%, #293331 100%);
  box-shadow: 0 3px 0 #1e2524, 0 7px 18px var(--ui-shadow), inset 0 1px 0 rgba(214, 192, 151, 0.18);
  pointer-events: auto;
}

.goal-progress__heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--tan);
  font-size: 0.63rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.goal-progress__heading strong {
  color: #f1dfbb;
  letter-spacing: 0;
}

.goal-progress__track {
  height: 9px;
  margin-top: 7px;
  padding: 2px;
  border: 1px solid #1c2522;
  border-radius: 5px;
  overflow: hidden;
  background: #1f2926;
}

.goal-progress__fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #676c2f, #9a9552);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 160ms ease;
}

.character-switcher {
  position: fixed;
  z-index: 920;
  left: 50%;
  bottom: max(58px, calc(env(safe-area-inset-bottom) + 58px));
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  padding: 6px;
  border: 3px solid #222b2a;
  border-radius: 11px;
  background: rgba(42, 51, 48, 0.94);
  box-shadow: 0 4px 0 rgba(30, 37, 36, 0.88), 0 8px 20px rgba(28, 27, 18, 0.28);
}

.character-switch {
  position: relative;
  min-width: 152px;
  min-height: 52px;
  display: grid;
  grid-template-columns: 28px 30px 1fr;
  align-items: center;
  gap: 6px;
  padding: 6px 9px 6px 6px;
  border: 2px solid #26302b;
  border-radius: 7px;
  background: #34413c;
  color: var(--beige);
  text-align: left;
  cursor: pointer;
}

.character-switch:hover { filter: brightness(1.06); }

.character-switch.is-active {
  border-color: #8d8d55;
  background: linear-gradient(180deg, #58683c, #445332);
  box-shadow: inset 0 0 0 1px rgba(214, 192, 151, 0.18);
}

.character-switch__key {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 2px solid #222b2a;
  border-radius: 5px;
  background: var(--deep-brown);
  color: var(--beige);
  font-size: 0.72rem;
  font-weight: 900;
}

.character-switch__icon {
  font-size: 1.2rem;
  line-height: 1;
  filter: saturate(0.72);
}

.character-switch__copy {
  display: grid;
  min-width: 0;
}

.character-switch__copy strong {
  font-size: 0.76rem;
}

.character-switch__copy small {
  color: #c1b18d;
  font-size: 0.61rem;
  white-space: nowrap;
}

.play-hint {
  bottom: max(12px, env(safe-area-inset-bottom));
}

.forest-cleared-banner {
  position: fixed;
  z-index: 1800;
  left: 50%;
  top: 50%;
  width: min(430px, calc(100vw - 32px));
  transform: translate(-50%, -50%) scale(0.94);
  display: grid;
  gap: 8px;
  padding: 24px 28px;
  border: 4px solid #2a3028;
  border-radius: 14px;
  background: linear-gradient(180deg, #d6c097, #bb9860);
  color: var(--deep-brown);
  box-shadow: 0 12px 34px rgba(0,0,0,0.34), inset 0 2px 0 rgba(255,255,255,0.23);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}

.forest-cleared-banner.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.forest-cleared-banner strong {
  font-size: 1.55rem;
  letter-spacing: 0.06em;
}

.forest-cleared-banner span {
  font-size: 0.82rem;
  font-weight: 700;
}

@media (max-width: 900px) {
  .goal-progress {
    top: 70px;
    width: 280px;
  }
}

@media (max-width: 720px) {
  .goal-progress {
    top: 62px;
    width: min(310px, calc(100vw - 28px));
    min-width: 0;
  }

  .character-switcher {
    left: auto;
    right: 12px;
    bottom: max(118px, calc(env(safe-area-inset-bottom) + 118px));
    transform: none;
    flex-direction: column;
    padding: 4px;
  }

  .character-switch {
    min-width: 134px;
    min-height: 44px;
    grid-template-columns: 24px 24px 1fr;
    padding: 4px 7px 4px 4px;
  }

  .character-switch__key {
    width: 22px;
    height: 22px;
  }

  .character-switch__icon { font-size: 1rem; }
  .character-switch__copy strong { font-size: 0.68rem; }
  .character-switch__copy small { font-size: 0.56rem; }

  .play-hint {
    display: none;
  }
}

@media (max-width: 520px) {
  .resource-chip__copy .resource-chip__label {
    max-width: 80px;
    line-height: 1.05;
  }

  .goal-progress {
    top: 65px;
  }
}

/* --------------------------------------------------------------------------
   Upgrade tree
   -------------------------------------------------------------------------- */

.game-button--upgrades {
  background: linear-gradient(180deg, #778342, #59652f);
}

.game-button--upgrades.is-active {
  border-color: #a78c59;
  background: linear-gradient(180deg, #8a7443, #684e2b);
}

.game-button__key {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  padding: 0 4px;
  border: 1px solid rgba(34, 43, 42, 0.75);
  border-radius: 4px;
  background: rgba(46, 56, 56, 0.7);
  color: var(--beige);
  font-size: 0.62rem;
  line-height: 1;
}

.upgrades-panel {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: grid;
  place-items: center;
  padding: 78px 18px 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.upgrades-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.upgrades-panel__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(25, 31, 29, 0.68);
  backdrop-filter: blur(2px);
  cursor: default;
}

.upgrade-dialog {
  position: relative;
  width: min(920px, calc(100vw - 36px));
  max-height: calc(100vh - 104px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 4px solid #202927;
  border-radius: 15px;
  background:
    linear-gradient(rgba(214, 192, 151, 0.06), rgba(214, 192, 151, 0.02)),
    #303b37;
  box-shadow:
    0 7px 0 #1e2524,
    0 22px 58px rgba(20, 23, 20, 0.48),
    inset 0 1px 0 rgba(214, 192, 151, 0.13);
  color: var(--cream);
}

.upgrade-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px 15px;
  border-bottom: 2px solid #202927;
  background: linear-gradient(180deg, #3c4943, #323d39);
}

.upgrade-dialog__eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--tan);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.upgrade-dialog h2 {
  margin: 0;
  color: #f0dfbd;
  font-size: 1.5rem;
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.upgrade-dialog__header p {
  margin: 5px 0 0;
  color: #c9b995;
  font-size: 0.78rem;
}

.upgrade-dialog__header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.upgrade-dialog__wood {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px 6px 8px;
  border: 2px solid #202927;
  border-radius: 8px;
  background: #29332f;
  box-shadow: inset 0 1px 0 rgba(214, 192, 151, 0.08);
}

.upgrade-dialog__wood strong {
  color: #f0dfbd;
  font-size: 1rem;
}

.upgrade-dialog__wood-icon,
.upgrade-node__cost-icon {
  position: relative;
  width: 24px;
  height: 20px;
  flex: 0 0 auto;
}

.upgrade-dialog__wood-icon::before,
.upgrade-dialog__wood-icon::after,
.upgrade-node__cost-icon::before,
.upgrade-node__cost-icon::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 8px;
  border: 1px solid var(--deep-brown);
  border-radius: 6px 4px 4px 6px;
  background: linear-gradient(90deg, #855a31 0 74%, #bb9860 75% 100%);
}

.upgrade-dialog__wood-icon::before,
.upgrade-node__cost-icon::before {
  left: 3px;
  top: 1px;
  transform: rotate(23deg);
}

.upgrade-dialog__wood-icon::after,
.upgrade-node__cost-icon::after {
  left: 2px;
  bottom: 1px;
  transform: rotate(-15deg);
}

.upgrade-dialog__close {
  width: 42px;
  height: 42px;
  border: 2px solid #202927;
  border-radius: 8px;
  background: #2a3430;
  color: var(--beige);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.upgrade-dialog__close:hover,
.upgrade-dialog__close:focus-visible {
  background: #46533c;
  outline: 2px solid #a58e59;
  outline-offset: 2px;
}

.upgrade-tree-root {
  position: relative;
  align-self: center;
  min-width: 188px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 15px auto 8px;
  padding: 9px 13px;
  border: 3px solid #282f28;
  border-radius: 9px;
  background: linear-gradient(180deg, #ccb783, #aa8e58);
  color: #3e321f;
  box-shadow: 0 3px 0 #242c28, inset 0 1px 0 rgba(255,255,255,0.28);
}

.upgrade-tree-root::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 14px;
  transform: translateX(-50%);
  background: #8b7649;
}

.upgrade-tree-root__icon {
  width: 28px;
  height: 24px;
  border: 2px solid #4e3d24;
  border-radius: 4px 4px 7px 7px;
  background: repeating-linear-gradient(0deg, #714e2b 0 5px, #8a6235 5px 8px);
}

.upgrade-tree-root span:last-child {
  display: grid;
  line-height: 1.05;
}

.upgrade-tree-root strong {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

.upgrade-tree-root small {
  margin-top: 3px;
  font-size: 0.58rem;
  font-weight: 700;
  opacity: 0.82;
}

.upgrade-tree {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  overflow-y: auto;
  padding: 8px 18px 18px;
  scrollbar-color: #6e6841 #29332f;
  scrollbar-width: thin;
}

.upgrade-tree::before {
  content: "";
  position: absolute;
  left: 25%;
  right: 25%;
  top: 0;
  height: 2px;
  background: #8b7649;
}

.upgrade-branch {
  min-width: 0;
  padding-top: 10px;
}

.upgrade-branch__header {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 2px solid #202927;
  border-radius: 8px;
  background: #29332f;
}

.upgrade-branch__badge {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid #1f2825;
  border-radius: 6px;
  background: var(--deep-brown);
  color: var(--beige);
  font-size: 0.72rem;
  font-weight: 900;
}

.upgrade-branch__header span:last-child {
  min-width: 0;
  display: grid;
}

.upgrade-branch__header strong {
  color: #eadab9;
  font-size: 0.8rem;
}

.upgrade-branch__header small {
  color: #aa9d7e;
  font-size: 0.62rem;
}

.upgrade-branch__path {
  position: relative;
  display: grid;
  justify-items: center;
  padding-top: 11px;
}

.upgrade-connector {
  width: 3px;
  height: 13px;
  background: #675d3c;
  box-shadow: 1px 0 0 rgba(0,0,0,0.22);
}

.upgrade-node {
  width: min(100%, 355px);
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 3px solid #202927;
  border-radius: 10px;
  background: linear-gradient(180deg, #3b4741, #313b37);
  box-shadow: 0 3px 0 #202725, inset 0 1px 0 rgba(214, 192, 151, 0.09);
  transition: border-color 120ms ease, filter 120ms ease, transform 120ms ease;
}

.upgrade-node.has-level {
  border-color: #58633c;
}

.upgrade-node.is-affordable {
  border-color: #7e8749;
}

.upgrade-node.is-locked {
  filter: saturate(0.38) brightness(0.72);
}

.upgrade-node.is-maxed {
  border-color: #947e4c;
  background: linear-gradient(180deg, #514b36, #3d3c31);
}

.upgrade-node.is-purchased {
  animation: upgradePurchased 260ms ease;
}

.upgrade-node__topline {
  display: flex;
  align-items: center;
  gap: 9px;
}

.upgrade-node__icon {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 2px solid #202927;
  border-radius: 8px;
  background: #252f2c;
  box-shadow: inset 0 1px 0 rgba(214, 192, 151, 0.08);
}

.upgrade-node__icon::before,
.upgrade-node__icon::after {
  content: "";
  position: absolute;
}

.upgrade-node__icon--axe::before {
  width: 5px;
  height: 25px;
  left: 17px;
  top: 7px;
  border-radius: 3px;
  background: #9b6b36;
  transform: rotate(36deg);
}

.upgrade-node__icon--axe::after {
  width: 18px;
  height: 10px;
  left: 10px;
  top: 7px;
  border-radius: 7px 2px 4px 7px;
  background: #c6b899;
  transform: rotate(-12deg);
}

.upgrade-node__icon--swing::before {
  left: 8px;
  top: 8px;
  width: 20px;
  height: 20px;
  border: 4px solid #c1b18d;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-32deg);
}

.upgrade-node__icon--swing::after {
  right: 5px;
  top: 4px;
  border-left: 7px solid #c1b18d;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transform: rotate(-18deg);
}

.upgrade-node__icon--boots::before,
.upgrade-node__icon--boots::after {
  width: 10px;
  height: 20px;
  bottom: 7px;
  border-radius: 5px 3px 3px 6px;
  background: #8d6032;
}

.upgrade-node__icon--boots::before { left: 8px; transform: rotate(9deg); }
.upgrade-node__icon--boots::after { right: 8px; transform: rotate(-9deg); }

.upgrade-node__icon--pack::before {
  left: 8px;
  top: 9px;
  width: 20px;
  height: 22px;
  border: 2px solid #3f301d;
  border-radius: 6px;
  background: #8b6337;
}

.upgrade-node__icon--pack::after {
  left: 12px;
  top: 4px;
  width: 12px;
  height: 10px;
  border: 3px solid #8b6337;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
}

.upgrade-node__icon--reach::before {
  left: 7px;
  top: 17px;
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: #c1b18d;
}

.upgrade-node__icon--reach::after {
  right: 5px;
  top: 12px;
  border-left: 8px solid #c1b18d;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.upgrade-node__title {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.upgrade-node__title strong {
  color: #f0dfbd;
  font-size: 0.85rem;
}

.upgrade-node__level {
  color: #b9aa87;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.upgrade-node__description {
  min-height: 30px;
  margin: 0;
  color: #bdae8e;
  font-size: 0.66rem;
  line-height: 1.35;
}

.upgrade-node__effect {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 29px;
  padding: 5px 7px;
  border-radius: 5px;
  background: rgba(31, 41, 38, 0.7);
  font-size: 0.64rem;
}

.upgrade-node__effect-label {
  color: #a99b7c;
}

.upgrade-node__effect-value {
  color: #e3cfaa;
  text-align: right;
}

.upgrade-node__requirement {
  color: #d1a276;
  font-size: 0.61rem;
  font-weight: 800;
  text-align: center;
}

.upgrade-node__buy {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid #293126;
  border-radius: 7px;
  background: linear-gradient(180deg, #65733d, #4f592b);
  color: #f0dfbd;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 0 #202725, inset 0 1px 0 rgba(255,255,255,0.1);
}

.upgrade-node.is-affordable .upgrade-node__buy:hover:not(:disabled) {
  filter: brightness(1.12);
}

.upgrade-node__buy:disabled {
  cursor: not-allowed;
  background: #303834;
  color: #7f806f;
  box-shadow: none;
}

.upgrade-node.is-maxed .upgrade-node__buy:disabled {
  background: #665a38;
  color: #e1ce9e;
}

.upgrade-node__cost {
  font-size: 0.74rem;
}

.upgrade-node__buy:disabled .upgrade-node__cost-icon {
  opacity: 0.32;
}

.upgrade-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 14px;
  border-top: 2px solid #202927;
  background: #29332f;
  color: #9f9478;
  font-size: 0.61rem;
}

.upgrade-dialog__footer kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  min-height: 20px;
  margin: 0 2px;
  padding: 1px 5px;
  border: 1px solid #746544;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #40321e;
  color: #d6c097;
  font: inherit;
  font-weight: 900;
}

@keyframes upgradePurchased {
  0% { transform: scale(1); }
  45% { transform: scale(1.018); filter: brightness(1.24); }
  100% { transform: scale(1); }
}

@media (max-width: 900px) {
  .upgrades-panel {
    padding-top: 124px;
  }

  .upgrade-dialog {
    max-height: calc(100vh - 146px);
  }

  .hud__actions .save-status {
    display: none;
  }
}

@media (max-width: 720px) {
  .hud__actions {
    gap: 4px;
  }

  .hud__actions .game-button {
    padding-inline: 8px;
    font-size: 0.69rem;
  }

  .game-button__key {
    display: none;
  }

  .upgrades-panel {
    padding: 118px 10px 10px;
  }

  .upgrade-dialog {
    width: 100%;
    max-height: calc(100vh - 128px);
  }

  .upgrade-dialog__header {
    padding: 13px;
  }

  .upgrade-dialog__header p {
    display: none;
  }

  .upgrade-dialog__wood {
    min-height: 40px;
  }

  .upgrade-tree-root {
    margin-top: 11px;
  }

  .upgrade-tree {
    grid-template-columns: 1fr;
    gap: 12px;
    padding-inline: 10px;
  }

  .upgrade-tree::before,
  .upgrade-tree-root::after {
    display: none;
  }

  .upgrade-branch {
    padding-top: 0;
  }

  .upgrade-node {
    width: 100%;
  }

  .upgrade-dialog__footer span:first-child {
    display: none;
  }

  .upgrade-dialog__footer {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .upgrades-panel,
  .upgrade-node {
    transition: none;
  }

  .upgrade-node.is-purchased {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   DEV MODE / BALANCE LAB
   Only exposed when the page is opened with ?dev=1.
   -------------------------------------------------------------------------- */

.dev-mode-button {
  position: fixed;
  z-index: 1180;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  min-width: 58px;
  height: 42px;
  border: 3px solid #1d2725;
  border-radius: 8px;
  background: linear-gradient(180deg, #8a5d30, #603921);
  color: #f0dfbd;
  box-shadow: 0 3px 0 #1d2422, 0 8px 20px rgba(20, 25, 22, 0.3);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.dev-mode-button:hover,
.dev-mode-button.is-active {
  filter: brightness(1.12);
}

.dev-panel,
.dev-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  padding: 22px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 130ms ease, visibility 130ms ease;
}

.dev-panel.is-open,
.dev-confirm-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.dev-confirm-overlay {
  z-index: 2200;
}

.dev-panel__backdrop,
.dev-confirm-overlay__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(20, 27, 25, 0.78);
  cursor: default;
}

.dev-dialog {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 4px solid #1f2927;
  border-radius: 13px;
  background: #313c38;
  box-shadow: 0 8px 0 #1c2422, 0 22px 60px rgba(17, 22, 20, 0.52), inset 0 1px 0 rgba(214, 192, 151, 0.1);
}

.dev-dialog__header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 19px 15px;
  border-bottom: 3px solid #202927;
  background: linear-gradient(180deg, #3e4a45, #333e3a);
}

.dev-dialog__header > div {
  min-width: 0;
}

.dev-dialog__eyebrow {
  display: block;
  margin-bottom: 3px;
  color: #bb9860;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.dev-dialog__header h2,
.dev-confirm h2 {
  margin: 0;
  color: #f0dfbd;
  font-size: 1.35rem;
  line-height: 1.1;
}

.dev-dialog__header p,
.dev-confirm p {
  max-width: 720px;
  margin: 6px 0 0;
  color: #bcae8d;
  font-size: 0.75rem;
  line-height: 1.45;
}

.dev-dialog__close {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 2px solid #1f2927;
  border-radius: 8px;
  background: #29332f;
  color: #d6c097;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.dev-toolbar {
  display: grid;
  grid-template-columns: minmax(250px, 0.9fr) minmax(320px, 1.1fr);
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 2px solid #222c29;
  background: #29332f;
}

.dev-toolbar__connection,
.dev-toolbar__changes {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.dev-toolbar__connection > span,
.dev-toolbar__changes > span,
.dev-toolbar__changes > strong {
  min-width: 0;
}

.dev-toolbar__connection > span {
  flex: 1;
  color: #b7aa8a;
  font-size: 0.69rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dev-toolbar__changes {
  justify-content: flex-end;
}

.dev-toolbar__changes strong {
  flex: 0 0 auto;
  color: #c6b899;
  font-size: 0.7rem;
}

.dev-toolbar__changes strong.has-changes {
  color: #e2c177;
}

.dev-toolbar__changes strong.has-error {
  color: #e3a07d;
}

#dev-status {
  flex: 1;
  color: #9f9478;
  font-size: 0.65rem;
  text-align: right;
  line-height: 1.35;
}

#dev-status code {
  color: #dac79e;
}

[data-tone="success"] { color: #c8cf8a !important; }
[data-tone="warning"] { color: #dfb875 !important; }
[data-tone="error"] { color: #e49a7b !important; }

.dev-form {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(rgba(45, 55, 51, 0.96), rgba(45, 55, 51, 0.96)),
    radial-gradient(circle at 30% 20%, rgba(103, 108, 47, 0.25), transparent 36%);
}

.dev-content {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.dev-section {
  border: 2px solid #202927;
  border-radius: 10px;
  overflow: hidden;
  background: #35403c;
  box-shadow: 0 2px 0 #252d2a, inset 0 1px 0 rgba(214, 192, 151, 0.07);
}

.dev-section__header {
  padding: 10px 12px;
  border-bottom: 2px solid #26302d;
  background: #303b37;
}

.dev-section__header h3 {
  margin: 0;
  color: #e9d7b4;
  font-size: 0.86rem;
}

.dev-section__header p {
  margin: 3px 0 0;
  color: #9f9478;
  font-size: 0.64rem;
  line-height: 1.35;
}

.dev-section__groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 10px;
  padding: 10px;
}

.dev-group {
  min-width: 0;
  border: 2px solid #29322f;
  border-radius: 8px;
  overflow: hidden;
  background: #2f3935;
}

.dev-group h4 {
  margin: 0;
  padding: 7px 9px;
  border-bottom: 1px solid #455048;
  background: #29332f;
  color: #d8c6a1;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.dev-group__fields {
  display: grid;
}

.dev-runtime-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px 12px;
}

.dev-runtime-actions__button {
  min-width: 170px;
}

.dev-field {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-bottom: 1px solid rgba(95, 103, 81, 0.3);
}

.dev-field:last-child {
  border-bottom: 0;
}

.dev-field--reload {
  background: rgba(116, 66, 36, 0.12);
}

.dev-field__copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.dev-field__copy strong {
  color: #d8c7a6;
  font-size: 0.67rem;
}

.dev-field__copy small {
  color: #8e866e;
  font-size: 0.56rem;
  line-height: 1.25;
}

.dev-field input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 2px solid #202927;
  border-radius: 6px;
  outline: 0;
  padding: 4px 7px;
  background: #d4be97;
  color: #2d2b21;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 900;
  text-align: right;
  box-shadow: inset 0 2px 0 rgba(64, 50, 30, 0.12);
}

.dev-field input:focus {
  border-color: #7c844c;
  box-shadow: 0 0 0 2px rgba(187, 152, 96, 0.24), inset 0 2px 0 rgba(64, 50, 30, 0.12);
}

.dev-field.has-error input {
  border-color: #9b5635;
  background: #dfb497;
}

.dev-dialog__footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-top: 3px solid #202927;
  background: #29332f;
}

.dev-dialog__footer-note {
  color: #8f876f;
  font-size: 0.6rem;
  line-height: 1.3;
}

.dev-dialog__footer-actions {
  display: flex;
  gap: 8px;
}

.dev-tool-button {
  min-height: 36px;
  border: 2px solid #202927;
  border-radius: 7px;
  padding: 7px 11px;
  color: #efddba;
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.035em;
  cursor: pointer;
  box-shadow: 0 2px 0 #1f2825, inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.dev-tool-button--primary {
  background: linear-gradient(180deg, #718143, #4f592b);
}

.dev-tool-button--secondary {
  background: linear-gradient(180deg, #53625c, #3a4b4b);
}

.dev-tool-button--ghost {
  background: #313b37;
  color: #b9aa87;
}

.dev-tool-button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.dev-tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  filter: grayscale(0.4);
  box-shadow: none;
}

.dev-confirm {
  position: relative;
  z-index: 1;
  width: min(650px, 100%);
  max-height: calc(100vh - 60px);
  overflow: auto;
  padding: 18px;
  border: 4px solid #1f2927;
  border-radius: 12px;
  background: #35403c;
  box-shadow: 0 7px 0 #1c2422, 0 18px 50px rgba(17, 22, 20, 0.55);
}

.dev-confirm__list {
  display: grid;
  gap: 5px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.dev-confirm__list li {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 9px;
  border: 1px solid #4b554a;
  border-radius: 6px;
  background: #2b3531;
}

.dev-confirm__list li > span:first-child {
  min-width: 0;
  display: grid;
}

.dev-confirm__list strong {
  color: #ddcaa5;
  font-size: 0.67rem;
}

.dev-confirm__list small {
  color: #8f876f;
  font-size: 0.55rem;
}

.dev-confirm__change {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
}

.dev-confirm__change del {
  color: #aa8d7a;
}

.dev-confirm__change b {
  color: #8f876f;
}

.dev-confirm__change ins {
  color: #d8cf89;
  font-weight: 900;
  text-decoration: none;
}

.dev-confirm__more {
  justify-content: center !important;
  color: #b8aa88;
  font-size: 0.64rem;
}

.dev-confirm__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 5px;
}

@media (max-width: 760px) {
  .dev-panel,
  .dev-confirm-overlay {
    padding: 8px;
  }

  .dev-dialog {
    max-height: calc(100vh - 16px);
  }

  .dev-dialog__header p {
    display: none;
  }

  .dev-toolbar {
    grid-template-columns: 1fr;
  }

  .dev-toolbar__changes {
    justify-content: flex-start;
  }

  #dev-status {
    text-align: left;
  }

  .dev-section__groups {
    grid-template-columns: 1fr;
  }

  .dev-dialog__footer {
    grid-template-columns: 1fr;
  }

  .dev-dialog__footer-note {
    display: none;
  }

  .dev-dialog__footer-actions,
  .dev-dialog__footer > .dev-tool-button {
    width: 100%;
  }

  .dev-dialog__footer-actions .dev-tool-button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dev-panel,
  .dev-confirm-overlay {
    transition: none;
  }
}
