:root{
  --bg:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --border:#e2e8f0;
  --shadow: 0 10px 30px rgba(2,6,23,.08);
  --primary:#5b7cfa;
  --radius:18px;

  --ok:#16a34a;
  --bad:#ef4444;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color:var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(91,124,250,.16), transparent 55%),
              radial-gradient(900px 500px at 90% 0%, rgba(91,124,250,.10), transparent 55%),
              var(--bg);
}

a{ color:#3757d6; text-decoration:none; }
a:hover{ text-decoration:underline; }

:focus-visible{
  outline: 3px solid rgba(91,124,250,.45);
  outline-offset: 3px;
  border-radius: 14px;
}

.container{
  width:min(100%, 1100px);
  margin:0 auto;
  padding: clamp(14px, 2.2vw, 22px);
}

.header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom: 12px;
}
.header h1{
  margin:0;
  font-size: clamp(18px, 3vw, 26px);
}
.header p{
  margin:0;
  color:var(--muted);
  font-size: 13px;
}

.panel{
  background: rgba(255,255,255,.88);
  border:1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: clamp(12px, 2.2vw, 18px);
}

.controls{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
}

.group{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}

.btn{
  appearance:none;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:10px 12px;
  border-radius: 12px;
  font-weight:650;
  font-size:13px;
  cursor:pointer;
}

.btn.primary{
  background: linear-gradient(135deg, var(--primary), #7f97ff);
  color:#fff;
  border-color: rgba(91,124,250,.55);
}

.btn.active{
  box-shadow: 0 10px 20px rgba(91,124,250,.20);
  border-color: rgba(91,124,250,.55);
}

.pill{
  font-size:12px;
  font-weight:750;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#f8fafc;
}

.layout{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 12px;
  margin-top: 12px;
}
@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
}

.mapWrap{
  position:relative;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(2,6,23,.06);
  min-height: 520px;
  overflow:hidden;
}

/* HUD encima del mapa */
.hud{
  position:absolute;
  left: 12px;
  top: 12px;
  right: 12px;
  display:flex;
  gap:10px;
  justify-content:space-between;
  align-items:flex-start;
  pointer-events:none;
  z-index:5;
}
.hud .badge,
.hud .score{
  pointer-events:none;
  background: rgba(255,255,255,.92);
  border:1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--muted);
}
.hud .badge strong{ color: var(--text); }

.hint{
  position:absolute;
  left: 12px;
  bottom: 12px;
  right: 12px;
  background: rgba(255,255,255,.90);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  z-index:5;
}

/* --- SVG MAP --- */
.svgMap{
  position:absolute;
  inset:0;
  padding: 56px 12px 56px 12px; /* deja hueco HUD + hint */
}

.svgMap svg{
  width:100%;
  height:100%;
  display:block;
}

/* RegiĆ³n: forma */
.regionShape{
  fill: rgba(91,124,250,.14);
  stroke: rgba(15,23,42,.22);
  stroke-width: 1.2;
  transition: fill .18s ease, transform .18s ease, filter .18s ease;
  transform-origin: center;
  cursor:pointer;
}
.regionShape:hover{
  fill: rgba(91,124,250,.22);
  filter: drop-shadow(0 6px 10px rgba(2,6,23,.10));
}

/* Estado revelado */
.region.revealed .regionShape{
  fill: rgba(91,124,250,.28);
  stroke: rgba(15,23,42,.28);
}

/* Etiquetas en el mapa (solo cuando revelado o en quiz si quieres) */
.regionLabel{
  font-size: 16px;
  font-weight: 900;
  fill: rgba(15,23,42,.92);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events:none;
  opacity: 0;
  transition: opacity .18s ease;
}
.region.revealed .regionLabel{ opacity: 1; }

.regionHint{
  font-size: 18px;
  font-weight: 1000;
  fill: rgba(15,23,42,.55);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events:none;
  opacity: 1;
}
.region.revealed .regionHint{ opacity: 0; }

/* Feedback quiz */
.region.okFlash .regionShape{
  stroke: rgba(22,163,74,.70);
  stroke-width: 2.6;
  filter: drop-shadow(0 0 0 rgba(0,0,0,0));
}
.region.badFlash .regionShape{
  stroke: rgba(239,68,68,.70);
  stroke-width: 2.6;
}

.side h2{ margin:0 0 10px 0; font-size: 16px; }
.list{
  display:grid;
  grid-template-columns: 1fr;
  gap:8px;
  max-height: 430px;
  overflow:auto;
  padding-right: 6px;
}
.item{
  border:1px solid var(--border);
  border-radius: 14px;
  background:#fff;
  padding: 10px 12px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
.item small{ color:var(--muted); font-weight:650; }

.quiz{
  margin-top: 10px;
  border-top:1px solid var(--border);
  padding-top: 10px;
}
.quiz .q{ margin:0 0 10px 0; font-size: 14px; }
.row{ display:flex; gap:10px; flex-wrap:wrap; }
.notice{ margin-top: 10px; font-size: 12px; color: var(--muted); }

@media (prefers-reduced-motion: reduce){
  .regionShape, .regionLabel{ transition:none; }
}

/* --- Estilos para el SVG real --- */
#svgHost svg { width:100%; height:100%; display:block; }

.regionShape{
  fill: rgba(91,124,250,.16) !important;
  stroke: rgba(15,23,42,.28) !important;
  stroke-width: 1.2 !important;
}

.revealed.regionShape,
.revealed .regionShape{
  fill: rgba(91,124,250,.30) !important;
}

.okFlash{
  stroke: rgba(22,163,74,.70) !important;
  stroke-width: 2.6 !important;
}

.badFlash{
  stroke: rgba(239,68,68,.70) !important;
  stroke-width: 2.6 !important;
}
/* --- Estilos para mapa SVG --- */
#svgHost svg { width:100%; height:100%; display:block; }

/* La ”°tarjeta”± es la propia comunidad */
.regionShape{
  fill: rgba(91,124,250,.16) !important;
  stroke: rgba(15,23,42,.28) !important;
  stroke-width: 1.2 !important;
  transition: fill .18s ease, filter .18s ease, stroke .18s ease, stroke-width .18s ease;
}
.regionShape:hover{
  fill: rgba(91,124,250,.26) !important;
  filter: drop-shadow(0 10px 14px rgba(2,6,23,.10));
}

.regionShape.revealed{
  fill: rgba(91,124,250,.34) !important;
  stroke: rgba(15,23,42,.30) !important;
}

/* Feedback quiz */
.regionShape.okFlash{
  stroke: rgba(22,163,74,.70) !important;
  stroke-width: 2.6 !important;
}
.regionShape.badFlash{
  stroke: rgba(239,68,68,.70) !important;
  stroke-width: 2.6 !important;
}

