@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Crimson+Pro:ital,wght@0,300;0,400;1,300&display=swap');

:root {
  --parch: #f2ead8;
  --parch2: #e8dfc5;
  --parch3: #ddd0b0;
  --ink: #2c2010;
  --ink2: #4a3820;
  --rust: #8b3a1a;
  --rust2: #c0432a;
  --gold: #b8862a;
  --gold2: #d4a840;
  --sea: #c8dce8;
  --sea2: #9bbdd0;
  --green: #3d7a5e;
  --green2: #5a9e7c;
  --muted: #7a6a50;
  --border: #c0a870;
  --panel: 340px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Crimson Pro", serif;
  background: var(--ink);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── HEADER ── */
header {
  background: var(--ink);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  gap: 12px;
}
.logo {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--parch);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.logo em { color: var(--gold2); font-style: normal; }
.header-center {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.header-right { display: flex; gap: 7px; align-items: center; }

.hbtn {
  font-family: "Crimson Pro", serif;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border: 1px solid #4a3820;
  background: transparent;
  color: #8a7a5a;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.hbtn:hover { border-color: var(--gold); color: var(--gold2); }
.hbtn.active-mode { border-color: var(--rust2); color: var(--rust2); background: rgba(192,67,42,0.1); }

/* ── SEARCH ── */
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap input {
  background: rgba(242,234,216,0.08);
  border: 1px solid #4a3820;
  color: var(--parch);
  font-family: "Crimson Pro", serif;
  font-size: 0.85rem;
  padding: 5px 30px 5px 11px;
  outline: none;
  width: 190px;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}
.search-wrap input::placeholder { color: #6a5840; }
.search-wrap input:focus { border-color: var(--gold); background: rgba(242,234,216,0.12); }
.search-icon { position: absolute; right: 9px; color: #6a5840; font-size: 0.78rem; pointer-events: none; }
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  width: 220px;
  background: #1e1608;
  border: 1px solid #4a3820;
  border-top: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}
.sri {
  padding: 7px 11px;
  font-size: 0.82rem;
  color: var(--parch2);
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sri:hover { background: rgba(184,134,42,0.15); color: var(--gold2); }
.sri img { width: 22px; height: 14px; object-fit: cover; border: 1px solid #3a2c18; }

select.hsel {
  background: rgba(242,234,216,0.08);
  border: 1px solid #4a3820;
  color: var(--parch);
  font-family: "Crimson Pro", serif;
  font-size: 0.8rem;
  padding: 5px 9px;
  outline: none;
  cursor: pointer;
}
select.hsel option { background: #1e1608; }

/* ── WORKSPACE ── */
.workspace { display: flex; flex: 1; overflow: hidden; position: relative; }

/* ── MAP ── */
#map-container { flex: 1; position: relative; overflow: hidden; cursor: grab; }
#map-container:active { cursor: grabbing; }
svg#map { width: 100%; height: 100%; }

.ocean { fill: var(--sea); }
.graticule { fill: none; stroke: rgba(130,165,185,0.3); stroke-width: 0.4; }
.land { fill: var(--parch); stroke: var(--border); stroke-width: 0.5; transition: fill 0.12s; cursor: pointer; }
.land:hover { fill: var(--parch2); }
.land.selected { fill: var(--gold2) !important; stroke: var(--rust); stroke-width: 1.5; }
.country-borders { fill: none; stroke: var(--ink2); stroke-width: 0.3; opacity: 0.5; }

/* ── CHOROPLETH LEGEND ── */
.legend-wrap {
  position: absolute;
  bottom: 40px;
  left: 16px;
  background: rgba(18,10,4,0.88);
  border: 1px solid #3a2c18;
  padding: 10px 14px;
  display: none;
  z-index: 10;
  backdrop-filter: blur(4px);
}
.legend-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.legend-bar { display: flex; gap: 0; height: 10px; width: 160px; border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.legend-labels { display: flex; justify-content: space-between; font-size: 0.6rem; color: var(--muted); }

/* ── MAP CONTROLS ── */
.map-controls { position: absolute; top: 16px; left: 16px; display: flex; flex-direction: column; gap: 4px; z-index: 10; }
.map-btn {
  width: 30px; height: 30px;
  background: rgba(18,10,4,0.85);
  border: 1px solid #3a2c18;
  color: #8a7050;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
  font-family: serif;
}
.map-btn:hover { border-color: var(--gold); color: var(--gold2); }

/* ── CONTINENT PILLS ── */
.cont-pills {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 10;
  flex-wrap: wrap;
  justify-content: center;
}
.cont-pill {
  padding: 4px 11px;
  background: rgba(18,10,4,0.85);
  border: 1px solid #3a2c18;
  color: #8a7050;
  font-family: "Cormorant Garamond", serif;
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  cursor: pointer;
  transition: all 0.18s;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.cont-pill:hover { border-color: var(--gold); color: var(--gold2); }
.cont-pill.active { background: var(--gold); border-color: var(--gold2); color: var(--ink); }

/* ── STATUSBAR ── */
.statusbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30px;
  background: rgba(18,10,4,0.85);
  border-top: 1px solid #3a2c18;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 16px;
  font-size: 0.6rem;
  color: #6a5840;
  letter-spacing: 0.06em;
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 5;
}
.statusbar span { color: #8a7050; }

/* ── TOOLTIP ── */
.tooltip {
  position: absolute;
  background: rgba(18,10,4,0.92);
  border: 1px solid var(--gold);
  padding: 8px 14px;
  font-family: "Cormorant Garamond", serif;
  font-size: 0.9rem;
  color: var(--parch);
  pointer-events: none;
  z-index: 50;
  display: none;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.tooltip img { height: 13px; vertical-align: middle; margin-right: 5px; border: 1px solid #4a3c28; }

/* ── INFO PANEL ── */
.info-panel {
  width: var(--panel);
  background: var(--parch);
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.info-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--rust), var(--gold2), var(--rust));
}

/* Tabs */
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; margin-top: 4px; }
.panel-tab {
  flex: 1;
  font-family: "Cormorant Garamond", serif;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 4px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.panel-tab:hover { color: var(--ink2); }
.panel-tab.active { color: var(--rust); border-bottom-color: var(--rust); }

.tab-content { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.tab-content.active { display: flex; }

/* Empty state */
.panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  padding: 36px;
  text-align: center;
}
.panel-empty .compass { font-size: 3rem; opacity: 0.15; animation: spin 30s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.panel-empty p { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 0.95rem; color: var(--muted); line-height: 1.7; }

/* Country header */
.country-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--parch), var(--parch2));
  flex-shrink: 0;
  position: relative;
}
.flag-img-wrap { margin-bottom: 10px; }
.flag-img-wrap img { border: 2px solid var(--border); box-shadow: 2px 3px 10px rgba(44,32,16,0.28); display: block; }
.flag-big { font-size: 3.8rem; line-height: 1; display: block; }
.flag-emoji { font-size: 2.8rem; line-height: 1; }
.country-name { font-family: "Cormorant Garamond", serif; font-size: 1.55rem; font-weight: 600; color: var(--ink); line-height: 1.1; margin-bottom: 2px; }
.country-name-en { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 0.82rem; color: var(--muted); }
.country-badges { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.badge { padding: 2px 9px; border: 1px solid var(--gold); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--rust); font-family: "Cormorant Garamond", serif; }
.fav-btn { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 1.3rem; cursor: pointer; opacity: 0.4; transition: all 0.2s; }
.fav-btn:hover, .fav-btn.active { opacity: 1; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.stat-cell { background: var(--parch); padding: 11px 14px; transition: background 0.12s; }
.stat-cell:hover { background: var(--parch2); }
.stat-label { font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-family: "Cormorant Garamond", serif; margin-bottom: 3px; }
.stat-value { font-family: "Cormorant Garamond", serif; font-size: 0.98rem; font-weight: 600; color: var(--ink); line-height: 1.2; }

/* Panel sections */
.panel-section { padding: 13px 18px; border-bottom: 1px solid rgba(192,168,112,0.25); }
.panel-section h4 { font-family: "Cormorant Garamond", serif; font-size: 0.6rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.panel-section p { font-size: 0.85rem; color: var(--ink2); line-height: 1.6; }

/* Bar chart */
.bar-wrap { margin-top: 4px; }
.bar-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.bar-label { font-size: 0.68rem; color: var(--muted); width: 80px; flex-shrink: 0; }
.bar-track { flex: 1; height: 5px; background: rgba(192,168,112,0.22); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--rust), var(--gold2)); transition: width 0.7s cubic-bezier(0.4,0,0.2,1); }
.bar-val { font-size: 0.65rem; color: var(--ink2); width: 45px; text-align: right; flex-shrink: 0; }

/* Neighbor chips */
.neighbor-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.neighbor-chip {
  padding: 2px 9px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--ink2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: "Crimson Pro", serif;
  display: flex;
  align-items: center;
  gap: 5px;
}
.neighbor-chip:hover { background: var(--gold2); color: var(--ink); border-color: var(--gold2); }
.neighbor-chip img { height: 11px; border: 1px solid rgba(0,0,0,0.15); }

/* History list */
.history-list { display: flex; flex-direction: column; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid rgba(192,168,112,0.2); cursor: pointer; transition: background 0.12s; }
.history-item:hover { background: var(--parch2); }
.history-item img { height: 16px; border: 1px solid var(--border); }
.history-item-name { font-size: 0.85rem; color: var(--ink2); flex: 1; }
.history-item-time { font-size: 0.62rem; color: var(--muted); }

/* Favorites */
.fav-list { display: flex; flex-direction: column; }
.fav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid rgba(192,168,112,0.2); cursor: pointer; transition: background 0.12s; }
.fav-item:hover { background: var(--parch2); }
.fav-item img { height: 16px; border: 1px solid var(--border); }
.fav-item-name { font-size: 0.85rem; color: var(--ink2); flex: 1; }
.fav-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 2px 5px; transition: color 0.15s; }
.fav-remove:hover { color: var(--rust2); }

/* Compare */
.compare-area { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.compare-slot { border: 1px solid var(--border); padding: 12px; background: var(--parch2); display: flex; align-items: center; gap: 10px; min-height: 58px; cursor: pointer; transition: background 0.15s; }
.compare-slot:hover { background: var(--parch3); }
.compare-slot img { height: 20px; border: 1px solid var(--border); }
.compare-slot-name { font-family: "Cormorant Garamond", serif; font-size: 1rem; color: var(--ink); }
.compare-slot-hint { font-size: 0.72rem; color: var(--muted); font-style: italic; }
.compare-vs { text-align: center; font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 0.9rem; color: var(--muted); }
.compare-stats { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 10px; }
.cmp-label { grid-column: 2; font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); text-align: center; align-self: center; }
.cmp-val { font-family: "Cormorant Garamond", serif; font-size: 0.92rem; color: var(--ink2); }
.cmp-val.winner { color: var(--rust); font-weight: 600; }
.cmp-val.left { text-align: right; }

/* ── QUIZ MODE ── */
.quiz-overlay {
  position: absolute; inset: 0;
  background: rgba(18,10,4,0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 80;
  gap: 20px;
  padding: 30px;
  backdrop-filter: blur(4px);
}
.quiz-overlay.active { display: flex; }
.quiz-question { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 1.1rem; color: var(--parch); text-align: center; letter-spacing: 0.04em; }
.quiz-flag-display { font-size: 4rem; }
.quiz-flag-display img { height: 80px; border: 3px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 460px; }
.quiz-option {
  font-family: "Cormorant Garamond", serif;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  padding: 11px 14px;
  border: 1px solid #4a3820;
  background: rgba(242,234,216,0.06);
  color: var(--parch2);
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}
.quiz-option:hover:not(:disabled) { border-color: var(--gold); color: var(--gold2); }
.quiz-option.correct { border-color: var(--green2) !important; background: rgba(61,122,94,0.25) !important; color: #a0e0b0 !important; }
.quiz-option.wrong { border-color: var(--rust2) !important; background: rgba(192,67,42,0.2) !important; color: #e09090 !important; }
.quiz-option:disabled { cursor: default; }
.quiz-score { font-family: "Cormorant Garamond", serif; font-size: 0.82rem; color: var(--muted); letter-spacing: 0.08em; }
.quiz-progress { width: 100%; max-width: 460px; height: 4px; background: rgba(192,168,112,0.2); border-radius: 2px; }
.quiz-progress-fill { height: 100%; background: linear-gradient(90deg, var(--rust), var(--gold2)); border-radius: 2px; transition: width 0.4s; }
.quiz-mode-btn { font-size: 0.72rem; color: var(--muted); }
.quiz-end { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.quiz-end-score { font-family: "Cormorant Garamond", serif; font-size: 2.5rem; font-weight: 600; color: var(--gold2); }
.quiz-end-msg { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 1rem; color: var(--parch2); }
.quiz-btn { font-family: "Crimson Pro", serif; font-size: 0.8rem; padding: 8px 20px; border: 1px solid var(--gold); color: var(--gold2); background: transparent; cursor: pointer; transition: all 0.18s; letter-spacing: 0.06em; }
.quiz-btn:hover { background: var(--gold); color: var(--ink); }

/* ── LOADING ── */
#loading {
  position: absolute; inset: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 18px;
  transition: opacity 0.4s;
}
.loading-compass { font-size: 3.5rem; animation: spin 3s linear infinite; opacity: 0.55; }
.loading-text { font-family: "Cormorant Garamond", serif; font-style: italic; color: var(--muted); font-size: 0.95rem; letter-spacing: 0.1em; }

/* Zoom controls */
.zoom-controls { position: absolute; bottom: 40px; right: 14px; display: flex; gap: 3px; z-index: 10; }
.zoom-btn {
  width: 28px; height: 28px;
  background: rgba(18,10,4,0.88);
  border: 1px solid #2e2010;
  color: #8a7050;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
}
.zoom-btn:hover { border-color: var(--gold); color: var(--gold2); }
#zoom-label { width: 44px; font-size: 0.58rem; }

/* Choropleth select */
.choropleth-wrap { position: absolute; top: 56px; right: 14px; z-index: 10; }
.choropleth-wrap select {
  background: rgba(18,10,4,0.88);
  border: 1px solid #3a2c18;
  color: #8a7050;
  font-family: "Crimson Pro", serif;
  font-size: 0.7rem;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.choropleth-wrap select option { background: #1e1608; }

/* scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #4a3820; border-radius: 3px; }

/* ── MOBILE PANEL HANDLE ── */
.panel-handle {
  display: none;
  width: 100%;
  padding: 8px 0 4px;
  cursor: pointer;
  text-align: center;
  flex-shrink: 0;
  background: var(--parch);
  touch-action: none;
}
.panel-handle-bar {
  display: inline-block;
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
@media (max-width: 650px) {
  .panel-handle { display: block; }
}
/* Collapsed panel state on mobile */
@media (max-width: 650px) {
  .info-panel.collapsed {
    flex: 0 0 44px;
    overflow: hidden;
  }
  .info-panel.expanded {
    flex: 1 1 65%;
  }
}

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE & TABLET
   ══════════════════════════════════════════ */

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
  :root { --panel: 280px; }
  .logo { font-size: 1.1rem; }
  .search-wrap input { width: 140px; }
  .header-center { gap: 5px; }
}

/* ── Mobile (≤ 650px) ── */
@media (max-width: 650px) {

  /* Body: allow scroll on the panel, not the whole page */
  body { height: 100dvh; overflow: hidden; }

  /* ── HEADER ── */
  header {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px;
    row-gap: 6px;
  }
  .logo { font-size: 1.1rem; flex-shrink: 0; }
  .header-center {
    order: 3;
    width: 100%;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-start;
  }
  .header-right { gap: 4px; }

  /* Smaller header buttons */
  .hbtn { font-size: 0.7rem; padding: 4px 8px; }
  select.hsel { font-size: 0.72rem; padding: 4px 6px; max-width: 120px; }

  /* Search bar full width on mobile */
  .search-wrap { flex: 1; min-width: 0; }
  .search-wrap input { width: 100%; min-width: 0; }
  .search-results { width: 100%; left: 0; }

  /* ── WORKSPACE: vertical stack on mobile ── */
  .workspace {
    flex-direction: column;
    overflow: hidden;
    height: calc(100dvh - var(--header-h, 90px));
  }

  /* MAP takes ~55% of vertical space */
  #map-container {
    flex: 0 0 55%;
    min-height: 0;
    max-height: 55%;
  }

  /* INFO PANEL: slides up from bottom, takes remaining space */
  .info-panel {
    width: 100%;
    border-left: none;
    border-top: 2px solid var(--border);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  .info-panel::before {
    height: 3px;
    background: linear-gradient(90deg, var(--rust), var(--gold2), var(--rust));
  }

  /* ── CONTINENT PILLS: horizontal scroll strip ── */
  .cont-pills {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    transform: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 8px;
    gap: 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cont-pills::-webkit-scrollbar { display: none; }
  .cont-pill { font-size: 0.62rem; padding: 3px 9px; flex-shrink: 0; }

  /* ── CHOROPLETH selector ── */
  .choropleth-wrap {
    top: auto;
    bottom: 36px;
    right: 8px;
  }
  .choropleth-wrap select { font-size: 0.65rem; padding: 3px 6px; }

  /* ── MAP CONTROLS: smaller, top-left below pills ── */
  .map-controls { top: 42px; left: 8px; gap: 3px; }
  .map-btn { width: 26px; height: 26px; font-size: 0.82rem; }

  /* ── LEGEND ── */
  .legend-wrap { bottom: 36px; left: 8px; padding: 7px 10px; }
  .legend-bar { width: 120px; }

  /* ── STATUS BAR: simplified on mobile ── */
  .statusbar { height: 24px; font-size: 0.55rem; padding: 0 8px; gap: 8px; }
  /* Hide the drag/zoom hint on small screens */
  .statusbar span:nth-child(4) { display: none; }

  /* ── TOOLTIP: smaller ── */
  .tooltip { font-size: 0.78rem; padding: 6px 10px; }

  /* ── PANEL: compact layout ── */
  .panel-tabs { margin-top: 2px; }
  .panel-tab { font-size: 0.6rem; padding: 6px 2px; }

  .country-header { padding: 12px 14px 10px; }
  .country-name { font-size: 1.25rem; }
  .flag-img-wrap img { max-width: 80px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-cell { padding: 8px 10px; }
  .stat-value { font-size: 0.88rem; }

  .panel-section { padding: 10px 14px; }

  /* ── COMPARE: stack vertically ── */
  .compare-stats { grid-template-columns: 1fr auto 1fr; gap: 4px 6px; }
  .cmp-val { font-size: 0.8rem; }

  /* ── QUIZ overlay: full-screen on mobile ── */
  .quiz-overlay { padding: 20px 16px; gap: 14px; }
  .quiz-question { font-size: 0.95rem; }
  .quiz-flag-display img { height: 60px; }
  .quiz-options { grid-template-columns: 1fr 1fr; gap: 6px; }
  .quiz-option { font-size: 0.82rem; padding: 9px 8px; }
  .quiz-end-score { font-size: 2rem; }

  /* ── Header zoom buttons: hide duplicate (only keep map-controls) ── */
  .header-right { display: none; }
}

/* ── Very small screens (≤ 380px) ── */
@media (max-width: 380px) {
  .logo { font-size: 0.95rem; }
  .hbtn { font-size: 0.65rem; padding: 3px 6px; }
  select.hsel { max-width: 100px; font-size: 0.65rem; }
  #map-container { max-height: 50%; }
  .quiz-options { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Landscape on mobile: wider map, narrower panel ── */
@media (max-width: 750px) and (orientation: landscape) {
  .workspace { flex-direction: row; }
  #map-container { flex: 1; max-height: none; }
  .info-panel {
    width: 260px;
    border-left: 2px solid var(--border);
    border-top: none;
    overflow-y: auto;
  }
  header { flex-wrap: nowrap; }
  .header-center { order: 0; width: auto; }
}
