:root {
  --bg-cream: #fcf7ec;
  --card-bg: #ffffff;
  --ink: #342b23;
  --muted: #6c5f52;
  --leaf: #569b51;
  --leaf-dark: #3b7437;
  --sky: #55a9c9;
  --warm-gold: #e69d35;
  --coral: #e57a62;
  --border: #e7dcc7;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-cream);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 14px 36px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 4px 12px rgba(90, 70, 40, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 50%;
  background: #edf7e4;
  border: 2px solid #c9e2b6;
}

.brand h1 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn, .back-btn, .action-btn {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fffdf8;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.14s ease, background 0.14s ease;
}

.pill-btn:active, .action-btn:active {
  transform: scale(0.97);
}

.primary-pill, .action-btn.primary {
  background: var(--leaf);
  border-color: var(--leaf-dark);
  color: #ffffff;
}

.action-btn {
  min-height: 58px;
  min-width: 128px;
  padding: 12px 18px;
  font-size: 1rem;
  border-radius: 16px;
}

.intro-banner {
  margin: 12px 0;
  padding: 12px 16px;
  background: #eef8e5;
  border: 2px solid #c7e2b4;
  border-radius: var(--radius);
  font-size: 0.94rem;
}

.intro-banner p { margin: 0; }

/* 地圖畫布 */
.map-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 520;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  background: #dff2ff;
  box-shadow: 0 6px 18px rgba(80, 65, 40, 0.08);
}

.map-bg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.map-pins {
  position: absolute;
  inset: 0;
}

.map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 60px;
  min-height: 60px;
  padding: 4px 7px;
  border-radius: 16px;
  border: 2px solid #fff;
  background: rgba(255, 252, 244, 0.94);
  box-shadow: 0 4px 10px rgba(45, 35, 20, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
}

.map-pin img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  pointer-events: none;
}

.map-pin.done {
  background: #eaf8e2;
  border-color: var(--leaf);
}

.map-pin .pin-tick {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--leaf);
  color: #fff;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
}

@media (max-width: 560px) {
  .map-pin {
    min-width: 42px;
    min-height: 42px;
    padding: 3px 5px;
    border-radius: 12px;
  }
  .map-pin img { width: 24px; height: 24px; }
  .map-pin span.pin-name { display: none; }
}

/* 分區卡片清單（手機上非常好點） */
.zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.zone-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.zone-card h2 {
  margin: 0 0 10px;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.station-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.station-btn {
  min-height: 64px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 14px;
  border: 2px solid #ede2ce;
  background: #fffcf6;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.station-btn:hover { border-color: var(--leaf); }
.station-btn.done { background: #f2faec; border-color: #b7dda7; }

.station-btn img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  object-fit: contain;
}

.station-meta {
  flex: 1;
}

.station-meta strong {
  display: block;
  font-size: 0.98rem;
}

.station-meta small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.station-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1e8d6;
  color: var(--muted);
  white-space: nowrap;
}

.station-btn.done .station-badge {
  background: var(--leaf);
  color: #fff;
}

/* 關卡內頁 */
.stage-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 8px;
}

.stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-title-wrap h2 {
  margin: 0;
  font-size: 1.25rem;
}

.zone-tag {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e3f2fd;
  color: #2c6282;
}

.speech-box {
  background: #ffffff;
  border: 2px solid #d5e7c9;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 0.96rem;
  margin-bottom: 10px;
  min-height: 48px;
}

.stage-playfield {
  position: relative;
  background: #eaf6fb;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 360px;
  user-select: none;
  touch-action: none;
}

.stage-canvas {
  width: 100%;
  height: 370px;
  display: block;
  cursor: pointer;
}

.stage-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

/* 互動卡片格（摸蜆、撿蛋、採百香果、拔蘿蔔、餵羊兔） */
.interactive-board {
  padding: 14px;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.hud-pill {
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  align-items: center;
  justify-items: center;
}

.tile-btn {
  width: 100%;
  min-height: 112px;
  padding: 10px 8px;
  border-radius: 18px;
  border: 2px solid rgba(255,255,255,0.85);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 4px 10px rgba(45, 35, 20, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  transition: transform 0.16s ease;
}

.tile-btn img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  pointer-events: none;
}

.tile-btn:active { transform: scale(0.95); }
.tile-btn.cleared {
  opacity: 0.52;
  background: rgba(240, 248, 232, 0.8);
}

/* 餵羊兔專屬 */
.pasture-stage {
  background: linear-gradient(180deg, #dff2ff 0%, #e7f4cb 42%, #cbe49a 100%);
}

.animals-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.animal-card {
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid #d5e6b9;
  border-radius: 18px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.animal-card.selected-target {
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(86, 155, 81, 0.25);
}

.animal-card img { width: 92px; height: 84px; object-fit: contain; }

.grass-tray {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.grass-btn {
  min-width: 72px;
  min-height: 68px;
  border-radius: 16px;
  border: 2px solid #96c77c;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px;
}

.grass-btn img { width: 42px; height: 38px; object-fit: contain; }
.grass-btn.used { opacity: 0.35; cursor: default; }

.notice-bar {
  font-size: 0.82rem;
  background: rgba(255, 252, 240, 0.92);
  border-radius: 12px;
  padding: 6px 10px;
  border: 1.5px solid #e7d8b5;
  color: var(--muted);
}

/* 對話框 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(34, 28, 22, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 22px;
  border: 2px solid var(--border);
  padding: 18px;
  box-shadow: 0 14px 32px rgba(25, 20, 10, 0.22);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h2 { margin: 0; font-size: 1.18rem; }

.close-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.sticker-item {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
  background: #faf6ec;
}

.sticker-item.earned {
  background: #f1faeb;
  border-color: var(--leaf);
}

.sticker-item img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: grayscale(1) opacity(0.35);
}

.sticker-item.earned img {
  filter: none;
}

.sticker-item strong { display: block; font-size: 0.88rem; margin-top: 4px; }
.sticker-item small { display: block; font-size: 0.75rem; color: var(--muted); }

.complete-card { text-align: center; }
.complete-art { display: block; margin: 0 auto 8px; object-fit: contain; }
.complete-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: #e9f6e0;
  color: var(--leaf-dark);
  font-weight: 700;
  font-size: 0.82rem;
}
.complete-note { font-size: 0.98rem; margin: 8px 0; }
.fact-box {
  background: #fff9eb;
  border: 1.5px solid #ead8ad;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: #4f4134;
  text-align: left;
}
.complete-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.reset-btn {
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid #e3c2ba;
  background: #fff5f3;
  color: #8c3d2b;
  font-size: 0.85rem;
  cursor: pointer;
}

/* 頁尾 */
.site-footer {
  margin-top: 24px;
  border-top: 2px solid var(--border);
  padding-top: 16px;
}

.parent-corner {
  background: #fffdf8;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.parent-corner h3 { margin: 0 0 8px; font-size: 1rem; }
.parent-corner ul { margin: 0; padding-left: 18px; font-size: 0.86rem; color: var(--muted); }
.parent-corner li + li { margin-top: 6px; }

.legal-line {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  transition: none !important;
  animation: none !important;
}
