/* ==========================================================================
   BASE
   ========================================================================== */
:root {
    --topbar-h: 64px;
    --safe: 16px;
    --card-w: 300px;
}

/* html también necesita fondo para que backdrop-filter no muestre otras ventanas del SO */
html {
    background: #f3f3f3;
}
html.modo-oscuro {
    background: #0d1117;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    text-align: center;
    background: #f3f3f3;
}

/* Eliminar delay de 300ms en tap — todos los elementos interactivos */
button, a, [onclick], .home-card, .modo-card, .subset-pill, .opt-btn, .pill {
    touch-action: manipulation;
}

/* ==========================================================================
   MODO OSCURO
   ========================================================================== */
body.modo-oscuro {
    background: #0d1117;
    color: #c9d1d9;
}

/* Topbar */
body.modo-oscuro #topbar {
    background: rgba(22, 27, 34, 0.85);
    border-color: rgba(48, 54, 61, 0.8);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
body.modo-oscuro #app-title { color: #d1862b; }
body.modo-oscuro .pill { background: #21262d; color: #c9d1d9; border-color: #30363d; }
body.modo-oscuro .pill.active { border-color: #58a6ff; color: #58a6ff; }
body.modo-oscuro .filtro-check { color: #3fb950; }
body.modo-oscuro #topbar h4 { color: #8b949e; }

/* Pregunta pill */
body.modo-oscuro #pregunta {
    background: rgba(22, 27, 34, 0.92);
    color: #f0f6fc;
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

/* Filtro valor pills */
body.modo-oscuro .filtro-valor-btn { filter: brightness(0.8); }

/* Select móvil */
body.modo-oscuro #topbar-right-mobile select {
    background: #21262d;
    border-color: #30363d;
    color: #c9d1d9;
}

/* Modal */
body.modo-oscuro .modal-overlay { background: rgba(0,0,0,0.75); }
body.modo-oscuro .modal-box {
    background: #161b22;
    border-color: #30363d;
    color: #c9d1d9;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
body.modo-oscuro .modal-box h2 { color: #f0f6fc; }
body.modo-oscuro .setting-row { color: #c9d1d9; }
body.modo-oscuro .modal-cerrar { color: #8b949e; }
body.modo-oscuro .modal-cerrar:hover { color: #f0f6fc; }
body.modo-oscuro .btn-modal-cancelar {
    background: #21262d;
    border-color: #30363d;
    color: #8b949e;
}
body.modo-oscuro .btn-modal-cancelar:hover { color: #f0f6fc; border-color: #58a6ff; }
body.modo-oscuro .lang-btn { background: #21262d; border-color: #30363d; color: #8b949e; }
body.modo-oscuro .lang-btn:hover { border-color: #58a6ff; color: #f0f6fc; }
body.modo-oscuro .lang-btn.activo { background: #e53935; border-color: #e53935; color: #fff; }

/* Tarjeta info región */
body.modo-oscuro #info-region {
    background: rgba(22, 27, 34, 0.97);
    border-color: #30363d;
    color: #c9d1d9;
}
body.modo-oscuro #info-region h3 { color: #f0f6fc; }
body.modo-oscuro #info-region ul { color: #8b949e; }
body.modo-oscuro #info-region ul li strong { color: #c9d1d9; }
body.modo-oscuro #info-region button.cerrar-info { color: #8b949e; }

/* Botones flotantes */
body.modo-oscuro .btn-volver {
    background: rgba(22, 27, 34, 0.9);
    color: #e6edf3;
    border: 1px solid #444c56;
}
body.modo-oscuro .btn-volver:hover { background: #21262d; border-color: #6e7681; }
body.modo-oscuro .btn-ajustes {
    background: rgba(22, 27, 34, 0.9);
    border-color: #30363d;
    color: #c9d1d9;
}

/* Modal resultados (práctica) */
body.modo-oscuro .resultado-fila { background: rgba(255,255,255,0.04); color: #c9d1d9; }
body.modo-oscuro .resultado-fila.precision .valor { color: #c9d1d9; }
body.modo-oscuro .resultado-barra { background: rgba(255,255,255,0.08); }
body.modo-oscuro .btn-resultado-secundario { border-color: #30363d; color: #8b949e; }
body.modo-oscuro .btn-resultado-secundario:hover { border-color: #8b949e; color: #f0f6fc; }

/* Tooltip error */
body.modo-oscuro .tooltip-error {
    background: #161b22;
    color: #f85149;
    border-color: #f85149;
}

/* ===================== MAP HOVER TOOLTIP ===================== */
.map-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: rgba(0,0,0,0.78);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
    transform: translate(-50%, -130%);
    opacity: 0;
    transition: opacity 0.12s;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.map-tooltip.visible { opacity: 1; }

/* ===================== REGION HINT (pista distrito) ===================== */
path.region-hint {
    fill: rgba(255, 214, 0, 0.38) !important;
    stroke: #FFC107 !important;
    stroke-width: 2 !important;
    transition: fill 0.6s, stroke 0.6s;
}

/* ===================== STREAK BADGE ===================== */
.pill.racha {
    background: linear-gradient(135deg, #ff6b35, #f7c59f);
    color: #fff;
    font-weight: 700;
    min-width: 2.8rem;
    transition: transform 0.15s;
}
.pill.racha.bump {
    transform: scale(1.25);
}

/* ===================== HINT BUTTON (fijo, junto al botón ⚙️) ===================== */
@keyframes pistaBlink {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,193,7,0); }
    50% { opacity: 0.55; box-shadow: 0 0 8px 3px rgba(255,193,7,0.5); }
}
.pista-blink {
    animation: pistaBlink 0.5s ease-in-out 3;
}

#btn-pista {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    height: 45px;
    padding: 0 1rem;
    font-size: 0.82rem;
    font-weight: 700;
    border: 1.5px solid #FFC107;
    background: rgba(255, 255, 255, 0.92);
    color: #b8860b;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transition: background 0.15s, color 0.15s, opacity 0.2s;
    white-space: nowrap;
}
#btn-pista:hover:not(:disabled) {
    background: rgba(255, 193, 7, 0.18);
    color: #7a5c00;
}
#btn-pista:disabled {
    opacity: 0.45;
    cursor: default;
    border-color: #ccc;
    color: #aaa;
    background: rgba(255,255,255,0.7);
}
body.modo-oscuro #btn-pista {
    background: rgba(22, 27, 34, 0.92);
    color: #FFC107;
    border-color: #FFC107;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}
body.modo-oscuro #btn-pista:hover:not(:disabled) {
    background: rgba(255, 193, 7, 0.15);
    color: #FFE082;
}
body.modo-oscuro #btn-pista:disabled {
    background: rgba(22,27,34,0.7);
}

@media (max-width: 430px) {
    #btn-pista {
        bottom: 14px;
        right: 65px;
        height: 40px;
        padding: 0 0.75rem;
        font-size: 0.77rem;
    }
}

/* ==========================================================================
   MODO 4 OPCIONES
   ========================================================================== */
path.region-current-4 {
    fill: #58a6ff !important;
    stroke: #1a6fcf !important;
    stroke-width: 1.5 !important;
    filter: drop-shadow(0 0 6px rgba(88,166,255,0.65));
    animation: pulse4 1.4s ease-in-out infinite;
}

@keyframes pulse4 {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

#opciones-container {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2200;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: min(520px, calc(100vw - 32px));
}

.opcion-btn {
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    border: 2px solid #30363d;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #f0f6fc;
    font-family: 'Inter', sans-serif;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
    text-align: center;
    line-height: 1.35;
    min-height: 54px;
}

/* Solo en dispositivos con hover real (ratón). En touch :hover "se pega" al último elemento tocado */
@media (hover: hover) {
    .opcion-btn:hover:not(:disabled) {
        border-color: #58a6ff;
        background: rgba(88,166,255,0.12);
        transform: translateY(-2px);
    }
}

.opcion-btn.opcion-correcta {
    border-color: #3fb950 !important;
    background: rgba(63,185,80,0.18) !important;
    color: #3fb950 !important;
    animation: opcionAcierto 0.3s ease;
}

.opcion-btn.opcion-erronea {
    border-color: #f44336 !important;
    background: rgba(244,67,54,0.1) !important;
    color: #888 !important;
    opacity: 0.5;
    animation: opcionShake 0.35s ease;
}

.opcion-btn.opcion-correcta-reveal {
    border-color: #3fb950 !important;
    background: rgba(63,185,80,0.18) !important;
    color: #3fb950 !important;
}

@keyframes opcionAcierto {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@keyframes opcionShake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-5px); }
    60%       { transform: translateX(5px); }
}

@media (max-width: 480px) {
    #opciones-container {
        grid-template-columns: 1fr;
        bottom: 12px;
    }
    .opcion-btn {
        font-size: 0.82rem;
        padding: 0.75rem 0.8rem;
        min-height: 48px;
    }
}

.oculto {
    display: none !important;
}

/* ==========================================================================
   MAPA CONTAINER
   ========================================================================== */
#mapa-container {
    width: calc(100vw - 32px);
    height: calc(100vh - (var(--topbar-h) + 48px));
    height: calc(100dvh - (var(--topbar-h) + 48px)); /* dvh: excluye chrome del navegador */
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    background: #1a1a1a;
    /* JS gestiona todo el touch (pan + pinch) — el navegador no debe interceptar */
    touch-action: none;
}

#mapa-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

#mapa-container svg path {
    stroke: #ffffff;
    stroke-width: 1px;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: fill 0.3s ease;
}

/* ==========================================================================
   SVG PATHS — estados
   ========================================================================== */
svg path {
    fill: #9E9E9E;
    stroke: #ffffff;
    stroke-width: 0.8px;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    svg path:not(.region-success-1):not(.region-success-2):not(.region-success-3):not(.region-failure):hover {
        fill: #616161;
        cursor: pointer;
        stroke: #333;
    }
}

.region-success-1 {
    fill: #4CAF50 !important;
    cursor: default;
    filter: brightness(1.1);
    stroke: #fff;
    stroke-width: 1px;
}

.region-success-2 {
    fill: #FBC02D !important;
    cursor: default;
    filter: brightness(1.1);
    stroke: #fff;
    stroke-width: 1px;
}

.region-success-3 {
    fill: #FF9800 !important;
    cursor: default;
    filter: brightness(1.1);
    stroke: #fff;
    stroke-width: 1px;
}

.region-failure {
    fill: #F44336 !important;
    cursor: default;
}

.region-error-temp {
    /* Visual gestionado por JS (style.opacity) para estabilidad en iOS/WebKit SVG */
}

.region-blink-correct {
    animation: regionBlink 0.45s step-start 0s infinite;
}

@keyframes regionBlink {
    50% {
        opacity: 0.15;
    }
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
#juego {
    min-height: 100vh;
    padding-top: calc(var(--topbar-h) + 22px);
    box-sizing: border-box;
}

#topbar {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    height: var(--topbar-h);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

#app-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 900;
    font-size: 1.35rem;
    letter-spacing: 0.2px;
    color: #d1862b;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#topbar.filtro-activo #app-title {
    opacity: 0;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 900;
    font-size: 0.95rem;
    color: #222;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   PREGUNTA
   ========================================================================== */
#pregunta {
    position: fixed;
    top: calc(16px + var(--topbar-h) + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2400;
    pointer-events: none;
    margin: 0;
    padding: 10px 20px;
    border-radius: 999px;
    max-width: min(980px, calc(100vw - 24px));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.45rem;
    letter-spacing: 0.2px;
    font-weight: 900;
    color: #222;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   NOTIFICACIÓN
   ========================================================================== */
#notificacion-resultado {
    position: fixed;
    top: calc(16px + var(--topbar-h) + 76px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2500;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 900;
    background: rgba(0, 0, 0, 0.50);
    color: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#notificacion-resultado.visible {
    opacity: 1;
}

/* ==========================================================================
   TARJETA INFO REGIÓN
   ========================================================================== */
#info-region {
    position: fixed;
    right: 16px;
    top: calc(16px + var(--topbar-h) + 10px);
    z-index: 2100;
    width: min(220px, calc(100vw - 32px));
    max-height: calc(100vh - (16px + var(--topbar-h) + 20px));
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
    border-radius: 14px;
    overflow: hidden;
}

#info-region .info-flag {
    height: 100px;
    padding: 4px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

#info-region .info-flag img {
    display: block;
    width: auto;
    height: auto;
    max-width: 96%;
    max-height: 86px;
    object-fit: contain;
    margin: 0 auto;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

#info-region .info-content {
    padding: 4px 12px 14px;
}

#info-region h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 0.95rem;
    line-height: 1.15;
    text-align: center;
}

#info-region ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    font-size: 0.9rem;
    color: #555;
}

#info-region ul li {
    margin-bottom: 4px;
}

#info-region button.cerrar-info {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
    z-index: 2;
}

#info-region button.cerrar-info:hover {
    color: #000;
}

@media (max-width: 600px) {
    #info-region {
        /* Móvil: aparece ARRIBA (bajo la topbar) para no pelear con la barra de Chrome */
        position: fixed;
        left: 0;
        right: 0;
        top: calc(var(--topbar-h, 52px) + 6px);
        bottom: auto;
        width: 100%;
        max-width: 100%;
        max-height: calc(100dvh - var(--topbar-h, 52px) - 80px);
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 0 0 16px 16px;
        border: none;
        border-bottom: 1px solid rgba(0,0,0,0.1);
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        z-index: 1500;
        /* Layout horizontal: bandera + datos en fila */
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 0;
    }

    #info-region .info-flag {
        flex-shrink: 0;
        width: 80px;
        height: auto;
        padding: 12px 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #info-region .info-flag img {
        max-width: 64px;
        max-height: 48px;
    }

    #info-region .info-content {
        flex: 1;
        padding: 10px 36px 10px 4px; /* espacio para el botón × */
        overflow-y: auto;
    }

    #info-region h3 {
        font-size: 0.88rem;
        text-align: left;
        margin-bottom: 4px;
    }

    #info-region ul {
        font-size: 0.78rem;
    }

    #info-region ul li {
        margin-bottom: 2px;
    }

    #info-region button.cerrar-info {
        top: 8px;
        right: 10px;
        font-size: 1.1rem;
    }
}

/* ==========================================================================
   TOOLTIP ERROR
   ========================================================================== */
.tooltip-error {
    position: fixed;
    z-index: 2147483647;
    pointer-events: none;
    background: rgba(220, 53, 69, 0.95);
    color: #fff;
    padding: 8px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

/* ==========================================================================
   BOTONES FLOTANTES
   ========================================================================== */
.btn-volver {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: rgba(255, 255, 255, 0.95);
    color: #222;
    border: 1px solid rgba(0,0,0,0.12);
    padding: 12px 24px;
    border-radius: 50px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-volver:hover {
    background-color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn-volver:active {
    transform: translateY(1px);
}

/* Ajustes — versión clara (juego + explorar) */
.btn-ajustes {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-ajustes:hover {
    transform: rotate(180deg) scale(1.1);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

/* Ajustes — versión oscura (solo home) */
body.home-page .btn-ajustes {
    background-color: rgba(29, 111, 164, 0.18);
    border: 1px solid #30363d;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

body.home-page .btn-ajustes:hover {
    transform: rotate(180deg) scale(1.1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   SHARE TOAST (feedback portapapeles)
   ========================================================================== */
.share-toast {
    position: fixed;
    bottom: 76px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: #323232;
    color: #fff;
    padding: 0.55rem 1.3rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.share-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   BOTÓN COMPARTIR (home — flota junto al de ajustes)
   ========================================================================== */
/* Botón compartir home — mismo aspecto que btn-ajustes */
#btn-compartir-home {
    position: fixed;
    bottom: 20px;
    right: 75px;        /* a la izquierda del btn-ajustes (45px + 10px gap) */
    width: 45px;
    height: 45px;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
body.home-page #btn-compartir-home {
    display: flex;
    bottom: auto;
    top: 20px;
    background-color: rgba(29, 111, 164, 0.18);
    border: 1px solid #30363d;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
body.home-page #btn-compartir-home:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
}
body.modo-oscuro #btn-compartir-home {
    background: rgba(22, 27, 34, 0.9);
    border-color: #30363d;
    color: #c9d1d9;
}
body.modo-oscuro #btn-compartir-home:hover {
    background: #21262d;
    border-color: #8b949e;
}
/* En la home, igualar al botón de ajustes (azul tintado) */
body.modo-oscuro.home-page #btn-compartir-home {
    background-color: rgba(29, 111, 164, 0.18);
    border-color: #30363d;
    color: #fff;
}

/* ==========================================================================
   TOOLTIPS — botones flotantes de la home
   Usamos un wrapper div como ancla para el tooltip, así el botón de ajustes
   puede girar libremente sin que el tooltip herede la rotación.
   ========================================================================== */
.home-btn-wrap {
    position: fixed;
    top: 20px;
    z-index: 1001;
    width: 45px;   /* igual que los botones — evita que el wrapper se expanda */
    height: 45px;
}
.home-btn-wrap--ajustes  { right: 20px; }
.home-btn-wrap--compartir { right: 75px; }

/* El botón dentro del wrapper no necesita su propio position:fixed */
.home-btn-wrap .btn-ajustes,
.home-btn-wrap #btn-compartir-home {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    right: auto !important;
}

/* Tooltip — aparece debajo (botones están arriba) */
.home-btn-wrap::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);   /* debajo del botón */
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: rgba(30, 30, 30, 0.88);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 1100;
}
.home-btn-wrap:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   MODAL AJUSTES
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.activo {
    opacity: 1;
    visibility: visible;
}

.modal-overlay.oculto {
    display: none;
}

.modal-box {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    padding: 2rem 2.4rem;
    min-width: 280px;
    max-width: 90vw;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #1a1a1a;
}
.modal-box h2 { color: #1a1a1a; }

.modal-overlay.activo .modal-box {
    transform: translateY(0);
}

.modal-box h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #f0f6fc;
    text-align: center;
}

.modal-cerrar {
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    background: none;
    border: none;
    color: #777;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}
.modal-cerrar:hover { color: #111; }

.modal-cerrar:hover {
    color: #f0f6fc;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    color: #333;
    font-size: 0.95rem;
    cursor: pointer;
}

/* ---- Toggle switch (reemplaza checkbox en ajustes) ---- */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.22s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.22s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-switch input:checked + .toggle-slider { background: #e53935; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
body.modo-oscuro .toggle-slider { background: #444c56; }
body.modo-oscuro .toggle-switch input:checked + .toggle-slider { background: #e53935; }

/* ocultar el checkbox nativo antiguo (por si queda alguno) */
.setting-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #e53935;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.2rem;
    justify-content: flex-end;
}

.btn-modal-guardar,
.btn-modal-cancelar {
    border: none;
    border-radius: 8px;
    padding: 0.45rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-modal-guardar {
    background: #e53935;
    color: #fff;
}
.btn-modal-guardar:hover { background: #c62828; }

.btn-modal-cancelar {
    background: #f3f3f3;
    color: #555;
    border: 1px solid #ddd;
}
.btn-modal-cancelar:hover { color: #1a1a1a; border-color: #aaa; }

.lang-selector {
    display: flex;
    gap: 0.4rem;
}

.lang-btn {
    background: #f3f3f3;
    border: 1px solid #ddd;
    color: #555;
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.lang-btn:hover {
    border-color: #e53935;
    color: #1a1a1a;
}

.lang-btn.activo {
    background: #e53935;
    border-color: #e53935;
    color: #fff;
}

/* ==========================================================================
   EXPLORAR
   ========================================================================== */
#explorar {
    padding-top: calc(var(--topbar-h) + 25px);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Regiones fuera del subset activo */
.region-disabled {
    fill: #2a2a2a !important;
    cursor: not-allowed !important;
    pointer-events: none;
    opacity: 0.35;
}

/* ==========================================================================
   FILTROS EXPLORAR
   ========================================================================== */
.filtro-modo-btn {
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.filtro-modo-btn.active {
    opacity: 1;
    outline: 2px solid rgba(0, 0, 0, 0.2);
    outline-offset: 1px;
}

#topbar-right-mobile {
    display: none;
    gap: 6px;
    align-items: center;
}

#topbar-right-mobile select {
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 20px;
    padding: 6px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #24292f;
    cursor: pointer;
    outline: none;
    max-width: 42vw;
}

#topbar-right-mobile select:disabled {
    opacity: 0.4;
}

#topbar-right-desktop {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    justify-content: flex-end;
}

#filtro-valores {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
    /* Fade lateral para indicar que hay más pills con scroll */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 4%, black 96%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 4%, black 96%, transparent 100%);
}

#filtro-valores::-webkit-scrollbar {
    display: none;
}

.filtro-valor-btn {
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.82rem;
    white-space: nowrap;
    border: 2px solid transparent;
    color: #fff;
    transition: all 0.2s ease;
    opacity: 0.75;
}

.filtro-valor-btn.active {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.6);
}

.filtro-valor-btn:hover {
    opacity: 1;
}

/* Leyenda */
#leyenda-explorar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    z-index: 1500;
    pointer-events: none;
}

.leyenda-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #222;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.leyenda-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filtro-check {
    display: none;
    font-size: 0.8rem;
    color: #1a7a1a;
    font-weight: 900;
    margin-right: 2px;
}

.filtro-modo-btn.active .filtro-check {
    display: inline;
}

.modo-card-wrap {
    display: flex;
    flex-direction: column;
}

.modo-cards {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.subset-panel {
    background: #0d1117;
    border: 1px solid #21262d;
    border-top: none;
    border-radius: 0 0 14px 14px;
    padding: 1rem 1.2rem;
    display: none;
    margin-top: -6px;
    /* se solapa ligeramente con la card de arriba */
}

.subset-panel.visible {
    display: block;
}

/* ==========================================================================
   MODAL RESULTADOS PRÁCTICA
   ========================================================================== */
.resultados-box {
    min-width: 300px;
    max-width: 420px;
    text-align: center;
}

.resultados-box h2 {
    font-size: 1.4rem;
    margin-bottom: 0.2rem;
}

.resultados-subset-label {
    font-size: 0.8rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    margin: 0 0 1.4rem 0;
}

.resultados-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.6rem;
}

.resultado-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.04);
    font-size: 0.92rem;
    color: #333;
}

.resultado-fila .label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.resultado-fila .valor {
    font-weight: 800;
    font-size: 1.05rem;
}

.resultado-fila.s1 .valor {
    color: #4caf50;
}

.resultado-fila.s2 .valor {
    color: #fbc02d;
}

.resultado-fila.s3 .valor {
    color: #ff9800;
}

.resultado-fila.fail .valor {
    color: #f44336;
}

.resultado-fila.tiempo .valor {
    color: #58a6ff;
}

.resultado-fila.precision .valor {
    color: #555;
}

.resultado-barra {
    height: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.1);
    margin-top: 0.3rem;
    overflow: hidden;
    width: 100%;
}

.resultado-barra-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.resultados-acciones {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-resultado-primario {
    padding: 0.7rem 1.6rem;
    border-radius: 999px;
    border: none;
    background: #3fb950;
    color: #0d1117;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-resultado-primario:hover {
    background: #46c957;
    transform: translateY(-2px);
}

.btn-resultado-secundario {
    padding: 0.7rem 1.6rem;
    border-radius: 999px;
    border: 1px solid #ccc;
    background: none;
    color: #555;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-resultado-secundario:hover {
    border-color: #888;
    color: #111;
}

/* Botón compartir — más pequeño y sutil, debajo de los otros dos */
.btn-resultado-compartir {
    padding: 0.38rem 1.1rem;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: none;
    color: #9ca3af;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.18s, color 0.18s, background 0.18s;
    letter-spacing: 0.02em;
}
.btn-resultado-compartir:hover {
    border-color: #9ca3af;
    color: #555;
    background: rgba(0,0,0,0.02);
}
body.modo-oscuro .btn-resultado-compartir { border-color: #21262d; color: #4b5563; }
body.modo-oscuro .btn-resultado-compartir:hover { border-color: #30363d; color: #6b7280; }

/* ==========================================================================
   PANTALLA EXPEDICIÓN — DESAFÍO COMPLETADO
   ========================================================================== */

.expedicion-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.expedicion-overlay.activo {
    opacity: 1;
    visibility: visible;
}

.expedicion-overlay.oculto {
    display: none;
}

/* Fondo: el mapa pintado detrás con blur */
.expedicion-bg {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 16, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.expedicion-contenido {
    position: relative;
    z-index: 1;
    width: min(560px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.6rem;
    padding: 2rem 1rem;
    transform: translateY(30px);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.expedicion-overlay.activo .expedicion-contenido {
    transform: translateY(0);
}

/* Cabecera */
.expedicion-header {
    text-align: center;
}

.expedicion-icono {
    font-size: 2.8rem;
    line-height: 1;
    margin-bottom: 0.6rem;
    filter: drop-shadow(0 0 12px rgba(255, 200, 50, 0.4));
}

.expedicion-titulo {
    font-family: 'Inter', sans-serif;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 900;
    color: #f0f6fc;
    margin: 0 0 0.3rem 0;
    letter-spacing: -0.5px;
}

.expedicion-subtitulo {
    font-size: 0.78rem;
    color: #6b7280;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
}

/* Tarjeta principal */
.expedicion-tarjeta {
    width: 100%;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 20px;
    padding: 1.6rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

/* Rango */
.expedicion-rango {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    padding: 0.8rem 1.2rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.exp-rango-emoji {
    width: 3.5rem;
    height: 3.5rem;
    object-fit: contain;
    display: block;
}

.exp-rango-texto {
    font-size: 1.15rem;
    font-weight: 800;
    color: #f0f6fc;
    letter-spacing: -0.2px;
}

/* Stats */
.expedicion-stats {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.exp-stat-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #c9d1d9;
}

.exp-stat-izq {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 160px;
}

.exp-stat-valor {
    font-weight: 800;
    font-size: 1rem;
    min-width: 28px;
    text-align: right;
}

.exp-stat-barra-wrap {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 999px;
    overflow: hidden;
    margin: 0 0.8rem;
}

.exp-stat-barra-fill {
    height: 100%;
    border-radius: 999px;
    width: 0%;
    transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.exp-stat-fila.s1 .exp-stat-valor {
    color: #4caf50;
}

.exp-stat-fila.s2 .exp-stat-valor {
    color: #fbc02d;
}

.exp-stat-fila.s3 .exp-stat-valor {
    color: #ff9800;
}

.exp-stat-fila.fail .exp-stat-valor {
    color: #f44336;
}

/* Meta (tiempo + precisión) */
.expedicion-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    border-top: 1px solid #21262d;
    padding-top: 1rem;
}

.exp-meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.exp-meta-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.exp-meta-valor {
    font-size: 1.4rem;
    font-weight: 900;
    color: #f0f6fc;
    letter-spacing: -0.5px;
}

/* Botones */
.expedicion-acciones {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-exp-primario {
    padding: 0.85rem 2rem;
    border-radius: 999px;
    border: none;
    background: #3fb950;
    color: #0d1117;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.btn-exp-primario:hover {
    background: #46c957;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(63, 185, 80, 0.35);
}

.btn-exp-secundario {
    padding: 0.85rem 2rem;
    border-radius: 999px;
    border: 1px solid #30363d;
    background: none;
    color: #8b949e;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-family: 'Inter', sans-serif;
}

.btn-exp-secundario:hover {
    border-color: #8b949e;
    color: #f0f6fc;
}

/* Compartir en expedición — sutil, debajo */
.btn-exp-compartir {
    padding: 0.38rem 1.1rem;
    border-radius: 999px;
    border: 1px solid #21262d;
    background: none;
    color: #4b5563;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.18s, color 0.18s;
    letter-spacing: 0.02em;
}
.btn-exp-compartir:hover { border-color: #30363d; color: #8b949e; }

@media (max-width: 480px) {
    .expedicion-tarjeta {
        padding: 1.2rem;
    }

    .exp-stat-izq {
        min-width: 120px;
    }

    .expedicion-acciones {
        flex-direction: column;
        align-items: center;
    }

    .btn-exp-primario,
    .btn-exp-secundario {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   PANTALLA DE INICIO — DESAFÍO
   ========================================================================== */

/* Lock body scroll while overlay is visible */
body.inicio-activo {
    overflow: hidden;
}

.inicio-overlay {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: clamp(0.75rem, 3vh, 2rem) 0;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.inicio-overlay.activo {
    opacity: 1;
    visibility: visible;
}

.inicio-bg {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 16, 0.95);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.inicio-contenido {
    position: relative;
    z-index: 1;
    width: min(520px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.6rem, 1.8vh, 1.4rem);
    padding: 0 1rem;
    margin: 0 auto;
}

/* ---- Historial de partidas ---- */
.inicio-historial {
    width: 100%;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 16px;
    padding: clamp(0.6rem, 1.4vh, 1rem) 1.4rem;
}

.historial-titulo {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 0.7rem;
}

.historial-lista {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.historial-fila {
    display: grid;
    grid-template-columns: 3.8rem 3rem 56px 5rem 1fr;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.historial-fila:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.historial-fecha {
    color: #8b949e;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.historial-prec {
    font-weight: 700;
    font-size: 0.82rem;
    min-width: 2.8rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.historial-barra-wrap {
    width: 52px;
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    overflow: hidden;
}

.historial-barra-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease 0.1s;
}

.historial-tiempo {
    color: #8b949e;
    font-size: 0.78rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    text-align: left;
    padding-left: 0.9rem;
}

.historial-rango {
    font-size: 0.72rem;
    color: #8b949e;
    white-space: nowrap;
    text-align: left;
    line-height: 1.3;
}

.inicio-header {
    text-align: center;
}

.inicio-icono {
    font-size: clamp(1.8rem, 3.5vh, 2.8rem);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.inicio-titulo {
    font-family: 'Inter', sans-serif;
    font-size: clamp(1.6rem, 4vh, 2.4rem);
    font-weight: 900;
    color: #f0f6fc;
    margin: 0 0 0.2rem 0;
    letter-spacing: -0.5px;
}

.inicio-subtitulo {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
}

/* Reglas */
.inicio-reglas {
    width: 100%;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 16px;
    padding: clamp(0.7rem, 1.6vh, 1.2rem) 1.4rem;
    display: flex;
    flex-direction: column;
    gap: clamp(0.4rem, 1vh, 0.75rem);
}

.inicio-regla {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: clamp(0.78rem, 1.5vh, 0.88rem);
    color: #c9d1d9;
    line-height: 1.4;
}

.regla-icono {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

/* Regla 4: colores en líneas separadas, alineados a la izquierda */
.inicio-regla-colores {
    padding-left: 0;
}
.inicio-regla-colores > span {
    display: block;
    line-height: 1.9;
    text-align: left;
}

/* Récord */
.inicio-record {
    width: 100%;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 16px;
    padding: clamp(0.6rem, 1.4vh, 1rem) 1.4rem;
}

.inicio-record.sin-record {
    opacity: 0.45;
}

.record-titulo {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 0.7rem;
}

.record-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    text-align: center;
}

.record-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.record-valor {
    font-size: 1.4rem;
    font-weight: 900;
    color: #f0f6fc;
    letter-spacing: -0.5px;
}

.record-label {
    font-size: 0.7rem;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.record-nuevo {
    display: inline-block;
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    letter-spacing: 0.05em;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* ========== SAVE BANNER (pantalla inicio desafío) ========== */
.save-banner {
    width: 100%;
    background: rgba(229, 57, 53, 0.07);
    border: 1px solid rgba(229, 57, 53, 0.22);
    border-radius: 14px;
    padding: 0.9rem 1.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    text-align: center;
}

.save-banner-titulo {
    font-size: 0.82rem;
    font-weight: 700;
    color: #c62828;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.save-banner-info {
    font-size: 0.83rem;
    color: #555;
    line-height: 1.4;
}

.save-banner-acciones {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 0.2rem;
}

.btn-save-continuar {
    padding: 0.5rem 1.3rem;
    border-radius: 999px;
    border: none;
    background: #e53935;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.16s, transform 0.16s;
}
.btn-save-continuar:hover { background: #c62828; transform: translateY(-1px); }

.btn-save-nueva {
    padding: 0.5rem 1.3rem;
    border-radius: 999px;
    border: 1px solid rgba(229, 57, 53, 0.3);
    background: transparent;
    color: #c62828;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.16s, border-color 0.16s;
}
.btn-save-nueva:hover { background: rgba(229,57,53,0.08); border-color: #e53935; }

/* Dark mode save banner */
body.modo-oscuro .save-banner {
    background: rgba(229, 57, 53, 0.1);
    border-color: rgba(229, 57, 53, 0.3);
}
body.modo-oscuro .save-banner-titulo { color: #e57373; }
body.modo-oscuro .save-banner-info   { color: #8b949e; }
body.modo-oscuro .btn-save-nueva     { color: #e57373; border-color: rgba(229,57,53,0.4); }
body.modo-oscuro .btn-save-nueva:hover { background: rgba(229,57,53,0.15); border-color: #e57373; }

/* ========== CONFIRM: SALIR DEL DESAFÍO ========== */
.confirm-salir-box {
    max-width: 360px;
    text-align: center;
}

.confirm-salir-desc {
    color: #555;
    font-size: 0.9rem;
    margin: 0.3rem 0 1.1rem;
    line-height: 1.5;
}

.confirm-salir-acciones {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    align-items: stretch;
}

.btn-confirm-seguir {
    padding: 0.75rem 1.4rem;
    border-radius: 999px;
    border: none;
    background: #e53935;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.16s, transform 0.16s;
}
.btn-confirm-seguir:hover { background: #c62828; transform: translateY(-1px); }

.btn-confirm-guardar {
    padding: 0.75rem 1.4rem;
    border-radius: 999px;
    border: 1px solid #ccc;
    background: #f3f3f3;
    color: #333;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.16s, border-color 0.16s;
}
.btn-confirm-guardar:hover { background: #e8e8e8; border-color: #999; }

.btn-confirm-descartar {
    padding: 0.55rem 1.4rem;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: #aaa;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.16s;
}
.btn-confirm-descartar:hover { color: #555; }

/* Dark mode confirm */
body.modo-oscuro .confirm-salir-desc     { color: #8b949e; }
body.modo-oscuro .btn-confirm-guardar    { background: #21262d; border-color: #30363d; color: #c9d1d9; }
body.modo-oscuro .btn-confirm-guardar:hover { background: #2d333b; border-color: #58a6ff; }
body.modo-oscuro .btn-confirm-descartar  { color: #6b7280; }
body.modo-oscuro .btn-confirm-descartar:hover { color: #c9d1d9; }

/* Botón */
.btn-comenzar {
    padding: 1rem 2.8rem;
    border-radius: 999px;
    border: none;
    background: #e53935;
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    letter-spacing: -0.2px;
}

.btn-comenzar:hover {
    background: #f44336;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(229, 57, 53, 0.4);
}

.inicio-volver {
    font-size: 0.88rem;
    color: #9ca3af;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.18s, border-color 0.18s, background 0.18s;
    padding: 0.4rem 1.1rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.13);
}

.inicio-volver:hover {
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.06);
}

@media (max-width: 420px) {
    .record-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .record-valor {
        font-size: 1.1rem;
    }
}

/* ==========================================================================
   RESPONSIVE MOBILE — 375px
   ========================================================================== */
@media (max-width: 430px) {

    /* Topbar móvil: ocultar versión desktop, mostrar selects */
    #topbar h4,
    #app-title,
    #topbar-right-desktop,
    .filtro-modo-btn {
        display: none;
    }

    #topbar-right-mobile {
        display: flex !important;
    }

    #topbar {
        gap: 8px;
        padding: 0 10px;
    }

    .topbar-left {
        gap: 6px;
    }

    .pill.filtro-modo-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    /* Modal: que no sobresalga en pantallas pequeñas */
    .modal-box {
        padding: 1.4rem 1.2rem;
        max-width: 95vw;
    }

    /* Lang selector: botones más compactos */
    .lang-btn {
        padding: 0.2rem 0.45rem;
        font-size: 0.78rem;
    }

    /* Pantalla inicio desafío: en móvil pequeño siempre flex-start + scroll */
    .inicio-overlay {
        align-items: flex-start;
        padding: 0.75rem 0;
    }

    .inicio-contenido {
        padding: 0.8rem 0.8rem;
    }

    /* Pantalla expedición: scroll en móvil */
    .expedicion-overlay {
        align-items: flex-start;
        overflow-y: auto;
        padding: 1rem 0;
    }

    .expedicion-contenido {
        padding: 1.2rem 0.8rem;
    }

    .expedicion-titulo {
        font-size: 1.4rem;
    }

    .exp-stat-izq {
        font-size: 0.8rem;
        min-width: 100px;
    }

    /* Botones flotantes: ligeramente más pequeños */
    .btn-volver {
        font-size: 0.85rem;
        padding: 8px 14px;
        bottom: 14px;
        left: 14px;
    }

    .btn-ajustes {
        width: 40px;
        height: 40px;
        bottom: 14px;
        right: 14px;
        font-size: 1.1rem;
    }

    /* Modal resultados práctica */
    .resultados-box {
        max-width: 95vw;
        padding: 1.2rem 1rem;
    }
}

/* ==========================================================================
   MÓVIL — RESPONSIVE GENERAL (≤ 768px)
   Topbar pegada al borde, mapa ocupa pantalla completa, pregunta adaptable
   ========================================================================== */
@media (max-width: 768px) {

    /* Reducir tamaño de topbar y pegarla al borde superior */
    :root { --topbar-h: 52px; }

    #topbar {
        top: 0;
        left: 0;
        right: 0;
        border-radius: 0 0 14px 14px;
        padding: 0 10px;
        gap: 6px;
    }

    /* Ajustar contenido de topbar para pantallas pequeñas */
    .pill {
        padding: 6px 9px;
        font-size: 0.85rem;
    }

    /* Juego (desafio + practica): ocupa exactamente la pantalla visible, sin scroll de página */
    #juego {
        padding-top: calc(var(--topbar-h) + 4px);
        height: 100dvh;
        overflow: hidden;
        box-sizing: border-box;
    }

    /* Explorar: lo mismo — evita el espacio muerto de 100vh en iOS */
    #explorar {
        padding-top: calc(var(--topbar-h) + 4px);
        height: 100dvh;
        overflow: hidden;
        box-sizing: border-box;
    }

    /* Mapa: ocupa todo el ancho, sin borde redondeado lateral */
    #mapa-container {
        width: 100%;
        margin: 0;
        border-radius: 0;
        height: calc(100dvh - var(--topbar-h) - 4px);
    }

    /* Pregunta: salto de línea permitido, fuente adaptable */
    #pregunta {
        top: calc(var(--topbar-h) + 8px);
        left: 8px;
        right: 8px;
        transform: none;
        max-width: 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        text-align: center;
        font-size: clamp(0.88rem, 4vw, 1.15rem);
        padding: 7px 14px;
        border-radius: 14px;
        line-height: 1.35;
    }

    /* Notificación: más abajo para no tapar la pregunta */
    #notificacion-resultado {
        top: calc(var(--topbar-h) + 66px);
        font-size: 0.88rem;
        padding: 8px 14px;
    }

    /* Topbar buttons: tamaño compacto */
    .topbar-btn-volver {
        height: 30px;
        padding: 0 8px;
        font-size: 0.78rem;
    }

    .topbar-btn-ajustes {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    /* Home: centrado vertical → scroll si hay overflow */
    body.home-page {
        justify-content: flex-start;
        padding-top: 2.5rem;
    }

    /* Botones fijos: compensar barra Chrome iOS (--vv-bottom) + safe-area física */
    .btn-empezar-wrap {
        bottom: calc(var(--vv-bottom, 0px) + 16px + env(safe-area-inset-bottom, 0px));
    }

    .btn-ajustes {
        bottom: calc(var(--vv-bottom, 0px) + 16px + env(safe-area-inset-bottom, 0px));
        right: 16px;
    }

    .btn-volver {
        bottom: calc(var(--vv-bottom, 0px) + 16px + env(safe-area-inset-bottom, 0px));
    }

    /* Botón de pista: también puede quedar detrás de la barra */
    #btn-pista {
        bottom: calc(var(--vv-bottom, 0px) + 16px + env(safe-area-inset-bottom, 0px));
    }
}

/* ═══════════════════════════════════════════════════════════════════
   PAGE LOADER — overlay pantalla completa mientras cargan SVG + datos
   ═══════════════════════════════════════════════════════════════════ */
#page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #0d1117;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.6rem;
    opacity: 1;
    transition: opacity 0.35s ease;
    font-family: 'Inter', sans-serif;
}
#page-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}
.loader-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #e53935;
    letter-spacing: -0.02em;
}
.loader-dot {
    font-size: 1.25rem;
    font-weight: 800;
    color: rgba(229,57,53,0.35);
    letter-spacing: -0.02em;
}
.loader-ring {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(229, 57, 53, 0.18);
    border-top-color: #e53935;
    border-radius: 50%;
    animation: loaderSpin 0.72s linear infinite;
}
@keyframes loaderSpin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════
   TOPBAR NAV BUTTONS (volver + ajustes integrados en topbar)
   Usados en explorar, practica, desafio
   ═══════════════════════════════════════════════════════════════════ */
.topbar-btn-volver {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 13px;
    height: 34px;
    border-radius: 999px;
    border: 1.5px solid rgba(0,0,0,0.18);
    background: rgba(255,255,255,0.92);
    color: #1a1a1a;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
    transition: background 0.16s, transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}
@media (hover: hover) {
    .topbar-btn-volver:hover {
        background: #fff;
        border-color: rgba(0,0,0,0.28);
        box-shadow: 0 2px 8px rgba(0,0,0,0.16);
        transform: translateX(-2px);
    }
}

.topbar-btn-ajustes {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.12);
    background: rgba(255,255,255,0.6);
    color: #333;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.16s, transform 0.3s;
}
@media (hover: hover) {
    .topbar-btn-ajustes:hover {
        background: rgba(255,255,255,0.92);
        transform: rotate(90deg);
    }
}

body.modo-oscuro .topbar-btn-volver,
body.modo-oscuro .topbar-btn-ajustes {
    background: rgba(33,38,45,0.92);
    border-color: #484f58;
    color: #e6edf3;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
@media (hover: hover) {
    body.modo-oscuro .topbar-btn-volver:hover,
    body.modo-oscuro .topbar-btn-ajustes:hover {
        background: rgba(48,54,61,0.98);
        border-color: #8b949e;
        box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    }
    body.modo-oscuro .topbar-btn-volver:hover { color: #f0f6fc; }
}

/* ═══════════════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   ═══════════════════════════════════════════════════════════════════ */
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pageExit {
    from { opacity: 1; }
    to   { opacity: 0; }
}

body.page-entering {
    animation: pageEnter 0.28s ease forwards;
}

body.page-exiting {
    animation: pageExit 0.18s ease forwards;
    pointer-events: none !important;
}