:root {
  --ink: #17211b;
  --muted: #5d6b61;
  --paper: #f4f1e7;
  --panel: rgba(255, 252, 239, 0.92);
  --fern: #315b3d;
  --moss: #6f8b4f;
  --river: #4d91a6;
  --clay: #b65f3a;
  --ember: #e49b45;
  --night: #202a32;
  --line: rgba(23, 33, 27, 0.16);
  --shadow: 0 18px 50px rgba(14, 24, 20, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 15% 5%, rgba(228, 155, 69, 0.35), transparent 30%),
    linear-gradient(160deg, #d9e9d2 0%, #d5e7ea 38%, #ede7cc 100%);
}

button {
  font: inherit;
}

.game-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.scene {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  border: 2px solid rgba(23, 33, 27, 0.12);
  border-radius: 8px;
  background: linear-gradient(#9ed0de 0%, #d7eedc 54%, #8fae67 55%, #5b7a4e 100%);
  box-shadow: var(--shadow);
}

.sun {
  position: absolute;
  top: 28px;
  right: 78px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #f4c853;
  box-shadow: 0 0 55px rgba(244, 200, 83, 0.8);
}

.cloud {
  position: absolute;
  width: 150px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.cloud::before,
.cloud::after {
  position: absolute;
  content: "";
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 62px;
  height: 62px;
  left: 24px;
  top: -24px;
}

.cloud::after {
  width: 72px;
  height: 72px;
  right: 18px;
  top: -31px;
}

.cloud-one {
  top: 52px;
  left: 10%;
}

.cloud-two {
  top: 92px;
  right: 22%;
  transform: scale(0.72);
}

.mountains {
  position: absolute;
  inset: 88px 0 auto 0;
  height: 120px;
  background:
    linear-gradient(135deg, transparent 0 50%, rgba(63, 98, 88, 0.75) 51% 76%, transparent 77%) 0 0 / 260px 120px repeat-x,
    linear-gradient(45deg, transparent 0 48%, rgba(88, 119, 105, 0.58) 49% 75%, transparent 76%) 120px 16px / 300px 105px repeat-x;
}

.forest-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 56px;
  height: 120px;
}

.forest-line::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    conic-gradient(from 135deg at 50% 70%, transparent 0 25%, currentColor 0 75%, transparent 0) 0 0 / 52px 92px repeat-x;
}

.forest-back {
  color: rgba(41, 83, 61, 0.55);
  bottom: 72px;
}

.forest-front {
  color: rgba(28, 69, 46, 0.82);
}

.camp {
  position: absolute;
  left: 50%;
  bottom: 35px;
  width: min(560px, 90%);
  height: 150px;
  transform: translateX(-50%);
}

.tent {
  position: absolute;
  left: 42px;
  bottom: 0;
  width: 118px;
  height: 80px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: linear-gradient(115deg, var(--river) 0 50%, #2f6174 51%);
  border-bottom: 8px solid rgba(23, 33, 27, 0.28);
}

.fire {
  position: absolute;
  left: 196px;
  bottom: 2px;
  width: 56px;
  height: 52px;
  opacity: 0.35;
}

.fire.is-lit {
  opacity: 1;
}

.fire::before {
  position: absolute;
  left: 13px;
  bottom: 13px;
  content: "";
  width: 28px;
  height: 39px;
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(#fff1a8 0 26%, #f0a044 27% 66%, #c84932 67%);
  animation: flame 0.9s infinite alternate ease-in-out;
}

.fire::after {
  position: absolute;
  left: 4px;
  bottom: 5px;
  content: "";
  width: 48px;
  height: 12px;
  border-radius: 999px;
  background: #543929;
  transform: rotate(-7deg);
  box-shadow: 0 8px 0 #4a3326;
}

.house {
  position: absolute;
  right: 24px;
  bottom: 0;
  width: 168px;
  height: 112px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.house.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.house::before {
  position: absolute;
  left: 18px;
  bottom: 0;
  content: "";
  width: 132px;
  height: 76px;
  background: linear-gradient(90deg, #6e8d55, #8ea25e);
  border: 4px solid rgba(23, 33, 27, 0.35);
}

.house::after {
  position: absolute;
  left: 0;
  bottom: 67px;
  content: "";
  width: 168px;
  height: 58px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #934e37;
}

.survivor {
  position: absolute;
  left: 282px;
  bottom: 7px;
  width: 30px;
  height: 62px;
}

.survivor::before {
  position: absolute;
  top: 0;
  left: 6px;
  content: "";
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #6f4b35;
}

.survivor::after {
  position: absolute;
  top: 23px;
  left: 8px;
  content: "";
  width: 15px;
  height: 38px;
  border-radius: 10px 10px 4px 4px;
  background: var(--night);
  box-shadow: -10px 10px 0 -5px #4b3428, 10px 10px 0 -5px #4b3428;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 18px;
}

.hud-copy {
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--fern);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 700;
  white-space: nowrap;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

.goal {
  margin-bottom: 0;
  color: var(--muted);
}

.reset-button,
.action-button,
.build-button,
#saveScoreButton {
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: var(--fern);
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.reset-button:hover,
.action-button:hover,
.build-button:hover,
#saveScoreButton:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.reset-button {
  flex: 0 0 auto;
  padding: 12px 16px;
}

.dashboard,
.action-area {
  display: grid;
  gap: 14px;
}

.dashboard {
  grid-template-columns: 0.8fr 0.9fr 1.35fr;
}

.action-area {
  grid-template-columns: 1.02fr 0.8fr 0.98fr;
  margin-top: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 8px 26px rgba(14, 24, 20, 0.08);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stat {
  margin-bottom: 13px;
}

.stat-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 33, 27, 0.1);
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--river), var(--moss));
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.item {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.46);
}

.item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.item span {
  color: var(--fern);
  font-size: 1.25rem;
  font-weight: 800;
}

.equipment-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.action-grid,
.build-list {
  display: grid;
  gap: 10px;
}

.action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-button,
.build-button {
  width: 100%;
  padding: 13px;
  text-align: left;
}

.action-button span,
.build-button span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.84rem;
}

.action-button:disabled,
.build-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.build-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.42);
}

.build-card.is-built {
  border-color: rgba(49, 91, 61, 0.5);
  background: rgba(111, 139, 79, 0.16);
}

.build-card h3 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.build-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.build-button {
  min-width: 92px;
  padding: 10px 12px;
  text-align: center;
  background: var(--clay);
}

.camp-preview-panel {
  display: flex;
  flex-direction: column;
}

.camp-preview {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    radial-gradient(circle at 18% 14%, rgba(245, 220, 112, 0.55), transparent 28%),
    linear-gradient(180deg, #c9e6ef 0%, #dcefdc 48%, #93b06d 49%, #68874e 100%);
}

.preview-sun {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f4c853;
  box-shadow: 0 0 28px rgba(244, 200, 83, 0.75);
}

.preview-ground {
  position: absolute;
  inset: auto 0 0 0;
  height: 132px;
  background:
    linear-gradient(rgba(67, 94, 54, 0.14), rgba(67, 94, 54, 0.14)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.05) 0 28px,
      transparent 28px 56px
    );
}

.preview-tree {
  position: absolute;
  bottom: 112px;
  width: 74px;
  height: 150px;
}

.preview-tree::before {
  position: absolute;
  left: 29px;
  bottom: 0;
  content: "";
  width: 14px;
  height: 64px;
  background: #5b3a2d;
}

.preview-tree::after {
  position: absolute;
  left: 0;
  bottom: 42px;
  content: "";
  width: 74px;
  height: 96px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #3f6d49;
}

.tree-left {
  left: 20px;
}

.tree-right {
  right: 18px;
  transform: scale(0.9);
}

.preview-fire,
.preview-lean-to,
.preview-garden,
.preview-cabin,
.preview-big-house {
  position: absolute;
  opacity: 0;
  transform: translateY(10px) scale(0.94);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.preview-fire.is-visible,
.preview-lean-to.is-visible,
.preview-garden.is-visible,
.preview-cabin.is-visible,
.preview-big-house.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.preview-fire {
  left: 50%;
  bottom: 120px;
  width: 54px;
  height: 48px;
  margin-left: -28px;
}

.preview-fire::before {
  position: absolute;
  left: 12px;
  bottom: 13px;
  content: "";
  width: 28px;
  height: 32px;
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(#fff1a8 0 26%, #f0a044 27% 66%, #c84932 67%);
  animation: flame 0.9s infinite alternate ease-in-out;
}

.preview-fire::after {
  position: absolute;
  left: 4px;
  bottom: 2px;
  content: "";
  width: 46px;
  height: 12px;
  border-radius: 999px;
  background: #5b3a2d;
  box-shadow: 0 8px 0 #503429;
}

.preview-lean-to {
  left: 34px;
  bottom: 118px;
  width: 112px;
  height: 82px;
}

.preview-lean-to::before {
  position: absolute;
  inset: auto 18px 0 18px;
  content: "";
  height: 34px;
  background: linear-gradient(90deg, #80654d, #9e7e60);
  border: 3px solid rgba(23, 33, 27, 0.3);
  border-top: 0;
}

.preview-lean-to::after {
  position: absolute;
  inset: 0 0 auto 0;
  content: "";
  height: 58px;
  clip-path: polygon(22% 18%, 100% 0, 78% 100%, 0 100%);
  background: linear-gradient(135deg, #7f8f55 0 55%, #5f7240 56%);
}

.preview-garden {
  right: 24px;
  bottom: 112px;
  width: 126px;
  height: 92px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 2px, transparent 2px) 0 0 / 32px 100%,
    linear-gradient(rgba(255, 255, 255, 0.08) 2px, transparent 2px) 0 0 / 100% 30px,
    linear-gradient(180deg, #7d553b, #65432d);
  border: 4px solid #8b6a4e;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.preview-garden::before {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 16px;
  bottom: 12px;
  content: "";
  background:
    radial-gradient(circle at 12px 12px, #8fd06d 0 6px, transparent 7px) 0 0 / 30px 26px repeat,
    radial-gradient(circle at 20px 20px, #6aa748 0 6px, transparent 7px) 8px 8px / 34px 28px repeat;
  opacity: 0.9;
}

.preview-cabin {
  left: 50%;
  bottom: 114px;
  width: 172px;
  height: 120px;
  margin-left: -86px;
}

.preview-cabin::before {
  position: absolute;
  left: 18px;
  bottom: 0;
  content: "";
  width: 136px;
  height: 76px;
  background: linear-gradient(90deg, #8b6a4e, #b0875d);
  border: 4px solid rgba(23, 33, 27, 0.34);
}

.preview-cabin::after {
  position: absolute;
  left: 2px;
  bottom: 67px;
  content: "";
  width: 168px;
  height: 56px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #8a4d34;
}

.preview-big-house {
  left: 50%;
  bottom: 104px;
  width: 220px;
  height: 148px;
  margin-left: -110px;
}

.preview-big-house::before {
  position: absolute;
  left: 18px;
  bottom: 0;
  content: "";
  width: 184px;
  height: 96px;
  background:
    linear-gradient(90deg, transparent 70px, rgba(23, 33, 27, 0.24) 70px 74px, transparent 74px),
    linear-gradient(90deg, #7e9d57, #97af66);
  border: 4px solid rgba(23, 33, 27, 0.34);
}

.preview-big-house::after {
  position: absolute;
  left: 0;
  bottom: 88px;
  content: "";
  width: 220px;
  height: 62px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #934e37;
}

.camp-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.leaderboard-panel {
  margin-top: 14px;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

#playerName {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  background: rgba(255, 255, 255, 0.62);
}

#playerName::placeholder {
  color: rgba(93, 107, 97, 0.78);
}

#saveScoreButton {
  min-width: 110px;
  padding: 10px 14px;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 24px;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px dashed rgba(23, 33, 27, 0.12);
  padding-bottom: 7px;
  color: var(--muted);
}

.leaderboard-list li strong {
  color: var(--ink);
}

.leaderboard-list li span {
  color: var(--fern);
  font-weight: 700;
}

.victory-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  border-color: rgba(49, 91, 61, 0.36);
  background: linear-gradient(90deg, rgba(255, 248, 214, 0.96), rgba(229, 244, 214, 0.96));
}

.victory-banner strong {
  font-size: 1.1rem;
}

.victory-banner span {
  color: var(--fern);
  font-weight: 700;
}

.footer-panel {
  margin-top: 14px;
}

#log {
  display: grid;
  max-height: 210px;
  gap: 8px;
  margin: 0;
  overflow: auto;
  padding-left: 22px;
  color: var(--muted);
}

#log li:first-child {
  color: var(--ink);
  font-weight: 700;
}

@keyframes flame {
  from {
    transform: scaleY(0.9) rotate(-4deg);
  }

  to {
    transform: scaleY(1.08) rotate(5deg);
  }
}

@media (max-width: 900px) {
  .dashboard,
  .action-area {
    grid-template-columns: 1fr;
  }

  .title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .scene {
    min-height: 230px;
  }
}

@media (max-width: 620px) {
  .game-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
  }

  .eyebrow {
    margin-bottom: 2px;
  }

  .reset-button {
    width: 100%;
  }

  .leaderboard-entry,
  .victory-banner {
    grid-template-columns: 1fr;
  }

  .victory-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .inventory-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .build-card {
    grid-template-columns: 1fr;
  }

  .camp {
    transform: translateX(-50%) scale(0.82);
    transform-origin: bottom center;
  }
}
