/* ============================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
   ============================================ */
:root {
    /* Colores principales - Temática Pokémon */
    --pokemon-red: #FF1C1C;
    --pokemon-yellow: #FFDE00;
    --pokemon-blue: #3B4CCA;
    --pokemon-light-blue: #5BA3E0;

    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-fire: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-water: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-grass: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);

    /* Colores de fondo */
    --bg-dark: #1a1a2e;
    --bg-card: rgba(255, 255, 255, 0.1);
    --bg-card-hover: rgba(255, 255, 255, 0.15);

    /* Colores de texto */
    --text-primary: #ffffff;
    --text-secondary: #b8b8d1;
    --text-dark: #2d3748;

    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(255, 222, 0, 0.5);

    /* Espaciado */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Bordes */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --border-radius-full: 50%;

    /* Transiciones */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ============================================
   RESET Y ESTILOS BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--gradient-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(255, 222, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(59, 76, 202, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   PANTALLAS
   ============================================ */
.screen {
    display: none;
    min-height: 100vh;
    padding: var(--spacing-lg);
    position: relative;
    z-index: 1;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   PANTALLA DE INICIO
   ============================================ */
.start-container {
    text-align: center;
    max-width: 600px;
    animation: slideUp 0.8s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

.title-icon {
    display: inline-block;
    animation: bounce 1s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
}

/* Pokéball animada */
.pokeball-animation {
    margin: var(--spacing-xl) 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pokeball-image {
    width: 160px;
    height: auto;
    display: block;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.pokeball-image:hover {
    transform: scale(1.05) translateY(-5px);
}

/* ============================================
   BOTONES
   ============================================ */
.btn-primary,
.btn-secondary,
.btn-check,
.btn-back {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: 'Poppins', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: var(--gradient-fire);
    color: white;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-check {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-check:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.btn-back {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(10px);
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.9rem;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.25);
}

.progress-info {
    margin-top: var(--spacing-lg);
    font-size: 1rem;
    color: var(--text-secondary);
}

#saved-progress {
    color: var(--pokemon-yellow);
    font-weight: 700;
}

/* ============================================
   SELECCIÓN DE NIVELES
   ============================================ */
.level-select-container {
    max-width: 1200px;
    width: 100%;
}

.screen-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: var(--spacing-xl);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.level-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.level-card:hover::before {
    opacity: 1;
}

.level-card:hover {
    transform: translateY(-8px);
    border-color: var(--pokemon-yellow);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-card.locked:hover {
    transform: none;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

.level-card.completed {
    border-color: var(--pokemon-yellow);
}

.level-number {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.level-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin: var(--spacing-xs) 0;
}

.level-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.level-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 1.2rem;
}

.level-status.completed {
    color: var(--pokemon-yellow);
}

/* ============================================
   PANTALLA DE JUEGO
   ============================================ */
.game-container {
    max-width: 1400px;
    width: 100%;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.level-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-number {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.level-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.stars-display {
    display: flex;
    gap: var(--spacing-xs);
    font-size: 1.5rem;
}

.game-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--spacing-lg);
}

/* Panel izquierdo */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.pokemon-display {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    border: 2px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pokemon-character {
    max-width: 200px;
    height: auto;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

.instructions-card,
.hint-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.instructions-card h3,
.hint-card h3 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
    color: var(--pokemon-yellow);
}

.instructions-card p,
.hint-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Panel derecho */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.html-viewer,
.selector-input-section,
.visual-preview {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.html-viewer h3,
.selector-input-section h3,
.visual-preview h3 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
    color: var(--pokemon-yellow);
}

.html-viewer pre {
    background: rgba(0, 0, 0, 0.3);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.html-viewer code {
    color: #a8dadc;
}

.input-group {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

#selector-input {
    flex: 1;
    padding: var(--spacing-sm);
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-sm);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-family: 'Courier New', monospace;
}

#selector-input:focus {
    outline: none;
    border-color: var(--pokemon-yellow);
    box-shadow: 0 0 10px rgba(255, 222, 0, 0.3);
}

.feedback {
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    text-align: center;
    transition: all var(--transition-normal);
}

.feedback.success {
    background: rgba(56, 239, 125, 0.2);
    border: 2px solid #38ef7d;
    color: #38ef7d;
}

.feedback.error {
    background: rgba(245, 87, 108, 0.2);
    border: 2px solid #f5576c;
    color: #f5576c;
}

.preview-box {
    background: white;
    padding: var(--spacing-md);
    border-radius: var(--border-radius-sm);
    min-height: 200px;
    color: var(--text-dark);
}

/* Estilos para elementos seleccionados en la vista previa */
.preview-box .selected {
    background: rgba(255, 222, 0, 0.3);
    border: 2px solid var(--pokemon-yellow);
    padding: 4px;
    border-radius: 4px;
}

/* ============================================
   MODALES
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    max-width: 500px;
    animation: scaleIn 0.4s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
}

.modal-stars {
    font-size: 3rem;
    margin: var(--spacing-md) 0;
}

.star-big {
    display: inline-block;
    animation: starPop 0.5s ease forwards;
}

.star-big:nth-child(1) {
    animation-delay: 0.1s;
}

.star-big:nth-child(2) {
    animation-delay: 0.2s;
}

.star-big:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes starPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.flag-container {
    margin: var(--spacing-lg) 0;
    padding: var(--spacing-md);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-md);
    border: 2px solid var(--pokemon-yellow);
}

.flag-container h3 {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-sm);
    color: var(--pokemon-yellow);
}

.flag-display {
    background: rgba(0, 0, 0, 0.5);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-sm);
    margin: var(--spacing-sm) 0;
}

.flag-display code {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: #38ef7d;
    font-weight: 700;
    letter-spacing: 1px;
    word-break: break-all;
}

.flag-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
}

/* ============================================
   SISTEMA DE VIDAS
   ============================================ */
.lives-display {
    display: flex;
    gap: var(--spacing-sm);
    font-size: 2rem;
    align-items: center;
}

.heart {
    display: inline-block;
    transition: all 0.3s ease;
    animation: heartFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
}

.heart:nth-child(1) {
    animation-delay: 0s;
}

.heart:nth-child(2) {
    animation-delay: 0.5s;
}

.heart:nth-child(3) {
    animation-delay: 1s;
}

@keyframes heartFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.heart.lost {
    opacity: 0.2;
    filter: grayscale(100%) drop-shadow(0 0 5px rgba(0, 0, 0, 0.3));
    transform: scale(0.7);
    animation: none;
}

.gameover-icon {
    font-size: 5rem;
    margin: var(--spacing-lg) 0;
}

.gameover-message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: var(--spacing-md) 0;
}

/* ============================================
   MODAL DE TROFEO
   ============================================ */
.trophy {
    font-size: 4em;
}