:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1f2630;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #9ba3af;
  --accent: #5eead4;
  --accent-2: #facc15;
  --land: #2a313c;
  --land-hover: #3a4452;
  --ocean: #0b0f14;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang TC", "Microsoft JhengHei", Helvetica, Arial, sans-serif;
  overflow: hidden;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 全站細微 noise texture（電影感）*/
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.3 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
}

/* 載入動畫 */
@keyframes topbar-slide-in {
  from { opacity: 0; transform: translateY(-100%); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes star-twinkle {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.25; }
}

.t-value,
.t-bar-real,
.time-label {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background:
    linear-gradient(180deg, rgba(14, 17, 22, 0.92) 0%, rgba(14, 17, 22, 0.78) 100%);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 4px 24px -8px rgba(0, 0, 0, 0.5);
  z-index: 20;
  animation: topbar-slide-in 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.brand { animation: fade-up 0.5s 0.1s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.search-wrap { animation: fade-up 0.5s 0.2s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.actions .tb-group:nth-child(1) { animation: fade-up 0.5s 0.3s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.actions .tb-group:nth-child(2) { animation: fade-up 0.5s 0.35s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.actions .tb-group:nth-child(3) { animation: fade-up 0.5s 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.actions .tb-group:nth-child(4) { animation: fade-up 0.5s 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.actions .lang-switch { animation: fade-up 0.5s 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
  padding: 4px 6px;
  border-radius: 8px;
  transition: transform 0.2s ease;
}

.brand:hover {
  transform: translateY(-1px);
}

.brand .logo {
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(94, 234, 212, 0.4));
  transition: transform 0.4s ease;
}

.brand:hover .logo {
  transform: rotate(15deg) scale(1.05);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.brand h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #e6edf3 0%, #5eead4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand .subtitle {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2px;
  font-weight: 500;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 380px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
  transition: color 0.15s;
}

.search-wrap:focus-within .search-icon {
  color: var(--accent);
}

#search {
  width: 100%;
  height: 38px;
  padding: 0 40px 0 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(22, 27, 34, 0.6);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

#search::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

#search:hover {
  background: var(--panel);
}

#search:focus {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.15);
}

.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  padding: 2px 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  pointer-events: none;
  letter-spacing: 0.5px;
}

.search-wrap:focus-within .search-kbd { opacity: 0; }

.suggestions {
  position: absolute;
  top: 44px;
  left: 0; right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: var(--shadow);
}

.suggestions li {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}

.suggestions li:hover,
.suggestions li.active {
  background: var(--panel-2);
  color: var(--accent);
}

.actions {
  display: flex;
  gap: 0;
  align-items: center;
}

/* topbar 分組（按鈕分組 + 垂直分隔線）*/
.tb-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  position: relative;
}

.tb-group + .tb-group::before,
.tb-group + .lang-switch::before,
.actions > .lang-switch::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 22px;
  background: linear-gradient(180deg, transparent 0%, var(--border) 50%, transparent 100%);
}

.tb-group:first-child { padding-left: 0; }

/* 統一所有 topbar 按鈕視覺 */
.tb-btn,
.lang-switch > button {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, color 0.15s, box-shadow 0.15s;
}

.tb-btn:hover,
.lang-switch > button:hover {
  background: rgba(94, 234, 212, 0.08);
  border-color: rgba(94, 234, 212, 0.25);
  color: var(--accent);
  transform: translateY(-1px);
}

.tb-btn:active,
.lang-switch > button:active {
  transform: translateY(0);
}

/* ghost 變體（清除 / 說明 / 語言）：默認更淡 */
.tb-btn-ghost {
  color: var(--muted);
  font-weight: 400;
}

.tb-btn-ghost:hover {
  color: var(--text);
}

/* active / pressed 狀態（如 失真 / 行政區 / 日夜 開啟時）*/
.tb-btn[aria-pressed="true"],
.tb-btn.active {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.15) 0%, rgba(250, 204, 21, 0.08) 100%);
  border-color: rgba(250, 204, 21, 0.45);
  color: var(--accent-2);
  font-weight: 700;
}

.tb-btn[aria-pressed="true"]:hover,
.tb-btn.active:hover {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.22) 0%, rgba(250, 204, 21, 0.12) 100%);
  border-color: rgba(250, 204, 21, 0.6);
  color: var(--accent-2);
}

/* 主題切換 */
.theme-switch {
  position: relative;
  padding-left: 10px;
}

.theme-switch > button {
  height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 160px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.theme-menu li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}

.theme-menu li:hover,
.theme-menu li.active {
  background: var(--panel-2);
  color: var(--accent);
}

.th-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  display: inline-block;
  flex-shrink: 0;
}

/* 語言切換 */
.lang-switch {
  position: relative;
  padding-left: 10px;
}

.lang-switch > button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
}

.lang-switch .caret {
  font-size: 9px;
  opacity: 0.7;
  margin-left: 2px;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 140px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.lang-menu li {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}

.lang-menu li:hover,
.lang-menu li.active {
  background: var(--panel-2);
  color: var(--accent);
}

.lang-menu li.active::before {
  content: "✓ ";
  color: var(--accent);
}

.mode-switch {
  display: inline-flex;
  align-items: center;
}

.projection-select {
  height: 34px;
  background: rgba(22, 27, 34, 0.6);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 30px 0 12px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 3.5 L5 6.5 L8 3.5' stroke='%235eead4' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.projection-select:hover {
  border-color: rgba(94, 234, 212, 0.4);
  background: var(--panel);
  transform: translateY(-1px);
}

.projection-select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.15);
}

/* active 狀態統一由 .tb-btn[aria-pressed="true"] / .tb-btn.active 處理 */

/* 行政區（州/縣/省/邦/府縣）共用 stroke + fill */
.country.subdivision {
  stroke: #2a313c;
  stroke-width: 0.4px;
  fill: #1e2a3a;
}

.country.subdivision:hover {
  fill: #2e3f55;
}

/* 行政區 dropdown */
.subdivisions-wrap {
  position: relative;
}

.subdivisions-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 220px;
  max-height: 360px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  z-index: 30;
}

.subdivisions-popover label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}

.subdivisions-popover label:hover {
  background: var(--panel-2);
  color: var(--accent);
}

.subdivisions-popover input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}

.subdivisions-popover .sub-loading {
  font-size: 11px;
  color: var(--accent-2);
  margin-left: auto;
}

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

button:hover {
  background: var(--panel-2);
  border-color: var(--accent);
}

.ad-slot {
  position: fixed;
  left: 0; right: 0;
  min-height: 90px;
  max-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  z-index: 8;
}

.ad-slot.ad-top {
  top: 64px;
}

.ad-slot.ad-bottom {
  bottom: 28px;
}

.ad-slot .adsbygoogle {
  width: 100%;
  max-width: 970px;
  min-height: 90px;
}

main {
  position: absolute;
  top: 164px; /* topbar 64 + ad-top 100 */
  left: 0; right: 0; bottom: 128px; /* footer 28 + ad-bottom 100 */
}

/* 沒 AdSense publisher ID 時，自動隱藏廣告版位並把地圖撐滿 */
html.no-ads .ad-slot { display: none; }
html.no-ads main { top: 64px; bottom: 28px; }
html.no-ads .time-controls { bottom: 36px; }

#map {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--ocean);
  cursor: grab;
  transition: opacity 0.25s ease;
}

#map.transitioning {
  opacity: 0.25;
}

/* 載入骨架 */
.loading-skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--ocean);
  z-index: 5;
  transition: opacity 0.4s ease;
}

.loading-skeleton.fading {
  opacity: 0;
  pointer-events: none;
}

.ls-globe {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #1a2330, #0a1018 60%, #040814 100%);
  box-shadow:
    0 0 0 2px rgba(94, 234, 212, 0.25),
    0 0 40px rgba(94, 234, 212, 0.35),
    inset -8px -8px 24px rgba(0,0,0,0.6);
  animation: ls-rotate 6s linear infinite, ls-pulse 2s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

.ls-globe::before, .ls-globe::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(94,234,212,0.25);
  pointer-events: none;
}
.ls-globe::after {
  transform: scaleY(0.4);
}

@keyframes ls-rotate {
  from { background-position: 0% 0%; }
  to   { background-position: 200% 0%; }
}

@keyframes ls-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(94,234,212,0.25), 0 0 40px rgba(94,234,212,0.25), inset -8px -8px 24px rgba(0,0,0,0.6); }
  50%      { box-shadow: 0 0 0 2px rgba(94,234,212,0.45), 0 0 60px rgba(94,234,212,0.55), inset -8px -8px 24px rgba(0,0,0,0.6); }
}

.ls-text {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 2px;
  margin: 0;
}

#map.dragging {
  cursor: grabbing;
}

.country {
  fill: var(--land);
  stroke: #11161d;
  stroke-width: 0.5px;
  transition: fill 0.15s;
}

.country:hover {
  fill: var(--land-hover);
  cursor: pointer;
}

.country.selected {
  /* color applied inline */
  stroke: #fff;
  stroke-width: 0.7px;
}

.graticule {
  fill: none;
  stroke: #1c232c;
  stroke-width: 0.5px;
  pointer-events: none;
}

.overlay-country {
  stroke: #fff;
  stroke-width: 1.2px;
  fill-opacity: 0.7;
  cursor: grab;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.55));
  animation: overlay-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
}

@keyframes overlay-pop {
  0%   { opacity: 0; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

.overlay-country.pulse {
  animation: overlay-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
             overlay-pulse 2.6s ease-in-out 0.35s infinite;
}

@keyframes overlay-pulse {
  0%, 100% { stroke-width: 1.2px; }
  50%      { stroke-width: 2.2px; }
}

.overlay-country.dragging {
  cursor: grabbing;
  fill-opacity: 0.82;
  animation: none;
  stroke-width: 2px;
}

.overlay-label {
  font-size: 13px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(0,0,0,0.65);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.selected-panel {
  position: fixed;
  top: 80px;
  right: 16px;
  width: 260px;
  background: linear-gradient(180deg, rgba(22, 27, 34, 0.85) 0%, rgba(22, 27, 34, 0.72) 100%);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 14px 14px 12px;
  z-index: 15;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 12px 36px -8px rgba(0, 0, 0, 0.6);
  animation: fade-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.selected-panel h2 {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.selected-panel h2::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.selected-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selected-panel li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "dot name btn"
    "dot meta btn";
  column-gap: 8px;
  row-gap: 1px;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.selected-panel li:hover {
  background: var(--panel);
  transform: translateX(2px);
}

.selected-panel li .dot {
  grid-area: dot;
  align-self: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.selected-panel li .name {
  grid-area: name;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--text);
}

.selected-panel li .meta {
  grid-area: meta;
  font-size: 11px;
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  white-space: nowrap;
}

.selected-panel li button {
  grid-area: btn;
  align-self: center;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 16px;
  line-height: 1;
}

.selected-panel li button:hover {
  color: #ff7676;
  background: transparent;
  border-color: transparent;
}

.time-controls {
  position: fixed;
  bottom: 136px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(22, 27, 34, 0.92) 0%, rgba(22, 27, 34, 0.78) 100%);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 12px 32px -6px rgba(0, 0, 0, 0.6);
  z-index: 12;
  animation: fade-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* slider thumb 美化 */
.time-controls #time-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(90deg, var(--panel-2), var(--accent), var(--panel-2));
  border-radius: 2px;
  outline: none;
}

.time-controls #time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0e1116;
  cursor: grab;
  box-shadow: 0 0 12px rgba(94, 234, 212, 0.6);
  transition: transform 0.15s;
}

.time-controls #time-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.time-controls #time-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.time-controls #time-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0e1116;
  cursor: grab;
  box-shadow: 0 0 12px rgba(94, 234, 212, 0.6);
}

.time-controls #time-slider {
  width: 260px;
  accent-color: var(--accent);
}

.time-controls select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}

#play-btn.playing {
  background: var(--accent);
  color: #0e1116;
  border-color: var(--accent);
  font-weight: 700;
}

.time-controls .time-label {
  font-size: 12px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 130px;
  text-align: center;
}

.time-controls button {
  font-size: 12px;
  padding: 4px 10px;
}

/* sun-toggle active 由統一 .tb-btn.active 樣式處理 */

.night-overlay {
  fill: rgba(8, 12, 22, 0.55);
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 0.5px;
  pointer-events: none;
}

.sun-marker {
  fill: #facc15;
  stroke: #fff7d6;
  stroke-width: 1.5px;
  pointer-events: none;
  filter: drop-shadow(0 0 12px rgba(250, 204, 21, 0.7));
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(22, 27, 34, 0.96) 0%, rgba(22, 27, 34, 0.88) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 220px;
  font-size: 12px;
  color: var(--text);
  z-index: 40;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 12px 32px -6px rgba(0, 0, 0, 0.7);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  transition: opacity 0.12s;
}

.tooltip .t-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.tooltip .t-flag {
  font-size: 18px;
  line-height: 1;
}

.tooltip .t-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.tooltip .t-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.tooltip .t-label {
  color: var(--muted);
}

.tooltip .t-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
}

.tooltip .t-distortion {
  color: var(--accent-2);
}

/* 分享 modal */
.share-modal-content {
  max-width: 480px;
}

.share-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.share-link-row input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  outline: none;
}

.share-link-row button {
  white-space: nowrap;
  font-size: 13px;
  padding: 0 14px;
}

.share-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.sb-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sb-btn:hover { transform: translateY(-2px); }
.sb-x:hover { background: #000; color: #fff; border-color: #000; }
.sb-fb:hover { background: #1877f2; color: #fff; border-color: #1877f2; font-family: Georgia, serif; }
.sb-line { font-size: 11px; }
.sb-line:hover { background: #00c300; color: #fff; border-color: #00c300; }
.sb-reddit:hover { background: #ff4500; color: #fff; border-color: #ff4500; }
.sb-threads:hover { background: #000; color: #fff; border-color: #000; }
.sb-snapshot { width: auto; padding: 0 14px; font-size: 13px; }
.sb-snapshot:hover { background: var(--accent); color: #0e1116; border-color: var(--accent); }

.share-popular {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-bottom: 8px;
}

.share-popular h3 {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 8px;
  font-weight: 600;
}

#popular-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#popular-list li {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  background: var(--panel-2);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

#popular-list li:hover {
  background: var(--panel);
  color: var(--accent);
  transform: translateX(4px);
}

/* About / SEO 區塊（預設隱藏，from-bottom drawer 樣式）*/
.about-section {
  position: fixed;
  left: 0; right: 0;
  bottom: 28px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 28px 36px 36px;
  z-index: 25;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.about-section.open {
  transform: translateY(0);
}

.about-section h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: var(--accent);
}

.about-section h3 {
  margin: 18px 0 6px;
  font-size: 16px;
  color: var(--accent-2);
}

.about-section p {
  line-height: 1.7;
  font-size: 14px;
  color: var(--text);
}

.about-section dl.faq {
  margin-top: 8px;
}

.about-section dl.faq dt {
  font-weight: 700;
  color: var(--text);
  margin-top: 12px;
  font-size: 14px;
}

.about-section dl.faq dd {
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.about-section .about-foot {
  margin-top: 20px;
  font-size: 12px;
  color: var(--muted);
}

.about-section a {
  color: var(--accent);
  text-decoration: none;
}

.about-section a:hover {
  text-decoration: underline;
}

.about-section .size-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 6px;
  font-size: 13px;
}

.about-section .size-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.about-section .size-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12.5px;
}

.about-section .size-table tr:hover td {
  background: var(--panel-2);
}

.about-section .size-table td:first-child {
  font-family: "Inter", "Noto Sans TC", sans-serif;
  color: var(--text);
}

.about-section .size-caption {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-top: 6px;
}

.about-section .api-sample {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0 16px;
}

.about-section .api-sample code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--accent);
  white-space: pre;
}

.about-section .contact-card {
  background: linear-gradient(180deg, rgba(94, 234, 212, 0.06) 0%, rgba(94, 234, 212, 0.02) 100%);
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 8px 0 16px;
}

.about-section .contact-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.7;
}

.about-section .contact-line .contact-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: 64px;
  font-weight: 600;
}

.about-section .contact-line .contact-value {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
}

.about-section .contact-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(94, 234, 212, 0.15);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.footer-mail {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.footer-mail:hover {
  color: var(--accent-2);
}

.footer-link {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0;
  font-size: 12px;
  cursor: pointer;
}

.footer-link:hover {
  color: var(--accent);
  background: transparent;
  border-color: transparent;
}

.footer-divider {
  color: var(--border);
  margin: 0 6px;
}

/* tooltip mini bar chart */
.t-mini-chart {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.t-mini-chart .bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.t-mini-chart .bar-label {
  font-size: 10px;
  color: var(--muted);
  width: 28px;
  flex-shrink: 0;
}

.t-mini-chart .bar-track {
  position: relative;
  flex: 1;
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
}

.t-mini-chart .bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.t-mini-chart .bar-fill.real { background: var(--accent); }
.t-mini-chart .bar-fill.visual { background: var(--accent-2); }

/* 已選取面板：每國家加 meta（面積 / 失真倍率）*/
.selected-panel li .meta {
  font-size: 11px;
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  flex-shrink: 0;
}

/* iframe embed 模式：隱藏一切非地圖 */
html.embed .topbar,
html.embed .footer,
html.embed .ad-slot,
html.embed .selected-panel,
html.embed .time-controls,
html.embed .about-section,
html.embed .loading-skeleton,
html.embed #onboarding { display: none !important; }
html.embed main { top: 0 !important; bottom: 0 !important; }
html.embed body { overflow: hidden; }
html.embed #map { cursor: grab; }

/* embed 模式下顯示 watermark */
html.embed .embed-watermark {
  position: fixed;
  bottom: 8px; right: 12px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  background: rgba(14, 17, 22, 0.7);
  padding: 4px 10px;
  border-radius: 12px;
  z-index: 50;
  font-family: "JetBrains Mono", monospace;
}

html:not(.embed) .embed-watermark { display: none; }

/* Quiz 問答 modal */
.quiz-content {
  max-width: 520px;
  padding: 24px 26px 22px;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quiz-header h2 {
  margin: 0;
  font-size: 20px;
}

.quiz-close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
}

.quiz-close-btn:hover {
  color: var(--text);
  background: var(--panel-2);
}

.quiz-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
}

.quiz-screen p { margin: 0; line-height: 1.6; font-size: 14px; }
.quiz-hint { color: var(--muted); font-size: 13px; }
.quiz-best { color: var(--accent-2); font-family: "JetBrains Mono", monospace; }

.quiz-progress {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.quiz-progress b { color: var(--accent); }
.quiz-score-mini b { color: var(--accent-2); }

.quiz-question {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 6px 0;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.quiz-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  min-height: 110px;
}

.quiz-opt:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  background: var(--panel);
}

.quiz-opt:disabled {
  cursor: default;
  transform: none;
}

.quiz-opt.correct {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.4) inset;
}

.quiz-opt.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.4) inset;
}

.quiz-opt .qo-flag { font-size: 38px; line-height: 1; }
.quiz-opt .qo-name { font-size: 14px; font-weight: 700; color: var(--text); }
.quiz-opt .qo-area {
  font-size: 11px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  margin-top: 2px;
  min-height: 14px;
}

.quiz-vs {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-2);
  letter-spacing: 1px;
}

.quiz-feedback {
  text-align: center;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.quiz-result-line {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.quiz-result-line.correct { color: #34d399; }
.quiz-result-line.wrong { color: #ef4444; }

.quiz-detail {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  font-family: "JetBrains Mono", monospace;
}

.quiz-final-score {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 2px;
}

.quiz-final-total {
  font-size: 28px;
  color: var(--muted);
  margin-left: 4px;
}

.quiz-stars {
  font-size: 22px;
  letter-spacing: 4px;
}

.quiz-comment {
  color: var(--text);
  font-size: 14px;
  font-style: italic;
}

.quiz-summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* 可見焦點環（無障礙）*/
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hamburger button — 桌面隱藏 */
.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
}

.menu-toggle:hover {
  background: var(--panel);
  border-color: rgba(94, 234, 212, 0.4);
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  transition: transform 0.25s, opacity 0.25s;
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* GIF 錄製進度 */
.gif-progress {
  margin: 14px 0;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 10px;
}

.gif-progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.gif-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.15s;
}

.gif-progress-text {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  text-align: center;
  font-family: "JetBrains Mono", monospace;
}

/* 響應式：≤768 → hamburger 模式 */
@media (max-width: 768px) {
  .topbar {
    padding: 0 12px;
    gap: 10px;
  }
  .brand .subtitle { display: none; }
  .brand h1 { font-size: 14px; }
  .search-wrap { max-width: none; flex: 1; }
  .search-kbd { display: none; }

  .menu-toggle { display: flex; }

  .actions {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 16px;
    background: linear-gradient(180deg, rgba(14, 17, 22, 0.96), rgba(14, 17, 22, 0.92));
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 32px -8px rgba(0,0,0,0.6);
    transform: translateY(-110%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s, visibility 0.25s;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    z-index: 19;
  }

  .actions.menu-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .tb-group {
    flex-wrap: wrap;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    width: 100%;
  }

  .tb-group:first-child { border-top: none; padding-top: 0; }
  .tb-group + .tb-group::before { display: none; }
  .actions > .lang-switch::before { display: none; }
  .theme-switch::before { display: none; }

  .tb-btn,
  .lang-switch > button,
  .theme-switch > button {
    width: 100%;
    justify-content: center;
  }

  .projection-select { width: 100%; }

  .lang-switch,
  .theme-switch {
    width: 100%;
    padding: 8px 0;
    border-top: 1px solid var(--border);
  }

  .selected-panel {
    top: auto;
    bottom: 168px;
    right: 8px;
    width: 200px;
    padding: 10px 12px;
  }
}

.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  color: var(--muted);
  background: linear-gradient(0deg, rgba(14, 17, 22, 0.92) 0%, rgba(14, 17, 22, 0.78) 100%);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 10;
  letter-spacing: 0.3px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 12, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  animation: fade-in 0.2s ease;
}

.modal.open {
  display: flex;
}

[hidden] {
  display: none !important;
}

.modal-content {
  background: linear-gradient(180deg, rgba(22, 27, 34, 0.96) 0%, rgba(22, 27, 34, 0.86) 100%);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 26px 30px;
  max-width: 480px;
  width: 92%;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 24px 64px -12px rgba(0, 0, 0, 0.8);
  animation: fade-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.modal-content ol {
  padding-left: 22px;
  line-height: 1.7;
  font-size: 14px;
  color: var(--text);
}

.modal-content .hint {
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-content button {
  background: var(--accent);
  color: #0e1116;
  border: none;
  font-weight: 700;
  padding: 9px 18px;
}

.modal-content button:hover {
  background: #34d4be;
}

.modal-content #restart-tour {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

.modal-content #restart-tour:hover {
  background: var(--panel);
  color: var(--accent);
}

/* 入門引導 Onboarding */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.onboarding-mask {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.7);
  pointer-events: auto;
}

.onboarding-spotlight {
  position: absolute;
  border-radius: 12px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(2, 6, 12, 0.7), 0 0 28px rgba(94, 234, 212, 0.45);
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
  pointer-events: none;
  background: transparent;
}

.onboarding-card {
  position: absolute;
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: top 0.25s ease, left 0.25s ease;
}

.onboarding-card .ob-progress {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.onboarding-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--accent);
}

.onboarding-card p {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.onboarding-card .ob-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.onboarding-card #ob-skip {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
}

.onboarding-card #ob-skip:hover {
  color: var(--text);
  background: transparent;
}

.onboarding-card .ob-nav {
  display: flex;
  gap: 6px;
}

.onboarding-card .ob-nav button {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
}

.onboarding-card .ob-nav .primary {
  background: var(--accent);
  color: #0e1116;
  border-color: var(--accent);
  font-weight: 700;
}

.onboarding-card .ob-nav .primary:hover {
  background: #34d4be;
}

.onboarding-card.no-target {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@media (max-width: 780px) {
  .brand .subtitle { display: none; }
  .brand h1 { font-size: 14px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .selected-panel { width: 180px; top: 76px; right: 8px; }
  #search { font-size: 13px; }
}
