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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.top-right-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 15px;
    z-index: 1000;
}

.top-left-logo {
    position: absolute;
    top: 15px;
    left: 20px;
    z-index: 1000;
}

.game-logo {
    width: clamp(55px, 12vw, 150px);
    height: auto;
    transition: transform 0.3s ease;
    border-radius: 12px;
    align-content: center;
}

.game-logo:hover {
    transform: scale(1.05);
}

.language-selector {
    display: flex;
    gap: 10px;
}

.flag {
    font-size: 28px;
    cursor: pointer;
    opacity: 1;
    transition: transform 0.2s;
}

.flag:hover {
    transform: scale(1.1);
}

.auth-button {
    display: flex;
    gap: 10px;
}

.auth-button button {
    padding: 8px 16px;
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.auth-button button:hover {
    background: #667eea;
    color: white;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 40px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.close {
    position: absolute;
    right: 20px;
    top: 10px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* Spread the word modal animation */
@keyframes pulse-animation {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.spread-the-word-msg {
    animation: pulse-animation 2s infinite ease-in-out;
    background: #f0f4ff;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    margin-bottom: 20px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
    text-align: center;
}

.invite-text-box {
    width: 100%;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    font-size: 14px;
    line-height: 1.5;
    color: #444;
    margin-bottom: 15px;
    white-space: pre-wrap;
    text-align: left;
    user-select: all;
}

.copy-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.copy-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.copy-btn:active {
    transform: translateY(0);
}

.form-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.form-section input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.forgot-password-link {
    margin: 5px 0;
    font-size: 13px;
}

.forgot-password-link a {
    color: #667eea;
    text-decoration: none;
}

.forgot-password-link a:hover {
    text-decoration: underline;
}

.form-section button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.form-section button:hover {
    background: #5568d3;
}

.form-section button.delete-user-btn:hover {
    background: #c82333;
}

.form-section p {
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.form-section a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

#main-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    padding: 40px;
    border-radius: 10px;
    margin-top: 20px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#game-title {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
}

#menu-screen h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.menu-options label {
    font-weight: bold;
    color: #333;
}

.menu-options select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.game-mode-container {
    display: flex;
    gap: 20px;
    align-items: center;
    width: 100%;
}

.game-mode-select {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-mode-select select {
    width: 100%;
}

.round-trip-checkbox {
    display: flex;
    align-items: center;
    padding-top: 20px;
}

.round-trip-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.round-trip-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.menu-options button {
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
}

.menu-options button:hover {
    background: #5568d3;
}

.game-info {
    text-align: center;
    margin-bottom: 5px;
}

.score-panel {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-bottom: 5px;
}

.score {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 20px;
    border-radius: 8px;
    transition: all 0.3s;
}

.score.active-turn {
    background: rgba(102, 126, 234, 0.15);
    transform: scale(1.05);
}

.player-name {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 5px;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.3s;
}

.player1-color {
    color: #dc3545;
    font-weight: bold;
}

.player2-color {
    color: #007bff;
    font-weight: bold;
}

.player-name.player1-color {
    color: #dc3545;
}

.player-name.player2-color {
    color: #007bff;
}

.score.active-turn .player-name.player1-color {
    background: rgba(220, 53, 69, 0.2);
}

.score.active-turn .player-name.player2-color {
    background: rgba(0, 123, 255, 0.2);
}

.score span:last-child {
    font-size: 24px;
    color: #667eea;
}

#message {
    color: #000501;
    font-weight: bold;
    min-height: 20px;
}

#continue-btn {
    margin: 15px auto 0;
    padding: 10px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#continue-btn:hover {
    background: #5568d3;
    transform: scale(1.05);
}

#game-end-continue-btn {
    margin: 15px auto 0;
    padding: 10px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
}

#game-end-continue-btn:hover {
    background: #5568d3;
    transform: scale(1.05);
}

#letter-popup {
    position: fixed;
    display: none;
    background: transparent;
    border: none;
    padding: 5px;
    z-index: 1000;
    gap: 5px;
}

#letter-popup.show {
    display: flex;
}

.letter-popup-btn {
    padding: 12px 20px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 50px;
    opacity: 0.6;
}

.letter-popup-btn:hover {
    background: #5568d3;
    transform: scale(1.1);
    opacity: 0.8;
}

#board-container {
    display: grid;
    gap: 3px;
    width: 100%;
    max-width: 95vw;
    margin: 0 auto 20px;
    background: #ddd;
    padding: 3px;
    border-radius: 5px;
}

@media (min-width: 768px) {
    #board-container {
        max-width: min(800px, 80vh);
    }
}

#board-container.size-5 {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    padding: 5px;
}

#board-container.size-6 {
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    padding: 4px;
}

#board-container.size-7 {
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 4px;
}

#board-container.size-8 {
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
}

#board-container.size-9 {
    grid-template-columns: repeat(9, 1fr);
    gap: 3px;
}

#board-container.size-10 {
    grid-template-columns: repeat(10, 1fr);
    gap: 3px;
}

#board-container.size-11 {
    grid-template-columns: repeat(11, 1fr);
    gap: 2px;
}

#board-container.size-12 {
    grid-template-columns: repeat(12, 1fr);
    gap: 2px;
}


.board-cell {
    aspect-ratio: 1;
    background: white;
    border: 2px solid #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    line-height: 1;
    position: relative;
}

.board-cell span {
    position: relative;
    z-index: 20;
}

.size-5 .board-cell {
    font-size: 8vw;
    border-width: 2px;
}

.size-6 .board-cell {
    font-size: 7vw;
    border-width: 2px;
}

.size-7 .board-cell {
    font-size: 6.5vw;
    border-width: 2px;
}

.size-8 .board-cell {
    font-size: 6vw;
    border-width: 1px;
}

.size-9 .board-cell {
    font-size: 5vw;
    border-width: 1px;
}

.size-10 .board-cell {
    font-size: 4.5vw;
    border-width: 1px;
}

.size-11 .board-cell {
    font-size: 4vw;
    border-width: 1px;
}

.size-12 .board-cell {
    font-size: 3.5vw;
    border-width: 1px;
}

@media (min-width: 768px) {
    .size-5 .board-cell {
        font-size: 60px;
        border-width: 3px;
    }

    .size-6 .board-cell {
        font-size: 52px;
        border-width: 3px;
    }

    .size-7 .board-cell {
        font-size: 48px;
        border-width: 2px;
    }

    .size-8 .board-cell {
        font-size: 42px;
        border-width: 2px;
    }

    .size-9 .board-cell {
        font-size: 38px;
        border-width: 2px;
    }

    .size-10 .board-cell {
        font-size: 34px;
        border-width: 2px;
    }

    .size-11 .board-cell {
        font-size: 30px;
        border-width: 2px;
    }

    .size-12 .board-cell {
        font-size: 28px;
        border-width: 2px;
    }
}

.board-cell:hover:not(.filled) {
    background: #f0f0f0;
}

.board-cell.filled {
    cursor: default;
    background: #e8e8e8;
}

/* --- MODIFICACIÓN: CLASES PARA RESALTAR --- */
.board-cell.last-move {
    border-color: #ff0000 !important;
    /* Rojo intenso */
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.6) inset;
    /* Resplandor interior */
}

.board-cell.popup-target {
    background-color: #999 !important;
    /* Fondo gris oscuro al seleccionar */
    border-color: #333 !important;
    transform: scale(0.95);
    /* Efecto de "presionado" */
}

/* --- FIN MODIFICACIÓN --- */

.debug-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #666;
    font-size: 0.8em;
    background: #f0f0f0;
    border: 1px solid #ddd;
}

.board-cell.player1-color {
    color: #dc3545;
}

.board-cell.player2-color {
    color: #007bff;
}

.board-cell.manual-selected {
    background: #fff3cd !important;
    border-color: #ffc107 !important;
}

.word-line {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.game-controls button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.game-controls button:hover {
    background: #5568d3;
}

.stats-container,
.history-container {
    margin-top: 30px;
}

#dashboard-screen h2 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
}

#dashboard-screen>button {
    display: block;
    margin: 0 auto 20px;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#stats-display {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 5px;
}

#stats-display p {
    margin: 10px 0;
    color: #333;
}

#history-display table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#history-display th {
    background: #667eea;
    color: white;
    padding: 10px;
    text-align: left;
}

#history-display td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

#history-display tr:hover {
    background: #f5f5f5;
}

.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: none;
    animation: slideDown 0.3s ease;
    max-width: 80%;
    text-align: center;
}

.notification.show {
    display: block;
}

.notification.error {
    background: #dc3545;
}

.notification.success {
    background: #28a745;
}

.notification.info {
    background: #17a2b8;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.confirm-dialog.show {
    display: flex;
}

.confirm-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.confirm-content p {
    margin: 0 0 20px;
    font-size: 16px;
    color: #333;
    text-align: center;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.confirm-yes {
    background: #667eea;
    color: white;
}

.confirm-yes:hover {
    background: #5568d3;
}

.confirm-no {
    background: #e0e0e0;
    color: #333;
}

.confirm-no:hover {
    background: #d0d0d0;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .top-right-controls {
        position: absolute;
        top: 20px;
        right: 15px;
        flex-direction: column-reverse;
        align-items: flex-end;
        gap: 10px;
    }

    #main-container {
        padding: 20px;
        margin-top: 20px;
    }

    .flag {
        font-size: 24px;
    }

    .top-left-logo {
        top: 20px;
        left: 15px;
    }
}

/* --- ESTILOS ESPECÍFICOS PARA LA VENTANA DE AYUDA --- */

/* Hacemos la ventana más ancha y permitimos scroll si es muy alta */
.help-modal-content {
    max-width: 700px;
    /* Mucho más ancha que el login (era 400px) */
    width: 95%;
    /* Ocupa casi todo el ancho en móviles */
    max-height: 90vh;
    /* Nunca superará el 90% de la altura de la pantalla */
    overflow-y: auto;
    /* Activa barra de scroll si el texto es muy largo */
    margin: 20px auto;
    /* Margen más pequeño arriba/abajo para aprovechar espacio */
    padding: 30px;
    /* Un poco más de aire interior */
}

/* Mejoramos la tipografía para que no se vea "apretujada" */
.help-section {
    margin-bottom: 25px;
    /* Separación entre secciones */
}

.help-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
    /* Línea separadora elegante */
    font-size: 1.2rem;
}

.help-section p {
    line-height: 1.6;
    /* Aumenta el espacio entre líneas de texto */
    margin-bottom: 15px;
    color: #444;
    font-size: 16px;
    /* Texto base un poco más grande y legible */
}

.help-section ul,
.help-section ol {
    padding-left: 25px;
    margin-bottom: 20px;
}

.help-section li {
    line-height: 1.6;
    /* Espaciado también en las listas */
    margin-bottom: 8px;
    /* Separación entre puntos de la lista */
    color: #444;
}

/* Botón de cerrar inferior más visible */
.close-help-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

.close-help-btn:hover {
    background: #5568d3;
}

/* Ajuste de la barra de scroll para que sea más bonita (opcional, funciona en Chrome/Edge/Safari) */
.help-modal-content::-webkit-scrollbar {
    width: 8px;
}

.help-modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.help-modal-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.help-modal-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.help-modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

/* --- FIN ESTILOS AYUDA --- */

/* --- ESTILOS PARA CONTROLES DE REPRODUCCIÓN --- */

#playback-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    border: 2px solid rgba(102, 126, 234, 0.3);
}

.playback-btn {
    width: 55px;
    height: 55px;
    font-size: 26px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.playback-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.5);
}

.playback-btn:active {
    transform: scale(0.95);
}

.playback-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.2);
}

.playback-btn:disabled:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.2);
}

#move-counter {
    font-size: 16px;
    font-weight: bold;
    color: #667eea;
    margin-left: 10px;
    padding: 8px 16px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Indicador visual cuando está navegando en el historial */
#board-container.navigating {
    border: 3px solid #ff9800;
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.5);
}

/* --- FIN ESTILOS REPRODUCCIÓN --- */

/* --- MAIN MENU STYLES --- */
.main-menu-container {
    position: relative;
}

.menu-btn {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #667eea;
    transition: transform 0.2s;
    padding: 0 10px;
    line-height: 1;
}

.menu-btn:hover {
    transform: scale(1.1);
}

.main-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    overflow: hidden;
    z-index: 1001;
    margin-top: 10px;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 12px 20px;
    text-align: left;
    background: none;
    border: none;
    font-size: 16px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: #f5f5f5;
    color: #667eea;
}

/* --- LEGAL & COOKIES MODAL STYLES --- */
.legal-content {
    margin-top: 20px;
    line-height: 1.6;
    color: #444;
}

.legal-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #667eea;
}

.legal-content p {
    margin-bottom: 15px;
}

.legal-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.legal-content a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    #playback-controls {
        gap: 5px;
        padding: 10px;
        margin: 10px 0;
    }

    .playback-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    #move-counter {
        font-size: 14px;
        align-items: flex-end;
        justify-content: flex-end;
        padding: 6px 10px;
        margin-left: 5px;
        white-space: nowrap;
    }
}

/* --- LOBBY Y MULTIJUGADOR REMOTO --- */

#lobby-container {
    max-width: 500px;
    margin: 20px auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: block;
}

#lobby-container h2 {
    color: #667eea;
    margin-bottom: 5px;
    text-align: center;
}

#lobby-container p {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
}

.user-list {
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 20px;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: white;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.user-item:hover {
    transform: translateY(-2px);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 12px;
    background: #ccc;
}

.status-dot.online {
    background: #28a745;
}

.status-dot.busy {
    background: #ffc107;
}

.status-dot.away {
    background: #dc3545;
}

.user-item .username {
    flex: 1;
    font-weight: 600;
    color: #333;
}

.btn-small {
    padding: 5px 12px;
    font-size: 13px;
    margin: 0;
}

.empty-msg {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

/* Modales personalizados para invitaciones */
#invitation-modal {
    z-index: 11000;
}

#invitation-modal .modal-content {
    text-align: center;
}

#invitation-modal h3 {
    color: #667eea;
    margin-bottom: 15px;
}

#invitation-modal .modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.btn-success {
    background: #28a745;
    color: white;
    border: none;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger:hover {
    background: #c82333;
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    z-index: 11001;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.cookie-banner p {
    margin-bottom: 15px;
    text-align: center;
    font-size: 14px;
}

.cookie-buttons {
    display: flex;
    gap: 10px;
}

.cookie-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

#accept-cookies-btn {
    background: #28a745;
    color: white;
}

#accept-cookies-btn:hover {
    background: #218838;
}

#reject-cookies-btn {
    background: #dc3545;
    color: white;
}

#reject-cookies-btn:hover {
    background: #c82333;
}

@media (min-width: 768px) {
    .cookie-banner {
        flex-direction: row;
        padding: 15px 40px;
    }

    .cookie-banner p {
        margin-bottom: 0;
        text-align: left;
        margin-right: 20px;
    }
}


/* =============================================
   SIDEBAR NAVIGATION SYSTEM — v2.1
   Layout: centrado junto al main-container
   Estilo: blanco, esquinas redondeadas
   ============================================= */

/* Body no necesita cambios — tiene padding: 20px ya */

/* --- APP SHELL: flex row centrado --- */
.app-shell {
    display: flex;
    flex-direction: row;
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
    align-items: flex-start;
}

/* --- SIDEBAR --- */
#sidebar-nav {
    width: 220px;
    min-width: 220px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

/* Contenedor del logo para centrado y borde inferior */
.sidebar-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px 16px 16px;
    border-bottom: 1px solid #f0f0f0;
}

/* Logo: columna (icono arriba, texto debajo) */
.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    width: 100%;
}

.sidebar-logo .game-logo {
    width: 100%;
    max-width: 160px; /* Tamaño equilibrado para el sidebar */
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sidebar-logo-title {
    font-size: 13px;
    font-weight: 700;
    color: #667eea;
    line-height: 1.3;
    text-align: center;
    letter-spacing: -0.2px;
}

.sidebar-section {
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-section:last-child {
    border-bottom: none;
    padding-bottom: 12px;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 16px 4px;
    display: block;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    min-height: 40px;
    line-height: 1.3;
}

.sidebar-item:hover {
    background: #f5f5ff;
    color: #667eea;
}

.sidebar-item .icon {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    /* Forzar rendering siempre visible */
    display: inline-block;
    font-style: normal;
}

.sidebar-user-info {
    padding: 10px 16px;
    color: #667eea;
    font-size: 13px;
    font-weight: 700;
    background: #f5f5ff;
    margin: 8px 10px 0;
    border-radius: 8px;
    word-break: break-word;
    border-left: 3px solid #667eea;
}

.sidebar-flags {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    align-items: center;
}

.sidebar-flags .flag {
    font-size: 22px;
    cursor: pointer;
    opacity: 0.85;
    transition: transform 0.2s, opacity 0.2s;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-flags .flag:hover {
    transform: scale(1.15);
    opacity: 1;
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Mobile header: oculto en desktop */
.mobile-header {
    display: none;
}

/* main-container dentro de main-content: sin márgenes extra */
.main-content #main-container {
    max-width: none;
    width: 100%;
    margin: 0;
    margin-top: 0;
}

/* game-title dentro del contenido */
.main-content #game-title {
    text-align: center;
    color: #667eea;
    margin-top: 10px;
    margin-bottom: 25px;
    font-size: clamp(1.3rem, 2.5vw, 1.9rem);
}

/* Ocultar elementos absolutos del sistema viejo */
.top-left-logo,
.top-right-controls {
    display: none !important;
}

/* SIDEBAR OVERLAY — solo móvil */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 300;
}

#sidebar-overlay.active {
    display: block;
}

/* =============================================
   MOBILE ≤ 900px — Sidebar becomes off-canvas drawer
   ============================================= */
@media (max-width: 900px) {

    body {
        padding: 0;
    }

    .app-shell {
        flex-direction: column;
        max-width: 100%;
        margin: 0;
        gap: 0;
    }

    /* Sidebar oculto fuera de pantalla por defecto */
    #sidebar-nav {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        max-height: 100vh;
        width: 280px;
        min-width: 280px;
        border-radius: 0;
        transform: translateX(-100%);
        z-index: 400;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
    }

    #sidebar-nav.open {
        transform: translateX(0);
    }

    /* Mobile header visible */
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        background: rgba(255, 255, 255, 0.18);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        position: sticky;
        top: 0;
        z-index: 200;
    }

    .mobile-header .game-logo {
        width: 42px;
        height: 42px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .mobile-header-title {
        flex: 1;
        font-size: 13px;
        font-weight: 700;
        color: white;
        line-height: 1.2;
    }

    .mobile-menu-btn {
        background: rgba(255, 255, 255, 0.22);
        border: none;
        color: white;
        font-size: 20px;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
        flex-shrink: 0;
    }

    .mobile-menu-btn:hover {
        background: rgba(255, 255, 255, 0.35);
    }

    .main-content {
        flex: 1;
    }

    .main-content #main-container {
        margin: 12px;
        width: calc(100% - 24px);
        padding: 18px 14px;
    }

    /* Touch targets ≥ 48px en móvil */
    .sidebar-item {
        min-height: 48px;
        padding: 12px 18px;
        font-size: 15px;
    }

    .menu-options select,
    .menu-options button {
        font-size: 16px;
    }
}

/* =============================================
   SIDEBAR NAVIGATION SYSTEM — v2.1
   Layout: centrado junto al main-container
   Estilo: blanco, esquinas redondeadas
   ============================================= */

/* --- APP SHELL: flex row centrado --- */
.app-shell {
    display: flex;
    flex-direction: row;
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
    align-items: flex-start;
}

/* --- SIDEBAR --- */
#sidebar-nav {
    width: 220px;
    min-width: 220px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px 16px 14px;
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    width: 100%;
}

/* Logo size defined globally and refined at the end of file */

.sidebar-logo-title {
    font-size: 13px;
    font-weight: 700;
    color: #667eea;
    line-height: 1.3;
    text-align: center;
}

.sidebar-section {
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-section:last-child {
    border-bottom: none;
    padding-bottom: 12px;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 16px 4px;
    display: block;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    min-height: 40px;
    line-height: 1.3;
    box-sizing: border-box;
}

.sidebar-item:hover {
    background: #f5f5ff;
    color: #667eea;
}

/* Iconos: siempre visibles, no afectados por i18n */
.sidebar-item .si-icon {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    display: inline-block;
}

.sidebar-user-info {
    padding: 10px 16px;
    color: #667eea;
    font-size: 13px;
    font-weight: 700;
    background: #f5f5ff;
    margin: 8px 10px 0;
    border-radius: 8px;
    word-break: break-word;
    border-left: 3px solid #667eea;
}

.sidebar-flags {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    align-items: center;
}

.sidebar-flags .flag {
    font-size: 22px;
    cursor: pointer;
    opacity: 0.85;
    transition: transform 0.2s, opacity 0.2s;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-flags .flag:hover {
    transform: scale(1.15);
    opacity: 1;
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Mobile header oculto en desktop */
.mobile-header {
    display: none;
}

/* main-container dentro de main-content: sin margenes extra */
.main-content #main-container {
    max-width: none;
    width: 100%;
    margin: 0;
    margin-top: 0;
}

.main-content #game-title {
    text-align: center;
    color: #667eea;
    margin-top: 10px;
    margin-bottom: 25px;
    font-size: clamp(1.3rem, 2.5vw, 1.9rem);
}

/* Ocultar elementos del sistema viejo */
.top-left-logo,
.top-right-controls {
    display: none !important;
}

/* SIDEBAR OVERLAY - solo movil */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 300;
}

#sidebar-overlay.active {
    display: block;
}

/* =============================================
   MOBILE <=900px
   ============================================= */
@media (max-width: 900px) {

    body {
        padding: 0;
    }

    .app-shell {
        flex-direction: column;
        max-width: 100%;
        margin: 0;
        gap: 0;
    }

    #sidebar-nav {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        max-height: 100vh;
        width: 280px;
        min-width: 280px;
        border-radius: 0;
        transform: translateX(-100%);
        z-index: 400;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
    }

    #sidebar-nav.open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        background: rgba(255, 255, 255, 0.18);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        position: sticky;
        top: 0;
        z-index: 200;
    }

    .mobile-header .game-logo {
        width: 42px;
        height: 42px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .mobile-header-title {
        flex: 1;
        font-size: 13px;
        font-weight: 700;
        color: white;
        line-height: 1.2;
    }

    .mobile-menu-btn {
        background: rgba(255, 255, 255, 0.22);
        border: none;
        color: white;
        font-size: 20px;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
        flex-shrink: 0;
    }

    .mobile-menu-btn:hover {
        background: rgba(255, 255, 255, 0.35);
    }

    .main-content #main-container {
        margin: 12px;
        width: calc(100% - 24px);
        padding: 18px 14px;
    }

    .sidebar-item {
        min-height: 48px;
        padding: 12px 18px;
        font-size: 15px;
    }

    .menu-options select,
    .menu-options button {
        font-size: 16px;
    }
}

/* Override: logo dentro del sidebar siempre 80x80 */
#sidebar-nav .sidebar-logo .game-logo,
#sidebar-nav .game-logo {
    width: 100%;
    max-width: 210px; /* Ocupa casi todo el ancho del sidebar */
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    margin-bottom: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

#sidebar-nav .sidebar-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px 16px 14px;
    border-bottom: 1px solid #f0f0f0;
}

#sidebar-nav .sidebar-logo {
    align-items: center;
    gap: 8px;
    text-decoration: none;
    width: 100%;
}

#sidebar-nav .sidebar-logo-title {
    font-size: 13px;
    font-weight: 700;
    color: #667eea;
    line-height: 1.3;
    text-align: center;
}