/* Reset y estilos base */
* {
    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;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

h1 {
    text-align: center;
    color: white;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Pantallas */
.screen {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* Menú principal */
.menu {
    text-align: center;
}

.name-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}

.name-section input {
    margin: 0;
}

.edit-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    min-width: auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-btn:hover {
    background: #5a6268;
}

input[type="text"], textarea {
    width: 100%;
    max-width: 300px;
    padding: 12px;
    margin: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
}

input[type="text"]:disabled {
    background-color: #f8f9fa;
    border-color: #28a745;
    color: #333;
    cursor: default;
}

button {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    margin: 8px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

button:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

button.primary {
    background: #28a745;
    font-size: 18px;
    padding: 15px 30px;
}

button.primary:hover {
    background: #218838;
}

button.share-btn {
    background: #25d366;
    color: white;
    font-size: 14px;
    padding: 8px 16px;
    margin-top: 10px;
}

button.share-btn:hover {
    background: #128c7e;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Información de sala */
.room-info {
    text-align: center;
    margin-bottom: 2rem;
}

.room-info h2 {
    color: #667eea;
    font-size: 1.8rem;
}

#room-id {
    background: #f8f9fa;
    padding: 8px 16px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

/* Lista de jugadores */
.players-section {
    margin: 2rem 0;
}

.players-section h3 {
    color: #495057;
    margin-bottom: 1rem;
}

#players-list {
    list-style: none;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    min-height: 60px;
}

#players-list li {
    padding: 8px 12px;
    margin: 4px 0;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#players-list li.host {
    border-left-color: #ffc107;
}

#players-list li.host::after {
    content: "👑 HOST";
    font-size: 12px;
    color: #ffc107;
    font-weight: bold;
}

/* Indicador de quién empieza la ronda */
.round-starter {
    margin-top: 8px;
    font-weight: 700;
    color: #17a2b8;
}


/* Controles del host */
#host-controls {
    border-top: 2px solid #eee;
    padding-top: 2rem;
    margin-top: 2rem;
}

.words-section {
    margin-bottom: 2rem;
}

.words-section h3 {
    color: #495057;
    margin-bottom: 1rem;
}

.words-section h4 {
    color: #6c757d;
    margin: 1.5rem 0 0.5rem 0;
    font-size: 1rem;
}

/* Selector de listas */
.lists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 1rem;
}

.list-card {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    position: relative;
}

.list-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.list-card.selected {
    border-color: #28a745;
    background: #d4edda;
}

.list-card .list-name {
    font-weight: bold;
    color: #495057;
    margin-bottom: 4px;
}

.list-card .list-count {
    font-size: 12px;
    color: #6c757d;
}

.list-card .delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: none;
}

.list-card:hover .delete-btn {
    display: block;
}

/* Lista activa */
.active-list {
    background: #e7f3ff;
    border: 2px solid #007bff;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    margin-bottom: 1rem;
}

#active-list-name {
    font-weight: bold;
    color: #007bff;
    margin-right: 8px;
}

#active-list-count {
    color: #6c757d;
    font-size: 14px;
}

/* Botones secundarios */
button.secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

button.secondary:hover {
    background: #5a6268;
}

/* Sección de palabras manuales */
.manual-words-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.manual-words-section small {
    display: block;
    color: #6c757d;
    font-style: italic;
    margin-top: 5px;
}

#custom-words {
    width: 100%;
    height: 100px;
    resize: vertical;
    font-family: inherit;
}

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

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 1.5rem 2rem 1rem 2rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #495057;
}

.close-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 1.5rem 2rem;
}

.modal-footer {
    padding: 1rem 2rem 1.5rem 2rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #495057;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    color: #6c757d;
    font-size: 12px;
    margin-top: 5px;
}

/* Pantalla de juego */
.round-info {
    text-align: center;
    margin-bottom: 2rem;
}

.round-info h2 {
    color: #667eea;
    font-size: 2rem;
}

/* Información de turno */
.turn-info {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 10px;
}

.turn-info h3 {
    color: #495057;
    margin-bottom: 0;
}

.word-display {
    text-align: center;
    margin: 2rem 0;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.word-display h3 {
    color: #495057;
    margin-bottom: 1rem;
}

.word {
    font-size: 2.5rem;
    font-weight: bold;
    color: #28a745;
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 3px solid #28a745;
    display: inline-block;
    min-width: 200px;
}

.impostor-text {
    font-size: 1.5rem;
    color: #dc3545;
    font-weight: bold;
    background: #ffe6e6;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #dc3545;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.game-info {
    text-align: center;
    margin-top: 2rem;
}

.game-info p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.instruction {
    font-style: italic;
    color: #666;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

/* Controles del host en el juego */
#game-host-controls {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #eee;
    text-align: center;
}

#game-host-controls button {
    margin: 0 10px;
}

/* Controles de turno del jugador */
.turn-controls {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #e8f4fd;
    border-radius: 10px;
    border: 2px solid #667eea;
    text-align: center;
}

.turn-controls .turn-instruction {
    margin: 0 0 1rem 0;
    font-weight: 600;
    color: #667eea;
    font-size: 1.1rem;
}

#pass-turn-btn {
    background: #28a745;
    font-size: 1.1rem;
    padding: 12px 30px;
    font-weight: 600;
}

#pass-turn-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

#pass-turn-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

#end-game-btn {
    background: #6c757d;
}

#end-game-btn:hover {
    background: #5a6268;
}

/* Mensajes de estado */
.status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.status.error {
    background: #dc3545;
}

.status.warning {
    background: #ffc107;
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Estado de conexión */
.connection-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#connection-indicator {
    font-size: 12px;
    animation: blink 2s infinite;
}

.connection-status.connected #connection-indicator {
    color: #28a745;
    animation: none;
}

.connection-status.connecting #connection-indicator {
    color: #ffc107;
}

.connection-status.disconnected #connection-indicator {
    color: #dc3545;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Reconexión automática */
.auto-reconnect-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.reconnect-message {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.reconnect-message h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.reconnect-message p {
    margin-bottom: 1.5rem;
    color: #666;
}

.reconnect-options {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 10px;
    padding: 1.5rem;
    margin: 1rem 0;
    text-align: center;
}

.reconnect-options h3 {
    color: #856404;
    margin-bottom: 1rem;
}

.reconnect-options button {
    margin: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .screen {
        padding: 1.5rem;
    }
    
    .word {
        font-size: 2rem;
        min-width: 150px;
    }
    
    input[type="text"], textarea {
        max-width: 100%;
    }
    
    button {
        min-width: 100px;
        padding: 10px 20px;
    }
    
    .status {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .word {
        font-size: 1.5rem;
        letter-spacing: 1px;
    }
    
    .impostor-text {
        font-size: 1.2rem;
    }
    
    .round-info h2 {
        font-size: 1.5rem;
    }
}

.kick-btn {
    margin-left: 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.95rem;
}
.kick-btn:hover {
    background: #b71c1c;
}
.pass-btn {
    margin-left: 5px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.95rem;
}
.pass-btn:hover {
    background: #0056b3;
}
