@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

:root {
    --primary: #83E4D1;
    --primary-dark: #5ac2af;
    --accent: #ff9f1c;
    --accent-hover: #e38a15;
    --text-dark: #2d3436;
    --text-light: #636e72;
    --bg-main: #f4f6f9;
    --card-bg: #ffffff;
    --surface: #ffffff;
    --bg: #f4f6f9;
    --text: #2d3436;
    --muted: #636e72;
    --border: #dfe6e9;
    --teal: #83E4D1;
    --teal-dark: #5ac2af;
    --orange: #ff9f1c;
    --radius-lg: 20px;
    --radius-md: 15px;
    --radius-sm: 12px;
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, .05);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, .08);
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, .12);
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Salvavidas global: ninguna imagen puede desbordar su contenedor,
   aunque le falte una regla específica (ej. atributos HTML mal
   escritos como height="18px"). */
img {
    max-width: 100%;
    height: auto;
}

html {
    height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: clip;

    margin: 0;
    font-family: 'Nunito', Arial, sans-serif;
    color: var(--text-dark);
    background-color: var(--bg-main);
    line-height: 1.6;
    letter-spacing: .5px;
}

main {
    flex: 1;
}


main {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.hero-section {
    text-align: center;
    background: #fff;
    padding: 50px 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .06);
    border-top: 8px solid var(--accent);
}

.hero-title {
    display: inline-block;
    border-bottom: 2px dashed rgba(255, 140, 0, 0.5);
    font-size: clamp(26px, 5vw, 40px);
    margin-bottom: 10px;
    color: #111;
}

.hero-subtitle {
    font-size: 20px;
    color: var(--text-light);
    max-width: 750px;
    margin: auto;
}

/* =============================================
   GAMEPLAY ISLAS & PILL TITLE BANNERS (Image 2)
   ============================================= */
.islas-showcase {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 10px auto 25px auto;
}

.gameplay-pill-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 22px;
}

.gameplay-pill-container.minijuegos-pill-wrap {
    margin-top: 36px;
    margin-bottom: 28px;
}

.gameplay-pill-title {
    background: linear-gradient(180deg, #ffa726 0%, #fb8c00 100%);
    border: 3px solid #e65100;
    border-radius: 16px;
    padding: 10px 48px;
    box-shadow: 0 6px 18px rgba(251, 140, 0, 0.45);
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.gameplay-pill-title:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(251, 140, 0, 0.6);
}

.gameplay-pill-title h2 {
    color: #ffffff !important;
    font-size: clamp(16px, 3.5vw, 25px);
    font-weight: 900;
    letter-spacing: 1.2px;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.islas-frame {
    width: 100%;
    max-width: 960px;
    /* Reserva el espacio del video ANTES de que cargue, para que el
       resto de la página no salte ni deje huecos negros mientras
       el .mp4 todavía está descargando. Ajustá 16/9 si el video
       real tiene otra proporción (por ej. 4/3 o 21/9). */
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    border: 4px solid #ff9f1c;
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(255, 159, 28, 0.5);
    overflow: hidden;
    background: #09121d;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.islas-frame:hover {
    transform: scale(1.01);
    box-shadow: 0 0 40px rgba(255, 159, 28, 0.8);
}

.video-preview-islas {
    width: 100%;
    height: 100%;
    /* "contain" = se ve el mapa completo, nunca lo recorta.
       Si sobra espacio a los costados, se rellena con el
       fondo oscuro de .islas-frame en vez de quedar cortado. */
    object-fit: contain;
    display: block;
    border-radius: 16px;
    opacity: 0;
    transition: opacity .45s ease;
}

.video-preview-islas.is-loaded {
    opacity: 1;
}

body.dark-mode .islas-frame {
    background: #050b14 !important;
    border-color: #ff9f1c !important;
    box-shadow: 0 0 35px rgba(255, 159, 28, 0.45) !important;
}

.juegos {
    border-radius: 15px;
    color: white;
    border: 4px orange solid;
    padding: 10px 16px;
    background-color: #ff9f1c;
    max-width: 100%;
    width: 100%;
    height: auto;
    text-align: center;
    font-size: clamp(16px, 4vw, 26px);
    box-sizing: border-box;
    margin: 15px auto 20px auto;
}

.ir-wrapper {
    margin: 6px 0 16px;
}

.ir {
    color: var(--teal-dark, #00b4d8);
    font-weight: 700;
    font-size: clamp(14px, 3.5vw, 17px);
    text-decoration: underline;
    display: inline-block;
    transition: color .2s;
}

.ir:hover {
    color: #ff9f1c;
}

.section-desc {
    color: var(--muted);
    margin-bottom: 24px;
    font-size: clamp(15px, 3.5vw, 18px);
    line-height: 1.6;
}

.video-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.video-section h2 {
    text-align: center;
    margin-bottom: 30px;
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
    justify-content: center;
    justify-items: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.videos-grid video,
.video-preview {
    width: 100%;
    max-width: 600px;
    /* Igual que el video principal: reserva el alto antes de
       cargar, para que la grilla no "salte" ni deje bloques
       negros mientras los 6 videos van bajando. */
    aspect-ratio: 16 / 9;
    height: auto;
    display: block;
    background: #09121d;
    object-fit: cover;
    border: 4px solid orange;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(255, 140, 0, .5);
    opacity: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity .45s ease;
    box-sizing: border-box;
}

.videos-grid video.is-loaded,
.video-preview.is-loaded {
    opacity: 1;
}

.videos-grid video:hover,
.video-preview:hover {
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(255, 140, 0, .8);
}

/* Support page styles duplicates removed */

iframe:not([id*="chatbase"]):not([src*="chatbase"]):not([class*="chatbase"]) {
    height: 500px;
    width: 100%;
    max-width: 500px;
    box-sizing: border-box;
}

.gameplay1 {
    text-align: left;
}

.gameplay2 {
    text-align: right;
}


/* ===========================
   SECTION HEADER
=========================== */
.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    margin-top: 8px;
    color: var(--text);
    font-size: 30px;
}

/* ===========================
   MECHANIC CARDS
=========================== */
.mechanic-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mechanic-icon {
    font-size: 36px;
    width: 64px;
    height: 64px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.mechanic-card h3 {
    font-size: 28px;
}

.mechanic-card p {
    font-size: 20px;
    color: var(--muted);
    line-height: 1.6;
}

/* ===========================
   LEVELS
=========================== */
.levels-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.level-item {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    border: 1.5px solid var(--border);
    transition: transform .2s, border-color .2s;
}

.level-item:hover {
    transform: translateX(6px);
    border-color: var(--teal);
}

.level-num {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    color: #fff;
    font-weight: 900;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.level-info {
    display: flex;
    flex-direction: column;
}

.level-info strong {
    font-size: 17px;
    color: var(--text);
}

.level-info span {
    font-size: 14px;
    color: var(--muted);
}

/* ===========================
   TIPS
=========================== */
.tips-section .section-header {
    margin-bottom: 20px;
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 768px) {
    .gp-hero {
        padding: 28px 20px;
    }

    .gp-hero h1 {
        font-size: 34px;
    }
}


.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
    .gp-hero {
        padding: 28px 20px;
    }

    .gp-hero h1 {
        font-size: 34px;
    }
}

/* Centralized hidden animations used */

/* ===========================
   MUSIC PLAYER
=========================== */
.music-player-container {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.music-player-card,
.music-playlist-card {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

body.dark-mode .music-player-card,
body.dark-mode .music-playlist-card {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.05);
}

.music-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.music-icon-animated {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: white;
    font-size: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseMusic 2s infinite ease-in-out;
}

@keyframes pulseMusic {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 159, 28, 0.4);
    }

    70% {
        transform: scale(1.08);
        box-shadow: 0 0 0 10px rgba(255, 159, 28, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 159, 28, 0);
    }
}

.track-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.track-status {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1.5px;
    color: var(--accent);
}

#music-current-song-title {
    font-size: 18px;
    color: var(--text-dark);
}

.player-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.player-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;

    background: var(--bg-main);
    color: var(--text-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.player-btn svg {
    width: 18px;
    height: 18px;
}

.player-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.player-btn.play-main {
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: white;
}

.player-btn.play-main:hover {
    background: var(--accent-hover);
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.time-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-light);
    min-width: 35px;
}

.progress-slider,
.volume-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.progress-slider::-webkit-slider-thumb,
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.progress-slider::-webkit-slider-thumb:hover,
.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 180px;
    margin: 0 auto;
}

.volume-btn {
    background: transparent;

    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.volume-btn svg {
    width: 20px;
    height: 20px;
}

.music-playlist-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 18px;
    color: var(--text-dark);
}

.playlist-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.playlist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

body.dark-mode .playlist-item {
    background: rgba(255, 255, 255, 0.02);
}

.playlist-item:hover {
    background: rgba(131, 228, 209, 0.15);
    border-color: rgba(131, 228, 209, 0.3);
}

.playlist-item.active {
    background: rgba(255, 159, 28, 0.1);
    border-color: rgba(255, 159, 28, 0.3);
}

.playlist-item .track-index {
    font-weight: 700;
    margin-right: 12px;
    color: var(--text-light);
}

.playlist-item.active .track-index,
.playlist-item.active .track-title {
    color: var(--accent);
    font-weight: 700;
}

.playlist-item .playing-indicator {
    opacity: 0;
    transition: opacity 0.2s ease;
    color: var(--accent);
}

.playlist-item.active .playing-indicator {
    opacity: 1;
}

@media (max-width: 900px) {
    .music-player-container {
        grid-template-columns: 1fr;
    }
}

/* Video Modal Visor */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-modal-overlay.open {
    display: flex;
    opacity: 1;
}

.video-modal-container {
    position: relative;
    max-width: 90%;
    max-height: 85%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.video-modal-container video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background: #000;
    border: 4px solid orange;
}

.video-modal-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: none;

    color: white;
    font-size: 40px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease;
}

.video-modal-close:hover {
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .video-modal-close {
        top: -40px;
        right: 5px;
    }
}

.hero-title:hover {
    cursor: pointer;
    color: var(--accent);
    transform: scale(1.02);
    transition: all 0.2s ease;
}

/* =============================================
   RESPONSIVE — TABLET
   ============================================= */
@media (max-width: 768px) {
    /* --- Contenedores principales --- */
    main, .page-content {
        padding: 20px 14px 70px;
        gap: 28px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .hero-section {
        padding: 30px 16px;
        box-sizing: border-box;
    }

    /* --- Islas showcase y frame --- */
    .islas-showcase {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 10px auto 20px;
    }

    .islas-frame {
        width: 100%;
        max-width: 100%;
        border-width: 3px;
        border-radius: 14px;
    }

    .video-preview-islas {
        border-radius: 11px;
    }

    /* --- Pill titles responsive --- */
    .gameplay-pill-title {
        padding: 8px 20px;
        border-radius: 12px;
        max-width: 100%;
    }

    .gameplay-pill-title h2 {
        font-size: clamp(13px, 3.5vw, 20px);
        letter-spacing: 0.5px;
    }

    .gameplay-pill-container.minijuegos-pill-wrap {
        margin-top: 24px;
        margin-bottom: 18px;
    }

    /* --- Grids a 1 columna --- */
    .videos-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .videos-grid video,
    .video-preview {
        max-width: 100%;
        width: 100%;
    }

    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* --- Cards y texto --- */
    .card,
    .mechanic-card {
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .mechanic-card h3 {
        font-size: 20px;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .mechanic-card p {
        font-size: 16px;
        overflow-wrap: break-word;
        word-break: break-word;
        white-space: normal;
    }

    .mechanic-icon {
        font-size: 28px;
        width: 52px;
        height: 52px;
    }

    .section-header h2 {
        font-size: 24px;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .level-info strong {
        font-size: 15px;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* --- Texto general: forzar wrap --- */
    h1, h2, h3, h4, p, strong, span, li, a, label {
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        white-space: normal !important;
    }

    .juegos {
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        hyphens: auto;
    }

    .section-desc,
    .hero-subtitle,
    .custom-list li {
        overflow-wrap: break-word;
        word-break: break-word;
        white-space: normal;
    }

    /* --- Niveles --- */
    .level-item {
        width: 100%;
        box-sizing: border-box;
    }

    /* --- Música --- */
    .music-player-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .music-player-card,
    .music-playlist-card {
        padding: 18px;
        box-sizing: border-box;
    }
}

/* =============================================
   RESPONSIVE — MÓVIL
   ============================================= */
@media (max-width: 480px) {
    main, .page-content {
        padding: 16px 10px 80px;
        gap: 22px;
    }

    .hero-section {
        padding: 22px 12px;
    }

    .hero-title {
        font-size: 22px;
    }

    .hero-subtitle {
        font-size: 15px;
    }

    /* --- Islas más compactas --- */
    .islas-frame {
        border-width: 2px;
        border-radius: 10px;
    }

    .video-preview-islas {
        border-radius: 8px;
    }

    .gameplay-pill-title {
        padding: 6px 14px;
        border-width: 2px;
        border-radius: 10px;
    }

    .gameplay-pill-title h2 {
        font-size: clamp(12px, 3.2vw, 17px);
        letter-spacing: 0.3px;
    }

    .gameplay-pill-container.minijuegos-pill-wrap {
        margin-top: 18px;
        margin-bottom: 14px;
    }

    .juegos {
        font-size: 17px;
        padding: 8px 12px;
    }

    .videos-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .card {
        padding: 18px 14px;
    }

    .mechanic-card h3 {
        font-size: 17px;
    }

    .mechanic-card p {
        font-size: 14px;
    }

    .control-buttons {
        gap: 14px;
    }

    .player-btn {
        width: 38px;
        height: 38px;
    }

    .player-btn.play-main {
        width: 48px;
        height: 48px;
    }

    #music-current-song-title {
        font-size: 14px;
        word-break: break-word;
    }

    .music-playlist-card h3 {
        font-size: 16px;
    }

    .level-item {
        padding: 10px 12px;
        gap: 12px;
    }

    .level-num {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .level-info strong {
        font-size: 14px;
    }

    .progress-container {
        gap: 8px;
    }

    .time-label {
        font-size: 11px;
        min-width: 28px;
    }

    .volume-container {
        width: 100%;
        max-width: 160px;
        margin: 0 auto;
    }
}

/* =============================================
   CORRECCIONES DE PRODUCCIÓN — LEXICA
   ============================================= */

/* overflow-x:hidden en html/body puede convertir al ancestro en
   contenedor de scroll y romper position:sticky en algunos navegadores.
   clip mantiene el recorte horizontal sin crear ese contenedor. */
html,
body {
    overflow-x: clip;
}

/* El video principal de las islas queda siempre limitado al marco. */
.islas-frame {
    width: 100%;
    max-width: 960px;
    max-height: 540px;
}

.islas-frame .video-preview-islas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    display: block;
}

/* =========================================================
   LEXICA FIX - VIDEO PRINCIPAL DE ISLAS
   El tamaño lo controla el marco, no la altura intrínseca del MP4.
========================================================= */
.islas-frame {
    width: 100% !important;
    max-width: 960px !important;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
    max-height: 540px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

.islas-frame .video-preview-islas {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    aspect-ratio: 16 / 9 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    object-fit: contain !important;
}

/* Los videos de la grilla también quedan limitados. */
.videos-grid video,
.videos-grid .video-preview {
    width: 100% !important;
    max-width: 600px !important;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
}
