/* 1. Variables y Reset */
:root {
    --primary-color: #1a2a6c;
    --secondary-color: #000001;
    --accent-color: #00ff39;
    --boton-nuevo-jugador: #ffd700;
    --text-color: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --gradient: linear-gradient(135deg, #1a2a6c, #000001);
    --vh: 1vh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

span {
    font-weight: bold;
}
span.player-card-position {
    color: #00ff39;
    font-weight: normal;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--primary-color);
    color: var(--text-color);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: -moz-available;
    min-height: fill-available;
    min-height: calc(var(--vh, 1vh) * 100);
    width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
}

html {
    height: 100%;
    height: -webkit-fill-available;
    height: -moz-available;
    height: fill-available;
}

/* 2. Layout General */
.screen {
    display: none;
    width: 100vw;
    height: 100%;
    height: -webkit-fill-available;
    height: -moz-available;
    height: fill-available;
    min-height: calc(var(--vh, 1vh) * 100);
    position: fixed;
    top: 0;
    left: 0;
    padding: 10px;
    text-align: center;
    overflow-y: auto;
    background: var(--gradient);
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

/* 3. Títulos y Texto */
h1 {
    font-size: 2.8em;
    color: #00ff39;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin: 20px 0;
    animation: bounce 1s infinite alternate;
}

h2 {
    font-size: 2em;
    color: #00ff39;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin: 15px 0;
}

h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: white;
}

/* 4. Componentes Comunes */
button {
    cursor: pointer;
    outline: none;
    border: none;
}

button:focus {
    outline: none;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-top: 20px;
    overflow: hidden;
}

.progress {
    width: 0%;
    height: 100%;
    background-color: var(--accent-color);
    transition: width 2s linear;
}

/* 5. Menú y Controles */
.menu-buttons {
    width: 100%;
    padding: 0 10px;
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
    margin: 10px 0;
    position: relative;
    z-index: 1;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 7px;
    padding: 8px 10px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 52px;
    font-size: 0.75em;
    transition: all 0.3s ease;
}

.menu-btn .btn-icon {
    font-size: 1.2em;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
    margin: 5px 0;
    margin-bottom: 10px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 5px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 60px;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.btn-icon {
    font-size: 1.3em;
}

/* Estilos específicos para cada tipo de botón */
#train-btn {
    background: linear-gradient(45deg, rgba(255, 215, 0, 0.3), rgba(255, 64, 64, 0.5));
}

#train-btn:hover {
    background: linear-gradient(45deg, rgba(255, 64, 64, 0.3), rgba(255, 64, 64, 0.5));
}

#eat-btn {
    background: linear-gradient(45deg, rgba(255, 193, 7, 0.2), rgba(255, 193, 7, 0.5));
}

#eat-btn:hover {
    background: linear-gradient(45deg, rgba(255, 193, 7, 0.3), rgba(255, 193, 7, 0.5));
}

#study-btn {
    background: linear-gradient(45deg, rgba(33, 150, 243, 0.2), rgba(33, 150, 243, 0.5));
}

#study-btn:hover {
    background: linear-gradient(45deg, rgba(33, 150, 243, 0.3), rgba(33, 150, 243, 0.5));
}

#shower-btn {
    background: linear-gradient(45deg, rgba(156, 39, 176, 0.2), rgba(156, 39, 176, 0.5));
}

#shower-btn:hover {
    background: linear-gradient(45deg, rgba(156, 39, 176, 0.3), rgba(156, 39, 176, 0.5));
}

#match-btn {
    background: linear-gradient(45deg, rgba(76, 175, 80, 0.2), rgba(76, 175, 80, 0.5));
}

#match-btn:hover {
    background: linear-gradient(45deg, rgba(76, 175, 80, 0.3), rgba(76, 175, 80, 0.5));
}

/* Botón de menú */
#menu-btn {
    background: linear-gradient(45deg, rgba(255, 87, 34, 0.2), rgba(255, 87, 34, 0.5));
}

#menu-btn:hover {
    background: linear-gradient(45deg, rgba(255, 87, 34, 0.3), rgba(255, 87, 34, 0.5));
}

#drink-btn {
    background: linear-gradient(45deg, rgba(0, 191, 255, 0.2), rgba(0, 191, 255, 0.5));
}

#drink-btn:hover {
    background: linear-gradient(45deg, rgba(0, 191, 255, 0.3), rgba(0, 191, 255, 0.5));
}

#friends-btn {
    background: linear-gradient(45deg, rgba(76, 175, 80, 0.2), rgba(76, 175, 80, 0.5));
}

#friends-btn:hover {
    background: linear-gradient(45deg, rgba(76, 175, 80, 0.2), rgba(76, 175, 80, 0.5));
}

/* 6. Personaje y Carta */
#character-container {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 10px;
    margin: 0;
    min-height: 200px;
    z-index: 1;
}

.character {
    width: min(35vh, 100vw);
    height: min(35vh, 100vw);
    min-width: 200px;
    min-height: 200px;
    max-width: 350px;
    max-height: 350px;
    margin: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 3px solid rgba(255, 255, 255, 0.3);
    animation: float 3s ease-in-out infinite;
    overflow: hidden;
    position: relative;
}

/* Para pantallas pequeñas o estrechas (como iPhone SE o similares) */
@media screen and (max-height: 700px), screen and (max-width: 380px) {
    .character {
        width: min(30vh, 85vw);
        height: min(30vh, 85vw);
        min-width: 150px;
        min-height: 150px;
        max-width: 250px;
        max-height: 250px;
    }
}

/* Para pantallas muy pequeñas */
@media screen and (max-height: 600px) {
    .character {
        width: min(25vh, 80vw);
        height: min(25vh, 80vw);
        min-width: 120px;
        min-height: 120px;
        max-width: 200px;
        max-height: 200px;
    }
}

.character video.character-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

img.character-image {
    max-width: 100%;
    max-height: 100%;
}

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

.modal.active {
    display: flex;
    pointer-events: auto; /* Por defecto, los modales normales sí interceptan clics */
}

.modal-content {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(0, 30, 60, 0.95));
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 15px;
    width: 90%;
    max-width: 350px;
    position: relative;
    border: 3px solid #00bfff;
    margin: 10px;
}

/* Estilos del botón de cerrar */
.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2em;
    transition: all 0.3s ease;
    padding: 0;
    line-height: 1;
    z-index: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Ajustar el espacio para el título del modal */
.modal-content h3 {
    margin: 5px 0 15px 0;
    text-align: center;
    position: relative;
}

/* 8. Carta FIFA */
.card-style {
    background: transparent;
    padding: 0;
    width: 90%;
    max-width: 280px;
    border: none;
    margin: 0 auto;
}

.player-card-fifa {
    background: linear-gradient(135deg, #00bfff 0%, #00ff39 100%);
    border-radius: 15px;
    padding: 15px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.player-card-fifa::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.game-title {
    color: #333;
    margin-top: 20px;
    font-size: 0.9em;
    font-weight: bold;
    text-transform: uppercase;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
    letter-spacing: 0.5px;
    text-align: center;
}

.rating-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.player-rating {
    font-size: 2.2em;
    font-weight: 800;
    color: #333;
    display: block;
    line-height: 1;
}

.player-position {
    font-size: 1em;
    font-weight: bold;
    color: #666;
}

.card-image-container {
    position: relative;
    margin: 15px 0;
    text-align: center;
}

.card-image {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.5);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.player-info {
    margin-top: 12px;
}

.card-name {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
    margin-bottom: 5px;
}

.player-level {
    color: #333;
    font-weight: 600;
    font-size: 0.9em;
    background: rgb(255 255 255 / 73%);
    padding: 3px 10px;
    border-radius: 12px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-stats {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    margin-top: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.stat-column {
    flex: 1;
    padding: 0 5px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
}

.stat-label {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9em;
}

.stat-value {
    color: #00ff39;
    font-weight: 800;
    font-size: 1.1em;
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: 8px;
}

span.stat-label.stat1-label {
    color: #000000;
}
span.stat-value.stat1-stat {
    color: #000000;
}
span.stat-label.stat2-label {
    color: #000000;
}
span.stat-value.stat2-stat {
    color: #000000;
}
span.stat-label.stat3-label {
    color: #000000;
}
span.stat-value.stat3-stat {
    color: #000000;
}
span.stat-label.stat4-label {
    color: #000000;
}
span.stat-value.stat4-stat {
    color: #000000;
}
span.stat-label.stat5-label {
    color: #000000;
}
span.stat-value.stat5-stat {
    color: #000000;
}
span.stat-label.stat6-label {
    color: #000000;
}
span.stat-value.stat6-stat {
    color: #000000;
}
span.player-rating {
    color: #0029ff;
}

/* 9. Animaciones */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-5px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 10. Scrollbar Personalizado */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    /*background: rgba(255,255,255,0.3);*/
    background-color: rgba(0,255,60,0.3);
    border-radius: 10px;
}

/* Pantalla de carga */
#loading-screen {
    display: none;
    width: 100%;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--gradient);
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

#loading-screen.active {
    display: flex;
}

/* Estilos para la pantalla de juego */
#game-screen {
    display: none;
    padding: 10px;
    height: 100%;
    height: -webkit-fill-available;
    height: -moz-available;
    height: fill-available;
    min-height: calc(var(--vh, 1vh) * 100);
    position: relative;
    background: var(--gradient);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#game-screen.active {
    display: flex;
    flex-direction: column;
}

/* Barra de carga inicial */
#loading-screen .progress-bar {
    width: 80%;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin: 20px auto;
    overflow: hidden;
}

#loading-screen .progress {
    width: 0%;
    height: 100%;
    background-color: var(--text-color);
    transition: width 2s linear;
}

/* Stats del jugador */
.player-stats {
    width: 95%;
    max-width: 400px;
    margin: 10px auto;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 12px;
    position: relative;
    z-index: 1;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

#player-name-display {
    font-size: 1.2em;
    font-weight: bold;
}

#player-level {
    background: var(--accent-color);
    color: #333;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
}

.stats-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-bar {
    display: flex;
    align-items: center;
    gap: 1px;
    height: 24px;
}

.stat-bar label {
    min-width: 65px;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.9);
}

.stat-bar .progress-bar {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    margin: 0;
    overflow: hidden;
}

.stat-bar .progress {
    height: 100%;
    transition: width 1.5s ease-in-out;
}

.stat-percent {
    min-width: 45px;
    text-align: right;
    font-size: 0.9em;
    color: rgb(0 255 57);
}

#energy-bar { 
    background: #FFD700; 
    border-radius: 5px;
    transition: width 1.5s ease-in-out;
}

#hunger-bar { 
    background: #32CD32; 
    border-radius: 5px;
    transition: width 1.5s ease-in-out;
}

#hygiene-bar { 
    background: #00BFFF; 
    border-radius: 5px;
    transition: width 1.5s ease-in-out;
}

/* Habilidades del jugador */
.player-skills {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 12px;
    width: 90%;
    max-width: 400px;
    margin: 10px auto;
}

.player-skills h3 {
    font-size: 1em;
    margin-bottom: 8px;
}

.skills-container {
    max-height: 70vh;
    overflow-y: auto;
    padding: 5px;
    margin: -5px;  /* Compensar el padding para alinear con el borde del modal */
}

.skills-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.skill {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skill-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1em;
    color: rgba(255, 255, 255, 0.9);
}

.skill-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.skill-progress {
    height: 100%;
    background: var(--accent-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.skill-value {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--accent-color);
    text-align: right;
}

/* Estilos para la selección de posición */
.position-select {
    margin: 20px 0;
}

.position-select h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: white;
}

.position-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 10px;
}

.position-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 15px 10px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    color: white;
}

.position-btn.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #333;
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.position-icon {
    font-size: 2em;
}

/* Estilos para el modal de confirmación */
#confirm-menu-modal .modal-content {
    max-width: 300px;
    text-align: center;
}

#confirm-menu-modal h3 {
    margin-bottom: 10px;
    color: white;
}

#confirm-menu-modal p {
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.8);
}

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

.confirm-btn, .cancel-btn {
    padding: 10px 25px;
    border-radius: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.confirm-btn {
    background: var(--accent-color);
    color: #333;
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    margin-top: 5%;
}

.confirm-btn:hover, .cancel-btn:hover {
    transform: translateY(-2px);
}

/* Estilos de Selección de Género */
.gender-select {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.gender-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 15px 25px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    color: white;
}

.gender-btn.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #333;
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.gender-icon {
    font-size: 2em;
}

/* Formulario de Creación */
#player-form {
    width: 90%;
    max-width: 400px;
    margin: 0 auto;
}

#player-name {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.1em;
    margin-bottom: 20px;
}

#player-name::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.submit-btn {
    background: var(--accent-color);
    color: #333;
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 5px;
    width: 100%;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Dentro de la sección de Formulario de Creación */
.back-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 25px;
    border-radius: 12px;
    font-size: 1em;
    margin-top: 15px;
    width: 90%;
    max-width: 400px;
    align-self: center;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Lista de Jugadores Guardados */
#saved-players {
    width: 90%;
    max-width: 400px;
    margin: 40px auto;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 5px;
}

.player-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.player-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.player-card-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-card-name {
    font-size: 1.1em;
    font-weight: bold;
    text-align: left;
    text-align-last: left;
    cursor: pointer;
    transition: color 0.3s ease;
}

.player-card-name:hover {
    color: var(--accent-color);
}

.player-card-level {
    font-size: 0.9em;
    color: #fff900;
    text-align: left;
}

.player-card-actions {
    display: flex;
    gap: 10px;
}

.play-btn {
    background: var(--accent-color);
    color: #333;
    padding: 8px 20px;
    border-radius: 12px;
    font-weight: bold;
}

.delete-btn {
    background: rgba(255, 0, 0, 0.3);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

/* Ajustes de la Carta FIFA */
.game-logo {
    height: 40px;
    object-fit: contain;
}

.player-nationality {
    color: #666;
    font-weight: 500;
    font-size: 0.9em;
    margin-top: 5px;
}

/* Ajustes del Menú Principal */
#new-player-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--boton-nuevo-jugador);
    color: var(--secondary-color);
    padding: 12px 25px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 100;
    width: 90%;
    min-width: 200px;
    margin: 0;
}

/* Asegurar que la pantalla de selección tiene scroll si es necesario */
#player-select {
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 100px; /* Espacio extra al final */
}

/* Media queries actualizados */
@media screen and (max-width: 360px) {
    .control-btn {
        min-width: 55px;
        font-size: 0.8em;
    }

    .btn-icon {
        font-size: 1.2em;
    }

    .character {
        min-width: 180px;
        min-height: 180px;
    }
}

@media screen and (min-width: 768px) {
    .character {
        width: min(50vh, 350px);
        height: min(50vh, 350px);
    }

    .control-btn {
        min-width: 90px;
        font-size: 1em;
    }

    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .skills-container {
        max-height: 80vh;
    }
}

@media screen and (min-width: 1024px) {
    .character {
        width: min(55vh, 400px);
        height: min(55vh, 400px);
        max-width: 400px;
        max-height: 400px;
    }
}

.player-card-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-card-stats {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.player-card-sleeping {
    color: #8b8bff;
    font-size: 0.9em;
    font-style: italic;
    margin-top: 2px;
    display: block;
    animation: sleep-text 2s infinite;
}

@keyframes sleep-text {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Estilizar el scrollbar para mejor apariencia */
#saved-players::-webkit-scrollbar {
    width: 8px;
}

#saved-players::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#saved-players::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

#saved-players::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Estilos para el input de editar nombre */
#edit-name-input {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.1em;
    margin-bottom: 20px;
}

#edit-name-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Estilos para el modal de error */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(45deg, #0088ff, #00bfff);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 15px;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    white-space: pre-line;
    width: 80vw;
    max-width: 500px;
    min-width: 280px;
    opacity: 0;
    animation: fadeInCenter 0.3s ease-out forwards;
}

.notification-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    z-index: 1000;
    text-align: center;
    animation: fadeInDown 0.3s ease-out;
    border: 2px solid #00ff39;
}

/* Estilos específicos para notificaciones de monedas */
.coins-notification-container {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 400px;
    z-index: 999;
    pointer-events: none;
}

.coins-notification {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 140px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #000000;
    padding: 12px;
    border-radius: 15px;
    text-align: center;
    animation: fadeInCoins 0.3s ease-out;
    border: 3px solid #FFD700;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 1.1em;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.coins-notification.removing {
    opacity: 0;
    transform: translateY(-20px);
}

.coins-notification .notification-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coins-notification .close-notification-btn {
    background: rgba(0, 0, 0, 0.2);
    color: #000000;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    border: none;
}

.coins-notification .close-notification-btn:hover {
    background: rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

@keyframes fadeInCenter {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes fadeInCoins {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos del tutorial */
.tutorial-style {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--accent-color);
    max-width: 300px;
    text-align: center;
    padding: 20px;
    z-index: 1000;
}

.tutorial-highlight {
    animation: pulse 1.5s infinite;
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 15px var(--accent-color);
    z-index: 1001 !important;
    position: relative;
}

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

#tutorial-message {
    color: white;
    font-size: 1.1em;
    line-height: 1.4;
    margin: 0;
    white-space: pre-line;
}

/* Estilo específico solo para el modal del tutorial */
#tutorial-modal.active {
    pointer-events: none;
    z-index: 999;
}

/* Solo cuando necesitamos que el tutorial modal capture clics */
#tutorial-modal.active[style*="pointer-events: auto"] {
    pointer-events: auto;
    z-index: 1002;
}

.training-rewards {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.coins-earned, .energy-lost, .hygiene-lost, .hunger-lost {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 5px;
    flex-direction: column;
}

.coins-earned {
    color: gold;
    background: rgba(255,215,0,0.1);
}

.energy-lost {
    color: #ff5555;
    background: rgba(255,85,85,0.1);
}

.hygiene-lost {
    color: #55aaff;
    background: rgba(85,170,255,0.1);
}

.hunger-lost {
    color: #ff9955;
    background: rgba(255,153,85,0.1);
}

.reward-icon {
    font-size: 1.2em;
}

.reward-value {
    font-weight: bold;
}

.player-actions {
    display: flex;
    gap: 4px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 6px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 60px;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

#coins-btn {
    background: linear-gradient(45deg, rgba(255, 215, 0, 0.5), rgba(255, 170, 0, 0.5));
}

#coins-btn:hover {
    background: linear-gradient(45deg, rgba(255, 215, 0, 0.7), rgba(255, 170, 0, 0.7));
    transform: translateY(-2px);
}

#sleep-btn {
    background: linear-gradient(45deg, rgba(147, 112, 219, 0.5), rgba(75, 0, 130, 0.5));
}

#sleep-btn:hover {
    background: linear-gradient(45deg, rgba(147, 112, 219, 0.7), rgba(75, 0, 130, 0.7));
    transform: translateY(-2px);
}

/* Estilos para el mensaje de no jugadores */
.no-players-message {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.empty-state {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    max-width: 300px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.empty-icon {
    font-size: 3em;
    margin-bottom: 10px;
    animation: wave 2s infinite;
}

.empty-state h3 {
    color: var(--accent-color);
    font-size: 1.3em;
    margin: 0;
}

.empty-state p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1em;
    line-height: 1.4;
    margin: 0;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-20deg); }
    75% { transform: rotate(20deg); }
}

/* Estilos del menú de comida */
.food-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    max-height: 68vh;
    overflow-y: auto;
    padding: 10px;
}

.food-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.food-item:hover {
    transform: translateY(-5px);
}

.food-item.common { border-color: rgba(255, 255, 255, 0.3); }
.food-item.rare { border-color: #4169E1; }
.food-item.epic { 
    border-color: #9400D3;
    background: linear-gradient(45deg, rgba(148, 0, 211, 0.1), rgba(75, 0, 130, 0.1));
}

.food-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.food-name {
    font-size: 1.2em;
    font-weight: bold;
}

.food-price {
    background: rgba(255, 215, 0, 0.2);
    padding: 4px 8px;
    border-radius: 10px;
    font-weight: bold;
}

.food-description {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9em;
}

.food-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.food-stat {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.9em;
}

.buy-food-btn {
    background: var(--accent-color);
    color: #333;
    padding: 8px;
    border-radius: 10px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.buy-food-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 255, 57, 0.3);
}

.buy-food-btn.disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

.buy-food-btn.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Animaciones de comida */
.floating-food {
    position: absolute;
    font-size: 2em;
    animation: float-to-character 1s ease-in;
}

.character.eating {
    animation: eat-bounce 0.5s ease-in-out;
}

.food-effects {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    animation: float-up 2s ease-out;
}

.effect-item {
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: bold;
}

@keyframes float-to-character {
    from {
        transform: translate(50px, -50px) rotate(20deg);
        opacity: 1;
    }
    to {
        transform: translate(0, 0) rotate(0);
        opacity: 0;
    }
}

@keyframes eat-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes float-up {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-50px);
    }
}

/* Ajustes para el modal de comida */
#food-modal .modal-content {
    max-width: 800px;  /* Más ancho para mostrar mejor las opciones de comida */
    padding: 20px;
    width: 95%;
    height: 90vh !important;
    max-height: 82vh !important;
}

#food-modal .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

#food-modal .food-content {
    padding-top: 10px;
}

/* Efectos especiales del chef */
.chef-special {
    position: absolute;
    font-size: 2em;
    animation: float-around-food 1.5s ease-out;
    transform-origin: center;
}

.special-effect {
    filter: brightness(1.5);
}

.super-special {
    animation: pulse-rainbow 2s linear;
}

.star-effect {
    position: absolute;
    width: 20px;
    height: 20px;
    background: gold;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: shoot-star 2s ease-out;
    animation-delay: var(--delay);
    transform-origin: center;
    transform: rotate(var(--angle)) translateX(0);
    opacity: 0;
}

@keyframes float-around-food {
    0% { 
        transform: translate(var(--start-x), var(--start-y)) scale(0) rotate(0deg);
        opacity: 0;
    }
    20% {
        transform: translate(var(--start-x), var(--start-y)) scale(1) rotate(90deg);
        opacity: 1;
    }
    100% { 
        transform: translate(var(--start-x), calc(var(--start-y) - 100px)) scale(0) rotate(360deg);
        opacity: 0;
    }
}

@keyframes pulse-rainbow {
    0% { filter: hue-rotate(0deg) brightness(1.5); }
    100% { filter: hue-rotate(360deg) brightness(1.5); }
}

@keyframes shoot-star {
    0% { transform: rotate(var(--angle)) translateX(0); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: rotate(var(--angle)) translateX(100px); opacity: 0; }
}

/* Efectos legendarios mejorados */
.legendary-effects-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: auto;
    z-index: 10000;
}

.legendary-particle {
    position: absolute;
    font-size: 3em;
    z-index: 10000;
    pointer-events: none;
    filter: drop-shadow(0 0 10px gold);
}

.legendary-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid gold;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.5);
    min-width: 300px;
    pointer-events: auto;
}

@keyframes message-appear {
    from {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.legendary-title {
    font-size: 2.5em;
    color: gold;
    text-shadow: 0 0 20px gold;
    margin-bottom: 15px;
    animation: pulse-scale 0.5s infinite alternate;
}

.legendary-subtitle {
    font-size: 1.5em;
    color: white;
    margin-bottom: 15px;
}

.legendary-bonus {
    font-size: 2em;
    color: gold;
    text-shadow: 0 0 15px gold;
    animation: bounce-up 0.5s infinite alternate;
}

.golden-explosion {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, transparent 70%);
    animation: pulse-gold 2s ease-out;
}

@keyframes pulse-scale {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

@keyframes bounce-up {
    from { transform: translateY(0); }
    to { transform: translateY(-5px); }
}

@keyframes pulse-gold {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 0.5; }
    100% { opacity: 0; transform: scale(2); }
}

.absorb-food {
    position: absolute;
    font-size: 2em;
    transform-origin: center;
    animation: absorb-to-center 1s ease-in forwards;
}

@keyframes absorb-to-center {
    0% {
        transform: translate(var(--start-x), var(--start-y)) scale(1);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: translate(0, 0) scale(0);
        opacity: 0;
    }
}

.legendary-button {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border: none;
    border-radius: 15px;
    padding: 15px 30px;
    font-size: 1.5em;
    font-weight: bold;
    color: #000;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 5px 15px rgba(255,215,0,0.3);
}

.legendary-button:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 25px rgba(255,215,0,0.5);
}

/* Quitar la animación automática de desaparición del mensaje */
.legendary-message {
    animation: message-appear 0.5s ease-out forwards;
}

.player-card-sleeping {
    color: #8b8bff;
    font-size: 0.9em;
    font-style: italic;
    margin-top: 5px;
    display: block;
    animation: sleep-text 2s infinite;
}

@keyframes sleep-text {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Soporte para dispositivos móviles */
@supports (-webkit-touch-callout: none) or (-moz-appearance: none) {
    html, body {
        height: -webkit-fill-available;
        height: -moz-available;
        height: fill-available;
    }

    #game-screen, .screen {
        height: -webkit-fill-available;
        height: -moz-available;
        height: fill-available;
        min-height: -webkit-fill-available;
        min-height: -moz-available;
        min-height: fill-available;
        padding-bottom: env(safe-area-inset-bottom);
        padding-bottom: constant(safe-area-inset-bottom);
        padding-top: env(safe-area-inset-top);
        padding-top: constant(safe-area-inset-top);
    }

    .menu-buttons, .control-row {
        padding-bottom: env(safe-area-inset-bottom, 10px);
        padding-bottom: constant(safe-area-inset-bottom, 10px);
    }
}

/* Prevenir selección de texto en elementos interactivos */
button, .btn-icon, .menu-btn, .control-btn, #coins-btn {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* Específicamente para el botón de monedas */
#coins-btn {
    touch-action: manipulation;
    cursor: pointer;
}

.sound-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    font-size: 1.2em;
    transition: transform 0.2s;
}

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