/* ==================================================================
   GeoAtlas — Estilo "atlas cartográfico"
   Tipografía: Fraunces (display) + Outfit (texto)
   ================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --ocean:        #0d4f5c;   /* primario (profundidad del mar) */
    --ocean-dark:   #08343d;
    --ocean-soft:   #e3eef0;
    --sand:         #f6f1e7;   /* fondo pergamino */
    --sand-2:       #efe7d4;
    --amber:        #e09f3e;   /* acento (brújula) */
    --amber-dark:   #b97d22;
    --green:        #1b7a43;
    --red:          #c0392b;
    --ink:          #1a2e35;
    --muted:        #6b7d85;
    --line:         #e4dcc9;
    --surface:      #ffffff;
    --shadow:       0 6px 22px rgba(13, 79, 92, .10);
    --shadow-sm:    0 2px 8px rgba(13, 79, 92, .08);
    --radius:       14px;
    --radius-sm:    9px;
}

html, body { height: 100%; }
body {
    font-family: "Outfit", system-ui, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 85% -10%, #fff7e8 0%, transparent 55%),
        radial-gradient(900px 500px at -5% 110%, #e3eef0 0%, transparent 50%),
        var(--sand);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================================================================
   BARRA SUPERIOR
   ================================================================== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem clamp(1rem, 3vw, 2rem);
    background: linear-gradient(110deg, var(--ocean-dark), var(--ocean));
    color: #fff;
    box-shadow: 0 4px 18px rgba(8, 52, 61, .25);
    z-index: 1000;
    flex-shrink: 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: #fff;
    font-size: 1.35rem;
}
.brand-mark { font-size: 1.5rem; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.brand-text { font-family: "Fraunces", serif; font-weight: 400; letter-spacing: .3px; }
.brand-text strong { font-weight: 800; }
.nav { display: flex; gap: 0.35rem; }
.nav-link {
    color: #dceef1;
    text-decoration: none;
    padding: 0.42rem 0.9rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all .2s ease;
}
.nav-link:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ==================================================================
   MENSAJES FLASH
   ================================================================== */
.flash-container {
    position: absolute;
    top: 70px;
    right: 18px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(340px, 86vw);
}
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideIn .3s cubic-bezier(.2,.8,.2,1);
}
.flash-success { background: var(--green); }
.flash-error   { background: var(--red); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ==================================================================
   LAYOUT GENERAL
   ================================================================== */
.content { flex: 1 1 auto; min-height: 0; display: flex; }

/* ==================================================================
   JUEGO — PANEL + MAPA
   ================================================================== */
.game-layout { display: flex; width: 100%; height: 100%; }

.panel {
    width: 360px;
    min-width: 360px;
    height: 100%;
    padding: 1.3rem;
    background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(246,241,231,.85));
    backdrop-filter: blur(6px);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    animation: panelIn .5s ease both;
}
@keyframes panelIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

.map-wrap { flex: 1; height: 100%; position: relative; }
#mapa { width: 100%; height: 100%; background: var(--ocean-soft); }

/* Caja de puntaje */
.score-box { display: flex; gap: 0.7rem; }
.score-item {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.7rem 0.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.score-item.streak { background: linear-gradient(160deg, #fff5e2, #fff); border-color: #f0d9ad; }
.score-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    font-weight: 600;
}
.score-value {
    display: block;
    margin-top: 0.15rem;
    font-family: "Fraunces", serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--ocean);
    line-height: 1.1;
}
.score-item.streak .score-value { color: var(--amber-dark); }
.flame { font-size: 1.1rem; }

/* Pregunta */
.pregunta-wrap .kicker {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--amber-dark);
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.pregunta {
    font-family: "Fraunces", serif;
    font-weight: 600;
    font-size: clamp(1.15rem, 1.4vw, 1.4rem);
    line-height: 1.3;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 5px solid var(--amber);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow-sm);
    min-height: 64px;
    display: flex;
    align-items: center;
}

/* Continentes */
.step {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 0.45rem;
}
.btn-continentes {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 0.7rem;
}
.btn-cont {
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    transition: all .18s ease;
}
.btn-cont:hover { border-color: var(--ocean); background: var(--ocean-soft); transform: translateY(-1px); }
.btn-cont.activo { background: var(--ocean); border-color: var(--ocean); color: #fff; }

/* Resultado */
.resultado {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    line-height: 1.45;
    box-shadow: var(--shadow-sm);
    animation: panelIn .3s ease both;
}
.resultado.ok   { background: #e7f4ec; border: 1px solid #bfe3cd; color: #15502b; }
.resultado.fail { background: #fdeceb; border: 1px solid #f5c6c0; color: #8a2317; }
.bono {
    display: inline-block;
    background: var(--amber);
    color: #4a2c00;
    font-weight: 700;
    font-size: 0.78rem;
    padding: 1px 8px;
    border-radius: 999px;
}

/* Botón principal */
.btn-principal {
    background: linear-gradient(120deg, var(--amber), var(--amber-dark));
    color: #fff;
    border: none;
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(185, 125, 34, .35);
    transition: transform .15s ease, box-shadow .15s ease;
}
.btn-principal:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(185, 125, 34, .42); }
.btn-principal:active { transform: translateY(0); }
.btn-principal span { transition: transform .15s ease; display: inline-block; }
.btn-principal:hover span { transform: translateX(4px); }

.oculto { display: none !important; }

/* ==================================================================
   ADMIN
   ================================================================== */
.admin-layout {
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
    padding: clamp(1.2rem, 3vw, 2.2rem);
    overflow-y: auto;
    height: 100%;
}
.admin-head { margin-bottom: 1.4rem; }
.admin-head .kicker {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--amber-dark);
    font-weight: 600;
}
.admin-head h1 {
    font-family: "Fraunces", serif;
    font-weight: 700;
    color: var(--ocean-dark);
    font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1.1rem, 2.5vw, 1.6rem);
    margin-bottom: 1.4rem;
    box-shadow: var(--shadow);
}
.card-title {
    font-family: "Fraunces", serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.contador {
    font-family: "Outfit", sans-serif;
    background: var(--ocean-soft);
    color: var(--ocean-dark);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 11px;
    border-radius: 999px;
}

.form-agregar {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.field {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    flex: 1;
    min-width: 200px;
}
.field span { margin-bottom: 0.3rem; }
.field input, .field select {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    background: #fffdf8;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--ocean);
    box-shadow: 0 0 0 3px var(--ocean-soft);
}
.form-agregar .btn-principal { height: fit-content; padding: 0.65rem 1.2rem; }

.ayuda {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.9rem;
    line-height: 1.4;
}

/* Tabla */
.tabla-wrap { overflow-x: auto; }
.tabla-paises { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tabla-paises th, .tabla-paises td {
    text-align: left;
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.tabla-paises th {
    background: var(--ocean-soft);
    color: var(--ocean-dark);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}
.tabla-paises tbody tr { transition: background .12s ease; }
.tabla-paises tbody tr:hover { background: #fbf8f1; }
.pais-nom { font-weight: 600; }
.muted { color: var(--muted); }
.vacio { text-align: center; color: var(--muted); padding: 1.6rem; }

.badge {
    display: inline-block;
    background: var(--ocean);
    color: #fff;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 500;
}

.btn-eliminar {
    background: #fff;
    color: var(--red);
    border: 1px solid #e6b3ad;
    padding: 0.34rem 0.8rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
}
.btn-eliminar:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ==================================================================
   LOGIN ADMIN
   ================================================================== */
.login-layout {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.login-card {
    width: min(400px, 94vw);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1.6rem, 4vw, 2.4rem);
    box-shadow: var(--shadow);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    animation: panelIn .35s ease both;
}
.login-icon { font-size: 2.6rem; }
.login-titulo { font-family: "Fraunces", serif; font-weight: 700; color: var(--ocean-dark); font-size: 1.5rem; }
.login-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem; }
.login-field { display: flex; flex-direction: column; text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.login-field input {
    margin-top: 0.3rem; padding: 0.65rem 0.7rem; border: 1px solid var(--line);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 0.95rem; background: #fffdf8;
}
.login-field input:focus { outline: none; border-color: var(--ocean); box-shadow: 0 0 0 3px var(--ocean-soft); }
.login-volver { display: inline-block; margin-top: 0.5rem; color: var(--muted); font-size: 0.85rem; text-decoration: none; }
.login-volver:hover { color: var(--ocean); }

.admin-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.btn-secundario.compacto { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* ==================================================================
   PROGRESO DE PARTIDA (aciertos / vidas)
   ================================================================== */
.progreso {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    box-shadow: var(--shadow-sm);
}
.prog-fila { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.prog-titulo { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.prog-num { font-family: "Fraunces", serif; font-weight: 700; color: var(--ocean); font-size: 0.95rem; }
.vidas { font-size: 0.95rem; letter-spacing: 1px; }
.barra { height: 8px; background: var(--sand-2); border-radius: 999px; overflow: hidden; margin-bottom: 0.55rem; }
.barra-relleno {
    height: 100%; width: 0;
    background: linear-gradient(90deg, var(--ocean), #2a9d8f);
    border-radius: 999px; transition: width .4s cubic-bezier(.2,.8,.2,1);
}

/* ==================================================================
   BOTON SECUNDARIO
   ================================================================== */
.btn-secundario {
    background: transparent;
    color: var(--ocean);
    border: 1px solid var(--ocean);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
}
.btn-secundario:hover { background: var(--ocean-soft); }
.btn-principal.compacto { padding: 0.5rem 1rem; font-size: 0.9rem; }

/* ==================================================================
   MODALES
   ================================================================== */
.modal {
    position: fixed; inset: 0;
    background: rgba(8, 52, 61, .55);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    z-index: 3000; padding: 1rem;
    animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-contenido {
    background: var(--surface);
    border-radius: var(--radius);
    padding: clamp(1.4rem, 4vw, 2.2rem);
    width: min(440px, 94vw);
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 24px 60px rgba(8, 52, 61, .4);
    text-align: center;
    animation: panelIn .3s ease both;
}
.modal-chico { width: min(380px, 94vw); }
.modal-titulo { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.6rem; color: var(--ocean-dark); margin-bottom: 0.4rem; }
.modal-mensaje { color: var(--muted); margin-bottom: 1.1rem; line-height: 1.4; }
.modal-stats { display: flex; justify-content: center; gap: 1.2rem; margin-bottom: 1.3rem; }
.modal-stats > div { display: flex; flex-direction: column; }
.ms-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.ms-val { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.3rem; color: var(--ocean); }

.form-ranking { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; text-align: left; }
.form-ranking label { font-size: 0.85rem; font-weight: 500; color: var(--ink); }
.form-ranking input {
    padding: 0.65rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.95rem; background: #fffdf8;
}
.form-ranking input:focus { outline: none; border-color: var(--ocean); box-shadow: 0 0 0 3px var(--ocean-soft); }

/* ==================================================================
   RANKING
   ================================================================== */
.ranking-lista { text-align: left; display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
.rank-fila {
    display: grid; grid-template-columns: 2rem 1fr auto auto; align-items: center; gap: 0.6rem;
    padding: 0.55rem 0.8rem; border-radius: var(--radius-sm);
    background: #fbf8f1; border: 1px solid var(--line);
}
.rank-pos { font-size: 1.05rem; font-weight: 700; color: var(--ocean-dark); }
.rank-nombre { font-weight: 600; color: var(--ink); }
.rank-meta { font-size: 0.78rem; color: var(--muted); }
.rank-puntaje { font-family: "Fraunces", serif; font-weight: 700; color: var(--amber-dark); }

/* ==================================================================
   SWITCH (toggle) para la configuracion
   ================================================================== */
.form-config { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.switch-wrap { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; user-select: none; }
.switch-wrap input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch {
    position: relative; width: 46px; height: 26px; border-radius: 999px;
    background: var(--sand-2); border: 1px solid var(--line); transition: background .2s ease; flex-shrink: 0;
}
.switch:before {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 20px; height: 20px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s ease;
}
.switch-wrap input:checked + .switch { background: var(--ocean); border-color: var(--ocean); }
.switch-wrap input:checked + .switch:before { transform: translateX(20px); }
.switch-label { font-size: 0.95rem; font-weight: 500; color: var(--ink); }

/* ==================================================================
   PISTAS + TARJETA DE PAÍS (info capital/bandera)
   ================================================================== */
.btn-pista {
    margin-top: 0.6rem;
    background: var(--ocean-soft);
    color: var(--ocean-dark);
    border: 1px solid var(--ocean);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
}
.btn-pista:hover:not(:disabled) { background: var(--ocean); color: #fff; }
.btn-pista:disabled, .btn-pista.agotado { opacity: .45; cursor: not-allowed; border-color: var(--line); color: var(--muted); }
.pista-info {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--amber-dark);
    background: #fff5e2;
    border: 1px solid #f0d9ad;
    padding: 0.45rem 0.7rem;
    border-radius: var(--radius-sm);
}
.info-pais {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    box-shadow: var(--shadow-sm);
    animation: panelIn .3s ease both;
}
.info-pais strong { display: block; font-family: "Fraunces", serif; font-size: 1.05rem; color: var(--ocean-dark); }
.info-pais .capital { display: block; font-size: 0.82rem; color: var(--muted); }
.bandera { width: 48px; height: 34px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); flex-shrink: 0; }

/* Formulario de parámetros (admin) */
.form-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.8rem; }
.form-params .field { min-width: 0; }
.form-params .btn-principal { grid-column: 1 / -1; width: fit-content; }

/* Botón de tema (claro/oscuro) */
.btn-tema {
    background: rgba(255,255,255,.14);
    border: none;
    color: #fff;
    font-size: 1.1rem;
    width: 38px; height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: background .2s ease;
    margin-left: 0.4rem;
}
.btn-tema:hover { background: rgba(255,255,255,.28); }

/* ==================================================================
   GRUPO DE BOTONES (panel) + AUTOCOMPLETAR (admin)
   ================================================================== */
.botones-extra { display: flex; gap: 0.5rem; }
.botones-extra .btn-secundario { flex: 1; }

.autocomplete { position: relative; }
.ac-lista {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; display: none; margin-top: 2px;
}
.ac-lista.visible { display: block; }
.ac-item {
    display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.7rem; cursor: pointer; font-size: 0.9rem; border-bottom: 1px solid var(--line);
}
.ac-item:last-child { border-bottom: none; }
.ac-item em { font-size: 0.75rem; color: var(--muted); font-style: normal; }
.ac-item:hover, .ac-item.activo { background: var(--ocean-soft); color: var(--ocean-dark); }
.ac-item.guardado { opacity: .6; }
.ac-item em.ya { font-size: 0.72rem; color: var(--green); font-weight: 600; font-style: normal; margin-left: .3rem; }
.aviso-dup { color: var(--red); font-size: 0.85rem; font-weight: 600; margin-top: 0.6rem; }

/* ==================================================================
   CONFETI
   ================================================================== */
.confeti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 4000; overflow: hidden; }
.confeti {
    position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px;
    animation-name: caer; animation-timing-function: linear; animation-fill-mode: forwards;
}
@keyframes caer {
    to { transform: translateY(105vh) rotate(720deg); opacity: .9; }
}

/* ==================================================================
   MODO OSCURO — cobertura completa (tokens + overrides específicos)
   ================================================================== */
:root[data-theme="oscuro"] {
    --ocean:        #4ea7b8;
    --ocean-dark:   #2d6b78;
    --ocean-soft:   #142b33;
    --sand:         #0f1f25;
    --sand-2:       #16303a;
    --amber:        #e09f3e;
    --amber-dark:   #f0c275;
    --ink:          #e8eef0;
    --muted:        #93a7af;
    --line:         #2a414a;
    --surface:      #182830;
    --shadow:       0 6px 22px rgba(0,0,0,.45);
    --shadow-sm:    0 2px 8px rgba(0,0,0,.35);
    --green:        #4caf50;
    --red:          #e57373;
}
/* cuerpo */
:root[data-theme="oscuro"] body {
    background:
        radial-gradient(1200px 600px at 85% -10%, #16303a 0%, transparent 55%),
        radial-gradient(900px 500px at -5% 110%, #142b33 0%, transparent 50%),
        var(--sand);
}
/* topbar */
:root[data-theme="oscuro"] .topbar { background: linear-gradient(110deg, #0a1a20, #122b34); }

/* panel (fondo translúcido claro → oscuro) */
:root[data-theme="oscuro"] .panel {
    background: linear-gradient(180deg, rgba(24,40,48,.92), rgba(15,31,37,.85));
    backdrop-filter: blur(6px);
}

/* inputs / selects con bg de pergamino claro */
:root[data-theme="oscuro"] .field input,
:root[data-theme="oscuro"] .field select,
:root[data-theme="oscuro"] .form-agregar input,
:root[data-theme="oscuro"] .form-agregar select,
:root[data-theme="oscuro"] .form-params input,
:root[data-theme="oscuro"] .form-ranking input,
:root[data-theme="oscuro"] .login-field input {
    background: #0f1f25; color: var(--ink);
}

/* botones */
:root[data-theme="oscuro"] .btn-principal {
    background: linear-gradient(120deg, var(--amber), #c07a20);
    box-shadow: 0 6px 16px rgba(0,0,0,.45);
}
:root[data-theme="oscuro"] .btn-secundario { border-color: var(--ocean); color: var(--ocean); }
:root[data-theme="oscuro"] .btn-secundario:hover { background: var(--ocean-soft); }
:root[data-theme="oscuro"] .btn-eliminar { background: transparent; color: var(--red); border-color: var(--red); }
:root[data-theme="oscuro"] .btn-eliminar:hover { background: var(--red); color: #fff; }

/* resultado + tarjeta info */
:root[data-theme="oscuro"] .resultado.ok { background: #16302a; color: #b6e8c4; border-color: #2d5e44; }
:root[data-theme="oscuro"] .resultado.fail { background: #2e1a18; color: #f5b8b0; border-color: #5e2d2d; }
:root[data-theme="oscuro"] .pista-info { background: #2a2410; color: var(--amber-dark); border-color: #4a3d16; }
:root[data-theme="oscuro"] .info-pais .bandera { border-color: var(--line); }

/* ranking */
:root[data-theme="oscuro"] .rank-fila { background: #12222a; border-color: var(--line); }

/* tabla admin */
:root[data-theme="oscuro"] .tabla-paises tbody tr:hover { background: #12222a; }

/* progreso (barra de fondo) */
:root[data-theme="oscuro"] .barra { background: #253d47; }

/* streak card (tenía degradado claro duro) */
:root[data-theme="oscuro"] .score-item.streak { background: linear-gradient(160deg, #1a2e10, #182830); border-color: #4a3d16; }

/* continente chips activos */
:root[data-theme="oscuro"] .btn-cont { border-color: var(--line); background: var(--surface); color: var(--ink); }
:root[data-theme="oscuro"] .btn-cont:hover { border-color: var(--ocean); background: var(--ocean-soft); }

/* autocompletar */
:root[data-theme="oscuro"] .ac-lista { background: var(--surface); border-color: var(--line); }

/* modal */
:root[data-theme="oscuro"] .modal { background: rgba(0,0,0,.6); }

/* tooltip Leaflet */
:root[data-theme="oscuro"] .leaflet-tooltip { background: #253d47; }

/* login */
:root[data-theme="oscuro"] .login-card { background: var(--surface); border-color: var(--line); }

/* flash container — auto-adaptable, solo ajustamos sombra */
:root[data-theme="oscuro"] .flash { box-shadow: 0 4px 14px rgba(0,0,0,.5); }

/* botón pista */
:root[data-theme="oscuro"] .btn-pista { background: var(--ocean-soft); border-color: var(--ocean); color: var(--ocean-dark); }
:root[data-theme="oscuro"] .btn-pista:hover:not(:disabled) { background: var(--ocean); color: #fff; }
:root[data-theme="oscuro"] .btn-pista:disabled { border-color: var(--line); color: var(--muted); opacity: .5; }

/* botón tema (blanco translúcido sobre topbar oscura — ambos temas) */
:root[data-theme="oscuro"] .btn-tema { background: rgba(255,255,255,.12); }
:root[data-theme="oscuro"] .btn-tema:hover { background: rgba(255,255,255,.22); }

/* contador en admin (era ocean-soft que ya es var → ok; solo aseguramos) */
:root[data-theme="oscuro"] .contador { background: var(--ocean-soft); color: var(--ocean); }

/* aviso duplicado en admin */
:root[data-theme="oscuro"] .aviso-dup { color: var(--red); }

/* tabla-paises th — hereda el token, aseguramos fondo */
:root[data-theme="oscuro"] .tabla-paises th { background: var(--ocean-soft); }
:root[data-theme="oscuro"] .tabla-paises th, :root[data-theme="oscuro"] .tabla-paises td { border-color: var(--line); }

/* preguntas */
:root[data-theme="oscuro"] .pregunta { background: var(--surface); color: var(--ink); }

/* ==================================================================
   RESPONSIVE
   ================================================================== */
@media (max-width: 980px) {
    body { overflow: auto; }
    .content { display: block; min-height: 100%; height: auto; }
    .game-layout { flex-direction: column; height: auto; min-height: 100%; }

    .panel {
        width: 100%; min-width: 0; height: auto;
        border-right: none; border-bottom: 1px solid var(--line);
    }
    .map-wrap { height: 62vh; min-height: 360px; }
}

@media (max-width: 560px) {
    .topbar { padding: 0.6rem 1rem; }
    .brand-text { font-size: 1.15rem; }
    .nav-link { padding: 0.4rem 0.7rem; font-size: 0.88rem; }

    .score-box { gap: 0.5rem; }
    .score-value { font-size: 1.4rem; }

    .form-agregar { flex-direction: column; align-items: stretch; }
    .form-agregar .btn-principal { width: 100%; }

    .form-config { flex-direction: column; align-items: stretch; }
    .form-config .btn-principal { width: 100%; }

    .rank-fila { grid-template-columns: 1.8rem 1fr auto; }
    .rank-meta { display: none; }
    .modal-stats { gap: 0.7rem; }

    .map-wrap { height: 58vh; min-height: 320px; }
}

/* Leaflet: tooltip y controles se ven bien sobre el tema */
.leaflet-tooltip {
    font-family: "Outfit", sans-serif;
    font-weight: 500;
    background: var(--ocean-dark);
    color: #fff;
    border: none;
    box-shadow: var(--shadow);
}
.leaflet-tooltip-top:before, .leaflet-tooltip-bottom:before { border-top-color: var(--ocean-dark); }
