/* TH Legendary tactical atlas (live map). Scoped under .thm so the rest of the site is untouched. */
.live-map-shell.thm-host { display: block; min-height: 0; gap: 0; }
.thm {
  --thm-bg: #0b0708;
  --thm-panel: rgba(18, 11, 13, .92);
  --thm-line: rgba(255, 255, 255, .09);
  --thm-line-2: rgba(255, 255, 255, .18);
  --thm-red: #e3262f;
  --thm-ember: #ff8a3d;
  --thm-gold: #f2b65a;
  --thm-text: #f6eff0;
  --thm-muted: #ab9da1;
  --thm-green: #3ddc84;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - var(--tl-bar-h, 68px) - 32px);
  min-height: 560px;
  border: 1px solid var(--thm-line-2);
  border-radius: 16px;
  overflow: hidden;
  background: var(--thm-bg);
  color: var(--thm-text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.dash-tab-panel .thm { height: 76vh; }

/* ---- command bar ---- */
.thm-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(227, 38, 47, .16), rgba(11, 7, 8, 0) 46%), #120b0d;
  border-bottom: 1px solid var(--thm-line-2);
}
.thm-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.thm-crest {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border-radius: 10px; background: linear-gradient(135deg, #e3262f, #ff6a3d);
  font: 800 13px/1 "Chakra Petch", sans-serif; color: #fff; letter-spacing: .5px;
  box-shadow: 0 0 18px rgba(227, 38, 47, .45);
}
.thm-brand b { display: block; font: 700 15px/1.15 "Chakra Petch", "Noto Sans Thai", sans-serif; letter-spacing: .4px; }
.thm-brand small { display: block; color: var(--thm-muted); font-size: 11.5px; }
.thm-stats { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.thm-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border: 1px solid var(--thm-line-2); border-radius: 999px; background: rgba(255, 255, 255, .03);
  font-size: 12px; color: var(--thm-muted); white-space: nowrap;
}
.thm-chip strong { color: var(--thm-text); font-variant-numeric: tabular-nums; }
.thm-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--thm-faint, #75696d); }
.thm-chip.is-live i { background: var(--thm-green); box-shadow: 0 0 0 0 rgba(61, 220, 132, .6); animation: thm-pulse 2s infinite; }
.thm-chip.is-off i { background: var(--thm-red); }
@keyframes thm-pulse { 70% { box-shadow: 0 0 0 7px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }

.thm-body { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.thm.panel-closed .thm-body { grid-template-columns: minmax(0, 1fr) 0; }

/* ---- stage ---- */
.thm-stage {
  position: relative; overflow: hidden; min-height: 0; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 50% 45%, #0e2a3a 0%, #071620 60%, #050c11 100%);
}
.thm-stage.is-dragging { cursor: grabbing; }
.thm-world { position: absolute; left: 0; top: 0; width: 1000px; height: 1000px; transform-origin: 0 0; will-change: transform; }
.thm-world img { position: absolute; inset: 0; width: 1000px; height: 1000px; user-select: none; -webkit-user-drag: none; filter: saturate(.92) brightness(.9); }
.thm-world svg, .thm-screen { position: absolute; left: 0; top: 0; overflow: visible; }
.thm-world svg { width: 1000px; height: 1000px; pointer-events: none; }
.thm-screen { width: 100%; height: 100%; pointer-events: none; }
.thm-world svg * { stroke-width: calc(1.4px / var(--z, 1)); }

.thm-grid line { stroke: rgba(255, 255, 255, .13); stroke-width: calc(1px / var(--z, 1)); }
.thm-grid text { fill: rgba(255, 255, 255, .42); font: 700 calc(11px / var(--z, 1)) "Chakra Petch", sans-serif; }

.thm-zone { fill-opacity: .2; stroke-opacity: .9; }
.thm-zone.sanctuary { fill: #b6f05c; stroke: #b6f05c; }
.thm-zone.migration { fill: #6fb6ff; stroke: #6fb6ff; stroke-dasharray: calc(6px / var(--z, 1)) calc(4px / var(--z, 1)); }
.thm-zone.patrol { fill: #ff5a64; stroke: #ff5a64; fill-opacity: .16; }
.thm-zone.spawn { fill: #f2b65a; stroke: #f2b65a; fill-opacity: .12; stroke-dasharray: calc(2px / var(--z, 1)) calc(3px / var(--z, 1)); }
.thm-zone.is-hit { fill-opacity: .42; stroke-width: calc(2.6px / var(--z, 1)); }
.thm-wall { fill: none; stroke: #ff3b3b; stroke-width: calc(2.2px / var(--z, 1)) !important; stroke-linejoin: round; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .9)); }
.thm-heat { fill: url(#thmHeat); stroke: none; }

/* ---- screen layer: labels & live markers ---- */
.thm-label { font: 700 11px "Chakra Petch", "Noto Sans Thai", sans-serif; paint-order: stroke; stroke: rgba(0, 0, 0, .85); stroke-width: 3px; stroke-linejoin: round; text-anchor: middle; letter-spacing: .2px; }
.thm-label.region { font-size: 13.5px; fill: #fff; letter-spacing: 1.6px; text-transform: uppercase; }
.thm-label.water { fill: #7fe6ff; font-weight: 600; }
.thm-label.bridge { fill: #f2b65a; }
.thm-label.tunnel { fill: #ff9a5a; }
.thm-label.coast { fill: #c9d6e6; font-weight: 600; font-style: italic; }
.thm-label.landmark { fill: #e7d3ff; }
.thm-label.spawn { fill: #f2b65a; font-size: 10px; }
.thm-poi-dot { stroke: rgba(0, 0, 0, .8); stroke-width: 1.2px; }
.thm-hit { pointer-events: all; cursor: pointer; }
.thm-node { fill: #3ddc84; stroke: #fff; stroke-width: 1.2px; }

.thm-player .ring { fill: none; stroke-width: 2px; }
.thm-player .core { stroke: #08120c; stroke-width: 2px; }
.thm-player text { font: 700 11px "Chakra Petch", "Noto Sans Thai", sans-serif; fill: #fff; paint-order: stroke; stroke: #000; stroke-width: 3px; text-anchor: middle; }
.thm-player.is-self .core { fill: #f2b65a; }
.thm-player.is-self .ring { stroke: #f2b65a; animation: thm-ring 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.thm-player .core { fill: #3ddc84; }
.thm-player .ring { stroke: #3ddc84; }
@keyframes thm-ring { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
.thm-ai circle { fill: #1a1310; stroke: #f2b65a; stroke-width: 1.4px; }
.thm-ai text { font: 800 8.5px "Chakra Petch", sans-serif; fill: #ffe3a0; text-anchor: middle; dominant-baseline: central; }
.thm-ai .thm-ai-icon { font: 14px "Segoe UI Emoji", "Apple Color Emoji", sans-serif; fill: #fff; stroke: none; }
.thm-pin path { fill: var(--thm-red); stroke: #fff; stroke-width: 1.5px; }

/* ---- HUD on stage ---- */
.thm-hud { position: absolute; z-index: 3; pointer-events: auto; }
.thm-zoom { right: 12px; bottom: 12px; display: grid; gap: 6px; }
.thm-btn {
  display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px;
  border: 1px solid var(--thm-line-2); border-radius: 10px; background: var(--thm-panel);
  color: var(--thm-text); font: 700 15px "Chakra Petch", sans-serif; cursor: pointer;
  backdrop-filter: blur(6px);
}
.thm-btn:hover { border-color: var(--thm-red); color: #fff; }
.thm-btn.is-on { background: var(--thm-red); border-color: var(--thm-red); }
.thm-readout {
  left: 12px; bottom: 12px; padding: 8px 12px; border: 1px solid var(--thm-line-2); border-radius: 10px;
  background: var(--thm-panel); font: 600 12px "Chakra Petch", monospace; color: var(--thm-muted);
  font-variant-numeric: tabular-nums; backdrop-filter: blur(6px);
}
.thm-readout b { color: var(--thm-gold); margin-right: 6px; }
.thm-scale { left: 12px; bottom: 54px; font: 600 10.5px "Chakra Petch", sans-serif; color: #fff; text-shadow: 0 1px 2px #000; }
.thm-scale span { display: block; height: 6px; border: 2px solid #fff; border-top: 0; margin-bottom: 2px; box-shadow: 0 1px 2px #000; }
.thm-rose { right: 14px; top: 12px; width: 46px; height: 46px; pointer-events: none; }
.thm-panel-toggle { left: 12px; top: 12px; }
.thm-card {
  left: 50%; top: 12px; transform: translateX(-50%); width: min(360px, calc(100% - 140px));
  padding: 12px 14px; border: 1px solid var(--thm-line-2); border-left: 3px solid var(--thm-red);
  border-radius: 12px; background: var(--thm-panel); backdrop-filter: blur(8px); display: none;
}
.thm-card.is-open { display: block; }
.thm-card p { margin: 0 0 2px; font: 700 10.5px "Chakra Petch", sans-serif; letter-spacing: 1.2px; color: var(--thm-red); text-transform: uppercase; }
.thm-card h3 { margin: 0 0 6px; font: 700 16px "Chakra Petch", "Noto Sans Thai", sans-serif; color: #fff; }
.thm-card code { display: block; font: 600 12px "Chakra Petch", monospace; color: var(--thm-muted); overflow-wrap: anywhere; }
.thm-card .thm-card-actions { display: flex; gap: 6px; margin-top: 8px; }
.thm-card .thm-btn { height: 30px; font-size: 12px; }
.thm-card-close { position: absolute; right: 8px; top: 8px; background: none; border: 0; color: var(--thm-muted); font-size: 18px; cursor: pointer; }

/* ---- side panel ---- */
.thm-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-left: 1px solid var(--thm-line-2); background: #100a0c; }
.thm.panel-closed .thm-panel { visibility: hidden; }
.thm-search { position: relative; padding: 12px; border-bottom: 1px solid var(--thm-line); }
.thm-search input {
  width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--thm-line-2); border-radius: 10px;
  background: #0b0708; color: var(--thm-text); font: 500 13px "Noto Sans Thai", sans-serif;
}
.thm-search input:focus { outline: none; border-color: var(--thm-red); }
.thm-results { position: absolute; left: 12px; right: 12px; top: 52px; z-index: 5; max-height: 260px; overflow: auto; border: 1px solid var(--thm-line-2); border-radius: 10px; background: #160e11; display: none; }
.thm-results.is-open { display: block; }
.thm-results button { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--thm-line); background: none; color: var(--thm-text); text-align: left; font: 500 13px "Noto Sans Thai", sans-serif; cursor: pointer; }
.thm-results button:hover, .thm-results button.is-active { background: rgba(227, 38, 47, .18); }
.thm-results small { color: var(--thm-muted); }
.thm-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--thm-line); }
.thm-tabs button { padding: 10px 4px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--thm-muted); font: 700 12.5px "Chakra Petch", "Noto Sans Thai", sans-serif; cursor: pointer; }
.thm-tabs button.is-on { color: #fff; border-bottom-color: var(--thm-red); }
.thm-pane { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 16px; }
.thm-pane[hidden] { display: none; }
.thm-group h4 { margin: 12px 0 6px; font: 700 10.5px "Chakra Petch", sans-serif; letter-spacing: 1.4px; color: var(--thm-muted); text-transform: uppercase; }
.thm-group:first-child h4 { margin-top: 2px; }
.thm-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.thm-toggle {
  display: flex; align-items: center; gap: 7px; padding: 7px 8px; border: 1px solid var(--thm-line); border-radius: 9px;
  background: rgba(255, 255, 255, .02); font-size: 12.5px; color: var(--thm-muted); cursor: pointer; user-select: none; min-width: 0;
}
.thm-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.thm-toggle i { width: 10px; height: 10px; flex: none; border-radius: 3px; background: var(--c); opacity: .35; }
.thm-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thm-toggle em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--thm-faint, #75696d); }
.thm-toggle.is-on { border-color: color-mix(in srgb, var(--c) 55%, transparent); color: #fff; background: color-mix(in srgb, var(--c) 10%, transparent); }
.thm-toggle.is-on i { opacity: 1; box-shadow: 0 0 8px var(--c); }
.thm-toggle:focus-within { outline: 1px solid var(--thm-red); }
.thm-select { width: 100%; margin-top: 6px; padding: 7px 8px; border: 1px solid var(--thm-line-2); border-radius: 9px; background: #0b0708; color: var(--thm-text); font: 500 12.5px "Noto Sans Thai", sans-serif; }
.thm-note { margin: 8px 0 0; padding: 8px 10px; border: 1px dashed var(--thm-line-2); border-radius: 9px; color: var(--thm-muted); font-size: 12px; line-height: 1.45; }
.thm-note a { color: var(--thm-gold); }
.thm-list { display: grid; gap: 6px; }
.thm-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--thm-line); border-radius: 9px; background: rgba(255, 255, 255, .02); color: var(--thm-text); font-size: 13px; cursor: pointer; text-align: left; }
.thm-row:hover { border-color: var(--thm-red); }
.thm-row i { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #3ddc84); }
.thm-row small { color: var(--thm-muted); font-size: 11.5px; }
.thm-empty { color: var(--thm-muted); font-size: 12.5px; padding: 6px 2px; }
.thm-facts { display: grid; gap: 8px; font-size: 12.5px; color: var(--thm-muted); line-height: 1.5; }
.thm-facts b { color: #fff; }

@media (max-width: 900px) {
  .thm { height: auto; min-height: 0; }
  .thm-body, .thm.panel-closed .thm-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 68vh auto; }
  .thm-panel { border-left: 0; border-top: 1px solid var(--thm-line-2); max-height: none; }
  .thm.panel-closed .thm-panel { display: none; }
  .thm-stats { margin-left: 0; }
  .thm-card { top: auto; bottom: 60px; width: calc(100% - 24px); }
}
@media (prefers-reduced-motion: reduce) { .thm-chip.is-live i, .thm-player.is-self .ring { animation: none; } }
