:root {
  --soil-dark: #6f4128;
  --soil-mid: #8b5a32;
  --wood: #744b2d;
  --paper: #fff7d6;
  --paper-strong: #fff0ba;
  --green: #2f6d4a;
  --green-light: #57a15d;
  --orange: #d99543;
  --ink: #293727;
  --muted: #76694e;
  --shadow: rgba(58, 45, 25, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #94d68d;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 390px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
  background: linear-gradient(180deg, #a9e29e 0%, #f8df91 52%, #c89358 100%);
}

.farm-stage {
  position: relative;
  min-height: calc(100vh - 36px);
  overflow: hidden;
  border: 5px solid rgba(91, 62, 34, 0.28);
  border-radius: 22px;
  background: linear-gradient(180deg, #83d7ff 0%, #cbf4d2 38%, #d2ab6a 100%);
  box-shadow: 0 20px 45px rgba(58, 45, 25, 0.22);
}

.sky {
  position: absolute;
  inset: 0 0 auto;
  height: 360px;
  overflow: hidden;
  background: linear-gradient(180deg, #83d7ff 0%, #cbf4d2 74%, rgba(203, 244, 210, 0) 100%);
}

.sun {
  position: absolute;
  right: 72px;
  top: 50px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #ffd76d;
  box-shadow: 0 0 42px rgba(255, 216, 96, 0.65);
  animation: sunPulse 4s ease-in-out infinite;
}

.cloud {
  position: absolute;
  width: 142px;
  height: 46px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 44px -16px 0 12px rgba(255, 255, 255, 0.9), 88px 0 0 4px rgba(255, 255, 255, 0.9);
  animation: drift 13s ease-in-out infinite;
}

.cloud-a {
  left: 40px;
  top: 80px;
}

.cloud-b {
  left: 56%;
  top: 138px;
  transform: scale(0.78);
  animation-duration: 17s;
}

.hill {
  position: absolute;
  bottom: -60px;
  border-radius: 50% 50% 0 0;
}

.hill-back {
  left: -100px;
  width: 620px;
  height: 210px;
  background: #81bf6e;
}

.hill-front {
  right: -120px;
  width: 680px;
  height: 180px;
  background: #62a95d;
}

.barn {
  position: absolute;
  left: 52px;
  bottom: 30px;
  width: 170px;
  height: 142px;
}

.barn .roof {
  width: 0;
  height: 0;
  border-left: 92px solid transparent;
  border-right: 92px solid transparent;
  border-bottom: 70px solid #b64a3a;
}

.barn .body {
  position: absolute;
  left: 20px;
  top: 60px;
  width: 144px;
  height: 96px;
  border: 5px solid #6b3b2a;
  border-radius: 8px;
  background: #d86f4a;
}

.door {
  position: absolute;
  left: 48px;
  bottom: 0;
  width: 48px;
  height: 58px;
  border-radius: 8px 8px 0 0;
  background: #734728;
}

.pond {
  position: absolute;
  right: 42px;
  bottom: 12px;
  width: 160px;
  height: 62px;
  border: 5px solid rgba(53, 111, 122, 0.35);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #b6f7ff, #5baec4);
  animation: waterPulse 2.8s ease-in-out infinite;
}

.fence {
  position: absolute;
  left: 260px;
  right: 250px;
  bottom: 28px;
  height: 34px;
  background: repeating-linear-gradient(90deg, #9a6638 0 10px, transparent 10px 44px);
  border-top: 8px solid #9a6638;
}

.hud,
.xp-track,
.farm-board,
.message,
.seed-dock,
.tool-dock,
.action-row {
  position: relative;
  z-index: 2;
}

.hud {
  display: flex;
  gap: 14px;
  align-items: stretch;
  padding: 18px 18px 0;
}

.date-card,
.stat-strip,
.panel {
  border: 4px solid rgba(90, 68, 42, 0.25);
  border-radius: 18px;
  background: rgba(255, 247, 214, 0.93);
  box-shadow: 0 12px 0 rgba(83, 57, 33, 0.14), 0 18px 35px rgba(64, 52, 31, 0.16);
}

.date-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
}

.date-card span {
  color: #667052;
  font-size: 15px;
  font-weight: 800;
}

.date-card strong {
  margin-top: 4px;
  color: var(--green);
  font-size: 34px;
  line-height: 1;
}

.stat-strip {
  min-width: 220px;
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  color: #493820;
  font-size: 16px;
  font-weight: 900;
}

.xp-track {
  height: 14px;
  margin: 12px 22px 0;
  border: 3px solid rgba(80, 61, 37, 0.25);
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.55);
}

.xp-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffd45f, #ff8b4a);
  transition: width 240ms ease;
}

.farm-board {
  width: min(680px, calc(100% - 44px));
  margin: 220px auto 0;
  padding: 20px;
  border: 6px solid #946338;
  border-radius: 26px;
  background: linear-gradient(180deg, #c99355, #9d6c3e);
  box-shadow: inset 0 8px 0 rgba(255, 255, 255, 0.16), 0 20px 38px rgba(71, 51, 26, 0.18);
}

.plot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.plot {
  position: relative;
  height: 116px;
  overflow: hidden;
  border: 5px solid var(--wood);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--soil-mid), var(--soil-dark));
  box-shadow: inset 0 10px 0 rgba(255, 221, 154, 0.14), 0 8px 0 rgba(76, 48, 28, 0.3);
}

.plot:hover {
  filter: brightness(1.08);
}

.plot:active {
  transform: scale(0.96);
}

.plot::before {
  content: "";
  position: absolute;
  inset: 22px 12px;
  border-top: 4px dashed rgba(255, 220, 154, 0.28);
  border-bottom: 4px dashed rgba(47, 29, 19, 0.25);
}

.plot.watered {
  background: linear-gradient(145deg, #77513b, #50392d);
}

.plot.ready {
  border-color: #ffe36b;
  box-shadow: 0 0 20px rgba(255, 226, 86, 0.56), 0 8px 0 rgba(76, 48, 28, 0.3);
}

.crop {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 2;
  text-shadow: 0 5px 0 rgba(45, 30, 18, 0.2);
}

.crop.stage-0 {
  font-size: 28px;
  transform: translateX(-50%) translateY(12px);
}

.crop.stage-1 {
  font-size: 38px;
}

.crop.stage-2 {
  font-size: 48px;
}

.crop.stage-3 {
  font-size: 58px;
  animation: cropIdle 1.5s ease-in-out infinite;
}

.plot.ready::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 20px;
  top: 20px;
  border-radius: 50%;
  background: #fff1a3;
  box-shadow: 74px 16px 0 #fff1a3, 0 0 16px #ffe36b;
  animation: sparkle 900ms ease-in-out infinite;
}

.plot.bump .crop {
  animation: pop 360ms ease;
}

.message {
  width: min(680px, calc(100% - 44px));
  min-height: 58px;
  margin: 18px auto 0;
  padding: 16px 18px;
  color: #4e3d24;
  font-size: 17px;
  font-weight: 800;
}

.seed-dock {
  width: min(680px, calc(100% - 44px));
  margin: 14px auto 0;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.seed-chip {
  flex: 0 0 180px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 0 12px;
  border: 4px solid rgba(74, 54, 34, 0.24);
  border-radius: 14px;
  color: #4c3f27;
  background: rgba(255, 247, 214, 0.93);
  font-weight: 900;
}

.seed-chip.active {
  border-color: var(--green);
  background: #e3ffc6;
}

.seed-chip .count {
  margin-left: auto;
  color: var(--green);
}

.tool-dock {
  width: min(680px, calc(100% - 44px));
  margin: 14px auto 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px;
}

.tool {
  min-height: 62px;
  border-radius: 14px;
  color: #66543a;
  background: rgba(255, 255, 255, 0.55);
  font-weight: 900;
}

.tool.active {
  color: var(--paper);
  background: linear-gradient(180deg, var(--green-light), var(--green));
}

.action-row {
  width: min(680px, calc(100% - 44px));
  margin: 14px auto 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pixel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 18px;
  border: 4px solid var(--wood);
  border-radius: 14px;
  color: var(--paper);
  background: linear-gradient(180deg, var(--green-light), var(--green));
  box-shadow: 0 7px 0 var(--wood);
  font-weight: 900;
}

.pixel-btn:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--wood);
}

.pixel-btn.orange {
  background: linear-gradient(180deg, var(--orange), #9d5d2f);
}

.pixel-btn.reset {
  width: 100%;
  margin-top: 18px;
  background: linear-gradient(180deg, #d76a54, #963f38);
}

.side-panel {
  min-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tab {
  min-height: 52px;
  border: 4px solid rgba(90, 68, 42, 0.24);
  border-radius: 14px;
  color: #644d2e;
  background: rgba(255, 247, 214, 0.78);
  font-weight: 900;
}

.tab.active {
  color: var(--paper);
  background: linear-gradient(180deg, #e8a74f, #a76231);
}

.drawer {
  display: none;
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

.drawer.active {
  display: block;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.drawer-head h2 {
  margin: 0;
  color: var(--green);
  font-size: 25px;
}

.drawer-head span {
  color: #9d5d2f;
  font-weight: 900;
}

.goods-list,
.order-list {
  display: grid;
  gap: 12px;
}

.good,
.order-card {
  padding: 14px;
  border: 4px solid rgba(90, 68, 42, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.46);
}

.good {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
}

.good-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid #9f7544;
  border-radius: 12px;
  background: var(--paper-strong);
  font-size: 30px;
}

.good h3,
.order-card h3 {
  margin: 0;
  color: #3c442b;
  font-size: 18px;
}

.good p,
.order-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.mini-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.mini-btn {
  min-height: 36px;
  border: 3px solid var(--wood);
  border-radius: 10px;
  color: var(--paper);
  background: linear-gradient(180deg, var(--green-light), var(--green));
  font-size: 13px;
  font-weight: 900;
}

.mini-btn.sell {
  background: linear-gradient(180deg, var(--orange), #9d5d2f);
}

.needs {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.need {
  display: grid;
  grid-template-columns: 34px 1fr 58px;
  align-items: center;
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 10px;
  color: #624e32;
  background: rgba(134, 83, 47, 0.12);
  font-size: 14px;
  font-weight: 800;
}

.need.enough {
  color: var(--green);
  background: rgba(84, 161, 93, 0.18);
}

.reward {
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
  color: #9d5d2f;
  font-size: 14px;
  font-weight: 900;
}

.bag-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.bag-item {
  min-height: 112px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 4px solid rgba(90, 68, 42, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.46);
  text-align: center;
  font-weight: 900;
}

.bag-item strong {
  display: block;
  font-size: 34px;
}

@media (max-width: 980px) {
  .game-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .farm-stage,
  .side-panel {
    min-height: auto;
  }

  .farm-board {
    margin-top: 205px;
  }

  .plot {
    height: 88px;
  }
}

@media (max-width: 620px) {
  .hud {
    flex-direction: column;
  }

  .stat-strip {
    min-width: 0;
    grid-template-columns: repeat(3, 1fr);
  }

  .farm-board {
    width: calc(100% - 20px);
    margin-top: 190px;
    padding: 12px;
  }

  .plot-grid {
    gap: 8px;
  }

  .plot {
    height: 74px;
    border-width: 4px;
  }

  .crop.stage-3 {
    font-size: 42px;
  }

  .message,
  .seed-dock,
  .tool-dock,
  .action-row {
    width: calc(100% - 20px);
  }

  .tool-dock {
    grid-template-columns: repeat(2, 1fr);
  }

  .seed-chip {
    flex-basis: 154px;
    font-size: 14px;
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translateX(-28px);
  }
  50% {
    transform: translateX(28px);
  }
}

@keyframes sunPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@keyframes cropIdle {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-5px);
  }
}

@keyframes pop {
  0% {
    transform: translateX(-50%) scale(0.72);
  }
  55% {
    transform: translateX(-50%) scale(1.18);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

@keyframes sparkle {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0) scale(0.8);
  }
  50% {
    opacity: 1;
    transform: translateY(-8px) scale(1.1);
  }
}

@keyframes waterPulse {
  0%,
  100% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(1.04);
  }
}
