* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0f0f1e 0%, #1a1a3f 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 30px;
    padding: 50px;
    max-width: 1000px;
    width: 100%;
    border: 1px solid rgba(88, 166, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(31, 38, 135, 0.37),
        inset 0 1px 0 rgba(200, 87, 217, 0.1);
    backdrop-filter: blur(4px);
    animation: containerSlideIn 1s ease-out;
}

@keyframes containerSlideIn {
    from {
        opacity: 0;
        transform: perspective(1000px) rotateX(10deg);
    }
    to {
        opacity: 1;
        transform: perspective(1000px) rotateX(0deg);
    }
}

h1 {
    text-align: center;
    background: linear-gradient(135deg, #58a6ff 0%, #c857d9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 40px;
    font-size: 3em;
    font-weight: 800;
    letter-spacing: -2px;
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(88, 166, 255, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(200, 87, 217, 0.5));
    }
}

.game-content {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 50px;
    align-items: start;
}

.grid-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Grid de palabras */
#wordSearchContainer {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 8px;
    background: rgba(20, 20, 40, 0.6);
    padding: 20px;
    border-radius: 20px;
    aspect-ratio: 1;
    border: 2px solid rgba(88, 166, 255, 0.2);
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(88, 166, 255, 0.1);
    animation: gridSlideIn 1s ease-out 0.2s both;
}

@keyframes gridSlideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#wordSearchContainer div {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a1a4f 100%);
    border: 2px solid rgba(88, 166, 255, 0.3);
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    color: #58a6ff;
    position: relative;
    overflow: hidden;
}

#wordSearchContainer div::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(88, 166, 255, 0.4), transparent);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
    z-index: 0;
}

#wordSearchContainer div span {
    position: relative;
    z-index: 1;
}

#wordSearchContainer div:hover {
    border-color: #58a6ff;
    background: linear-gradient(135deg, #2d5a8f 0%, #3d2a6f 100%);
    box-shadow: 
        0 0 20px rgba(88, 166, 255, 0.5),
        inset 0 0 15px rgba(88, 166, 255, 0.1);
    transform: translateY(-3px);
}

#wordSearchContainer div:hover::before {
    width: 100px;
    height: 100px;
}

/* Clase selected - cuando se selecciona una celda */
#wordSearchContainer div.selected {
    background: linear-gradient(135deg, #58a6ff 0%, #79c0ff 100%);
    color: #0f0f1e;
    border-color: #79c0ff;
    font-weight: 800;
    box-shadow: 
        0 0 25px rgba(88, 166, 255, 0.8),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
    animation: cellSelect 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cellSelect {
    0% { 
        transform: scale(0.85) rotate(-5deg);
    }
    50% { 
        transform: scale(1.15) rotate(2deg);
    }
    100% { 
        transform: scale(1) rotate(0deg);
    }
}

/* Clase found - cuando se encuentra una palabra */
#wordSearchContainer div.found {
    background: linear-gradient(135deg, #3fb950 0%, #2ea043 100%);
    color: #fff;
    border-color: #3fb950;
    box-shadow: 
        0 0 30px rgba(63, 185, 80, 0.8),
        inset 0 0 20px rgba(255, 255, 255, 0.15);
    animation: cellFound 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cellFound {
    0% {
        transform: scale(1) rotateZ(0deg);
        box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.8);
    }
    50% {
        transform: scale(1.2) rotateZ(5deg);
        box-shadow: 0 0 0 15px rgba(63, 185, 80, 0);
    }
    100% {
        transform: scale(1) rotateZ(0deg);
        box-shadow: 0 0 30px rgba(63, 185, 80, 0.8);
    }
}

#wordSearchContainer div.found:hover {
    transform: none;
}

/* Sección de palabras a encontrar */
.words-section {
    display: flex;
    flex-direction: column;
    animation: sidebarSlideIn 1s ease-out 0.3s both;
}

@keyframes sidebarSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.words-section h2 {
    background: linear-gradient(135deg, #58a6ff 0%, #c857d9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: 700;
}

#wordsList {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
}

#wordsList::-webkit-scrollbar {
    width: 6px;
}

#wordsList::-webkit-scrollbar-track {
    background: rgba(88, 166, 255, 0.1);
    border-radius: 10px;
}

#wordsList::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #58a6ff, #c857d9);
    border-radius: 10px;
}

#wordsList li {
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.6), rgba(42, 26, 79, 0.6));
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: 12px;
    transition: all 0.3s ease;
    color: #ccc;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

#wordsList li::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(88, 166, 255, 0.2), transparent);
    transition: left 0.5s ease;
    z-index: 0;
}

#wordsList li::after {
    content: '✓';
    position: absolute;
    right: 0;
    opacity: 0;
    transition: all 0.3s ease;
}

#wordsList li:hover {
    background: linear-gradient(135deg, rgba(45, 90, 143, 0.8), rgba(60, 42, 111, 0.8));
    border-color: #58a6ff;
    box-shadow: 0 0 15px rgba(88, 166, 255, 0.3);
    transform: translateX(5px);
}

#wordsList li:hover::before {
    left: 100%;
}

#wordsList li[data-word].found {
    background: linear-gradient(135deg, rgba(63, 185, 80, 0.2), rgba(46, 160, 67, 0.2));
    border-color: #3fb950;
    color: #3fb950;
    text-decoration: line-through;
    font-weight: 700;
}

#wordsList li[data-word].found::after {
    opacity: 1;
    color: #3fb950;
    font-weight: bold;
}

/* Botón */
.button-section {
    margin-top: 40px;
    display: flex;
    gap: 15px;
}

#generateNew {
    background: linear-gradient(135deg, #58a6ff 0%, #79c0ff 100%);
    color: #0f0f1e;
    border: none;
    padding: 10px 25px;
    font-size: 0.95em;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 15px rgba(88, 166, 255, 0.4);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
    width: fit-content;
    align-self: center;
}

#generateNew::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;
}

#generateNew:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(88, 166, 255, 0.6),
        inset 0 0 15px rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, #79c0ff 0%, #c857d9 100%);
}

#generateNew:hover::before {
    width: 250px;
    height: 250px;
}

#generateNew:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        padding: 30px;
    }

    h1 {
        font-size: 2.2em;
        margin-bottom: 30px;
    }

    .game-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .words-section {
        order: 2;
    }

    #wordSearchContainer {
        order: 1;
    }

    .grid-section {
        order: 1;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }

    #wordSearchContainer {
        gap: 4px;
        padding: 15px;
    }

    #wordSearchContainer div {
        font-size: 0.95em;
        border-radius: 8px;
    }

    #wordsList li {
        padding: 10px 12px;
        font-size: 0.9em;
    }

    #generateNew {
        padding: 8px 20px;
        font-size: 0.9em;
    }
}
