:root {
  color-scheme: light;
  --ink: #233b40;
  --muted: #486164;
  --paper: #fffaf0;
  --coral: #b9492f;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #d7e9e7;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible { outline: 3px solid #214a62; outline-offset: 3px; }

.game {
  --header-height: calc(54px + env(safe-area-inset-top, 0px));
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  min-height: 500px;
  margin: 0 auto;
  overflow: hidden;
  background: #f5d18f;
}

.app-bar {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  display: grid;
  height: var(--header-height);
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  column-gap: 8px;
  padding: env(safe-area-inset-top, 0px) 15px 0;
  color: #21495b;
  background: #b7ddf2;
  border-bottom: 1px solid #ffffff9c;
}

.app-bar h1 {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 780;
  letter-spacing: .06em;
}

.app-bar h1 span { color: #487990; }

.app-mark, .help-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
}

.app-mark img { object-fit: contain; }

.help-button {
  border: 0;
  background: none;
  font-size: 0;
}

.help-button::before {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  content: "?";
  border: 1.25px solid #37647c;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 750;
}

.scene {
  position: absolute;
  overflow: hidden;
  inset: var(--header-height) 0 0;
  background: linear-gradient(#59b8f3 12%, #f5d18f 42%);
}

.map {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  user-select: none;
  --seed-x: 25.8%;
  --seed-y: 49.2%;
  --well-x: 81%;
  --well-y: 49.7%;
  --garden-x: 23.2%;
  --garden-y: 61%;
}

.town-art, .map-overlay {
  position: absolute;
  pointer-events: none;
  display: block;
}

.town-art { inset: 0; width: 100%; height: 100%; }

.well-art, .garden-art { inset: 0; width: 100%; height: 100%; animation: restored .55s ease-out both; }

.plant-art {
  left: var(--seed-x);
  top: calc(var(--seed-y) + 1%);
  width: 15%;
  height: auto;
  transform: translate(-50%, -95%);
  animation: emerging .42s ease-out both;
}

:is([data-phase="build"], [data-phase="complete"]) .plant-art { width: 28%; animation: growing .52s ease-out both; }

.mascot-art {
  left: 40%;
  top: 52.5%;
  width: 13%;
  transform: translate(-50%, -95%);
  transition: left .5s ease, top .5s ease;
  filter: drop-shadow(0 4px 1px #6c4e382e);
}

:is([data-phase="well"], [data-phase="repair"], [data-phase="reward"]) .mascot-art {
  left: 68%;
  top: 55.5%;
}

[data-phase="repair"] .mascot-art { animation: working .55s ease-in-out infinite alternate; }

.hotspot {
  --spot-x: var(--seed-x);
  --spot-y: var(--seed-y);
  position: absolute;
  left: var(--spot-x);
  top: var(--spot-y);
  display: grid;
  justify-items: center;
  align-content: end;
  min-width: 72px;
  min-height: 65px;
  padding: 3px;
  gap: 1px;
  transform: translate(-50%, -91%);
  border: 0;
  color: #523922;
  background: transparent;
  white-space: nowrap;
  z-index: 1;
}

.hotspot[data-spot="well"] { --spot-x: var(--well-x); --spot-y: var(--well-y); }
.hotspot[data-spot="garden"] { --spot-x: var(--garden-x); --spot-y: var(--garden-y); }

.hotspot-label {
  grid-row: 1;
  border: 1px solid #f3d69a;
  border-radius: 20px;
  background: #fff9dd;
  box-shadow: 0 2px 6px #74512232;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 750;
}

.hotspot-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 2px solid #fff3cd;
  border-radius: 50%;
  color: #663e19;
  background: #ffce72;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 4px #ffface75, 0 2px 8px #8e571b43;
  animation: point 1.8s ease-in-out infinite;
}

.hotspot-icon[data-icon="leaf"] {
  background: #fff4bf url("./assets/leaf.webp") center / 20px no-repeat;
}

.map-countdown {
  position: absolute;
  left: var(--well-x);
  top: calc(var(--well-y) - 4%);
  transform: translate(-50%, -50%);
  min-width: 64px;
  padding: 7px 12px;
  border: 1px solid #e5bb70;
  border-radius: 17px;
  color: #623c1c;
  background: #fff7d7;
  text-align: center;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.scene-hud {
  position: absolute;
  inset: 13px 12px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.level-status, .balances {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 36px;
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid #ffffffc7;
  border-radius: 18px;
  background: #fff9e9f5;
  box-shadow: 0 2px 5px #374c6620;
}

.level-status { padding-left: 6px; }
.level-status > span:last-child { display: flex; align-items: center; gap: 5px; }
.level-status strong, .balances strong { font-size: 13px; color: #294b40; }
.level-icon { display: grid; place-items: center; }
.level-icon img { width: 19px; height: 19px; object-fit: contain; }
.balances > span { display: flex; align-items: center; gap: 3px; }
.balances > span + span { border-left: 1px solid #ecdcae; padding-left: 7px; }
.energy-icon { color: #97541b; font-size: 16px; }
.prosperity-icon { color: #4f753a; font-size: 15px; }

.announcement {
  position: absolute;
  inset: 60px 10px auto;
  max-width: max-content;
  margin: auto;
  padding: 8px 12px;
  border-radius: 20px;
  color: #fff8ea;
  background: #284c3f;
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity .18s, transform .18s;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.announcement:empty { visibility: hidden; }
.announcement.is-visible { opacity: 1; transform: translateY(0); }

.guide {
  position: absolute;
  z-index: 2;
  inset: auto 13px calc(13px + env(safe-area-inset-bottom, 0px));
  max-width: 420px;
  margin: 0 auto;
  padding: 13px 15px 14px;
  border: 1px solid #fffbeb;
  border-radius: 23px;
  background: var(--paper);
  box-shadow: 0 7px 0 #9f6c3532, 0 9px 23px #72543443;
}

.guide-progress { display: flex; gap: 4px; margin-bottom: 7px; }
.guide-progress span { width: 17px; height: 3px; border-radius: 4px; background: #eadcbd; }
.guide-progress span.filled { background: #658b4a; }

.guide-topic {
  margin: 0 0 2px;
  color: #496b39;
  font-size: 11px;
  font-weight: 780;
  letter-spacing: .09em;
}

.guide h2, .settings-body h2, .future-content h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 850;
  line-height: 1.32;
  letter-spacing: .01em;
}

.guide-description, .settings-body p:not(.guide-topic), .future-content p:not(.guide-topic) {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.primary-button {
  min-height: 46px;
  width: 100%;
  border: 1px solid #8c3522;
  border-radius: 16px;
  color: #fffdf4;
  background: var(--coral);
  box-shadow: inset 0 1px 0 #ffffff52, 0 2px 0 #863522;
  font-size: 16px;
  font-weight: 780;
  letter-spacing: .045em;
}

.primary-button:not(:disabled):active { transform: translateY(1px); box-shadow: inset 0 1px 3px #79322088; }
.primary-button:disabled { cursor: default; background: #e9dbba; color: #604c34; border-color: #dac79c; box-shadow: none; }
[data-phase="complete"] .primary-button, .future-content .primary-button {
  background: #386742;
  border-color: #2a5133;
  box-shadow: inset 0 1px 0 #ffffff42, 0 2px 0 #27482f;
}

.guide-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -1px 0 9px;
  color: #4f6236;
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.guide-timer span { min-width: 36px; text-align: right; white-space: nowrap; }

.guide-timer progress {
  flex: 1;
  height: 7px;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
  appearance: none;
  background: #eadfca;
  color: #64894c;
}

.guide-timer progress::-webkit-progress-bar { background: #eadfca; }
.guide-timer progress::-webkit-progress-value { background: #64894c; transition: width .25s ease; }
.guide-timer progress::-moz-progress-bar { background: #64894c; }

.sheet-dialog, .future-dialog {
  border: 1px solid #fff6dc;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
}

.sheet-dialog {
  width: min(350px, calc(100% - 35px));
  border-radius: 24px;
  box-shadow: 0 12px 30px #19362242;
}

.sheet-dialog::backdrop, .future-dialog::backdrop { background: #213e4ba6; }
.settings-body { padding: 21px; }

.reset-button {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #794337;
  font-size: 13px;
  font-weight: 700;
}

.future-dialog {
  position: fixed;
  width: min(100%, 480px);
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  border: 0;
  overflow: hidden;
}

.future-art { position: absolute; inset: 0; background: #d8e9bf url("./assets/town-future.webp") center / cover no-repeat; }
.future-content {
  position: absolute;
  inset: auto 13px calc(13px + env(safe-area-inset-bottom, 0px));
  padding: 14px 15px;
  border: 1px solid #fffdf1;
  border-radius: 23px;
  background: #fffaf0f7;
  box-shadow: 0 8px 22px #23442e44;
}

.future-back {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: max(13px, calc(50% - 227px));
  width: 44px;
  height: 44px;
  padding: 0 0 6px;
  border: 1px solid #ffffffca;
  border-radius: 50%;
  color: #294649;
  background: #fffaf0f6;
  font-size: 32px;
  line-height: 1;
}

@keyframes emerging {
  from { opacity: 0; transform: translate(-50%, -88%) scale(.58); }
  to { opacity: 1; transform: translate(-50%, -95%) scale(1); }
}

@keyframes restored { from { opacity: 0; } to { opacity: 1; } }

@keyframes growing {
  from { transform: translate(-50%, -95%) scale(.55); transform-origin: bottom; }
  to { transform: translate(-50%, -95%) scale(1); transform-origin: bottom; }
}

@keyframes working {
  from { transform: translate(-50%, -95%) rotate(-5deg); }
  to { transform: translate(-50%, -102%) rotate(5deg); }
}

@keyframes point {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@media (min-width: 520px) {
  body {
    background: radial-gradient(ellipse at 45% 35%, #f5f9e5, #e1efeb 52%, #b1d5de);
  }

  .game { box-shadow: 0 0 65px #28524f37; }
}

@media (max-width: 345px) {
  .scene-hud { inset-inline: 7px; }
  .level-status, .balances { gap: 4px; padding-inline: 6px; }
  .balances > span + span { padding-left: 4px; }
}

@media (max-height: 690px) {
  .guide { padding: 10px 12px 11px; }
  .guide h2 { font-size: 19px; }
  .guide-description { margin-bottom: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
