:root {
  --sage: #dfe9d3;
  --sage-2: #c9dbb8;
  --cream: #faf4e6;
  --moss: #5f7a4a;
  --moss-dark: #42573a;
  --ink: #3b4634;
  --ink-soft: #66735c;
  --rose: #d9607a;
  --rose-dark: #b4465f;
  --gold: #f2b632;
  --card: #fffaf0;
  --shadow: 0 10px 30px rgba(50, 65, 40, 0.25);
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sage);
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 252, 240, 0.85), rgba(255, 252, 240, 0) 60%),
    linear-gradient(180deg, #e7efdb 0%, #d5e4c4 55%, #c4d8b0 100%);
}

button {
  font-family: inherit;
  touch-action: manipulation;
}

/* ---------- screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

/* ---------- buttons ---------- */

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #fff;
  background: linear-gradient(180deg, #e9798f 0%, var(--rose) 55%, var(--rose-dark) 100%);
  box-shadow:
    0 4px 0 #9b3a51,
    0 10px 18px rgba(120, 40, 60, 0.25);
  cursor: pointer;
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease;
  min-height: 48px;
}

.btn:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #9b3a51,
    0 4px 10px rgba(120, 40, 60, 0.25);
}

.btn.big {
  font-size: 22px;
  padding: 18px 40px;
  animation: breathe 2.4s ease-in-out infinite;
}

.btn.ghost {
  color: var(--moss-dark);
  background: linear-gradient(180deg, #fbf8ee, #ece6d3);
  box-shadow:
    0 4px 0 #cfc6ab,
    0 8px 14px rgba(60, 70, 40, 0.15);
}

.btn.ghost:active {
  box-shadow: 0 1px 0 #cfc6ab;
}

.btn.danger {
  color: var(--rose-dark);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  font-size: 20px;
  font-weight: 900;
  color: var(--moss-dark);
  background: rgba(255, 252, 240, 0.85);
  box-shadow: 0 3px 0 rgba(90, 110, 70, 0.35);
  cursor: pointer;
  flex: none;
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(90, 110, 70, 0.35);
}

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

/* ---------- title ---------- */

#screen-title {
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.title-flowers {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.title-flowers .drift {
  position: absolute;
  top: 105%;
  opacity: 0.85;
  animation-name: drift;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 4px 6px rgba(50, 60, 30, 0.2));
}

@keyframes drift {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  100% {
    transform: translateY(-125vh) rotate(360deg);
  }
}

.title-box {
  position: relative;
  text-align: center;
  padding: 30px 26px 34px;
  border-radius: 34px;
  background: rgba(255, 250, 238, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  margin: 0 16px;
}

.logo {
  margin: 0;
  font-size: clamp(56px, 18vw, 86px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -1px;
  display: flex;
  flex-direction: column;
}

.logo .l1 {
  color: var(--rose);
  text-shadow: 0 4px 0 #b4465f33;
  animation: bob 3s ease-in-out infinite;
}

.logo .l2 {
  color: var(--moss);
  text-shadow: 0 4px 0 #42573a33;
  animation: bob 3s ease-in-out 0.4s infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-6px) rotate(1deg);
  }
}

.tagline {
  margin: 10px 0 24px;
  color: var(--ink-soft);
  font-size: 17px;
  font-weight: 700;
}

/* ---------- map: a stepping-stone path through the gardens ---------- */

#screen-map {
  background: #a9bf8c;
}

.map-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  gap: 8px;
  background: linear-gradient(180deg, rgba(250, 245, 230, 0.96), rgba(250, 245, 230, 0.85));
  box-shadow: 0 4px 14px rgba(50, 60, 35, 0.25);
}

.map-top h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  color: var(--moss-dark);
}

.map-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.map-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.map-path {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
}

.map-lawn {
  position: absolute;
  left: 0;
  right: 0;
  background: url("art/map-lawn.jpg") center / 100% 100% no-repeat;
}

.map-lawn.flip {
  transform: scaleY(-1);
}

/* where a garden begins: a soft window onto that garden's own backdrop */
.map-band {
  position: absolute;
  left: 0;
  right: 0;
  background-size: cover;
  background-position: center 70%;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 35%, #000 65%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 35%, #000 65%, transparent 100%);
  opacity: 0.9;
}

.path-stone {
  position: absolute;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 2px 1.5px rgba(30, 40, 20, 0.35));
}

.map-sign {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  padding: 8px 18px 9px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0) 0 9px, rgba(60, 30, 10, 0.12) 9px 10px),
    linear-gradient(180deg, #b98552, #8e5f33);
  border: 2px solid #6e4524;
  box-shadow:
    0 4px 0 #5a381c,
    0 10px 16px rgba(40, 25, 10, 0.35);
  white-space: nowrap;
  z-index: 1;
}

.map-sign::before,
.map-sign::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4f3418;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-50%);
}

.map-sign::before {
  left: 6px;
}

.map-sign::after {
  right: 6px;
}

.map-sign-text {
  color: #fff4dc;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 0 rgba(60, 30, 10, 0.6);
}

/* each level is a painted flagstone */
.level-node {
  position: absolute;
  width: 84px;
  height: 56px;
  margin: -28px 0 0 -42px;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.level-node:active {
  transform: translateY(3px);
}

.node-stone {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 5px 3px rgba(30, 35, 20, 0.4));
}

.node-num {
  position: relative;
  font-size: 23px;
  font-weight: 900;
  color: #fff7e4;
  -webkit-text-stroke: 1px rgba(60, 45, 30, 0.55);
  text-shadow:
    0 2px 0 rgba(60, 45, 30, 0.75),
    0 0 6px rgba(40, 30, 20, 0.45);
}

.level-node.done .node-num {
  color: #f6ffe6;
}

.level-node.current {
  animation: none;
}

.level-node.current::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid rgba(255, 220, 120, 0.95);
  box-shadow: 0 0 18px rgba(255, 220, 120, 0.9);
  animation: glow 1.6s ease-in-out infinite;
  pointer-events: none;
}

.level-node.current .node-num {
  color: #ffe3ea;
}

@keyframes glow {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

.level-node.locked {
  cursor: default;
  filter: saturate(0.5) brightness(0.82);
}

.level-node.locked .node-num {
  color: rgba(255, 247, 228, 0.7);
}

.node-flower {
  position: absolute;
  right: -10px;
  top: -12px;
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 2px rgba(40, 40, 20, 0.35));
}

.node-marker {
  position: absolute;
  left: 50%;
  top: -46px;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  filter: drop-shadow(0 4px 3px rgba(40, 40, 20, 0.4));
  animation: hover-bob 1.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes hover-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

.node-stars {
  position: absolute;
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%);
  padding: 1px 6px 2px;
  border-radius: 8px;
  background: linear-gradient(180deg, #9a6a3c, #7a4f2a);
  box-shadow: 0 2px 0 #5a381c;
  font-size: 12px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: rgba(255, 240, 210, 0.35);
  line-height: 1.3;
}

.node-stars .on {
  color: var(--gold);
  text-shadow: 0 1px 0 #6b4a0a;
}

#garden-map {
  z-index: 1;
}

.goal-left {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--rose-dark);
  font-size: 14px;
  white-space: nowrap;
}

/* ---------- game HUD ---------- */

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 4px;
}

.hud-moves {
  flex: none;
  width: 70px;
  height: 70px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffaf0, #efe6cf);
  box-shadow: 0 4px 0 #cfc6ab;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hud-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
}

.hud-big {
  font-size: 30px;
  font-weight: 900;
  color: var(--moss-dark);
  line-height: 1;
}

.hud-big.low {
  color: var(--rose-dark);
}

.hud-big.bump {
  animation: bump 0.3s ease;
}

@keyframes bump {
  40% {
    transform: scale(1.25);
  }
}

.hud-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-level {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
  text-align: center;
}

.hud-goals {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.goal {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.9);
  box-shadow: 0 3px 0 rgba(120, 130, 90, 0.35);
  transition: background 0.3s ease;
}

.goal.met {
  background: #e3f0d3;
}

.goal-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.star-icon {
  color: var(--gold);
  font-size: 26px;
}

.goal-count {
  font-size: 18px;
  font-weight: 900;
  color: var(--moss-dark);
  min-width: 18px;
}

.goal.met .goal-count {
  color: var(--moss);
}

.hud-score {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 18px 0;
}

.score-bar {
  position: relative;
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.8);
  box-shadow: inset 0 2px 3px rgba(70, 80, 50, 0.25);
}

.score-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #f6cf58, var(--gold));
  box-shadow: 0 0 8px rgba(242, 182, 50, 0.6);
}

.star-mark {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  line-height: 1;
  color: #d8d2bf;
  text-shadow: 0 1px 0 rgba(90, 90, 60, 0.4);
  transition:
    color 0.3s ease,
    transform 0.3s ease;
}

.star-mark.on {
  color: var(--gold);
  transform: translate(-50%, -50%) scale(1.2);
  text-shadow: 0 1px 0 #a8770f;
}

.score-num {
  min-width: 70px;
  text-align: right;
  font-size: 20px;
  font-weight: 900;
  color: var(--moss-dark);
  font-variant-numeric: tabular-nums;
}

.board-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  padding-bottom: 6px;
}

/* ---------- painted gardens (top-down backyards, one per section) ---------- */

.garden-1,
.garden-2,
.garden-3 {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.garden-1 {
  background-image: url("art/garden-1.jpg");
  background-color: #b7c99a;
}

.garden-2 {
  background-image: url("art/garden-2.jpg");
  background-color: #d9a888;
}

.garden-3 {
  background-image: url("art/garden-3.jpg");
  background-color: #b9c98f;
}

#screen-game,
#screen-title {
  z-index: 0;
}

/* soft veil so the board and HUD stay the focus */
#screen-game::before,
#screen-title::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(90% 60% at 50% 48%, rgba(250, 246, 232, 0.28), rgba(250, 246, 232, 0.05) 70%);
}

#screen-title::before {
  background: rgba(244, 240, 222, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.garden-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#garden-game {
  z-index: -1;
}

.hud {
  position: relative;
}

.hud::before {
  content: "";
  position: absolute;
  left: -20px;
  right: -20px;
  top: calc(-1 * var(--safe-top) - 20px);
  bottom: -46px;
  z-index: -1;
  background: linear-gradient(180deg, rgba(250, 245, 230, 0.92) 30%, rgba(250, 245, 230, 0));
  pointer-events: none;
}

.score-num {
  text-shadow: 0 1px 0 rgba(255, 250, 235, 0.9);
}

.board-wrap canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  display: block;
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(45, 60, 35, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.card {
  width: 100%;
  max-width: 360px;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  border-radius: 30px;
  padding: 24px 22px 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
  transform: scale(0.85);
  opacity: 0;
  transition:
    transform 0.28s cubic-bezier(0.2, 1.4, 0.4, 1),
    opacity 0.2s ease;
}

.modal.open .card {
  transform: none;
  opacity: 1;
}

.card h2 {
  margin: 2px 0 14px;
  font-size: 28px;
  font-weight: 900;
  color: var(--moss-dark);
}

.card-kicker {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--rose);
}

.goal-list,
.help-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  text-align: left;
}

.goal-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 16px;
  background: #f4eedc;
  font-weight: 800;
  font-size: 16px;
}

.goal-list li.met {
  background: #e3f0d3;
  color: var(--moss);
}

.goal-list li.met::after {
  content: "✓";
  margin-left: auto;
  font-weight: 900;
}

.help-list li {
  padding: 8px 4px;
  border-bottom: 1px dashed #ddd3b8;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.moves-line {
  margin: 4px 0 8px;
  font-weight: 900;
  font-size: 18px;
  color: var(--ink-soft);
}

.tip {
  margin: 6px 0 14px;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
  color: var(--ink-soft);
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.btn-row .btn {
  flex: 1;
  padding-left: 12px;
  padding-right: 12px;
}

.btn-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 2px 0 6px;
}

.big-star {
  font-size: 58px;
  line-height: 1;
  color: #e2dcc8;
  transform: scale(0.7);
  transition:
    color 0.2s ease,
    transform 0.35s cubic-bezier(0.2, 1.8, 0.4, 1);
}

.big-star:nth-child(2) {
  transform: translateY(-10px) scale(0.7);
}

.big-star.on {
  color: var(--gold);
  transform: scale(1.1);
  text-shadow: 0 3px 0 #a8770f;
}

.big-star:nth-child(2).on {
  transform: translateY(-10px) scale(1.25);
}

.result-score {
  margin: 4px 0;
  font-size: 34px;
  font-weight: 900;
  color: var(--moss-dark);
}

.new-best {
  margin: 0 0 6px;
  color: var(--rose);
  font-weight: 900;
}

@media (prefers-reduced-motion: reduce) {
  .btn.big,
  .logo span,
  .level-node.current,
  .title-flowers .drift {
    animation: none;
  }
}

@media (min-height: 820px) {
  .hud-moves {
    width: 78px;
    height: 78px;
  }
}
