/* tac-world.css — แผนที่โรงเรียนแบบเกมแทคติก (FAA.tacworld) · โหลดหลัง game.css
   ชั้นที่เพิ่มทั้งหมด pointer-events:none · หมุดเดิมของ map.js ยังเป็นปุ่มเหมือนเดิม */
.mapwrap.tw-on {
  --tw-ink: #2b1a0c; --tw-ink2: #5a3d22; --tw-brown: #3a2312; --tw-tan: #a9824c;
  --tw-gold: #e2b54a; --tw-gold2: #f7dc8a; --tw-blue: #0d3a78; --tw-night: #0a2147;
  --tw-paper: #fbf3dd; --tw-paper2: #ecdcb3;
  container-type: inline-size;
  border: 3px solid var(--tw-brown); border-radius: 10px;
  box-shadow: 0 3px 0 rgba(32,16,4,.45);
  background: #6f8f4e;
}
/* กรอบไม้ + เส้นทองด้านใน (ชั้นบนสุดของแผนที่ ไม่รับการแตะ) */
.tw-frame {
  position: absolute; inset: 0; z-index: 5; pointer-events: none; border-radius: 7px;
  box-shadow: inset 0 0 0 2px var(--tw-gold), inset 0 0 0 3px #6b4a20, inset 0 0 0 5px rgba(255,236,180,.35);
}
.tw-frame::before, .tw-frame::after {
  content: ""; position: absolute; width: 12px; height: 12px; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--tw-gold2), #b9821f); box-shadow: 0 0 0 1.5px var(--tw-brown);
}
.tw-frame::before { left: -5px; top: -5px; }
.tw-frame::after { right: -5px; bottom: -5px; }
/* โทนแผนที่โลกเก่าเล็กน้อย (กล่องแผนที่เท่านั้น) */
.mapwrap.tw-on .worldcv { filter: saturate(.92) sepia(.12) contrast(1.02); }
.mapwrap.tw-on.tod-eve .worldcv { filter: saturate(.95) sepia(.24) brightness(.96); }

/* ---------- ชื่อสถานที่ ---------- */
.mapwrap.tw-on .maplabel {
  font: 600 10.5px var(--fh, Kanit, sans-serif); letter-spacing: .02em;
  fill: #fff8e3; stroke: #3a2312; stroke-width: 3.2px; paint-order: stroke;
}

/* ---------- เส้นทาง ---------- */
.tw-routes { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; overflow: visible; }
.tw-route path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tw-case { stroke: #3a2312; stroke-width: 5; opacity: .8; }
.tw-line { stroke: #f2c95a; stroke-width: 2.4; }
.tw-glint { stroke: #fff6cf; stroke-width: 1; stroke-dasharray: 1.2 7; opacity: .85; }
.tw-route-done .tw-case { opacity: .55; stroke-width: 4.4; }
.tw-route-done .tw-line { stroke: #d9ad45; stroke-width: 2; opacity: .9; }
.tw-route-done .tw-glint { display: none; }
.tw-route-open .tw-case { stroke-width: 6; opacity: .9; }
.tw-route-open .tw-line { stroke: #ffd65e; stroke-width: 3.2; }
.tw-route-open .tw-glint { stroke-dasharray: 3.5 9; stroke-width: 1.5; animation: twFlow 1.3s linear infinite; }
.tw-route-locked .tw-case { stroke: rgba(43,26,12,.5); stroke-width: 3.6; stroke-dasharray: 4 5; opacity: 1; }
.tw-route-locked .tw-line { stroke: rgba(255,240,200,.8); stroke-width: 1.5; stroke-dasharray: 4 5; }
.tw-hub-b { stroke: #3a2312; stroke-width: 1.3; fill: #d9ad45; }
.tw-hub-t { fill: rgba(255,250,220,.8); }
.tw-hub-open .tw-hub-b { fill: #ffd65e; }
.tw-hub-locked .tw-hub-b { fill: #c9c2b0; stroke: rgba(43,26,12,.6); }
.tw-hub-locked .tw-hub-t { fill: rgba(255,255,255,.5); }
@keyframes twFlow { to { stroke-dashoffset: -14; } }

/* ---------- เข็มทิศ ---------- */
.tw-c-disc { fill: rgba(251,243,221,.92); stroke: #3a2312; stroke-width: 1.6; }
.tw-c-ring { fill: none; stroke: #a9824c; stroke-width: 1; }
.tw-c-ring2 { fill: none; stroke: #c8a76c; stroke-width: .8; stroke-dasharray: 1.2 1.6; }
.tw-c-tick { stroke: #5a3d22; stroke-width: .9; }
.tw-c-minor { fill: #c99a3a; } .tw-c-minor2 { fill: #8a611c; }
.tw-c-m1 { fill: #1a56a6; } .tw-c-m2 { fill: #0a2147; }
.tw-c-n1 { fill: #e0362d; } .tw-c-n2 { fill: #8a1912; }
.tw-c-hub { fill: #f7dc8a; stroke: #3a2312; stroke-width: .9; }
.tw-c-n { font: 700 9px var(--fh, Kanit, sans-serif); fill: #fff8e3; stroke: #3a2312; stroke-width: 2.6px; paint-order: stroke; }

/* ---------- หมุด → อัญมณีข้าวหลามตัด ---------- */
/* ซ่อนวงกลมเดิม (ยกเว้นวงแรกที่เป็นเป้ากดใส) · ตัวเลข/ไอคอนของ map.js ยังอยู่บนอัญมณี */
.mapwrap.tw-on .pin.tw-pin > circle:not(:first-of-type) { display: none; }
.tw-node { pointer-events: none; }
.tw-shadow { fill: rgba(20,12,4,.38); }
.tw-halo { fill: rgba(255,248,220,.0); stroke: rgba(255,240,190,.0); }
.tw-open .tw-halo { fill: rgba(140,200,255,.18); stroke: rgba(210,236,255,.55); stroke-width: 1; }
.tw-cur .tw-halo { fill: rgba(255,170,140,.22); stroke: rgba(255,226,200,.7); stroke-width: 1.2; }
.tw-passed .tw-halo { fill: rgba(255,226,140,.18); stroke: rgba(255,240,190,.45); stroke-width: 1; }
.tw-sidering { fill: none; stroke: #ffe28a; stroke-width: 1.6; stroke-dasharray: 3 2.4; }
.tw-top { stroke: none; }
.tw-facet-a { fill: rgba(255,255,255,.34); }
.tw-facet-b { fill: rgba(0,0,0,.2); }
.tw-table { fill: rgba(255,255,255,.1); stroke: rgba(255,255,255,.45); stroke-width: .8; }
.tw-rim { fill: none; stroke: #2a1709; stroke-width: 1.8; stroke-linejoin: round; }
.tw-rim-in { fill: none; stroke: rgba(255,236,170,.75); stroke-width: .9; }
.tw-cur .tw-rim-in, .tw-passed .tw-rim-in { stroke: #ffe9a6; }
.tw-shine { fill: rgba(255,255,255,.55); }
.tw-locked .tw-shine { fill: rgba(255,255,255,.35); }
.tw-side-l, .tw-side-r { stroke: #2a1709; stroke-width: 1.2; stroke-linejoin: round; }
.tw-pulse { fill: none; stroke: #bfe2ff; stroke-width: 2; transform-box: fill-box; transform-origin: center;
  animation: twPulse 1.8s ease-out infinite; }
.tw-cur .tw-pulse { stroke: #ffcf9e; }
@keyframes twPulse { from { opacity: .95; transform: scale(.9); } to { opacity: 0; transform: scale(1.55); } }
.tw-arrow { transform-box: fill-box; transform-origin: center bottom; animation: twBob 1s ease-in-out infinite; }
.tw-arrow-b { fill: #f7c640; stroke: #3a2312; stroke-width: 1.6; stroke-linejoin: round; }
.tw-arrow-h { fill: #fff6cf; }
@keyframes twBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ตัวเลข/ไอคอนบนอัญมณี */
.mapwrap.tw-on .pinnum { font: 700 13px var(--fh, Kanit, sans-serif); fill: #fff; stroke: rgba(10,20,40,.75); stroke-width: 2.6px; paint-order: stroke; }
.mapwrap.tw-on .pin-locked .pinnum { fill: #f3f5f7; stroke: #3f4851; }
.mapwrap.tw-on .pin-passed .pinic path { stroke: #4a2f05; stroke-width: 3.4; }
.mapwrap.tw-on .pin-passed.pin-sel .pinic path { stroke: #fff; }
.mapwrap.tw-on .pinsmall { font: 700 9.5px var(--fh, Kanit, sans-serif); fill: #fff8e3; stroke: #3a2312; stroke-width: 2.6px; paint-order: stroke; }
.mapwrap.tw-on .pinlock circle { fill: #fbf3dd; stroke: #3a2312; stroke-width: 2; }
.mapwrap.tw-on .pinlock path, .mapwrap.tw-on .pinlock rect { stroke: #3f4851; }
/* โฟกัสคีย์บอร์ด: ขอบขาว + เส้นทองหนา */
.mapwrap.tw-on .pin:focus-visible .tw-rim { stroke: #fff; stroke-width: 3.2; }
.mapwrap.tw-on .pin:focus-visible .tw-halo { fill: rgba(255,255,255,.25); stroke: #ffb400; stroke-width: 2.4; }
.mapwrap.tw-on .pin:hover .tw-top { filter: brightness(1.08); }

/* ---------- ป้ายชื่อหมุดที่เลือก (กระดาษ) ---------- */
.tw-plate {
  position: absolute; z-index: 4; pointer-events: none; box-sizing: border-box;
  padding: .32em .6em .38em; color: var(--tw-ink);
  font-size: clamp(10.5px, 2.95cqw, 15px); line-height: 1.25;
  border: 2px solid var(--tw-brown); border-radius: 6px;
  background-color: var(--tw-paper);
  background-image:
    repeating-radial-gradient(circle at 17% 23%, rgba(120,80,30,.05) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, var(--tw-paper) 0%, #f3e6c4 60%, var(--tw-paper2) 100%);
  box-shadow: inset 0 0 0 1px #fffaea, inset 0 0 0 2px var(--tw-tan), 0 3px 0 rgba(32,16,4,.5);
  animation: twPlateIn .22s ease-out both;
}
.tw-plate-kick { display: flex; align-items: center; gap: .4em; font: 600 .82em/1.2 var(--fh, Kanit, sans-serif); }
.tw-plate-kick b { color: #fff; background: linear-gradient(180deg, #2a66b8, var(--tw-blue) 55%, var(--tw-night)); padding: .05em .45em; border-radius: 3px; font-weight: 600; box-shadow: 0 0 0 1px var(--tw-gold); }
.tw-plate-tag { margin-left: auto; padding: 0 .45em; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.tw-tag-open { color: #fff; background: #0755ad; }
.tw-tag-passed { color: #3d2800; background: #f2c24a; }
.tw-tag-locked { color: #fff; background: #56616c; }
.tw-plate-name { font: 700 1.12em/1.25 var(--fh, Kanit, sans-serif); margin-top: .15em; color: var(--tw-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-plate-sub { font-size: .78em; color: var(--tw-ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-plate-tail { position: absolute; width: 10px; height: 10px; background: #f3e6c4; border: 2px solid var(--tw-brown); transform: rotate(45deg); }
.tw-plate-top .tw-plate-tail { bottom: -7px; margin-left: -6px; border-top: 0; border-left: 0; background: var(--tw-paper2); }
.tw-plate-bottom .tw-plate-tail { top: -7px; margin-left: -6px; border-bottom: 0; border-right: 0; background: var(--tw-paper); }
.tw-plate-right .tw-plate-tail { left: -7px; margin-top: -6px; border-top: 0; border-right: 0; }
.tw-plate-left .tw-plate-tail { right: -7px; margin-top: -6px; border-bottom: 0; border-left: 0; }
@keyframes twPlateIn { from { opacity: 0; transform: translateY(4px) scale(.97); } }

/* ---------- ป้ายชื่อบท ---------- */
.tw-chapter {
  position: absolute; z-index: 4; pointer-events: none; left: 50%; top: 1.1%;
  transform: translateX(-50%); width: max-content; max-width: 66%; box-sizing: border-box;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .5em; align-items: center;
  padding: .28em .9em .32em .7em; font-size: clamp(10px, 3cqw, 15px);
  color: #fff; border: 2px solid var(--tw-brown); border-radius: 6px;
  background: linear-gradient(180deg, #2a66b8 0%, var(--tw-blue) 48%, var(--tw-night) 100%);
  box-shadow: inset 0 0 0 1px var(--tw-gold), inset 0 1px 0 1px rgba(255,255,255,.2), 0 3px 0 rgba(32,16,4,.5);
  animation: twChIn .35s ease-out both;
}
.tw-ch-orn { grid-row: 1 / span 2; width: .9em; height: .9em; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--tw-gold2), #b9821f); box-shadow: 0 0 0 1.5px var(--tw-brown), 0 0 0 3px rgba(247,220,138,.35); margin: 0 .2em; }
.tw-ch-label { font: 600 .74em/1.15 var(--fh, Kanit, sans-serif); color: var(--tw-gold2); letter-spacing: .06em; }
.tw-ch-title { grid-column: 2; font: 700 1.04em/1.2 var(--fh, Kanit, sans-serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 0 #041633; }
.tw-ch-prog { position: absolute; right: -2px; bottom: -.95em; font: 600 .66em/1 var(--fh, Kanit, sans-serif); color: var(--tw-ink);
  background: var(--tw-gold2); border: 1.5px solid var(--tw-brown); border-radius: 999px; padding: .12em .5em; }
@keyframes twChIn { from { opacity: 0; transform: translate(-50%, -6px); } }

.tw-live { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }

/* ---------- ไม่มีการเคลื่อนไหว ---------- */
.mapwrap.tw-still .tw-pulse, .mapwrap.tw-still .tw-arrow, .mapwrap.tw-still .tw-glint,
.mapwrap.tw-still .tw-plate, .mapwrap.tw-still .tw-chapter { animation: none; }
.mapwrap.tw-still .tw-pulse { display: none; }
@media (prefers-reduced-motion: reduce) {
  .tw-pulse, .tw-arrow, .tw-glint, .tw-plate, .tw-chapter { animation: none !important; }
  .tw-pulse { display: none; }
}

/* ---------- คำอธิบายสัญลักษณ์ (FAA.tacworld.legend) ---------- */
.tw-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .8rem; color: #3a2a18; margin: 10px 2px 8px; }
.tw-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tw-lg { display: inline-block; width: 11px; height: 11px; transform: rotate(45deg); border: 1.5px solid #2a1709; border-radius: 1px;
  box-shadow: 1.5px 1.5px 0 rgba(42,23,9,.55); }
.tw-lg-open { background: linear-gradient(135deg, #9fd2ff, #3f8ae6 45%, #1550a8); }
.tw-lg-cur { background: linear-gradient(135deg, #ffb4a3, #f05a44 45%, #c42c22); }
.tw-lg-passed { background: linear-gradient(135deg, #fff2b8, #f5cf5a 45%, #d39a22); }
.tw-lg-locked { background: linear-gradient(135deg, #e3e8ec, #aab5bf 45%, #7d8a96); }
.tw-lg-side { background: #fbf3dd; border: 1.5px dashed #b9821f; box-shadow: none; }
/* ที่เลือกแต่ผ่าน/ล็อก: เรืองแดงรอบอัญมณี */
.tw-passed.tw-cur .tw-halo, .tw-locked.tw-cur .tw-halo { fill: rgba(240,90,68,.22); stroke: #ffb4a3; stroke-width: 1.4; }
.tw-passed.tw-cur .tw-pulse, .tw-locked.tw-cur .tw-pulse { stroke: #ffb4a3; }
