:root {
  color-scheme: light;
  --ink: #24313a;
  --muted: #60717d;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(45, 75, 72, 0.16);
  --sky: #9bd8f4;
  --mint: #66b7a8;
  --leaf: #469c72;
  --coral: #ef7e6d;
  --sun: #f8c95b;
  --violet: #8d80c7;
  --shadow: 0 18px 50px rgba(30, 55, 58, 0.18);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef9fb 0%, #f8f2dd 48%, #dff1df 100%);
}

button {
  font: inherit;
}

.game-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  padding: 14px;
}

.village-panel,
.side-panel {
  min-width: 0;
}

.village-panel {
  display: grid;
  grid-template-rows: auto minmax(460px, 1fr) auto;
  gap: 12px;
}

.topbar,
.status-panel,
.goal-panel,
.decor-panel,
.log-panel,
.action-dock {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  min-height: 78px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1,
.side-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.1;
}

.brand p,
.status-panel p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.resource-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.resource-strip span {
  min-width: 82px;
  text-align: center;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.village-scene {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(42, 101, 92, 0.18);
  background:
    radial-gradient(circle at 18% 19%, rgba(255, 255, 255, 0.72) 0 8%, transparent 20%),
    linear-gradient(180deg, var(--sky) 0 45%, #d4f1d7 46% 64%, #6fbd77 65% 100%);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.sky-layer,
.mountain-layer,
.decor-layer,
.cat-layer {
  position: absolute;
  inset: 0;
}

.sun {
  position: absolute;
  top: 34px;
  right: 66px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 18px rgba(248, 201, 91, 0.2), 0 0 70px rgba(248, 201, 91, 0.55);
  animation: sunPulse 6s ease-in-out infinite;
}

.cloud {
  position: absolute;
  width: 128px;
  height: 44px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.82);
  filter: drop-shadow(0 8px 14px rgba(42, 91, 107, 0.12));
  animation: cloudDrift 26s linear infinite;
}

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

.cloud::before {
  width: 54px;
  height: 54px;
  left: 22px;
  top: -26px;
}

.cloud::after {
  width: 62px;
  height: 62px;
  left: 62px;
  top: -32px;
}

.cloud-a {
  left: 8%;
  top: 72px;
}

.cloud-b {
  left: 44%;
  top: 104px;
  transform: scale(0.72);
  animation-duration: 38s;
}

.mountain-layer {
  top: 32%;
  background:
    linear-gradient(135deg, transparent 0 42%, rgba(91, 148, 132, 0.7) 43% 52%, transparent 53%) 4% 0 / 34% 100% no-repeat,
    linear-gradient(135deg, transparent 0 42%, rgba(79, 130, 116, 0.55) 43% 52%, transparent 53%) 46% 0 / 38% 100% no-repeat;
  opacity: 0.8;
}

.home {
  position: absolute;
  bottom: 118px;
  width: clamp(116px, 16vw, 186px);
  height: clamp(88px, 11vw, 132px);
  background: #fff0c8;
  border: 3px solid rgba(93, 70, 52, 0.16);
  border-radius: 8px 8px 16px 16px;
  box-shadow: 0 20px 26px rgba(61, 78, 58, 0.16);
}

.home::before {
  content: "";
  position: absolute;
  left: -14px;
  right: -14px;
  top: -52px;
  height: 68px;
  clip-path: polygon(50% 0, 100% 80%, 0 80%);
  background: var(--coral);
}

.home span {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 34px;
  height: 54px;
  transform: translateX(-50%);
  border-radius: 16px 16px 0 0;
  background: #6d5542;
}

.home-a {
  left: 8%;
}

.home-b {
  right: 11%;
  background: #fbe5b5;
}

.home-b::before {
  background: var(--mint);
}

.pond {
  position: absolute;
  left: 41%;
  bottom: 72px;
  width: min(24vw, 260px);
  height: min(10vw, 104px);
  min-width: 132px;
  min-height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 52% 36%, #bdf1f9 0 22%, #63bee3 70%);
  border: 5px solid rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 -18px 30px rgba(43, 116, 136, 0.2);
}

.garden-path {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: -34px;
  height: 184px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(246, 218, 145, 0.74) 0 38%, transparent 68%);
}

.decor-item {
  position: absolute;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: 0 10px 18px rgba(34, 65, 52, 0.13);
}

.decor-item::before {
  content: attr(data-symbol);
  font-size: 34px;
  line-height: 1;
}

.cat {
  position: absolute;
  width: 76px;
  height: 70px;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  filter: drop-shadow(0 12px 12px rgba(33, 48, 42, 0.24));
  transition: transform 180ms ease, filter 180ms ease;
  animation: catBob 2.5s ease-in-out infinite;
}

.cat:hover,
.cat.selected {
  transform: translate(-50%, -54%) scale(1.08);
  filter: drop-shadow(0 18px 18px rgba(33, 48, 42, 0.28));
}

.cat-body {
  position: absolute;
  left: 10px;
  right: 8px;
  bottom: 4px;
  height: 46px;
  border-radius: 45% 45% 42% 42%;
  background: var(--cat-color);
}

.cat-body::before,
.cat-body::after {
  content: "";
  position: absolute;
  top: -14px;
  width: 22px;
  height: 22px;
  background: var(--cat-color);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.cat-body::before {
  left: 8px;
}

.cat-body::after {
  right: 8px;
}

.cat-face {
  position: absolute;
  left: 23px;
  top: 30px;
  width: 31px;
  height: 18px;
}

.cat-face::before,
.cat-face::after {
  content: "";
  position: absolute;
  top: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #1f2933;
}

.cat-face::before {
  left: 3px;
}

.cat-face::after {
  right: 3px;
}

.cat-mouth {
  position: absolute;
  left: 12px;
  top: 8px;
  width: 8px;
  height: 6px;
  border-bottom: 2px solid #1f2933;
  border-radius: 50%;
}

.cat-tail {
  position: absolute;
  right: 0;
  bottom: 18px;
  width: 28px;
  height: 12px;
  border-radius: 999px;
  background: var(--cat-color);
  transform-origin: left center;
  animation: tailWave 1.4s ease-in-out infinite;
}

.cat-label {
  position: absolute;
  left: 50%;
  top: -24px;
  transform: translateX(-50%);
  min-width: 58px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  color: #34434b;
  font-size: 12px;
  white-space: nowrap;
}

.event-toast {
  position: absolute;
  left: 18px;
  bottom: 18px;
  max-width: min(520px, calc(100% - 36px));
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(36, 49, 58, 0.84);
  color: #fff;
  line-height: 1.38;
  box-shadow: 0 12px 24px rgba(16, 33, 37, 0.18);
  z-index: 12;
}

.action-dock {
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  gap: 8px;
}

.action-button,
.decor-card,
.icon-button {
  min-height: 48px;
  border: 1px solid rgba(37, 94, 86, 0.2);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 750;
}

.action-button:hover,
.decor-card:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 94, 86, 0.42);
  box-shadow: 0 10px 18px rgba(33, 66, 60, 0.14);
}

.action-button:active,
.decor-card:active,
.icon-button:active {
  transform: translateY(1px);
}

.button-icon,
.icon-button::before {
  width: 22px;
  height: 22px;
  display: inline-block;
  position: relative;
}

.bowl-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 3px;
  height: 12px;
  border-radius: 2px 2px 12px 12px;
  background: var(--coral);
}

.bowl-icon::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sun);
}

.hand-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 15px;
  height: 15px;
  border-radius: 50% 50% 45% 45%;
  background: var(--mint);
  box-shadow: -5px -2px 0 -2px var(--mint), 5px -2px 0 -2px var(--mint);
}

.ball-icon::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: conic-gradient(var(--violet) 0 33%, var(--sun) 0 66%, var(--coral) 0);
}

.eye-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 6px;
  width: 20px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--leaf);
}

.eye-icon::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--leaf);
}

.save-icon::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 3px;
  background: var(--violet);
}

.save-icon::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 5px;
  height: 6px;
  border-radius: 2px;
  background: #fff;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto minmax(190px, auto) minmax(0, 1fr);
  gap: 12px;
}

.status-panel,
.goal-panel,
.decor-panel,
.log-panel {
  border-radius: var(--radius);
  padding: 14px;
}

.side-panel h2 {
  font-size: 16px;
  line-height: 1.2;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.icon-button {
  width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
}

.icon-button::before {
  content: "";
  border: 3px solid var(--coral);
  border-left-color: transparent;
  border-radius: 50%;
}

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

.stat-row {
  display: grid;
  grid-template-columns: 70px 1fr 34px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.stat-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(96, 113, 125, 0.15);
  overflow: hidden;
}

.stat-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sun));
}

#goalList,
#storyLog {
  margin: 10px 0 0;
  padding-left: 20px;
}

#goalList li,
#storyLog li {
  margin: 7px 0;
  color: var(--muted);
  line-height: 1.35;
}

#goalList li.done {
  color: #2f8b63;
  text-decoration: line-through;
}

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

.decor-card {
  min-height: 74px;
  padding: 9px;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.decor-card.locked {
  opacity: 0.55;
}

.decor-symbol {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(102, 183, 168, 0.13);
  font-size: 21px;
}

.decor-card b,
.decor-card small {
  display: block;
}

.decor-card b {
  font-size: 13px;
}

.decor-card small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.25;
}

.log-panel {
  overflow: auto;
  min-height: 120px;
}

.weather-evening {
  --sky: #b6b4ed;
}

.weather-rain {
  --sky: #91c6d7;
}

.weather-rain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(110deg, rgba(255, 255, 255, 0.28) 0 1px, transparent 1px 20px);
  background-size: 32px 32px;
  animation: rainSlide 800ms linear infinite;
  z-index: 5;
}

@keyframes catBob {
  0%,
  100% {
    margin-top: 0;
  }
  50% {
    margin-top: -5px;
  }
}

@keyframes tailWave {
  0%,
  100% {
    transform: rotate(18deg);
  }
  50% {
    transform: rotate(-16deg);
  }
}

@keyframes cloudDrift {
  0% {
    translate: -10vw 0;
  }
  100% {
    translate: 88vw 0;
  }
}

@keyframes sunPulse {
  50% {
    transform: scale(1.06);
  }
}

@keyframes rainSlide {
  to {
    background-position: 0 32px;
  }
}

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

  .village-panel {
    grid-template-rows: auto minmax(430px, 58vh) auto;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto;
  }

  .log-panel {
    grid-column: span 2;
  }
}

@media (max-width: 620px) {
  .game-shell {
    padding: 8px;
    gap: 8px;
  }

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

  .brand h1 {
    font-size: 20px;
  }

  .resource-strip {
    justify-content: stretch;
    width: 100%;
  }

  .resource-strip span {
    flex: 1 1 86px;
    min-width: 0;
  }

  .village-panel {
    grid-template-rows: auto minmax(390px, 54vh) auto;
  }

  .village-scene {
    min-height: 390px;
  }

  .home {
    bottom: 102px;
  }

  .home-a {
    left: 3%;
  }

  .home-b {
    right: 2%;
  }

  .pond {
    left: 34%;
    bottom: 66px;
  }

  .cat {
    width: 66px;
    height: 62px;
  }

  .action-dock {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
  }

  .action-button {
    min-height: 52px;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .log-panel {
    grid-column: auto;
  }

  .decor-grid {
    grid-template-columns: 1fr;
  }
}
