/* มติ 865 — หน้าวางแปลนรั้ว «โหมดเกม» (คอม) · ทุกกฎอยู่ใต้ `.fence-play` จึงไม่รั่วไปหน้าอื่น */
.fence-play { max-width: 1600px; margin: 0 auto; padding: 16px; box-sizing: border-box; color: #1f1d1e; }
.fence-play .fp-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 12px; }
.fence-play .fp-head h1 { margin: 0; font-size: 26px; flex: 0 0 auto; }
.fence-play .fp-spec { display: flex; flex-wrap: wrap; gap: 8px 12px; flex: 1 1 auto; }
.fence-play .fp-spec label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: #4b5563; }
.fence-play .fp-spec select { min-height: 36px; padding: 4px 8px; border: 1px solid #cfcfcf; border-radius: 8px; font: inherit; font-size: 14px; color: #1f1d1e; background: #fff; }
.fence-play .fp-back { font-size: 14px; }
/* มติ 867 — ช่องความสูงตอนเลือกชุด = เปลี่ยนเฉพาะชุดนั้น */
.fence-play .fp-spec label.is-sel { color: #2563eb; font-weight: 700; }
.fence-play .fp-spec label.is-sel select { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, .2); }

.fence-play .fp-main { display: grid; grid-template-columns: 96px minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.fence-play .fp-tools { display: flex; flex-direction: column; gap: 8px; padding: 10px 8px; border-radius: 14px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06); position: sticky; top: 12px; }
.fence-play .fp-tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 72px; padding: 6px 4px; border: 2px solid transparent; border-radius: 12px; background: #f3f4f6; font: inherit; font-size: 12px; color: #1f1d1e; cursor: pointer; }
.fence-play .fp-tool:hover { border-color: #e5e7eb; }
.fence-play .fp-tool[aria-pressed="true"] { background: #ffd70a; border-color: #1f1d1e; }
.fence-play .fp-tool kbd { position: absolute; top: 3px; right: 6px; font: inherit; font-size: 10px; color: #4b5563; }

.fence-play .fp-stage-wrap { position: relative; border-radius: 14px; background: #eef1f4; box-shadow: inset 0 0 0 1px #e1e5ea; overflow: hidden; }
.fence-play .fp-stage-top { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.fence-play .fp-hint { margin: 0; padding: 8px 12px; border-radius: 10px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08); font-size: 14px; max-width: 70%; pointer-events: auto; }
.fence-play .fp-stage-btns { display: flex; gap: 6px; pointer-events: auto; }
.fence-play .fp-stage { height: min(78vh, 760px); min-height: 460px; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; }
.fence-play .fp-stage svg { width: 100%; height: 100%; display: block; }
.fence-play .fp-stage.is-fence { cursor: crosshair; }
.fence-play .fp-stage .fp-hit { fill: transparent; pointer-events: none; }
.fence-play .fp-stage.is-pick .fp-hit { pointer-events: all; cursor: pointer; }
.fence-play .fp-stage.is-pick .fp-hit:hover { fill: rgba(255, 215, 10, .28); stroke: #c99a00; stroke-width: 14; }
.fence-play .fp-stage.is-select .fb-iso-prop { cursor: move; }   /* มติ 871 — ย้ายของได้เฉพาะเครื่องมือเลือก */
/* มติ 866 — เครื่องมือ «เลือก»: กรอบฟ้าทั้งชุด + จุดจับปลาย */
.fence-play .fp-stage.is-select .fp-hit { cursor: move; }
.fence-play .fp-stage .fp-sel-piece { fill: rgba(37, 99, 235, .16); stroke: #2563eb; stroke-width: 22; pointer-events: none; }
.fence-play .fp-stage .fp-handle { fill: #fff; stroke: #2563eb; stroke-width: 28; cursor: grab; }
.fence-play .fp-selbar { position: absolute; left: 10px; bottom: 10px; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.1); font-size: 13px; font-weight: 700; color: #2563eb; }
.fence-play .fp-selbar[hidden] { display: none; }
.fence-play .fp-selbar kbd { margin-left: 4px; font: inherit; font-size: 11px; font-weight: 400; color: #6b7280; }
.fence-play .fp-toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 10px; background: #1f1d1e; color: #fff; font-size: 14px; z-index: 3; }
.fence-play .fp-bubble { position: absolute; z-index: 3; pointer-events: none; display: flex; flex-direction: column; padding: 6px 10px; border-radius: 9px; background: #1f1d1e; color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.2); transform: translate(12px, 12px); }
.fence-play .fp-bubble b { font-size: 18px; }
.fence-play .fp-bubble span { font-size: 12px; color: #d1d5db; }

.fence-play .fp-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 14px; border: 1px solid #cfcfcf; border-radius: 10px; background: #fff; font: inherit; font-size: 14px; color: #1f1d1e; cursor: pointer; text-decoration: none; }
.fence-play .fp-btn:hover { border-color: #ffd70a; }
.fence-play .fp-primary { background: #06c755; border-color: #06c755; color: #fff; font-weight: 700; }

.fence-play .fp-side { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 14px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06); position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; box-sizing: border-box; }
.fence-play .fp-tabs { display: flex; padding: 3px; border-radius: 10px; background: #f1f3f5; }
.fence-play .fp-tabs button { flex: 1 1 0; min-height: 38px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: 14px; font-weight: 700; color: #1f1d1e; cursor: pointer; }
.fence-play .fp-tabs button[aria-selected="true"] { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.fence-play .fp-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fence-play .fp-metric { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 10px; background: #f3f4f6; }
.fence-play .fp-metric b { font-size: 24px; line-height: 1.1; }
.fence-play .fp-metric span { font-size: 12px; color: #4b5563; }
.fence-play .fp-bom { width: 100%; border-collapse: collapse; font-size: 13px; }
.fence-play .fp-bom td { padding: 6px 4px; border-bottom: 1px solid #eef0f2; vertical-align: top; }
.fence-play .fp-bom td.r { text-align: right; white-space: nowrap; }
.fence-play .fp-bom tfoot td { font-weight: 700; }
.fence-play .fp-bom tr.grand td { font-size: 15px; }
.fence-play .fp-cta { display: flex; gap: 8px; flex-wrap: wrap; }
.fence-play .fp-save { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid #eef0f2; font-size: 13px; }
.fence-play .fp-save select, .fence-play .fp-save input { min-height: 36px; padding: 4px 8px; border: 1px solid #cfcfcf; border-radius: 8px; font: inherit; }
.fence-play .fp-tray { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 420px; overflow-y: auto; padding: 2px; }
/* มติ 874 — ค้นหา + แท็บหมวดของคลังของ */
.fence-play .fp-prop-q { width: 100%; box-sizing: border-box; min-height: 36px; margin: 6px 0; padding: 4px 10px; border: 1px solid #cfcfcf; border-radius: 8px; font: inherit; font-size: 14px; }
.fence-play .fp-prop-cats { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.fence-play .fp-prop-cats button { min-height: 30px; padding: 2px 10px; border: 1px solid #e3e5e8; border-radius: 999px; background: #fff; font: inherit; font-size: 12px; color: #1f1d1e; cursor: pointer; }
.fence-play .fp-prop-cats button[aria-pressed="true"] { background: #ffd70a; border-color: #1f1d1e; font-weight: 700; }
.fence-play .fp-tray button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border: 1px solid #e3e5e8; border-radius: 12px; background: #fff; font: inherit; font-size: 11px; line-height: 1.2; color: #1f1d1e; cursor: grab; touch-action: none; }
.fence-play .fp-tray img { width: 48px; height: 48px; object-fit: contain; pointer-events: none; }
.fence-play .fp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fence-play .fp-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border: 1px solid #e3b878; border-radius: 999px; background: #fdf3e6; font-size: 13px; }
.fence-play .fp-chip button { min-width: 30px; min-height: 30px; border: 0; border-radius: 50%; background: none; font-size: 15px; cursor: pointer; }
.fp-ghost-img { position: fixed; z-index: 1000; width: 64px; height: 64px; object-fit: contain; pointer-events: none; transform: translate(-50%, -50%); opacity: .85; }

/* มติ 868 — โจทย์: จอเลือก + เช็กลิสต์ (✕/✓ + พื้นอ่อนต่างความสว่าง — คนแยกแดงเขียวไม่ออกก็อ่านได้) */
.fence-play .fp-goals { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(238, 241, 244, .94); }
.fence-play .fp-goals[hidden] { display: none; }
.fence-play .fp-goals-card { max-width: 860px; padding: 24px; border-radius: 16px; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.12); text-align: center; }
.fence-play .fp-goals-card h2 { margin: 0 0 6px; font-size: 22px; }
.fence-play .fp-goals-card p { margin: 0 0 16px; color: #4b5563; font-size: 14px; }
.fence-play .fp-goal-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.fence-play .fp-goal-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; border: 2px solid #e5e7eb; border-radius: 14px; background: #fff; font: inherit; color: #1f1d1e; cursor: pointer; }
.fence-play .fp-goal-card:hover, .fence-play .fp-goal-card:focus-visible { border-color: #ffd70a; }
.fence-play .fp-goal-card b { font-size: 16px; }
.fence-play .fp-goal-card span { font-size: 13px; color: #4b5563; }
.fence-play .fp-goal { padding: 10px; border: 2px solid #e5e7eb; border-radius: 12px; }
.fence-play .fp-goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.fence-play .fp-link { white-space: nowrap; padding: 0; border: 0; background: none; font: inherit; font-size: 12px; color: #4b5563; text-decoration: underline; cursor: pointer; }
.fence-play .fp-goal-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fence-play .fp-goal-list li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; font-size: 13px; }
.fence-play .fp-goal-list li.ok { background: #e7f6ec; color: #13653a; }
.fence-play .fp-goal-list li.bad { background: #fdecec; color: #9b1c1c; padding: 0; }
.fence-play .fp-goal-list li.bad button { display: flex; gap: 8px; width: 100%; padding: 6px 8px; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.fence-play .fp-goal-list .mk { font-weight: 700; flex: 0 0 auto; }
.fence-play .fp-goal-note { margin: 8px 0 0; font-size: 12px; color: #4b5563; }
.fence-play .fp-goal-note.done { color: #13653a; font-weight: 700; font-size: 14px; }
.fence-play .fp-flash { position: absolute; z-index: 3; width: 96px; height: 96px; margin: -48px 0 0 -48px; border: 4px solid #dc2626; border-radius: 50%; pointer-events: none; animation: fp-pulse .8s ease-out 3; }
@keyframes fp-pulse { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.3); opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .fence-play .fp-flash { animation: none; } }

/* มติ 870 — ปุ่มความกว้างทางเดิน */
.fence-play .fp-walkw { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 10px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08); font-size: 14px; font-weight: 700; pointer-events: auto; }
.fence-play .fp-walkw[hidden] { display: none; }
.fence-play .fp-walkw .fp-btn { min-height: 32px; min-width: 32px; padding: 2px 8px; }

.fence-play .fp-mobile-note { display: none; }
/* จอแคบ = ดูอย่างเดียว (เจ้าของสั่ง 19 ต.ค. 2569 · มติ 865) */
@media (max-width: 1023px) {
  .fence-play .fp-main { grid-template-columns: minmax(0, 1fr); }
  .fence-play .fp-tools, .fence-play #fp-tab-props, .fence-play .fp-stage-top .fp-hint, .fence-play #fp-undo, .fence-play .fp-selbar, .fence-play #fp-goal-open, .fence-play .fp-goals { display: none; }
  .fence-play .fp-mobile-note { display: block; margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: #fff8d6; border: 1px solid #f0df8a; font-size: 14px; }
  .fence-play .fp-stage { height: 56vh; min-height: 300px; }
  .fence-play .fp-side { position: static; max-height: none; }
}
