:root{
  --board:#1b2b22;
  --board-edge:#14201a;
  --chalk:#f4f1e6;
  --chalk-dim: rgba(244,241,230,0.28);
  --accent:#f2c14e;
  --accent-soft: rgba(242,193,78,0.18);
  --wood:#5b3d2b;
  --wood-dark:#432c1f;
  --ink:#eef0ea;
}
*{box-sizing:border-box; -webkit-tap-highlight-color: transparent;}
html,body{
  margin:0; padding:0; height:100%;
  background: #0d1310;
  color:var(--ink);
  font-family:'Noto Sans Thai', sans-serif;
  overscroll-behavior:none;
}
.stage{
  max-width:480px;
  margin:0 auto;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  padding: 18px 16px 24px;
}
header{ text-align:center; margin-bottom:8px; }
.eyebrow{
  font-size:12px; letter-spacing:0.14em; text-transform:uppercase;
  color: var(--accent); font-weight:600; margin-bottom:6px;
}
h1{
  font-family:'Mali', cursive;
  font-size: 30px;
  margin: 0 0 6px;
  color: var(--chalk);
}
.subtitle{
  font-size:14px;
  color: rgba(238,240,234,0.65);
  line-height:1.5;
  margin: 0 auto;
  max-width: 340px;
}
.board-frame{
  position:relative;
  margin: 18px auto 10px;
  padding: 14px;
  background: var(--wood);
  background-image: linear-gradient(180deg, var(--wood), var(--wood-dark));
  border-radius: 14px;
  box-shadow: 0 14px 30px rgba(0,0,0,0.45), inset 0 0 0 3px rgba(0,0,0,0.15);
  width: 100%;
}
.board{
  background: radial-gradient(120% 100% at 50% 0%, var(--board) 0%, var(--board-edge) 100%);
  border-radius: 8px;
  width:100%;
  display:block;
  touch-action:none;
  aspect-ratio: 400 / 460;
}
.chalk-line{ stroke: var(--chalk-dim); stroke-width:5; stroke-linecap:round; fill:none; filter:url(#chalkTexture); }
.accent-line{ stroke: var(--accent); stroke-width:6; stroke-linecap:round; fill:none; filter:url(#chalkTexture); opacity:0; transition: opacity .12s ease; }
.rubber-line{ stroke: rgba(242,193,78,0.55); stroke-width:5; stroke-linecap:round; fill:none; }
.node{ fill: var(--chalk); stroke: rgba(0,0,0,0.25); stroke-width:1; filter: drop-shadow(0 0 4px rgba(244,241,230,0.35)); }
.node.active{ fill: var(--accent); }
.node.hint{ fill: var(--accent); }
.hint-ring{
  fill:none; stroke: var(--accent); stroke-width:2.5; stroke-dasharray: 4 5;
  opacity:0; transition: opacity .2s ease;
}
.hud{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:4px; }
.mode-toggle{
  display:flex; gap:6px; justify-content:center;
  margin: 10px auto 0; background: rgba(244,241,230,0.06);
  padding: 4px; border-radius: 999px; border:1px solid rgba(244,241,230,0.12);
  max-width: 340px;
}
.mode-btn{
  flex:1; font-family:'Noto Sans Thai', sans-serif; font-size:12.5px; font-weight:600;
  padding: 7px 10px; border-radius: 999px; border:none;
  background:transparent; color: rgba(238,240,234,0.6); cursor:pointer;
}
.mode-btn.active{ background: var(--accent); color:#241a08; }
.counter{
  font-size:14px; font-weight:600; color: var(--chalk);
  background: rgba(244,241,230,0.08);
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid rgba(244,241,230,0.15);
}
.counter span{ color: var(--accent); }
.btnrow{ display:flex; gap:8px; }
button{
  font-family:'Noto Sans Thai', sans-serif;
  font-size:14px; font-weight:600;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid rgba(244,241,230,0.2);
  background: rgba(244,241,230,0.06);
  color: var(--chalk);
  cursor:pointer;
}
button:active{ transform: scale(0.96); }
button:disabled{ opacity:0.4; cursor:default; }
button.primary{ background: var(--accent); color:#241a08; border-color: var(--accent); }
.hint-caption{
  text-align:center; font-size:12.5px; color: rgba(242,193,78,0.9);
  height: 18px; margin-top:8px; opacity:0; transition:opacity .2s ease;
}
.hint-caption.show{ opacity:1; }
.toast{
  position: fixed; left:50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #2a2018; color: var(--chalk);
  border: 1px solid rgba(242,193,78,0.4);
  padding: 12px 18px; border-radius: 12px; font-size:14px;
  opacity:0; pointer-events:none; transition: all .25s ease;
  max-width: 86%; text-align:center;
}
.toast.show{ opacity:1; transform: translateX(-50%) translateY(0); }
.modal{
  position: fixed; inset:0; background: rgba(6,10,8,0.72);
  display:flex; align-items:center; justify-content:center;
  padding: 24px; opacity:0; pointer-events:none; transition: opacity .25s ease;
  z-index: 10;
}
.modal.show{ opacity:1; pointer-events:auto; }
.modal-card{
  background: #16211a; border: 1px solid rgba(244,241,230,0.12);
  border-radius: 18px; padding: 26px 22px; max-width: 380px; width:100%;
  text-align:center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-card h2{ font-family:'Mali', cursive; font-size:26px; margin:0 0 6px; color:var(--accent); }
.modal-card .time{ font-size:14px; color: rgba(238,240,234,0.7); margin-bottom:16px; }
.explain{
  text-align:left; font-size:13.5px; line-height:1.65;
  background: rgba(244,241,230,0.06);
  border-left: 3px solid var(--accent);
  padding: 12px 14px; border-radius: 8px;
  color: rgba(238,240,234,0.9);
  margin-bottom: 18px;
}
.explain b{ color: var(--accent); }
.modal-actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.modal-actions a{
  font-family:'Noto Sans Thai', sans-serif;
  font-size:14px; font-weight:600;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid rgba(244,241,230,0.2);
  background: transparent; color: var(--chalk);
  text-decoration:none; display:inline-flex; align-items:center;
}
.feedback-note{ margin-top:18px; text-align:center; font-size:12.5px; color: rgba(238,240,234,0.45); line-height:1.6; }
.ad-slot{
  margin-top:16px; padding: 14px; border-radius: 12px;
  border: 1px dashed rgba(244,241,230,0.25); background: rgba(244,241,230,0.04);
  text-align:center; font-size:12px; color: rgba(238,240,234,0.4);
  display:flex; flex-direction:column; gap:8px; align-items:center;
}
.ad-slot-cta{ font-size:12.5px; padding: 7px 14px; border-radius:999px; background: transparent; color: var(--accent); border:1px solid rgba(242,193,78,0.4); }
.faq-block{ margin-top:20px; padding-top:16px; border-top:1px solid rgba(244,241,230,0.1); font-size:13px; color: rgba(238,240,234,0.65); line-height:1.6; }
.faq-block h2{ font-size:13px; text-transform:uppercase; letter-spacing:0.08em; color: rgba(238,240,234,0.4); margin:0 0 10px; }
.faq-block h3{ font-size:14px; color: var(--chalk); margin:12px 0 4px; }
.faq-block p{ margin:0; }

/* Share row: explicit per-network buttons instead of relying only on the OS share sheet */
.share-row{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:16px; }
.share-label{ font-size:12.5px; color: rgba(238,240,234,0.5); margin-right:2px; }
.share-pill{
  font-family:'Noto Sans Thai', sans-serif; font-size:12.5px; font-weight:700;
  padding:8px 14px; border-radius:999px; text-decoration:none; border:none; cursor:pointer;
  display:inline-flex; align-items:center; gap:5px;
}
.share-generic{ background: rgba(244,241,230,0.08); color:var(--chalk); border:1px solid rgba(244,241,230,0.2); }
.share-fb{ background:#1877F2; color:#fff; }
.share-line{ background:#06C755; color:#fff; }
.share-copy{ background:transparent; color:var(--chalk); border:1px solid rgba(244,241,230,0.25); }

.page-nav{ display:flex; gap:8px; margin-top:14px; }
.nav-btn{
  flex:1; text-align:center; padding: 11px 8px; border-radius:12px;
  background: rgba(244,241,230,0.05); border:1px solid rgba(244,241,230,0.15);
  color: var(--chalk); font-size:13px; font-weight:600; text-decoration:none;
}
.nav-btn.nav-home{ background: rgba(242,193,78,0.12); border-color: rgba(242,193,78,0.35); color: var(--accent); }
.nav-btn.disabled{ opacity:0.3; pointer-events:none; }

.scroll-top-btn{
  position:fixed; right:18px; bottom:18px; width:44px; height:44px; border-radius:50%;
  background: var(--accent); color:#241a08; font-size:18px; font-weight:700;
  border:none; box-shadow: 0 8px 18px rgba(0,0,0,0.4);
  opacity:0; pointer-events:none; transform: translateY(10px);
  transition: all .2s ease; z-index:15;
}
.scroll-top-btn.show{ opacity:1; pointer-events:auto; transform: translateY(0); }

.premium-modal{
  position: fixed; inset:0; background: rgba(6,10,8,0.85);
  display:flex; align-items:center; justify-content:center;
  padding: 24px; opacity:0; pointer-events:none; transition: opacity .2s ease; z-index:20;
}
.premium-modal.show{ opacity:1; pointer-events:auto; }
.premium-card{
  background:#16211a; border:1px solid rgba(244,241,230,0.12); border-radius:16px;
  padding:26px; text-align:center; max-width:300px; width:100%;
}
.premium-card button{ margin-top:10px; }

/* Matchstick mechanic */
.slot-guide{ stroke: rgba(244,241,230,0.32); stroke-width:3; stroke-linecap:round; fill:none; stroke-dasharray:1 8; }
.stick{ stroke: var(--chalk-dim); stroke-width:7; stroke-linecap:round; fill:none; filter:url(#chalkTexture); cursor:grab; touch-action:none; }
.stick.dragging{ opacity:0.25; }
.stick-ghost{ stroke: var(--accent); stroke-width:7; stroke-linecap:round; fill:none; opacity:0.9; pointer-events:none; filter:url(#chalkTexture); }
.parking-label{ fill: rgba(238,240,234,0.35); font-size:11px; font-family:'Noto Sans Thai',sans-serif; }

/* River crossing mechanic */
.river-stage{ display:flex; gap:8px; align-items:stretch; min-height:230px; }
.bank{ flex:1; background: rgba(255,255,255,0.03); border-radius:10px; padding:10px 8px; display:flex; flex-direction:column; gap:8px; min-width:0; }
.bank-title{ font-size:11px; color: rgba(238,240,234,0.45); text-align:center; }
.bank-items{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center; align-content:flex-start; flex:1; }
.item-chip{
  font-family:'Noto Sans Thai', sans-serif;
  background: rgba(244,241,230,0.06); border:2px solid rgba(244,241,230,0.18);
  border-radius:10px; padding:8px 6px; display:flex; flex-direction:column; align-items:center; gap:2px;
  min-width:56px;
}
.item-emoji{ font-size:26px; }
.item-label{ font-size:10px; color: rgba(238,240,234,0.6); }
.item-chip.selected{ border-color: var(--accent); background: rgba(242,193,78,0.15); }
.item-chip.disabled{ opacity:0.3; pointer-events:none; }
.river-strip{
  width:46px; flex:0 0 46px; border-radius:8px; position:relative; overflow:hidden;
  background: linear-gradient(180deg, rgba(70,130,150,0.28), rgba(30,70,90,0.4));
  display:flex; align-items:center;
}
.farmer-wrap{ position:relative; width:100%; height:34px; }
#farmerIcon{
  position:absolute; left:0; top:0; font-size:24px; transition: transform .5s ease;
}
.river-strip.boarded #farmerIcon::after{ content:''; }
.row-btn{
  width:100%; margin-top:12px; padding:14px; border-radius:12px;
  font-size:15px; font-weight:700;
}

/* Coin weighing mechanic */
.scale-wrap{ text-align:center; padding: 10px 0 4px; }
.scale-beam{
  width:220px; height:6px; background: var(--chalk-dim); margin:0 auto 6px;
  border-radius:4px; transition: transform .4s ease; transform-origin:center;
}
.scale-pans{ display:flex; justify-content:space-between; max-width:260px; margin:0 auto 10px; gap:10px; }
.scale-pan{
  flex:1; min-height:44px; border:1px dashed rgba(244,241,230,0.3); border-radius:10px;
  display:flex; align-items:center; justify-content:center; font-size:12px; color: rgba(238,240,234,0.6);
  padding:6px;
}
.scale-result{ font-size:13px; color: var(--accent); min-height:18px; margin-bottom:10px; }
.coins-row{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
.coin{
  width:40px; height:40px; border-radius:50%;
  background: radial-gradient(circle at 35% 30%, #e8c86a, #b8892a);
  border: 2px solid rgba(0,0,0,0.25); color:#2a1c05; font-weight:700; font-size:14px;
}
.coin.pan-l{ outline: 3px solid var(--accent); }
.coin.pan-r{ outline: 3px solid #7fd1c9; }
#guessBtn.active{ background: var(--accent); color:#241a08; border-color: var(--accent); }

/* Water jug mechanic */
.jugs-wrap{ display:flex; gap:24px; justify-content:center; align-items:flex-end; padding: 16px 0; }
.jug{ display:flex; flex-direction:column; align-items:center; gap:8px; }
.jug-body{
  width:70px; height:140px; border:3px solid rgba(244,241,230,0.4); border-radius:0 0 10px 10px;
  border-top:none; position:relative; overflow:hidden; background: rgba(244,241,230,0.04);
}
.jug-water{
  position:absolute; bottom:0; left:0; width:100%;
  background: linear-gradient(180deg, #7fc4e8, #3f8bb5);
  transition: height .4s ease;
}
.jug-label{ font-size:12px; color: rgba(238,240,234,0.7); text-align:center; line-height:1.4; }
.jug-actions{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:14px; }
.jug-btn{
  font-family:'Noto Sans Thai', sans-serif; font-size:12.5px; font-weight:600;
  padding: 9px 12px; border-radius:10px;
  background: rgba(244,241,230,0.06); border:1px solid rgba(244,241,230,0.18); color: var(--chalk);
}
.jug-btn.pour{ background: rgba(242,193,78,0.1); border-color: rgba(242,193,78,0.35); }

/* Tangram mechanic */
.tangram-guide{ fill:none; stroke: rgba(244,241,230,0.25); stroke-width:2; stroke-dasharray:3 6; }
.tangram-piece{ stroke:#fff; stroke-width:2; cursor:grab; opacity:0.9; touch-action:none; }
.tangram-piece.selected{ stroke: var(--accent); stroke-width:3; }
.tangram-piece.docked{ filter: drop-shadow(0 0 10px rgba(242,193,78,0.95)); stroke: var(--accent); stroke-width:3; stroke-dasharray:4 3; }
.tangram-piece.locked{ opacity:0.95; pointer-events:none; }
.piece-N{ fill:#e07a5f; } .piece-E{ fill:#81b29a; } .piece-S{ fill:#f2cc8f; } .piece-W{ fill:#3d5a80; }
.rotate-btn{ width:100%; margin-top:10px; padding:12px; border-radius:12px; font-size:14px; font-weight:700; }

/* Predict-and-reveal mechanic */
.predict-diagram{ display:flex; justify-content:center; padding: 10px 0 6px; }
.predict-options{ display:flex; flex-direction:column; gap:10px; margin-top: 6px; }
.predict-option{
  text-align:left; padding:14px 16px; border-radius:12px;
  background: rgba(244,241,230,0.05); border:1.5px solid rgba(244,241,230,0.18);
  color: var(--chalk); font-size:14.5px; font-weight:500; line-height:1.4;
}
.predict-option:active{ transform: scale(0.98); }
.predict-option:disabled{ opacity:0.6; }
.predict-option.correct{ border-color:#7fbf6a; background: rgba(127,191,106,0.15); opacity:1; color:#d7f0cf; }
.predict-option.wrong{ border-color:#d9776a; background: rgba(217,119,106,0.15); opacity:1; color:#f6d9d4; }
.predict-reveal{
  margin-top:16px; padding:16px; border-radius:12px;
  background: rgba(244,241,230,0.06); border-left:3px solid var(--accent);
  opacity:0; max-height:0; overflow:hidden; transition: all .35s ease;
}
.predict-reveal.show{ opacity:1; max-height:600px; padding:16px; }
.predict-reveal h3{ margin:0 0 8px; color:var(--accent); font-family:'Mali',cursive; font-size:19px; }
.predict-reveal p{ margin:0; font-size:14px; line-height:1.65; color: rgba(238,240,234,0.9); }
.diagram-after{ opacity:0; transition: opacity .4s ease; }
.diagram-after.show{ opacity:1; }
