:root {
  /* 卡卡頌美術色盤（手繪風） */
  --grass: #83a851;
  --grass-2: #67903c;
  --grass-3: #a4c56c;
  --road: #e7d3a0;
  --road-2: #c9ac72;
  --road-edge: #b89a63;
  --road-line: rgba(84, 60, 26, 0.45);
  --city: #b06a3c;
  --city-2: #8a5027;
  --city-hi: #cf9560;
  --city-shadow: #7f4a26;
  --wall: #efe3c2;
  --wall-2: #d6c49a;
  --roof: #b83d2b;
  --roof-2: #8c2c1f;
  --roof-hi: #d15f48;
  --wood: #6d4a28;
  --flag: #dcae43;
  --water: #4a7290;
  --stone: #b6ab98;
  --ink: #362a1a;
  --tile-border: #362a1a;

  /* 介面色 */
  --parch: #f6ecd2;
  --parch-line: #d9c79a;
  --ink: #2e2417;
  --ink-soft: #6a5a41;
  --accent: #b06a3c;
  --accent-dark: #8a5230;
  --radius: 14px;
  --max: 1000px;

  /* 字型套用改由 justfont 後台的「CSS 設定」控制；此處僅為後備字型 */
  --serif: "Iowan Old Style", "Palatino Linotype", "Noto Serif TC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 62px; }

body {
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.75;
  background: #5f7d3e;
}

/* ===== 全填滿的板塊背景 ===== */
#board-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  display: grid;
  gap: 0;
  overflow: hidden;
}
#board-bg .bgtile { width: 100%; height: 100%; display: block; }
.ktile { width: 100%; height: 100%; display: block; }

.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(20, 14, 4, 0) 40%, rgba(20, 14, 4, 0.35) 100%),
    linear-gradient(180deg, rgba(20, 14, 4, 0.12), rgba(20, 14, 4, 0.28));
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--parch) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--parch-line);
}
.nav {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.6rem clamp(0.7rem, 3vw, 1.25rem);
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1rem);
}
.brand {
  flex: 0 0 auto;
  white-space: nowrap;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.05rem, 3.4vw, 1.35rem);
  color: var(--ink);
  text-decoration: none;
}
.nav-links {
  margin-left: auto;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: clamp(0.5rem, 2.6vw, 1.1rem);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: clamp(0.82rem, 2.7vw, 0.95rem);
  font-weight: 600;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent); }

/* ===== Hero ===== */
.hero {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.25rem 4rem;
  position: relative;
}
.board-cluster {
  display: grid;
  grid-template-columns: repeat(3, clamp(72px, 12.5vw, 116px));
  grid-auto-rows: clamp(72px, 12.5vw, 116px);
  gap: 3px;
  padding: 8px;
  background: rgba(30, 20, 8, 0.25);
  border-radius: 10px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
  margin-bottom: 2.2rem;
}
.clus-tile {
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  animation: fly-in 0.85s cubic-bezier(0.2, 0.85, 0.25, 1) backwards;
}
@keyframes fly-in {
  from { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--r0)) scale(0.5); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
}

.hero-text {
  max-width: 660px;
  background: radial-gradient(120% 120% at 50% 40%, rgba(246, 236, 210, 0.92) 55%, rgba(246, 236, 210, 0) 100%);
  padding: 1.5rem 1rem 0.5rem;
  border-radius: 30px;
}
.eyebrow {
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
h1 {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: 0.02em;
}
h1 .lang {
  display: block;
  font-size: 0.34em;
  letter-spacing: 0.32em;
  color: var(--accent-dark);
  font-weight: 600;
  margin-top: 0.4rem;
  text-transform: uppercase;
}
.subtitle { color: var(--ink-soft); font-size: 1.12rem; margin: 1.2rem auto 1.8rem; max-width: 560px; }

.cta { display: flex; gap: 0.9rem; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 0.72rem 1.6rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.18s, background 0.18s, color 0.18s;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(140, 80, 40, 0.4); }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-2px); }
.btn-ghost { background: rgba(246, 236, 210, 0.85); color: var(--ink); border-color: var(--parch-line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

.scroll-cue {
  position: absolute;
  bottom: 1.4rem;
  font-size: 1.8rem;
  color: var(--parch);
  text-decoration: none;
  animation: bob 1.6s ease-in-out infinite;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }

/* ===== 捲動拼接區 ===== */
.connect { height: 240vh; position: relative; }
.connect-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem;
}
.connect-head {
  max-width: 620px;
  text-align: center;
  background: rgba(246, 236, 210, 0.92);
  border: 2px solid var(--parch-line);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.connect-head h2 { font-family: var(--serif); font-size: 1.7rem; margin-bottom: 0.4rem; }
.connect-head p { color: var(--ink-soft); font-size: 1rem; }

.connect-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctile {
  width: clamp(140px, 32vw, 230px);
  height: clamp(140px, 32vw, 230px);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  will-change: transform;
}
.join-spark {
  position: absolute;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 150, 0.95), rgba(255, 200, 80, 0) 70%);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.join-meeple {
  position: absolute;
  width: clamp(26px, 6vw, 40px);
  opacity: 0;
  transform: translateY(10px) scale(0.6);
  transition: opacity 0.35s, transform 0.35s;
  pointer-events: none;
}
.connect-stage.joined .join-spark { opacity: 1; transform: scale(1.1); }
.connect-stage.joined .join-meeple { opacity: 1; transform: translateY(0) scale(1); }

.connect-hint {
  color: var(--parch);
  font-weight: 600;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s;
}
.connect-hint.done { opacity: 0; }

/* ===== 內容區塊 ===== */
.content { max-width: var(--max); margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.panel {
  background: rgba(246, 236, 210, 0.94);
  border: 2px solid var(--parch-line);
  border-radius: 18px;
  padding: 2.2rem clamp(1.2rem, 4vw, 2.6rem);
  margin-bottom: 2rem;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}
.panel h2 { font-family: var(--serif); font-size: clamp(1.6rem, 4vw, 2.1rem); margin-bottom: 1.1rem; }
.panel p { color: var(--ink); margin-bottom: 0.9rem; }
.panel p:last-child { margin-bottom: 0; }
b { color: var(--accent-dark); }

.facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.2rem;
}
.facts li {
  background: #fff;
  border: 1px solid var(--parch-line);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* 玩法步驟（垂直排列，左動畫右文字）*/
.steps { list-style: none; display: flex; flex-direction: column; gap: 1rem; }
.steps li {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #fff;
  border: 1px solid var(--parch-line);
  border-radius: 12px;
  padding: 1.1rem 1.3rem;
}
.step-text { flex: 1; min-width: 0; }
.step-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.4rem; }
.step-no {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
}
.steps h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0; }
.steps p { color: var(--ink-soft); font-size: 0.97rem; margin: 0; }

/* 計分卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.card {
  background: #fff;
  border: 1px solid var(--parch-line);
  border-radius: 12px;
  padding: 1.5rem 1.3rem;
  transition: transform 0.2s;
}
.card:hover { transform: translateY(-4px); }
.card h3 { font-family: var(--serif); font-size: 1.2rem; margin-bottom: 0.4rem; }
.card p { color: var(--ink-soft); font-size: 0.96rem; margin: 0; }
.card-icon { width: 46px; height: 46px; border-radius: 8px; margin-bottom: 0.8rem; border: 2px solid var(--tile-border); }
.road-ic { background: var(--grass); background-image: linear-gradient(var(--road), var(--road)); background-size: 100% 34%; background-position: center; background-repeat: no-repeat; }
.city-ic { background: var(--city); }
.mon-ic { background: var(--grass); position: relative; }
.mon-ic::after { content: ""; position: absolute; inset: 32%; background: var(--wall); border-top: 6px solid var(--roof); }
.field-ic { background: var(--grass); }

/* 地形展示 */
.tiles-sub { color: var(--ink-soft); }
.tile-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}
.gallery-item { text-align: center; }
.gallery-item .ktile {
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  border: 2px solid var(--tile-border);
}
.gallery-item span { display: block; margin-top: 0.5rem; font-weight: 600; }

.meeple-note {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--parch-line);
  border-radius: 12px;
  padding: 1.3rem;
  margin-top: 0.6rem;
}
.meeple-note p { flex: 1; min-width: 240px; color: var(--ink-soft); margin: 0; }
.meeple-swatches { display: flex; gap: 0.4rem; }
.meeple-swatches svg { width: 34px; height: 34px; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 1.6rem 1.25rem;
  color: var(--parch);
  font-size: 0.88rem;
  background: rgba(30, 20, 8, 0.55);
}

/* ===== 玩法步驟動畫 ===== */
.step-stage {
  position: relative;
  flex: none;
  width: 210px;
  height: 116px;
  border-radius: 10px;
  background: rgba(120, 150, 90, 0.16);
  border: 1px solid var(--parch-line);
  overflow: hidden;
}
@media (max-width: 560px) {
  .steps li { flex-direction: column; align-items: stretch; gap: 0.9rem; }
  .step-stage { width: 100%; }
}
.mtile { position: absolute; width: 50px; height: 50px; }
.mtile svg { display: block; width: 100%; height: 100%; border-radius: 4px; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); }

/* 面朝下的板塊（牌庫）*/
.deck { position: absolute; left: 50%; bottom: 12px; width: 50px; height: 50px; transform: translateX(-50%); }
.deck span {
  position: absolute; inset: 0; border-radius: 4px;
  border: 2px solid var(--ink);
  background: repeating-linear-gradient(45deg, #6d4a28 0 6px, #5a3c22 6px 12px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}
.deck span:nth-child(1) { transform: translate(-5px, 5px) rotate(-5deg); }
.deck span:nth-child(2) { transform: translate(2px, 2px) rotate(4deg); }

/* 步驟 1：抽板塊 */
.anim-draw { left: 50%; bottom: 12px; margin-left: -25px; animation: drawUp 3s ease-in-out infinite; }
@keyframes drawUp {
  0%   { transform: translateY(0) scale(0.7); opacity: 0; }
  16%  { opacity: 1; }
  42%  { transform: translateY(-52px) scale(1) rotate(-3deg); opacity: 1; }
  74%  { transform: translateY(-52px) scale(1) rotate(0); opacity: 1; }
  88%  { transform: translateY(-52px) scale(1); opacity: 0; }
  100% { transform: translateY(0) scale(0.7); opacity: 0; }
}

/* 步驟 2：拼接 */
.place-fixed { left: 50%; top: 29px; margin-left: -50px; }
.anim-place  { left: 50%; top: 29px; margin-left: 0; animation: slideIn 3s ease-in-out infinite; }
@keyframes slideIn {
  0%   { transform: translateX(78px) rotate(7deg); opacity: 0; }
  22%  { opacity: 1; }
  55%  { transform: translateX(0) rotate(0); opacity: 1; }
  90%  { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(78px) rotate(7deg); opacity: 0; }
}

/* 步驟 3：放米寶 */
.place-fixed2 { left: 50%; top: 29px; margin-left: -25px; }
.dropmeeple { position: absolute; left: 50%; top: 30px; margin-left: -12px; width: 24px; animation: meepleDrop 2.6s ease-in-out infinite; }
.dropmeeple svg { display: block; width: 100%; }
@keyframes meepleDrop {
  0%   { transform: translateY(-46px) scale(0.8); opacity: 0; }
  22%  { opacity: 1; }
  46%  { transform: translateY(3px) scale(1); }
  56%  { transform: translateY(-7px); }
  66%  { transform: translateY(0); }
  88%  { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(0); opacity: 0; }
}

/* 步驟 4：結算 */
.rd1 { left: 50%; top: 29px; margin-left: -50px; }
.rd2 { left: 50%; top: 29px; margin-left: 0; }
.scoremeeple { position: absolute; left: 50%; top: 30px; margin-left: -12px; width: 24px; animation: meepleReturn 3s ease-in-out infinite; }
.scoremeeple svg { display: block; width: 100%; }
.pts {
  position: absolute; left: 50%; top: 22px;
  font-family: var(--serif); font-weight: 800; font-size: 1.3rem;
  color: var(--accent-dark); animation: ptsPop 3s ease-in-out infinite;
}
@keyframes meepleReturn {
  0%, 45% { transform: translateY(0); opacity: 1; }
  72%     { transform: translateY(-38px) scale(0.9); opacity: 1; }
  86%     { transform: translateY(-38px); opacity: 0; }
  100%    { transform: translateY(0); opacity: 0; }
}
@keyframes ptsPop {
  0%, 42% { opacity: 0; transform: translate(-50%, 8px) scale(0.6); }
  58%     { opacity: 1; transform: translate(-50%, -14px) scale(1.15); }
  82%     { opacity: 1; transform: translate(-50%, -26px) scale(1); }
  100%    { opacity: 0; transform: translate(-50%, -32px) scale(1); }
}

/* ===== 計分區（垂直排列，左文字右動畫）===== */
.scores { display: flex; flex-direction: column; gap: 1rem; }
.score-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #fff;
  border: 1px solid var(--parch-line);
  border-radius: 12px;
  padding: 1.1rem 1.3rem;
}
.score-text { flex: 1; min-width: 0; }
.card-icon.mini { width: 30px; height: 30px; margin: 0; flex: none; }

.mtile2 { position: absolute; width: 46px; height: 46px; }
.mtile2 svg { display: block; width: 100%; height: 100%; border-radius: 4px; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); }
.mon-cell, .mon-center { width: 34px; height: 34px; }
.mon-cell { animation: monPop 3s ease-in-out infinite; }
@keyframes monPop {
  0%   { opacity: 0; transform: scale(0.4); }
  12%  { opacity: 1; transform: scale(1); }
  84%  { opacity: 1; transform: scale(1); }
  94%  { opacity: 0; transform: scale(0.5); }
  100% { opacity: 0; }
}
.farmer { position: absolute; width: 22px; transform: rotate(90deg); }
.farmer svg { display: block; width: 100%; }

@media (max-width: 560px) {
  .score-row { flex-direction: column; align-items: stretch; gap: 0.9rem; }
}

/* ===== 動手拼板塊 ===== */
.sandbox-controls { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin: 1.2rem 0 0.5rem; }
.sb-preview-box { display: flex; align-items: center; gap: 0.6rem; }
.sb-label { font-weight: 600; color: var(--ink-soft); }
.sb-preview {
  width: 64px; height: 64px;
  border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 2px solid var(--parch-line);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.sb-preview:hover { transform: rotate(-4deg) scale(1.05); }
.sb-preview svg { width: 100%; height: 100%; display: block; }
.sandbox-controls .btn { padding: 0.55rem 1.15rem; }
.sandbox-status { color: var(--ink-soft); font-weight: 600; min-height: 1.5rem; margin: 0.3rem 0 0.8rem; }

.sandbox-board {
  display: grid;
  gap: 3px;
  background: rgba(58, 78, 44, 0.92);
  padding: 6px;
  border-radius: 12px;
  border: 2px solid var(--parch-line);
  max-width: 560px;
  margin: 0 auto;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.35);
}
.sb-cell { aspect-ratio: 1; border-radius: 4px; overflow: hidden; }
.sb-cell.empty { background: rgba(255, 255, 255, 0.05); }
.sb-cell.valid {
  background: rgba(246, 196, 90, 0.28);
  outline: 2px dashed var(--flag);
  outline-offset: -3px;
  cursor: pointer;
  animation: sbPulse 1.6s ease-in-out infinite;
}
.sb-cell.valid:hover { background: rgba(246, 196, 90, 0.6); animation: none; }
.sb-cell svg { width: 100%; height: 100%; display: block; }
@keyframes sbPulse { 0%, 100% { outline-color: rgba(220, 174, 67, 0.5); } 50% { outline-color: rgba(246, 196, 90, 1); } }

@media (prefers-reduced-motion: reduce) {
  .sb-cell.valid { animation: none; }
  .sb-preview:hover { transform: none; }
}

/* ===== 台灣地圖段落 ===== */
.taiwan-layout { display: flex; gap: clamp(1rem, 4vw, 2.4rem); align-items: center; flex-wrap: wrap; }
.taiwan-art { flex: 0 0 auto; width: clamp(150px, 34vw, 220px); }
.tw-svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.25)); }
.tw-label {
  font-size: 6.5px;
  font-weight: 700;
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--wall);
  stroke-width: 2.4px;
  stroke-linejoin: round;
}
.taiwan-text { flex: 1 1 300px; min-width: 260px; }
.taiwan-facts { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0; }
.taiwan-facts li {
  display: flex; gap: 0.6rem; align-items: flex-start;
  background: #fff; border: 1px solid var(--parch-line); border-radius: 10px;
  padding: 0.6rem 0.9rem; color: var(--ink); font-size: 0.97rem;
}
.taiwan-facts li span { flex: none; }
.taiwan-story {
  background: rgba(246, 196, 90, 0.14);
  border-left: 4px solid var(--flag);
  border-radius: 0 10px 10px 0;
  padding: 0.8rem 1rem; color: var(--ink-soft); margin-top: 0.4rem;
}
.taiwan-link { display: inline-block; margin-top: 1.1rem; }
.taiwan-credit { font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.5rem; }

/* Reveal 動畫 */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .clus-tile, .scroll-cue { animation: none; }
  .reveal { opacity: 1; transform: none; }
  .anim-draw, .anim-place, .dropmeeple, .scoremeeple, .pts, .mon-cell { animation: none; opacity: 1; }
  .anim-draw { transform: translateY(-52px); }
  .anim-place { transform: none; }
  .mon-cell { transform: none; }
}

@media (max-width: 560px) {
  .connect { height: 200vh; }
}

