#player-settings-container {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.player-config-section {
    background-color: var(--section-deep);
    padding: var(--base-padding);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color-light);
    position: relative;
    margin-top: 1rem; /* Añadido espacio entre secciones de jugador */
}

/* Contenedor para la fila superior (Nombre, Selector de Modo, Color) */
.player-config-header {
    display: flex;
    justify-content: space-between; /* Mantiene extremos separados */
    align-items: center;
    gap: 0.75rem; /* Espacio entre nombre, select y color */
    margin-bottom: 1.5rem; /* Espacio antes de los sliders */
    flex-wrap: nowrap; /* Evitar wrap por defecto */
}

/* Nombre del jugador (ajustar max-width si es necesario) */
.player-config-header legend {
    flex-shrink: 1; /* Permitir que el nombre se encoja si es necesario */
    margin-bottom: 0;
    font-size: 1.1rem;
    color: var(--text-color-light);
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 60px; /* Ancho mínimo razonable */
    flex-grow: 1; /* Permitir que crezca si hay espacio */
}
.player-name-editable {
    cursor: text;
    padding: 0.1em 0.3em;
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    display: inline-block; /* Para que el legend controle el ancho */
    width: auto; /* Que se ajuste al contenido */
    max-width: 100%; /* Asegurar que no desborde el legend */
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
.player-name-editable:hover,
.player-name-editable:focus {
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px var(--info-color-light);
    overflow: visible; /* Mostrar completo al editar */
}

.mode-selector {
    /* Hereda algunos estilos de select global, pero los sobreescribimos/ajustamos */
    flex-shrink: 0; /* No encoger */
    flex-basis: 110px; /* Ancho base preferido */
    width: auto; /* Ancho automático basado en flex-basis */
    max-width: 130px; /* Límite superior */
    padding: 0.3rem 0.5rem; /* Padding más compacto */
    font-size: 0.9em; /* Fuente ligeramente más pequeña */
    margin-bottom: 0; /* Quitar margen inferior global de select */
    height: auto; /* Altura automática */
    background-color: var(--input-bg-color); /* Usar el fondo de input normal */
    border: 1px solid var(--border-color-light);
    color: var(--text-color);
    border-radius: var(--border-radius-sm);
    text-align: center; /* Centrar texto opción */
    cursor: pointer;
    /* Podríamos añadir appearance: none y un icono de flecha personalizado */
}
.mode-selector:focus {
    outline: none;
    border-color: var(--link-color);
    box-shadow: 0 0 0 3px var(--focus-ring-color);
}

/* Cuadro Selector de Color */
.color-selector-box {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: var(--box-shadow-sm);
}
.color-selector-box:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px var(--focus-ring-info-color);
}
.color-selector-box:active {
    transform: scale(0.95);
}

/* Contenedor para los SLIDERS de tiempo (Apilados) */
.time-inputs {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-top: 0; /* El margen ya lo da el header */
}

/* Grupo individual de slider */
.slider-group {
    width: 100%;
}

.slider-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-color);
    width: 100%;
    cursor: default;
}

.slider-value-display {
    font-variant-numeric: tabular-nums;
    font-weight: bold;
    font-size: 1em;
    text-align: right;
    padding: 0.1em 0.4em;
    background-color: var(--info-color);
    color: var(--text-color-light);
    border-radius: var(--border-radius-sm);
    margin-left: 0.5rem;
    min-width: 1.5em; /* Asegura espacio para 2 dígitos */
}

.slider-group input[type="range"] {
    width: 100%;
    margin-top: 0;
    margin-bottom: 0;
}


/* --- Vista del Juego (N > 2 jugadores) --- */
#game-view {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color); /* Color base, se sobreescribe */
    padding: 0;
    z-index: 100;
    overflow: hidden;
}
#game-screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around; /* Distribuye espacio */
    align-items: center;
    text-align: center;
    padding: 1rem 1rem 2rem 1rem; /* Padding arriba/lados/abajo */
    cursor: pointer; /* Indica que es interactivo */
    transition: background-color 0.5s ease;
    color: var(--text-color-light); /* Color texto por defecto (puede cambiar) */
    overflow: hidden;
    width: 100%;
    height: 100%;
    user-select: none; /* Evita seleccionar texto al hacer clic rápido */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
#current-player-name {
    font-size: clamp(1.8rem, 6vw, 3rem);
    font-weight: bold;
    margin-bottom: 0.5rem;
    word-break: break-word; /* Rompe nombres largos */
}
#current-player-time {
    font-size: clamp(5rem, 20vw, 12rem); /* Tamaño gigante adaptable */
    font-weight: bold;
    font-variant-numeric: tabular-nums; /* Números de ancho fijo */
    line-height: 1;
    transition: color 0.3s ease;
}
#current-player-time.negative-time {
    color: var(--danger-color); /* Rojo para tiempo negativo */
}

#game-button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(0.5rem, 3vw, 1.5rem); /* Espacio adaptable entre botones */
    flex-wrap: wrap; /* Permitir que envuelvan si no caben */
    width: 100%; /* Ocupa el ancho para centrar correctamente */
    margin-top: 1rem; /* Espacio sobre los botones */
    /* Permitir clics en los botones dentro de game-screen */
    pointer-events: auto;
}

#game-button-container .btn {
    min-width: 110px; /* Ancho mínimo */
    flex-grow: 0; /* No crecer por defecto */
    flex-shrink: 0; /* No encoger */
    font-size: clamp(1rem, 3.5vw, 1.2rem); /* Tamaño fuente adaptable */
    padding: 0.7rem 1rem; /* Padding adaptable */
    /* Restaurar pointer-events para los botones mismos */
    pointer-events: auto !important; /* Asegurar clickeabilidad */
    user-select: auto !important; /* Permitir selección de texto si es necesario */
}

/* --- Vista de Ajedrez (2 jugadores) --- */
#two-player-view {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    background-color: var(--bg-darkest);
    user-select: none;
    -webkit-user-select: none;
}
.player-area {
    flex: 1; /* Ocupa mitad de la pantalla */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    transition: background-color 0.4s ease;
    overflow: hidden;
}
.player-area.inactive {
    background-color: var(--bg-darker) !important;
}
.player-area .player-name, .player-area .player-time {
    transition: color 0.4s ease;
    text-align: center;
    color: var(--text-color-light); /* Color por defecto */
}
.player-area .player-name {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: bold;
    margin-bottom: 0.2em;
}
.player-area .player-time {
    font-size: clamp(4rem, 18vw, 10rem);
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.player-area.inactive .player-name,
.player-area.inactive .player-time {
    color: var(--text-muted-color);
}
.player-time.negative-time {
    color: var(--danger-color-light) !important;
}
/* Jugador de arriba, rotado */
#player-area-0 {
    transform: rotate(180deg);
}
/* Controles centrales */
#two-player-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 110;
    display: flex;
    gap: 1rem;
    background-color: rgba(0,0,0,0.4);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-lg);
    pointer-events: none; /* Los clics pasan a través del contenedor */
}
#two-player-controls .btn {
    pointer-events: auto; /* Pero los botones sí son clickeables */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Vista de Resumen --- */
#summary-view {
    display: flex; /* Cambiado a flex para centrar main/nav verticalmente */
    flex-direction: column;
    align-items: center; /* Centra horizontalmente section/nav */
    justify-content: center; /* Centra verticalmente en la pantalla */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* Ocupa toda la pantalla */
    background-color: var(--bg-color);
    padding: var(--base-padding);
    z-index: 90; /* Por debajo de game-view si alguna vez se superponen */
    overflow-y: auto; /* Permite scroll si el resumen es muy largo */
    animation: fadeIn 0.3s ease-out forwards; /* Animación suave al aparecer */
}

#summary-view section {
    /* Hereda estilos de section global, pero ajustamos si es necesario */
    max-width: 500px; /* Limitar ancho del contenido del resumen */
    width: 100%;
    animation: none; /* Evitar doble animación si section ya la tiene */
}

#summary-content {
    /* Estilos para el contenedor de los tiempos individuales */
    margin-bottom: 1rem;
}

#summary-content > div { /* Estilo para cada fila de jugador */
    color: var(--text-color);
    font-size: 1.1rem;
    display: flex; /* Usar flex para controlar alineación y espacio */
    justify-content: space-between; /* Separa nombre y tiempo */
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color-light); /* Separador entre jugadores */
    gap: 1rem; /* Espacio entre nombre y tiempo si envuelve */
}
#summary-content > div:last-child {
    border-bottom: none; /* Quitar borde inferior al último elemento */
}

#summary-content > div span:first-child { /* Nombre del jugador */
   margin-right: 0.5rem; /* Espacio ligero a la derecha */
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
   flex-shrink: 1; /* Permitir que el nombre se encoja */
}
#summary-content > div span:last-child { /* Tiempo del jugador */
    color: var(--text-color-light);
    font-weight: bold;
    flex-shrink: 0; /* Evitar que el tiempo se encoja */
    white-space: nowrap; /* Evitar que el MM:SS se parta */
}

#total-time-summary {
    color: var(--text-color-light);
    text-align: center;
    margin-top: 1.5rem;
    font-weight: bold;
    font-size: 1.2rem;
}

/* --- Asegurar que nav en summary también se centre --- */
#summary-view nav {
     max-width: 500px; /* Igual que la sección */
     width: 100%;
}


/* --- Ajustes responsivos --- */
@media (max-width: 600px) {
    .player-config-header {
        gap: 0.5rem; /* Menos espacio */
        margin-bottom: 1rem; /* Un poco menos de espacio abajo */
    }
     .player-config-header legend {
        min-width: 50px;
    }
    .mode-selector {
        flex-basis: 100px; /* Más estrecho */
        font-size: 0.85em;
    }
    .player-config-section > .time-inputs {
        gap: 1rem;
    }
    .slider-group label {
       font-size: 0.85em;
    }
    #game-button-container .btn {
        min-width: 100px; /* Botones un poco más pequeños */
        font-size: clamp(0.9rem, 3vw, 1.1rem);
        padding: 0.6rem 0.8rem;
    }
}

@media (max-width: 480px) {
    .player-config-section {
        padding: 0.8rem;
    }
    .player-config-header {
        flex-wrap: wrap; /* Forzar wrap en pantallas muy pequeñas */
        justify-content: center; /* Centrar elementos cuando envuelven */
        margin-bottom: 0.8rem;
        gap: 0.5rem 1rem; /* Espacio vertical y horizontal */
    }
    .player-config-header legend {
        flex-basis: 100%; /* Ocupar toda la primera línea */
        text-align: center; /* Centrar nombre */
        margin-bottom: 0.5rem; /* Espacio antes de select/color */
        order: -1; /* Poner el nombre primero */
        overflow: hidden; /* Asegurar que elipsis funcione */
        text-overflow: ellipsis;
        white-space: nowrap;
    }
     .player-name-editable {
        display: inline; /* Para que text-align:center funcione */
     }

    /* Selector de modo y color en la segunda línea, centrados */
    .mode-selector {
        order: 0; /* Después del nombre */
        flex-basis: auto; /* Ancho automático */
        flex-grow: 1; /* Permitir que crezca un poco */
        margin: 0 0.5rem; /* Margen lateral */
    }
    .color-selector-box {
        width: 24px;
        height: 24px;
        order: 1; /* Después del selector */
    }

    .time-inputs {
        gap: 0.8rem;
        margin-top: 1rem; /* Añadir espacio si el header envolvió */
    }
    .slider-group label {
        font-size: 0.8em;
    }
    .slider-value-display {
        padding: 0.1em 0.3em;
        font-size: 0.95em;
    }

    #current-player-name {
       font-size: clamp(1.5rem, 5vw, 2.5rem);
    }
    #current-player-time {
       font-size: clamp(4rem, 18vw, 10rem);
    }
    #game-button-container {
        gap: 0.5rem; /* Menos espacio entre botones */
    }
    #game-button-container .btn {
        min-width: 90px; /* Aún más pequeños */
        font-size: 0.9rem;
        padding: 0.5rem 0.7rem;
    }
    #summary-content > div {
        font-size: 1rem; /* Texto del resumen un poco más pequeño */
    }
    #total-time-summary {
        font-size: 1.1rem;
    }

}

/* Fade-in animation (si no está ya en main.css) */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}