:root {
  --bg: #0f1a24;
  --panel: #1a2a3a;
  --soil: #3d2914;
  --soil-edge: #5c3d1e;
  --leaf: #6ee7b7;
  --text: #f0f6fc;
  --muted: #b6c7d9;
  --accent: #7dd3fc;
  --good: #6ee7b7;
  --warn: #fbbf24;
  --danger: #fca5a5;
  --shadow: rgba(0, 0, 0, 0.35);
  --touch: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --radius: 16px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 0;
  display: flex;
  flex-direction: column;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background:
    radial-gradient(ellipse at 15% 0%, #1e3a5f 0%, transparent 50%),
    radial-gradient(ellipse at 85% 100%, #14532d 0%, transparent 48%),
    var(--bg);
  color: var(--text);
  padding:
    max(0.5rem, var(--safe-t))
    max(0.65rem, var(--safe-r))
    max(0.5rem, var(--safe-b))
    max(0.65rem, var(--safe-l));
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  color: inherit;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app {
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.screen.hidden,
.overlay.hidden,
.hidden {
  display: none !important;
}

.top-header {
  text-align: center;
  flex-shrink: 0;
}

.top-header h1 {
  font-size: clamp(1.05rem, 3.6vw, 1.4rem);
  letter-spacing: 0.04em;
  color: var(--accent);
  line-height: 1.35;
  font-weight: 800;
}

.gentle {
  color: var(--muted);
  font-size: clamp(0.92rem, 2.7vw, 1.08rem);
  line-height: 1.45;
  margin-top: 0.3rem;
  font-weight: 600;
}

.gentle.tiny {
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.top-actions {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.55rem;
  flex-wrap: wrap;
}

.btn-chip {
  min-height: 48px;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.12);
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: var(--accent);
  font-weight: 800;
  font-size: 1rem;
}

.panel,
.home-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid rgba(125, 211, 252, 0.15);
  border-radius: var(--radius);
  padding: 0.9rem 0.9rem 1rem;
  box-shadow: 0 8px 24px var(--shadow);
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.section-label {
  font-size: clamp(0.98rem, 2.9vw, 1.12rem);
  font-weight: 800;
  color: var(--warn);
  margin: 0.4rem 0 0.5rem;
}

.section-label.small {
  font-size: 0.95rem;
  margin: 0.55rem 0 0.35rem;
  color: var(--muted);
}

.player-chips,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.player-chips button,
.chip {
  min-height: var(--touch);
  min-width: 5.5rem;
  padding: 0.55rem 0.9rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 2px solid rgba(155, 176, 196, 0.25);
  color: var(--text);
  font-weight: 800;
  font-size: clamp(1rem, 3vw, 1.15rem);
}

.player-chips button.active,
.chip.active {
  border-color: var(--warn);
  background: rgba(251, 191, 36, 0.18);
  color: var(--warn);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.current-player {
  margin-top: 0.65rem;
  font-size: 1.15rem;
  font-weight: 800;
}

.current-player span {
  color: var(--warn);
}

.hint-line {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
  font-weight: 600;
}

.btn-start,
.btn.big,
.btn-primary.big,
.btn-secondary.big,
.btn-ghost.big,
.btn-warn.big {
  min-height: 72px;
  width: 100%;
  margin-top: 0.85rem;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.btn-start,
.btn-primary {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  color: #052e16;
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.35);
}

.btn-secondary {
  background: linear-gradient(180deg, #7dd3fc 0%, #0ea5e9 100%);
  color: #082f49;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.btn-warn {
  background: linear-gradient(180deg, #fca5a5 0%, #ef4444 100%);
  color: #450a0a;
}

/* —— 遊戲中 —— */
.game-header {
  background: var(--panel);
  border: 1px solid rgba(110, 231, 183, 0.18);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  flex-shrink: 0;
}

.game-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.game-title {
  font-size: 1.15rem;
  color: var(--leaf);
  font-weight: 900;
}

.play-player {
  font-weight: 900;
  color: var(--warn);
  font-size: 1.05rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

.stat {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 0.4rem 0.25rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.stat-value {
  display: block;
  font-size: clamp(0.95rem, 3vw, 1.15rem);
  font-weight: 900;
  color: var(--text);
  margin-top: 0.1rem;
}

.level-name {
  margin-top: 0.4rem;
  text-align: center;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.98rem;
}

.toast-line {
  min-height: 1.35em;
  margin-top: 0.25rem;
  text-align: center;
  color: var(--good);
  font-weight: 800;
  font-size: 0.95rem;
}

.game-header.compact {
  padding: 0.5rem 0.7rem 0.45rem;
}

.game-header.compact .stats {
  gap: 0.28rem;
}

.game-header.compact .stat {
  padding: 0.28rem 0.2rem;
}

/* —— 整片菜園場景 —— */
.garden-scene {
  position: relative;
  flex: 1 1 auto;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: auto;
  border: 2px solid rgba(110, 231, 183, 0.25);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  background: #1a3a28;
}

.scene-sky {
  position: relative;
  height: 52px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #7dd3fc 0%, #bae6fd 55%, #86efac 100%);
  overflow: hidden;
}

.cloud {
  position: absolute;
  font-size: 1.4rem;
  opacity: 0.85;
  animation: cloud-drift 18s linear infinite;
}

.cloud.c1 { top: 6px; left: 8%; }
.cloud.c2 { top: 18px; left: 55%; animation-duration: 24s; animation-direction: reverse; }

.butterfly {
  position: absolute;
  font-size: 1.05rem;
  animation: butterfly-fly 9s ease-in-out infinite;
}

.butterfly.b1 { top: 10px; left: 30%; }
.butterfly.b2 { top: 22px; left: 70%; animation-delay: -3s; animation-duration: 11s; }

/* 小雞／兔子／松鼠 */
.critters {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  height: 48px;
  z-index: 1;
  pointer-events: none;
}

.critter {
  position: absolute;
  bottom: 0;
  font-size: 1.55rem;
  line-height: 1;
  background: transparent;
  border: none;
  padding: 0.15rem;
  pointer-events: none;
  cursor: default;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
  -webkit-tap-highlight-color: transparent;
}

.critter:active {
  transform: scale(1.2);
}

.critter.chicken.ch1 {
  left: 6%;
  animation: critter-peck 2.4s ease-in-out infinite, critter-walk-right 22s linear infinite;
}
.critter.chicken.ch2 {
  left: 18%;
  font-size: 1.25rem;
  animation: critter-peck 1.8s ease-in-out infinite, critter-walk-left 18s linear infinite;
  animation-delay: -1s, -4s;
}
.critter.rabbit.rb1 {
  left: 55%;
  animation: critter-hop 1.1s ease-in-out infinite, critter-walk-right 26s linear infinite;
  animation-delay: 0s, -8s;
}
.critter.rabbit.rb2 {
  left: 72%;
  font-size: 1.35rem;
  animation: critter-hop 1.3s ease-in-out infinite, critter-walk-left 20s linear infinite;
  animation-delay: -0.4s, -2s;
}
.critter.squirrel.sq1 {
  left: 40%;
  animation: critter-scurry 0.9s ease-in-out infinite, critter-walk-right 16s linear infinite;
  animation-delay: -0.2s, -6s;
}

@keyframes critter-peck {
  0%, 70%, 100% { transform: translateY(0) rotate(0deg); }
  80% { transform: translateY(3px) rotate(12deg); }
  90% { transform: translateY(0) rotate(-6deg); }
}

@keyframes critter-hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-4px); }
}

@keyframes critter-scurry {
  0%, 100% { transform: translateY(0) scaleX(1); }
  50% { transform: translateY(-3px) scaleX(1); }
}

@keyframes critter-walk-right {
  0% { margin-left: 0; }
  50% { margin-left: 42px; }
  100% { margin-left: 0; }
}

@keyframes critter-walk-left {
  0% { margin-left: 0; }
  50% { margin-left: -36px; }
  100% { margin-left: 0; }
}

/* 收成慶祝：媽媽跳舞（對齊連連看） */
.dance-stage {
  height: clamp(160px, 28vh, 240px);
  margin: 0 auto 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.dance-photo-wrap {
  position: relative;
  width: min(200px, 50vw);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
  border-radius: 16px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.18);
}

.dance-photo-wrap video {
  max-height: 100%;
  max-width: 100%;
  width: auto;
  height: 100%;
  object-fit: contain;
  border-radius: 14px;
  pointer-events: none;
}

.dance-note {
  position: absolute;
  font-size: 1.2rem;
  opacity: 0.9;
  z-index: 2;
  animation: note-float 1.1s ease-in-out infinite;
}

.dance-note.n1 { left: 8%; top: 12%; }
.dance-note.n2 { right: 10%; top: 20%; animation-delay: 0.25s; }
.dance-note.n3 { left: 14%; bottom: 18%; animation-delay: 0.5s; }

@keyframes note-float {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(-8px); opacity: 1; }
}

.cele-music-btn {
  display: block;
  width: 100%;
  margin: 0 0 0.55rem;
  min-height: 52px;
  border: 2px solid rgba(251, 191, 36, 0.85);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  color: #1a1205;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.35);
  animation: music-pulse 1.2s ease-in-out infinite;
}

.cele-music-btn.playing {
  border-color: rgba(110, 231, 183, 0.85);
  background: linear-gradient(180deg, #6ee7b7, #34d399);
  color: #052e1a;
  animation: none;
  box-shadow: 0 4px 16px rgba(110, 231, 183, 0.3);
}

@keyframes music-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.field-sign {
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  text-align: center;
  pointer-events: none;
}

.sign-board {
  display: inline-block;
  background: linear-gradient(180deg, #fde68a, #d97706);
  color: #451a03;
  font-weight: 900;
  font-size: clamp(0.95rem, 3.2vw, 1.12rem);
  padding: 0.35rem 0.9rem;
  border-radius: 8px;
  border: 3px solid #92400e;
  box-shadow: 0 4px 0 #78350f, 0 6px 12px rgba(0, 0, 0, 0.25);
}

.next-hint {
  position: relative;
  z-index: 4;
  margin: 1.55rem 0.5rem 0.35rem;
  text-align: center;
  font-weight: 900;
  font-size: clamp(0.95rem, 3vw, 1.1rem);
  color: #052e16;
  background: rgba(254, 249, 195, 0.92);
  border: 2px solid #ca8a04;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.field-body {
  flex: 1 1 auto;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    linear-gradient(180deg, #4d7c0f 0%, #3f6212 12%, #5c3d1e 18%, #3d2914 100%);
  padding: 0.35rem 0.55rem 0.55rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.field-grass-top {
  height: 10px;
  margin: 0 -0.55rem 0.35rem;
  background: repeating-linear-gradient(
    90deg,
    #65a30d 0 10px,
    #4d7c0f 10px 18px
  );
  border-radius: 0 0 4px 4px;
  opacity: 0.9;
}

.field-soil-bed {
  flex: 1 1 auto;
  min-height: 220px;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(140, 95, 50, 0.45) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 70%, rgba(90, 55, 28, 0.5) 0%, transparent 45%),
    linear-gradient(180deg, #7a4e28 0%, #523318 40%, #3d2914 100%);
  border: 4px solid #1a1008;
  border-radius: 16px;
  padding: 0.55rem;
  box-shadow: inset 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(251, 191, 36, 0.2);
}

.field-grass-edge {
  height: 14px;
  margin: 0.35rem -0.55rem -0.15rem;
  background: linear-gradient(180deg, #65a30d, #3f6212);
  border-radius: 4px;
}

.basket-dock {
  position: absolute;
  right: 0.45rem;
  bottom: 0.45rem;
  z-index: 8;
}

.basket {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 26, 36, 0.88);
  border: 2px solid #fbbf24;
  border-radius: 16px;
  padding: 0.4rem 0.55rem;
  min-width: 108px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s;
}

.basket.pop {
  animation: basket-pop 0.45s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.basket-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.basket-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.basket-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 800;
}

.basket-count {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--warn);
}

.basket-last {
  font-size: 1.15rem;
  min-width: 1.2em;
}

/* 選菜列：大按鈕，左右滑 */
.seed-picker {
  flex-shrink: 0;
  background: rgba(26, 42, 58, 0.98);
  border: 1px solid rgba(125, 211, 252, 0.25);
  border-radius: 14px;
  padding: 0.45rem 0.4rem 0.5rem;
}

.seed-picker-title {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--warn);
  text-align: center;
  margin-bottom: 0.35rem;
}

.seed-picker-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0.2rem 0.35rem;
  scroll-snap-type: x mandatory;
}

.seed-pick-btn {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-width: 4.6rem;
  min-height: 4.6rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 3px solid rgba(155, 176, 196, 0.28);
  color: var(--text);
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.4rem;
}

.seed-pick-btn .pick-emoji {
  font-size: 1.65rem;
  line-height: 1;
}

.seed-pick-btn .pick-name {
  font-size: 0.78rem;
  line-height: 1.1;
  white-space: nowrap;
}

.seed-pick-btn.active {
  border-color: var(--warn);
  background: rgba(251, 191, 36, 0.22);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35);
  color: var(--warn);
}

.seed-picker-current {
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.seed-picker-current span {
  color: var(--good);
  font-weight: 900;
}

.fly-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.fly-emoji {
  position: fixed;
  font-size: 2rem;
  z-index: 91;
  pointer-events: none;
  transition: left 0.55s cubic-bezier(0.4, 0, 0.2, 1), top 0.55s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.55s ease, opacity 0.55s ease;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.plots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  height: auto;
  min-height: 220px;
  align-content: start;
}

@media (min-width: 520px) {
  .plots {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 土地坑：整格可點 */
.plot {
  position: relative;
  z-index: 2;
  min-height: 148px;
  border-radius: 50% 50% 42% 42% / 38% 38% 62% 62%;
  background:
    radial-gradient(ellipse at 50% 35%, #a06a35 0%, #6b4423 42%, #3d2914 100%);
  border: 4px solid #1a1008;
  padding: 0.45rem 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
  box-shadow:
    inset 0 6px 14px rgba(0, 0, 0, 0.4),
    0 5px 0 #120a04,
    0 0 0 1px rgba(253, 224, 71, 0.18);
  overflow: visible;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.15s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.plot:active:not(.locked) {
  transform: scale(0.97);
}

.plot.empty-soil {
  /* 空地微光，提示可點 */
  box-shadow:
    inset 0 6px 14px rgba(0, 0, 0, 0.4),
    0 5px 0 #120a04,
    0 0 0 3px rgba(253, 224, 71, 0.4);
}

.plot.empty-soil::after {
  content: "點土種植";
  position: absolute;
  bottom: 0.4rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  font-weight: 900;
  color: #fef08a;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  pointer-events: none;
}

.plot.has-crop.empty-soil::after,
.plot.locked::after {
  content: none;
}

.plot.locked {
  opacity: 0.55;
  filter: grayscale(0.3);
}

.plot.ready {
  border-color: var(--warn);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  animation: plot-ready-glow 1.6s ease-in-out infinite;
}

.plot.growing {
  border-color: rgba(110, 231, 183, 0.45);
}

.plot.dry {
  border-color: rgba(251, 191, 36, 0.35);
}

.plot-stage-label {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--warn);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  z-index: 2;
}

.plot-plant-wrap {
  position: relative;
  width: 100%;
  height: 3.4rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-top: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  pointer-events: none;
}

.plot-emoji {
  font-size: 2.35rem;
  line-height: 1;
  display: inline-block;
  transform-origin: 50% 90%;
  transform: scale(var(--grow-scale, 1));
  transition: transform 0.45s cubic-bezier(0.34, 1.45, 0.64, 1), filter 0.3s;
  will-change: transform;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.plot.growing .plot-emoji {
  animation: plant-sway 2.8s ease-in-out infinite;
}

.plot.ready .plot-emoji {
  animation: plant-bounce 1.1s ease-in-out infinite;
}

.plot.dry .plot-emoji {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)) saturate(0.75);
}

/* 點擊作物：開心跳一下 */
.plot-emoji.cheer {
  animation: plant-cheer 0.55s cubic-bezier(0.34, 1.5, 0.64, 1) !important;
}

.plot-emoji.pop-in {
  animation: plant-pop-in 0.55s cubic-bezier(0.34, 1.5, 0.64, 1) !important;
}

.plot-emoji.harvest-fly {
  animation: harvest-fly 0.7s ease-in forwards !important;
}

.plot-name {
  font-weight: 900;
  font-size: 0.88rem;
  text-align: center;
  color: #fef3c7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  line-height: 1.15;
  max-width: 100%;
}

.plot-status {
  font-size: 0.72rem;
  color: #e7e5e4;
  font-weight: 800;
  text-align: center;
  min-height: 1.1em;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  padding: 0 0.15rem;
}

/* 成長進度條 */
.grow-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.grow-bar.hidden-bar {
  visibility: hidden;
}

.grow-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4ade80, #fbbf24 70%, #f472b6);
  transition: width 0.45s linear;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.45);
}

.plot.ready .grow-bar-fill {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  animation: bar-shimmer 1.2s ease-in-out infinite;
}

/* 土地操作以點整格為主，小按鈕僅輔助（可隱藏） */
.plot-btn {
  display: none;
}

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

@keyframes butterfly-fly {
  0%, 100% { transform: translate(0, 0) rotate(-8deg); }
  50% { transform: translate(18px, -8px) rotate(10deg); }
}

@keyframes basket-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* —— 特效層：水滴／星星／泥土 —— */
.plot-fx {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
}

.fx-drop {
  position: absolute;
  font-size: 1.1rem;
  opacity: 0;
  animation: drop-fall 0.9s ease-in forwards;
}

.fx-spark {
  position: absolute;
  font-size: 1rem;
  opacity: 0;
  animation: spark-burst 0.85s ease-out forwards;
}

.fx-dirt {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a16207;
  opacity: 0;
  animation: dirt-pop 0.65s ease-out forwards;
}

@keyframes plant-sway {
  0%, 100% { transform: scale(var(--grow-scale, 1)) rotate(-3deg); }
  50% { transform: scale(var(--grow-scale, 1)) rotate(3deg); }
}

@keyframes plant-bounce {
  0%, 100% { transform: scale(var(--grow-scale, 1.2)) translateY(0); }
  50% { transform: scale(calc(var(--grow-scale, 1.2) * 1.08)) translateY(-6px); }
}

@keyframes plant-cheer {
  0% { transform: scale(var(--grow-scale, 1)); }
  35% { transform: scale(calc(var(--grow-scale, 1) * 1.35)) translateY(-10px) rotate(-8deg); }
  60% { transform: scale(calc(var(--grow-scale, 1) * 1.1)) translateY(-2px) rotate(6deg); }
  100% { transform: scale(var(--grow-scale, 1)); }
}

@keyframes plant-pop-in {
  0% { transform: scale(0.15) translateY(18px); opacity: 0.2; }
  60% { transform: scale(calc(var(--grow-scale, 1) * 1.2)) translateY(-4px); opacity: 1; }
  100% { transform: scale(var(--grow-scale, 1)) translateY(0); opacity: 1; }
}

@keyframes harvest-fly {
  0% { transform: scale(var(--grow-scale, 1.2)) translateY(0); opacity: 1; }
  100% { transform: scale(0.4) translateY(-70px); opacity: 0; }
}

@keyframes drop-fall {
  0% { transform: translateY(-12px) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(72px) scale(1); opacity: 0; }
}

@keyframes spark-burst {
  0% { transform: translate(0, 0) scale(0.4); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(var(--dx, 20px), var(--dy, -40px)) scale(1.2); opacity: 0; }
}

@keyframes dirt-pop {
  0% { transform: translate(0, 0) scale(0.5); opacity: 0.9; }
  100% { transform: translate(var(--dx, 10px), var(--dy, -20px)) scale(0.2); opacity: 0; }
}

@keyframes plot-ready-glow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.25); }
  50% { box-shadow: 0 0 12px 3px rgba(251, 191, 36, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.25); }
}

@keyframes bar-shimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

@media (prefers-reduced-motion: reduce) {
  .plot.growing .plot-emoji,
  .plot.ready .plot-emoji,
  .plot-emoji.cheer,
  .plot-emoji.pop-in,
  .plot.ready,
  .cloud,
  .butterfly,
  .critter,
  .dance-note,
  .cele-music-btn,
  .basket.pop {
    animation: none !important;
  }
  .grow-bar-fill,
  .fly-emoji {
    transition: none;
  }
}

.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-bottom: 0.15rem;
}

.btn.action-btn {
  min-height: 58px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 1.02rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn.action-btn.primary {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  border: none;
  color: #052e16;
}

.btn.action-btn.ghost {
  background: rgba(0, 0, 0, 0.22);
}

/* —— Overlay —— */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5, 12, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(0.75rem, var(--safe-t))
    max(0.75rem, var(--safe-r))
    max(0.75rem, var(--safe-b))
    max(0.75rem, var(--safe-l));
  overflow-y: auto;
}

.overlay-card {
  width: min(560px, 100%);
  max-height: min(92dvh, 900px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border: 1px solid rgba(125, 211, 252, 0.2);
  border-radius: 18px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.overlay-card h2 {
  text-align: center;
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  color: var(--warn);
  font-weight: 900;
  margin-bottom: 0.4rem;
}

.win-emoji {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.win-msg,
.win-rank {
  text-align: center;
  font-weight: 800;
  line-height: 1.45;
  margin: 0.35rem 0;
}

.win-rank {
  color: var(--good);
  font-size: 1.02rem;
}

.win-label {
  text-align: center;
}

.win-actions,
.shop-actions,
.confirm-actions,
.lb-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 72px;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(155, 176, 196, 0.22);
}

.shop-item.active {
  border-color: var(--warn);
  background: rgba(251, 191, 36, 0.12);
}

.shop-item.locked {
  opacity: 0.55;
}

.shop-item .emoji {
  font-size: 1.8rem;
  width: 2.2rem;
  text-align: center;
}

.shop-item .meta {
  flex: 1;
  min-width: 0;
}

.shop-item .name {
  font-weight: 900;
  font-size: 1.08rem;
}

.shop-item .sub {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.shop-item .price {
  font-weight: 900;
  color: var(--warn);
  white-space: nowrap;
}

.help-list {
  margin: 0.75rem 0 0.75rem 1.2rem;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.65;
  font-weight: 700;
}

.lb-current {
  text-align: center;
  font-weight: 800;
  color: var(--muted);
}

.lb-current span {
  color: var(--warn);
  margin-left: 0.25rem;
}

.lb-rank-banner {
  margin: 0.5rem 0 0.35rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(110, 231, 183, 0.1);
  border: 1px solid rgba(110, 231, 183, 0.25);
  text-align: center;
  font-weight: 800;
  color: var(--good);
  min-height: 2.4em;
}

.lb-table-wrap {
  margin-top: 0.55rem;
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lb-empty {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  padding: 1rem 0.5rem;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.lb-table th,
.lb-table td {
  padding: 0.55rem 0.35rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.lb-table th {
  color: var(--muted);
  font-size: 0.82rem;
  position: sticky;
  top: 0;
  background: var(--panel);
}

.lb-table tr.me td {
  color: var(--warn);
}

.lb-table tr.highlight {
  background: rgba(251, 191, 36, 0.1);
}

.btn-linkish {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  min-height: 44px;
  text-decoration: underline;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 380px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .game-actions {
    grid-template-columns: 1fr;
  }
}


/* P1.2 win celebrate */
.overlay:not(.hidden) .win-card h2,
.overlay:not(.hidden) #win-title {
  font-size: clamp(1.9rem, 7vw, 2.75rem);
  color: #fde68a;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 12px rgba(251, 191, 36, 0.5);
}
.overlay:not(.hidden) .overlay-card.win-card {
  border: 2px solid rgba(251, 191, 36, 0.55);
}
