:root {
    --grid-size: 10;
    --cell-size-desktop: 45px;
    --cell-size-tablet: 32px;
    --cell-size-mobile: 28px;
    --gap: 2px;
    --padding: 10px;
}

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

body {
    font-family: 'Open Sans', sans-serif;
    background-color: #E9E7DA;
    color: #444444;
    min-height: 100vh;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    font-family: 'Merriweather', serif;
    font-size: 2rem;
    color: #161616;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    color: #636B46;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.game-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 1000px;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.nivel-info {
    background: #CDA34F;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
}

.puntuacion {
    background: #636B46;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
}

.timer {
    background: #636B46;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-family: monospace;
    transition: background-color 0.3s ease;
}

.game-board {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* GRID - Desktop */
.grid-container {
    display: grid;
    grid-template-columns: repeat(var(--grid-size), var(--cell-size-desktop));
    grid-template-rows: repeat(var(--grid-size), var(--cell-size-desktop));
    gap: var(--gap);
    background: #f8f8f8;
    padding: var(--padding);
    border-radius: 10px;
    margin: 0 auto;
}

.grid-cell {
    background: white;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    border-radius: 2px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.grid-cell:hover {
    background: #f0f0f0;
    border-color: #CDA34F;
}

.grid-cell.selected {
    background: #CDA34F;
    color: white;
    border-color: #636B46;
}

.grid-cell.found {
    background: #636B46;
    color: white;
    border-color: #636B46;
}

.words-panel {
    background: #f8f8f8;
    padding: 20px;
    border-radius: 10px;
    min-width: 200px;
    flex-shrink: 0;
}

.words-title {
    font-family: 'Merriweather', serif;
    color: #161616;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.word-list {
    list-style: none;
}

.word-item {
    padding: 8px 12px;
    margin: 5px 0;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #CDA34F;
    transition: all 0.3s ease;
}

.word-item.found {
    background: #636B46 !important;
    color: white !important;
    text-decoration: line-through !important;
    text-decoration-color: white !important;
    text-decoration-thickness: 2px !important;
    opacity: 0.8;
}

.progress {
    margin-top: 20px;
    text-align: center;
    font-weight: 600;
    color: #636B46;
}

/* Game Controls */
.game-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-control {
    background: #CDA34F;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.btn-control:hover {
    background: #b8932a;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-content h3 {
    font-family: 'Merriweather', serif;
    color: #161616;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.modal-content p {
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Form Styles */
.modal-content form {
    text-align: left;
}

.modal-content label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #444444;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.modal-content input:focus {
    outline: none;
    border-color: #CDA34F;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    flex: 1;
    background: #636B46;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.btn-primary:hover {
    background: #525a39;
}

.btn-secondary {
    flex: 1;
    background: #CDA34F;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.btn-secondary:hover {
    background: #b8932a;
}

.btn-close {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 15px;
}

.btn-close:hover {
    background: #c0392b;
}

/* Level Selector */
.level-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-level {
    background: #f8f8f8;
    border: 2px solid #CDA34F;
    color: #444444;
    padding: 15px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-level:hover {
    background: #CDA34F;
    color: white;
}

.btn-level.active {
    background: #636B46;
    color: white;
    border-color: #636B46;
}

/* CTA Banner */
.cta-banner {
    background: linear-gradient(135deg, #636B46, #CDA34F);
    margin: 30px auto;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 1000px;
    overflow: hidden;
}

.cta-content {
    display: flex;
    align-items: center;
    padding: 25px;
    gap: 20px;
}

.cta-logo {
    height: 60px;
    width: auto;
    flex-shrink: 0;
}

.cta-text {
    flex: 1;
    color: white;
}

.cta-text h3 {
    font-family: 'Merriweather', serif;
    font-size: 1.3rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.cta-text p {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

.cta-button {
    background: white;
    color: #636B46;
    padding: 12px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.cta-button:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .cta-content {
        flex-direction: column;
        text-align: center;
        padding: 20px;
        gap: 15px;
    }
    
    .cta-logo {
        height: 50px;
    }
    
    .cta-text h3 {
        font-size: 1.2rem;
    }
    
    .cta-text p {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .cta-content {
        padding: 15px;
    }
    
    .cta-logo {
        height: 40px;
    }
    
    .cta-text h3 {
        font-size: 1.1rem;
    }
    
    .cta-button {
        padding: 10px 20px;
    }
}
.ranking-modal {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.ranking-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #CDA34F;
}

.tab-btn.active {
    color: #636B46;
    border-bottom-color: #636B46;
}

.ranking-content {
    min-height: 200px;
}

.ranking-list {
    list-style: none;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin: 8px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #CDA34F;
}

.ranking-item.top-3 {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-left-color: #636B46;
}

.ranking-position {
    font-size: 1.2rem;
    font-weight: bold;
    color: #636B46;
    margin-right: 15px;
    min-width: 30px;
}

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.ranking-details {
    font-size: 0.9rem;
    color: #666;
}

.ranking-score {
    font-size: 1.3rem;
    font-weight: bold;
    color: #CDA34F;
}

.loading {
    text-align: center;
    padding: 50px;
    color: #666;
}

.no-data {
    text-align: center;
    padding: 50px;
    color: #999;
}

.ranking-stats {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.ranking-stats .stat {
    display: inline-block;
    margin: 0 15px;
    text-align: center;
}

.ranking-stats .stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #636B46;
}

.ranking-stats .stat-label {
    font-size: 0.9rem;
    color: #666;
}

.footer {
    margin-top: 30px;
    text-align: center;
    color: #636B46;
    font-size: 0.9rem;
}

/* Tablet */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .game-container {
        padding: 15px;
    }
    
    .game-board {
        flex-direction: column;
        gap: 15px;
    }
    
    .grid-container {
        grid-template-columns: repeat(var(--grid-size), var(--cell-size-tablet));
        grid-template-rows: repeat(var(--grid-size), var(--cell-size-tablet));
    }
    
    .grid-cell {
        font-size: 12px;
    }
    
    .words-panel {
        min-width: auto;
        width: 100%;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .form-buttons {
        flex-direction: column;
    }
    
    .level-buttons {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .game-container {
        padding: 10px;
    }
    
    .grid-container {
        grid-template-columns: repeat(var(--grid-size), var(--cell-size-mobile));
        grid-template-rows: repeat(var(--grid-size), var(--cell-size-mobile));
        padding: 8px;
    }
    
    .grid-cell {
        font-size: 11px;
    }
    
    .game-header {
        justify-content: center;
    }
    
    .words-panel {
        padding: 15px;
    }
    
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
    
    .game-controls {
        gap: 8px;
    }
    
    .btn-control {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Modal de transición entre sopas */
.transition-modal {
    max-width: 400px;
    text-align: center;
    animation: modalBounceIn 0.5s ease-out;
}

.transition-emoji {
    font-size: 3rem;
    margin-bottom: 15px;
    animation: bounceEmoji 1s infinite alternate;
}

.transition-modal h3 {
    color: #636B46;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.transition-modal p {
    color: #666;
    margin-bottom: 20px;
}

.transition-stats {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    color: #666;
    font-weight: 500;
}

.stat-value {
    color: #636B46;
    font-weight: bold;
}

@keyframes modalBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px);
    }
    50% {
        opacity: 1;
        transform: scale(1.1) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes bounceEmoji {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

/* Ligazón discreta para rematar */
.finish-link-container {
    text-align: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.finish-link {
    font-size: 0.85rem;
    color: #999;
    text-decoration: none;
    transition: color 0.3s ease;
    font-style: italic;
}

.finish-link:hover {
    color: #636B46;
    text-decoration: underline;
}