/* หน้าต่างผู้เฝ้าประตูวาร์ป Wren (warp-window.js · 3 ต.ค.)
   สี: ครีม #f3e6c8/#fffaf0 · ทีล #2f6f73 (เลือก/ปุ่มหลัก) · ทอง #e8b64a (ขอบ/ไอคอน) · น้ำตาล #342c26 · ส้มแดงจาง #b4552d (Gold ไม่พอ) · เทา #8a8070 (ล็อก)
   ⚠️ ตัวหนังสือไม่ต่ำกว่า 13px · สถานะไม่ใช้สีอย่างเดียว (ไอคอน 🔒 ⚠ ✓ + ข้อความ + ปุ่ม disabled) */

#windows .win[data-win="warp"] { box-sizing: border-box; width: min(94vw, 820px); height: min(88vh, 640px); max-height: none; display: flex; flex-direction: column; }
html[data-skin="wood"] body .win[data-win="warp"] > .body { max-height: none; }
#windows .win[data-win="warp"] > .body { padding: 0; overflow: hidden; flex: 1; min-height: 0; display: flex; }
#windows .win.warp-win > header { min-height: 56px; }
#windows .win.warp-win header .win-ic, #windows .win.warp-win header .win-ic .wp-emblem, #windows .win.warp-win header .win-ic .wp-face { width: 46px; height: 46px; }
#windows .win.warp-win header .wp-face { display: block; object-fit: cover; border-radius: 12px; border: 2px solid #e8b64a; background: #f3e6c8; }
#windows .win.warp-win header .wp-emblem { display: grid; place-items: center; font-size: 26px; border-radius: 12px; border: 2px solid #e8b64a; background: radial-gradient(circle, #3f8a8e, #2f6f73); box-shadow: inset 0 0 8px #0003; }
#windows .win.warp-win header > span { display: grid; line-height: 1.15; }
#windows .win.warp-win header > span b { font: 800 18px/1.15 var(--font-head); }
#windows .win.warp-win header > span small { font: 600 13px/1.2 var(--font); opacity: .8; }

#windows .warp { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; color: #342c26; font-size: 14px; }
#windows .wp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 10px 16px; background: linear-gradient(90deg, #f6ead0, #fbf4e2); border-bottom: 1px solid #e3d2a8; }
#windows .wp-top p { margin: 0; font-size: 14px; color: #5b4a36; flex: 1 1 260px; }
#windows .wp-here { flex: none; padding: 4px 12px; border-radius: 999px; background: #eef6f5; border: 1px solid #2f6f7355; color: #2f6f73; font-weight: 600; white-space: nowrap; }
#windows .wp-here b { color: #234f52; }
#windows .wp-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(250px, 42%) minmax(0, 1fr); }
#windows .wp-empty { margin: auto; padding: 24px; color: #6b5a44; text-align: center; }

/* ── ซ้าย: การ์ดปลายทาง ─────────────────────────── */
#windows .wp-list { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 10px 12px 14px; background: #fbf5e7; border-right: 1px solid #e3d2a8; }
#windows .wp-card { flex: none; position: relative; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 84px; padding: 8px 10px; text-align: left; font: inherit; color: inherit;
  border-radius: 14px; border: 2px solid transparent; background: #fffdf7; box-shadow: 0 1px 0 #e7d8b4; cursor: pointer; transition: background .18s, border-color .18s, box-shadow .18s; }
#windows .wp-card:hover { background: #fff8e6; }
#windows .wp-card:focus-visible { outline: 3px solid #e8b64a; outline-offset: 2px; }
#windows .wp-card.sel { border-color: #2f6f73; background: #eef6f5; box-shadow: 0 2px 8px #2f6f7338; }
#windows .wp-check { position: absolute; left: 8px; top: 8px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #2f6f73; color: #fff; font: 800 13px/1 var(--font); font-style: normal; box-shadow: 0 1px 3px #0004; }
#windows .wp-img { position: relative; display: block; width: 76px; height: 64px; border-radius: 10px; overflow: hidden; background: linear-gradient(135deg, #e9d9ae, #d9c28a); box-shadow: inset 0 0 0 1px #c9a85f88; }
#windows .wp-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
#windows .wp-img::after { content: '🌀'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; opacity: .4; z-index: 0; }
#windows .wp-img img { position: relative; z-index: 1; }
#windows .wp-body { display: grid; gap: 1px; min-width: 0; }
#windows .wp-body b { font: 700 16px/1.2 var(--font-head); }
#windows .wp-sub { font-size: 13px; color: #6b5a44; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#windows .wp-fee { display: inline-flex; align-items: center; gap: 5px; font: 700 14px/1.3 var(--font); color: #8a5a32; }
#windows .wp-fee i { font-style: normal; }
#windows .wp-fee.poor, #windows .wp-fee.poor i { color: #b4552d; }
#windows .wp-note { font-style: normal; font-size: 13px; color: #2f6f73; font-weight: 600; }
#windows .wp-note.poor { color: #b4552d; }
#windows .wp-note.lock { color: #6f6656; font-weight: 600; white-space: normal; }
#windows .wp-go { display: grid; place-items: center; min-width: 64px; height: 40px; padding: 0 14px; border-radius: 12px; font: 800 15px/1 var(--font-head); color: #fff;
  background: linear-gradient(#3f8a8e, #2f6f73); box-shadow: 0 2px 0 #1f4f52; pointer-events: auto; }
#windows .wp-go[aria-disabled="true"] { background: #cfc6b0; color: #7a705c; box-shadow: none; }
#windows .wp-lockbadge { font-size: 22px; opacity: .7; padding: 0 6px; }
#windows .wp-card.locked { background: #f1ebdc; }
#windows .wp-card.locked .wp-img img { filter: grayscale(1) opacity(.55); }
#windows .wp-card.locked .wp-body b, #windows .wp-card.locked .wp-fee { color: #7a705c; }
#windows .wp-card.poor .wp-img img { filter: saturate(.8); }

/* ── ขวา: รายละเอียด ─────────────────────────── */
#windows .wp-detail { min-height: 0; display: flex; flex-direction: column; background: #fffaf0; }
#windows .wp-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 18px 8px; display: flex; flex-direction: column; gap: 8px; }
#windows .wp-back { display: none; align-self: flex-start; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: #efe3c4; color: #5b4a36; font: 700 14px var(--font); cursor: pointer; }
#windows .wp-hero .wp-img.big { width: 100%; height: clamp(80px, 13vh, 120px); border-radius: 14px; }
#windows .wp-hero .wp-img.big::after { font-size: 48px; }
#windows .wp-detail h3 { margin: 4px 0 0; font: 800 22px/1.15 var(--font-head); }
#windows .wp-hsub { margin: 0; font-size: 14px; color: #2f6f73; font-weight: 600; }
#windows .wp-rows { display: grid; gap: 2px; margin-top: 4px; }
#windows .wp-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 4px; border-bottom: 1px dashed #e3d2a8; font-size: 14px; }
#windows .wp-row span { color: #6b5a44; }
#windows .wp-row b { color: #342c26; }
#windows .wp-row b.poor { color: #b4552d; }
#windows .wp-fac h4 { margin: 6px 0 4px; font: 700 14px var(--font-head); color: #2f6f73; }
#windows .wp-fac ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
#windows .wp-fac li { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 6px; border-radius: 999px; background: #f3e6c8; color: #5b4a36; font-size: 13px; font-weight: 600; }
#windows .wp-foot { flex: none; display: grid; gap: 8px; padding: 10px 18px 14px; background: linear-gradient(#fffaf0, #f6ecd2); border-top: 1px solid #e3d2a8; }
#windows .wp-gold { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: #f3ead2; box-shadow: inset 0 0 0 1px #d8c595; text-align: center; }
#windows .wp-gold small { display: block; font-size: 13px; color: #6b5a44; }
#windows .wp-gold b { font: 800 16px var(--font-head); color: #342c26; }
#windows .wp-gold > i { font: 800 22px/1 var(--font); font-style: normal; color: #8a7a60; }
#windows .wp-gold.poor > span:last-child b { color: #b4552d; }
#windows .wp-why { margin: 0; font-size: 14px; font-weight: 700; text-align: center; }
#windows .wp-why.poor { color: #b4552d; }
#windows .wp-why.locked { color: #6f6656; }
#windows .wp-cta { height: 52px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; cursor: pointer; font: 800 18px/1 var(--font-head); color: #fff;
  background: linear-gradient(#3f8a8e, #2f6f73); box-shadow: 0 3px 0 #1f4f52, 0 0 0 2px #e8b64a inset; transition: transform .12s; }
#windows .wp-cta:active { transform: translateY(2px); box-shadow: 0 1px 0 #1f4f52, 0 0 0 2px #e8b64a inset; }
#windows .wp-cta:disabled { background: #cfc6b0; color: #7a705c; box-shadow: none; cursor: not-allowed; }
#windows .wp-cta:focus-visible { outline: 3px solid #e8b64a; outline-offset: 2px; }

/* ── ป๊อปอัปยืนยัน (ใบเดียว) ─────────────────────────── */
#windows .wp-confirm { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: #3a2c1c66; animation: wpfade .15s ease-out; }
#windows .wp-dlg { width: min(360px, 100%); display: grid; gap: 10px; padding: 16px 18px 16px; border-radius: 16px; background: #fffaf0; box-shadow: 0 10px 30px #0005, 0 0 0 2px #e8b64a inset; }
#windows .wp-dlg h4 { margin: 0; text-align: center; font: 800 18px var(--font-head); color: #2f6f73; }
#windows .wp-dlg p { margin: 0; text-align: center; color: #4a3f33; }
#windows .wp-dlg-to { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; background: #f3ead2; }
#windows .wp-dlg-to .wp-img { width: 72px; height: 56px; flex: none; }
#windows .wp-dlg-to span:last-child { display: grid; }
#windows .wp-dlg-to b { font: 800 17px var(--font-head); }
#windows .wp-dlg-to small { font-size: 14px; color: #8a5a32; font-weight: 700; }
#windows .wp-dlg-a { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
#windows .wp-dlg-a button { height: 48px; border: 0; border-radius: 12px; font: 800 16px var(--font-head); cursor: pointer; }
#windows .wp-no { background: #e9dcb9; color: #5b4a36; }
#windows .wp-yes { background: linear-gradient(#3f8a8e, #2f6f73); color: #fff; box-shadow: 0 2px 0 #1f4f52; }
#windows .wp-dlg-a button:focus-visible { outline: 3px solid #e8b64a; outline-offset: 2px; }
@keyframes wpfade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #windows .wp-confirm { animation: none; } #windows .wp-card, #windows .wp-cta { transition: none; } }

/* ── จอแคบ (≤ 640px): ขั้น 1 รายการ → ขั้น 2 รายละเอียด ปุ่มวาร์ปติดล่าง ─────────── */
@media (max-width: 640px) {
  html:not(.touch-ui) #windows .win[data-win="warp"] { width: 100vw; height: 100vh; }
  #windows .wp-main { grid-template-columns: minmax(0, 1fr); }
  #windows .wp-list { border-right: 0; padding: 12px; }
  #windows .wp-card { min-height: 92px; }
  #windows .warp[data-view="list"] .wp-detail, #windows .warp[data-view="detail"] .wp-list { display: none; }
  #windows .wp-back { display: inline-flex; align-items: center; }
  #windows .wp-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  #windows .wp-cta { height: 56px; }
}

/* ── จอสัมผัสแนวนอน (เตี้ยราว 390px): บีบให้เห็นการ์ด + ปุ่มวาร์ปพร้อมกัน ─────────── */
html.touch-ui.land #windows .wp-top { padding: 5px 12px; }
html.touch-ui.land #windows .wp-top p { display: none; }
html.touch-ui.land #windows .wp-card { min-height: 64px; padding: 6px 8px; grid-template-columns: 60px minmax(0, 1fr) auto; }
html.touch-ui.land #windows .wp-img { width: 60px; height: 50px; }
html.touch-ui.land #windows .wp-sub { display: none; }
html.touch-ui.land #windows .wp-hero { display: none; }
html.touch-ui.land #windows .wp-scroll { padding: 6px 12px; gap: 4px; }
html.touch-ui.land #windows .wp-detail h3 { font-size: 18px; }
html.touch-ui.land #windows .wp-foot { padding: 6px 12px 8px; gap: 5px; }
html.touch-ui.land #windows .wp-why { display: none; }
html.touch-ui.land #windows .wp-gold { padding: 4px 10px; }
html.touch-ui.land #windows .wp-gold small { font-size: 13px; line-height: 1.1; }
html.touch-ui.land #windows .wp-fac h4 { display: none; }
html.touch-ui.land #windows .wp-cta { height: 48px; }
html.touch-ui.land #windows .wp-go { height: 44px; }
html.touch-ui #windows .wp-card, html.touch-ui #windows .wp-go { min-height: 44px; }

#windows .wp-fi { width: 24px; height: 24px; object-fit: contain; flex: none; }

/* ── 4 ต.ค.: ตัวนับ "เมือง 2/3" · เลเวลแนะนำบนการ์ด · การ์ดเมืองที่ยืนอยู่ ─────────── */
#windows .wp-count { flex: none; padding: 4px 12px; border-radius: 999px; background: #fff4d8; border: 1px solid #e8b64a99; color: #5b4a36; font-weight: 600; white-space: nowrap; }
#windows .wp-count b { color: #8a5a32; }
#windows .wp-count i { font-style: normal; color: #6b5a44; }
#windows .wp-lv { margin-left: 3px; padding: 1px 8px; border-radius: 999px; background: #eef6f5; color: #2f6f73; font: 700 13px/1.4 var(--font); }
#windows .wp-card.locked .wp-lv { background: #e6dfcd; color: #6f6656; }
#windows .wp-note.here { color: #2f6f73; }
#windows .wp-card.here { background: #f4f8f3; border-style: dashed; border-color: #2f6f7355; }
#windows .wp-card.here.sel { border-style: solid; border-color: #2f6f73; }
#windows .wp-why.here { color: #2f6f73; }
#windows .wp-fee { flex-wrap: wrap; white-space: nowrap; row-gap: 2px; }
/* จอสัมผัสแนวนอนซ่อน .wp-why เพื่อประหยัดที่ — แต่เมืองที่ล็อก/ที่ยืนอยู่ต้องเห็นเหตุผลเต็ม (ไม่มีอะไรให้คำนวณ Gold) */
html.touch-ui.land #windows .wp-why.locked, html.touch-ui.land #windows .wp-why.here { display: block; font-size: 13px; }
html.touch-ui.land #windows .wp-foot:has(.wp-why.locked) .wp-gold, html.touch-ui.land #windows .wp-foot:has(.wp-why.here) .wp-gold { display: none; }
html.touch-ui.land #windows .wp-count i { display: none; }
html.touch-ui.land #windows .wp-count, html.touch-ui.land #windows .wp-here { padding: 2px 10px; }
