:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --accent: #38bdf8;
  --line: #e2e8f0;
  --ink: #0f172a;
  --muted: #64748b;
  --header-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: linear-gradient(120deg, var(--bg), var(--bg2));
  color: #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 1100;
}
.brand h1 { font-size: 1.15rem; margin: 0; font-weight: 700; letter-spacing: .2px; }
.brand p { margin: 2px 0 0; font-size: .76rem; color: #94a3b8; }

.controls { display: flex; align-items: flex-end; gap: .9rem; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field span { font-size: .68rem; text-transform: uppercase; letter-spacing: .6px; color: #94a3b8; }
.field select {
  appearance: none;
  background: #fff;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .42rem 1.8rem .42rem .6rem;
  font-size: .9rem;
  min-width: 160px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .55rem center;
}
.field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#status { color: #cbd5e1; font-size: .8rem; align-self: center; min-width: 70px; }

#map { height: calc(100vh - var(--header-h)); width: 100%; background: #aadaff; }

.count-icon {
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

#legend {
  position: absolute;
  bottom: 18px;
  left: 18px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .75rem;
  max-height: 42vh;
  overflow-y: auto;
  font-size: .78rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(4px);
}
#legend h4 { margin: 0 0 .4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
#legend .row { display: flex; align-items: center; gap: .45rem; line-height: 1.65; }
#legend .swatch { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(0, 0, 0, 0.25); }

.leaflet-popup-content-wrapper { border-radius: 10px; }
.city-popup { font-size: .85rem; min-width: 230px; }
.city-popup h3 { margin: 0 0 .45rem; font-size: 1rem; }
.bc-rows { display: flex; flex-direction: column; }
/* Crypto subheading in the combined (BTC + USDT TRC20) popup. */
.bc-crypto { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: .4rem 0 .1rem; }
.bc-crypto:first-child { margin-top: 0; }
/* Whole row is the BestChange link. */
.bc-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: .5rem;
  padding: 5px 6px;
  border-top: 1px solid #f1f5f9;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.bc-row:first-child { border-top: none; }
.bc-row:hover { background: #f1f5f9; }
.bc-row .code { font-weight: 600; }
.bc-row .sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.bc-row .count { color: var(--muted); }
.bc-row .rate { color: var(--ink); text-align: right; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.bc-row .rate .min { font-size: .72rem; color: var(--muted); }
.bc-row .go { color: var(--accent); font-weight: 700; }

/* SEO content section below the map. */
.content { max-width: 760px; margin: 0 auto; padding: 2rem 1.25rem 3rem; line-height: 1.6; }
.content .intro p { margin: 0 0 1rem; color: #1e293b; }
.content h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }
.faq-item { border-top: 1px solid var(--line); padding: .5rem 0; }
.faq-item summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
.faq-item .faq-a { color: #334155; padding: .25rem 0 .5rem; }
.faq-item .faq-a p { margin: 0 0 .6rem; }

footer { border-top: 1px solid var(--line); padding: 1.25rem; text-align: center; color: var(--muted); font-size: .9rem; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* RTL (Arabic). */
[dir="rtl"] .bc-row { grid-template-columns: auto 1fr auto auto; }
[dir="rtl"] .bc-row .rate { text-align: left; align-items: flex-start; }
[dir="rtl"] .bc-row .sw { margin-right: 0; margin-left: 5px; }
[dir="rtl"] #legend { left: auto; right: 18px; }
[dir="rtl"] .content { text-align: right; }

@media (max-width: 640px) {
  header { flex-direction: column; height: auto; padding: .6rem 1rem; align-items: flex-start; gap: .5rem; }
  .field select { min-width: 130px; }
  #map { height: calc(100vh - 132px); }
}
