/* ─────────────────────────────────────────────────────────────
   Bangna Weather Twin
   A self-contained visual language for the 3D sub-page.
   ───────────────────────────────────────────────────────────── */

:root {
  --bg0: #030b14;
  --bg1: #061827;
  --bg2: #0a2233;
  --ink: #eaf7ff;
  --muted: #8db2c7;
  --dim: #5f8298;
  --cyan: #3ee8ff;
  --teal: #1ad1b0;
  --amber: #ffb454;
  --violet: #a08dff;
  --red: #ff6b7a;
  --glass: rgba(5, 20, 33, 0.62);
  --glass-2: rgba(9, 31, 48, 0.42);
  --stroke: rgba(120, 220, 255, 0.17);
  --stroke-strong: rgba(120, 220, 255, 0.38);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
  --sans: "IBM Plex Sans Thai", "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body.tw-body {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 700px at 52% 28%, #0b2c42 0%, transparent 62%),
    radial-gradient(900px 600px at 15% 90%, #071c2b 0%, transparent 58%),
    linear-gradient(160deg, var(--bg0) 0%, var(--bg1) 48%, #020810 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.tw-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.tw-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.tw-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 45%, rgba(0, 0, 0, 0.28) 100%),
    linear-gradient(to bottom, rgba(2, 8, 14, 0.34), transparent 22%, transparent 72%, rgba(2, 8, 14, 0.58));
}

.tw-grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

/* ── Glass ─────────────────────────────────────────────────── */
.tw-glass {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 32%),
    linear-gradient(180deg, var(--glass), var(--glass-2));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
}

/* ── Top bar ───────────────────────────────────────────────── */
.tw-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tw-topbar > * { pointer-events: auto; }

.tw-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.tw-brand-mark {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.tw-brand-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(62, 232, 255, 0.5);
  box-shadow: 0 0 22px rgba(62, 232, 255, 0.22), inset 0 0 18px rgba(62, 232, 255, 0.14);
  animation: tw-spin 14s linear infinite;
}

.tw-brand-ring::before,
.tw-brand-ring::after {
  content: "";
  position: absolute;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.tw-brand-ring::before {
  top: -2px;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: translateX(-50%);
}

.tw-brand-ring::after {
  bottom: 3px;
  right: 3px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  opacity: 0.6;
}

.tw-brand-diamond {
  font-size: 15px;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(62, 232, 255, 0.85);
}

.tw-brand-copy { min-width: 0; }

.tw-kicker {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--cyan);
  text-transform: uppercase;
  white-space: nowrap;
}

.tw-title {
  margin: 3px 0 1px;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.55);
}

.tw-sub {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

.tw-topbar-center {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tw-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(4, 18, 29, 0.55);
  backdrop-filter: blur(14px);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  white-space: nowrap;
}

.tw-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 rgba(26, 209, 176, 0.5);
  animation: tw-pulse 2.1s ease-out infinite;
}

.tw-live.is-stale { color: var(--amber); }
.tw-live.is-offline { color: var(--red); }
.tw-live.is-offline .tw-live-dot { animation: none; opacity: 0.7; }

.tw-condition {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(4, 18, 29, 0.55);
  backdrop-filter: blur(14px);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
.tw-condition-icon { font-size: 15px; line-height: 1; }
.tw-condition-label { letter-spacing: 0.01em; }

.tw-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 100px;
}

.tw-clock-time {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1;
}

.tw-clock-date {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.tw-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tw-lang {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--stroke);
  background: rgba(4, 18, 29, 0.52);
  backdrop-filter: blur(14px);
}

.tw-chip {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease;
}

.tw-chip:hover { color: var(--ink); }
.tw-chip.is-on {
  color: #03121a;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  box-shadow: 0 0 18px rgba(62, 232, 255, 0.28);
}

.tw-icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 11px;
  border: 1px solid var(--stroke);
  background: rgba(4, 18, 29, 0.52);
  color: var(--muted);
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.tw-icon-btn svg { width: 16px; height: 16px; }
.tw-icon-btn:hover {
  color: var(--cyan);
  border-color: var(--stroke-strong);
  background: rgba(10, 38, 56, 0.7);
  transform: translateY(-1px);
}
.tw-icon-btn:active { transform: translateY(0); }

/* ── HUD ───────────────────────────────────────────────────── */
.tw-hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.tw-hud > * { pointer-events: auto; }

/* ── Metrics ───────────────────────────────────────────────── */
.tw-metrics {
  position: absolute;
  left: 26px;
  bottom: 64px;
  width: 600px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-radius: 22px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tw-metric {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 9px 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.tw-metric:hover {
  border-color: var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  transform: translateY(-1px);
}

.tw-metric-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 9px;
  border: 1px solid rgba(62, 232, 255, 0.16);
  background: linear-gradient(145deg, rgba(62, 232, 255, 0.16), rgba(26, 209, 176, 0.05));
  color: var(--cyan);
}

.tw-metric-icon svg { width: 15px; height: 15px; }

.tw-metric-body { min-width: 0; }

.tw-metric-label {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.tw-metric-value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-top: 1px;
  line-height: 1.05;
}

.tw-metric-value b {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.tw-unit {
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--dim);
  white-space: nowrap;
}

.tw-metric-sub {
  margin-top: 2px;
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Wind compass ──────────────────────────────────────────── */
.tw-wind {
  position: absolute;
  right: 26px;
  bottom: 428px;
  width: 178px;
  padding: 12px 14px 11px;
  border-radius: 20px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tw-wind-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.tw-wind-dir {
  color: var(--cyan);
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

.tw-compass {
  position: relative;
  width: 132px;
  height: 132px;
  margin: 8px auto 7px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(62, 232, 255, 0.08) 0%, transparent 66%),
    rgba(3, 14, 24, 0.45);
  border: 1px solid var(--stroke);
}

.tw-compass-rings {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px dashed rgba(120, 220, 255, 0.16);
}

.tw-compass-rings::before,
.tw-compass-rings::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(120, 220, 255, 0.1);
}
.tw-compass-rings::before { inset: 14px; }
.tw-compass-rings::after { inset: 27px; }

.tw-cardinal {
  position: absolute;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--dim);
}
.tw-cardinal.n { top: 5px; left: 50%; transform: translateX(-50%); color: var(--cyan); }
.tw-cardinal.e { right: 6px; top: 50%; transform: translateY(-50%); }
.tw-cardinal.s { bottom: 5px; left: 50%; transform: translateX(-50%); }
.tw-cardinal.w { left: 6px; top: 50%; transform: translateY(-50%); }

.tw-needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 55px;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.tw-needle-tip {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 12px solid var(--amber);
  filter: drop-shadow(0 0 7px rgba(255, 180, 84, 0.8));
}

.tw-needle::before {
  content: "";
  position: absolute;
  inset: 10px 0 0;
  background: linear-gradient(to top, rgba(255, 180, 84, 0.05), rgba(255, 180, 84, 0.8));
}

.tw-needle-tail {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 12px;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, rgba(255, 180, 84, 0.4), transparent);
}

.tw-compass-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(120, 220, 255, 0.18);
  background: rgba(3, 14, 24, 0.78);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 24px rgba(62, 232, 255, 0.08);
}

.tw-compass-center b {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
}

.tw-compass-center span {
  margin-top: 2px;
  font-size: 7.5px;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.tw-wind-foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 8px;
  letter-spacing: 0.05em;
  color: var(--dim);
  text-transform: uppercase;
}

.tw-wind-foot b {
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
}

/* ── Camera ────────────────────────────────────────────────── */
.tw-camera {
  position: absolute;
  right: 26px;
  bottom: 64px;
  width: 342px;
  padding: 9px;
  border-radius: 20px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tw-cam-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 3px 8px;
}

.tw-cam-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--cyan);
}

.tw-cam-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px rgba(255, 107, 122, 0.9);
  animation: tw-blink 1.8s ease-in-out infinite;
}

.tw-cam-expand {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--stroke);
  background: rgba(4, 18, 29, 0.5);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.tw-cam-expand svg { width: 12px; height: 12px; }
.tw-cam-expand:hover { color: var(--cyan); border-color: var(--stroke-strong); }

.tw-cam-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(120, 220, 255, 0.14);
  background:
    radial-gradient(circle at 50% 45%, rgba(62, 232, 255, 0.08), transparent 60%),
    #020a12;
}

.tw-cam-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: opacity 0.5s ease, transform 0.7s ease;
}

.tw-cam-frame:hover img { transform: scale(1.02); }

.tw-cam-empty {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 14px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--dim);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 9px),
    radial-gradient(circle at 50% 40%, rgba(62, 232, 255, 0.06), transparent 65%);
}

.tw-camera.is-empty .tw-cam-empty { display: grid; }
.tw-camera.is-empty img { opacity: 0; }

.tw-cam-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 3px 1px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--dim);
}

.tw-cam-foot span:first-child { color: var(--muted); }

/* ── Hotspots ──────────────────────────────────────────────── */
.tw-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 18;
}

.tw-hotspot {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.4s ease;
  -webkit-appearance: none;
  appearance: none;
}

.tw-hotspot.is-visible { opacity: 1; }

.tw-hotspot-dot {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(62, 232, 255, 0.45), 0 0 14px rgba(62, 232, 255, 0.9);
  animation: tw-hotspot 2.4s ease-out infinite;
}

.tw-hotspot-dot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid rgba(62, 232, 255, 0.35);
}

.tw-hotspot-label {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(3, 14, 24, 0.78);
  backdrop-filter: blur(10px);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.tw-hotspot:hover .tw-hotspot-label,
.tw-hotspot.is-active .tw-hotspot-label {
  opacity: 1;
  transform: translateX(0);
  color: var(--ink);
}

.tw-hotspot:hover .tw-hotspot-dot,
.tw-hotspot.is-active .tw-hotspot-dot {
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(255, 180, 84, 0.4), 0 0 18px rgba(255, 180, 84, 0.95);
}

/* ── Detail card ───────────────────────────────────────────── */
.tw-detail {
  position: absolute;
  left: 50%;
  bottom: 84px;
  z-index: 22;
  width: min(430px, calc(100vw - 32px));
  padding: 20px 22px 19px;
  border-radius: 20px;
  transform: translateX(-50%);
  animation: tw-up 0.3s ease both;
}

.tw-detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.tw-detail-close:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }

.tw-detail-kicker {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
}

.tw-detail-title {
  margin: 4px 0 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tw-detail-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}

.tw-detail-value b {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
}

.tw-detail-value span {
  font-size: 11px;
  color: var(--muted);
}

.tw-detail-desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}

/* ── Footer ────────────────────────────────────────────────── */
.tw-footer {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--dim);
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.tw-hint { color: var(--dim); }
.tw-source { text-align: right; }
.tw-sensors-link {
  color: var(--cyan);
  text-decoration: none;
  pointer-events: auto;
  white-space: nowrap;
}
.tw-sensors-link:hover { text-decoration: underline; }

/* ── Loading ───────────────────────────────────────────────── */
.tw-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    radial-gradient(700px 500px at 50% 45%, #0a2538 0%, transparent 62%),
    linear-gradient(160deg, #030b14, #020810);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.tw-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tw-loading-mark {
  position: relative;
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.tw-loading-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(62, 232, 255, 0.16);
  border-top-color: var(--cyan);
  border-right-color: rgba(26, 209, 176, 0.6);
  animation: tw-spin 1.7s linear infinite;
  box-shadow: 0 0 34px rgba(62, 232, 255, 0.16);
}

.tw-loading-hex {
  font-size: 22px;
  color: var(--cyan);
  text-shadow: 0 0 22px rgba(62, 232, 255, 0.9);
  animation: tw-breathe 2.2s ease-in-out infinite;
}

.tw-loading-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tw-loading-sub {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  min-height: 14px;
}

.tw-loading-bar {
  width: min(320px, 64vw);
  height: 2px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(120, 220, 255, 0.13);
  overflow: hidden;
}

.tw-loading-bar span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  box-shadow: 0 0 14px rgba(62, 232, 255, 0.65);
  transition: width 0.45s ease;
}

/* ── Fallback / noscript ───────────────────────────────────── */
.tw-fallback {
  position: fixed;
  top: 84px;
  left: 50%;
  z-index: 40;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 84, 0.25);
  background: rgba(28, 18, 4, 0.72);
  backdrop-filter: blur(14px);
  font-size: 10px;
  color: #ffd7a0;
}

.tw-fallback-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  flex: 0 0 auto;
}

.tw-noscript {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #030b14;
  color: var(--ink);
  font-size: 14px;
}

/* ── Cinematic mode ────────────────────────────────────────── */
body.cinematic .tw-metrics,
body.cinematic .tw-wind,
body.cinematic .tw-camera,
body.cinematic .tw-footer,
body.cinematic .tw-hotspots,
body.cinematic .tw-actions,
body.cinematic .tw-topbar-center {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

body.cinematic .tw-hotspot { pointer-events: none; }

body.cinematic .tw-topbar {
  padding-top: 28px;
}

body.cinematic::before,
body.cinematic::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  height: 7vh;
  z-index: 24;
  background: #000;
  pointer-events: none;
  animation: tw-bar 0.5s ease both;
}

body.cinematic::before { top: 0; }
body.cinematic::after { bottom: 0; }

.tw-cinema-exit {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(4, 18, 29, 0.72);
  backdrop-filter: blur(14px);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.tw-cinema-exit:hover { color: var(--ink); border-color: var(--stroke-strong); }

.tw-cinema-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

/* ── Camera modal ──────────────────────────────────────────── */
.tw-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
}

.tw-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 6, 11, 0.82);
  backdrop-filter: blur(12px);
}

.tw-modal-body {
  position: relative;
  z-index: 1;
  width: min(1100px, 94vw);
  max-height: 90vh;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(4, 16, 26, 0.92);
  box-shadow: var(--shadow);
  animation: tw-modal-in 0.3s ease both;
}

.tw-modal-body img {
  display: block;
  width: 100%;
  max-height: calc(90vh - 70px);
  object-fit: contain;
  border-radius: 11px;
  background: #020a12;
}

.tw-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: rgba(4, 18, 29, 0.92);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.tw-modal-foot {
  display: flex;
  justify-content: space-between;
  padding: 9px 4px 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes tw-spin { to { transform: rotate(360deg); } }
@keyframes tw-pulse {
  0% { box-shadow: 0 0 0 0 rgba(26, 209, 176, 0.5); }
  70% { box-shadow: 0 0 0 9px rgba(26, 209, 176, 0); }
  100% { box-shadow: 0 0 0 0 rgba(26, 209, 176, 0); }
}
@keyframes tw-hotspot {
  0% { box-shadow: 0 0 0 0 rgba(62, 232, 255, 0.45), 0 0 14px rgba(62, 232, 255, 0.9); }
  70% { box-shadow: 0 0 0 12px rgba(62, 232, 255, 0), 0 0 14px rgba(62, 232, 255, 0.9); }
  100% { box-shadow: 0 0 0 0 rgba(62, 232, 255, 0), 0 0 14px rgba(62, 232, 255, 0.9); }
}
@keyframes tw-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes tw-breathe {
  0%, 100% { opacity: 0.65; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.04); }
}
@keyframes tw-up {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes tw-bar {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
@keyframes tw-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Detail card uses translateX(-50%) already; override the shared keyframe
   origin for elements that are not horizontally centered. */
.tw-detail { animation-name: tw-up-detail; }
@keyframes tw-up-detail {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .tw-metrics { width: 545px; }
  .tw-camera { width: 310px; }
  .tw-wind { width: 168px; bottom: 400px; }
  .tw-compass { width: 122px; height: 122px; }
  .tw-needle { height: 50px; }
}

@media (max-width: 980px) {
  .tw-topbar-center { display: none; }
  .tw-metrics { width: 500px; }
  .tw-camera { width: 286px; }
  .tw-wind { width: 156px; bottom: 372px; }
  .tw-compass { width: 112px; height: 112px; }
  .tw-needle { height: 46px; }
  .tw-compass-center { width: 56px; height: 56px; }
  .tw-compass-center b { font-size: 16px; }
}

@media (max-width: 820px) {
  .tw-topbar {
    padding: 14px 14px;
    align-items: flex-start;
  }
  .tw-brand { gap: 9px; }
  .tw-brand-mark { width: 36px; height: 36px; }
  .tw-brand-diamond { font-size: 12px; }
  .tw-kicker { font-size: 7.5px; }
  .tw-title { font-size: 18px; }
  .tw-sub { display: none; }
  .tw-actions { gap: 4px; }
  .tw-lang { padding: 2px; }
  .tw-chip { min-width: 28px; height: 23px; font-size: 8.5px; }
  .tw-icon-btn { width: 30px; height: 30px; border-radius: 9px; }
  .tw-icon-btn svg { width: 14px; height: 14px; }
  .tw-metrics {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding: 8px;
    border-radius: 18px;
  }
  .tw-metric { padding: 7px 7px 6px; gap: 7px; }
  .tw-metric-icon { width: 25px; height: 25px; }
  .tw-metric-icon svg { width: 13px; height: 13px; }
  .tw-metric-value b { font-size: 17px; }
  .tw-wind { display: none; }
  .tw-camera {
    top: 72px;
    right: 12px;
    bottom: auto;
    width: 158px;
    padding: 6px;
    border-radius: 14px;
  }
  .tw-cam-head { padding: 1px 2px 5px; }
  .tw-cam-live { font-size: 7px; }
  .tw-cam-foot { font-size: 7.5px; padding-top: 5px; }
  .tw-footer { display: none; }
  .tw-detail { bottom: 12px; }
  .tw-hotspot-label { display: none; }
  .tw-hotspot-dot { width: 8px; height: 8px; }
  .tw-hotspot-dot::after { inset: -4px; }
  .tw-fallback { top: 64px; font-size: 9px; }
}

@media (max-width: 560px) {
  .tw-title { font-size: 16px; }
  .tw-kicker { font-size: 7px; letter-spacing: 0.24em; }
  .tw-brand-mark { width: 32px; height: 32px; }
  .tw-brand-diamond { font-size: 10px; }
  .tw-actions .tw-icon-btn#btnReset,
  .tw-actions .tw-icon-btn#btnFull { display: none; }
  .tw-metric-icon { display: none; }
  .tw-metric { padding: 6px 8px; }
  .tw-metric-value b { font-size: 16px; }
  .tw-metric-sub { font-size: 7.5px; }
  .tw-camera { width: 138px; top: 66px; }
  .tw-cam-foot span:last-child { display: none; }
  .tw-detail-value b { font-size: 28px; }
}

@media (max-height: 720px) and (min-width: 821px) {
  .tw-metrics { bottom: 52px; }
  .tw-camera { bottom: 52px; }
  .tw-wind { bottom: 400px; }
  .tw-footer { bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
  .tw-loading-ring,
  .tw-brand-ring { animation: none; }
}
