body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* MANTENER FLEX: Esto centra el Canvas y el Menú en la pantalla. */
    display: flex; 
    justify-content: center; 
    align-items: center;
    height: 100vh;
    background-color: #2c3e50; 
    overflow: hidden; 
    position: relative;
    color: #333;
}

/* CORRECCIÓN DE DISPOSICIÓN: Fija el tamaño del contenedor del Canvas y los HUDs */
#gameArea {
    position: relative;
    display: none; 
    width: 1000px; /* Ancho del Canvas */
    height: 800px; /* Alto del Canvas */
}

/* CORRECCIÓN DE DISPOSICIÓN: El Canvas debe ser absoluto para no interferir con los HUDs */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    background-color: #f0f0f0;
    border: 8px solid #34495e; 
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    z-index: 1; /* Fondo del juego */
}

/* ------------------- Menú Principal ------------------- */
#menu {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    text-align: center;
    max-width: 600px; 
    width: 90%;
    transition: transform 0.3s ease-in-out;
}

#menu h1 {
    color: #3498db;
    margin-bottom: 25px;
    font-size: 2.2em;
    font-weight: 700;
    text-shadow: 1px 1px 1px #eee;
}

#menu label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

#playerName {
    padding: 12px;
    margin-bottom: 25px;
    width: 90%;
    max-width: 350px;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1em;
    transition: border-color 0.2s;
}
#playerName:focus {
    border-color: #3498db;
    outline: none;
}

#startGameButton {
    background-color: #2ecc71;
    color: white;
    padding: 15px 30px;
    font-size: 1.3em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 25px;
    width: 100%;
    max-width: 350px;
    font-weight: bold;
    transition: background-color 0.2s, transform 0.1s;
}

#startGameButton:hover:not(:disabled) {
    background-color: #27ae60;
    transform: translateY(-2px);
}

#startGameButton:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

/* --- Selectores de Personalización --- */
h2 {
    color: #34495e;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 5px;
    margin-top: 30px;
    font-size: 1.3em;
}

#skinSelector, #backgroundSelector, #musicSelector {
    display: flex; 
    justify-content: center;
    flex-wrap: wrap; /* Asegura que se envuelvan si hay muchos, como con 9 skins */
    margin-bottom: 20px;
    gap: 10px;
}

/* Skins */
.skin-option, .locked-item-wrapper.locked-skin-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    object-fit: cover;
    border: 4px solid #ccc;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.skin-option.selected, .locked-item-wrapper.locked-skin-wrapper.selected {
    border-color: #e74c3c; 
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.7);
}

/* Fondos */
.background-option {
    width: 120px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    border: 4px solid #ccc;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.background-option.selected {
    border-color: #e74c3c;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.7);
}

/* Música */
.music-option {
    padding: 10px 18px; 
    border: 2px solid #ddd;
    border-radius: 6px; 
    cursor: pointer;
    background-color: #f5f5f5;
    transition: background-color 0.2s, border-color 0.2s;
    font-size: 0.9em;
}
.music-option:hover {
    background-color: #ecf0f1;
}
.music-option.selected {
    border-color: #3498db;
    background-color: #e9f7ff;
    font-weight: bold;
    color: #3498db;
}

/* --- Elementos Bloqueados (Compra) --- */
.locked-item-wrapper {
    position: relative;
    background-color: #4c4c4c;
    overflow: hidden;
    /* Usar flex para centrar vertical y horizontalmente */
    display: flex;
    flex-direction: column; /* Apilar contenido (precio, botón) */
    justify-content: center;
    align-items: center;
    /* Fondo semi-transparente para que la imagen de fondo se vea un poco */
    background-color: rgba(0, 0, 0, 0.6); 
    background-size: cover;
    background-position: center;
}

.locked-item-wrapper.locked-skin-wrapper {
    background-image: none !important;
    border: 4px dashed #aaa;
    background: repeating-linear-gradient(45deg, #4c4c4c, #4c4c4c 5px, #333 5px, #333 10px);
}

.locked-item-wrapper .price-tag {
    /* CORRECCIÓN CRUCIAL: Eliminar el posicionamiento absoluto y el fondo oscuro para que el precio y el botón sean visibles */
    position: static; /* <-- CAMBIO CLAVE: Fluye con el contenedor flex */
    width: auto;
    height: auto;
    background: transparent; /* <-- CAMBIO CLAVE: Fondo transparente */
    color: white;
    
    /* Estilos de texto */
    display: block; 
    font-size: 12px; 
    line-height: 1.2;
    font-weight: bold;
    z-index: 10;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8); /* Sombra para resaltar el texto */
    margin-bottom: 5px; /* Espacio entre precio y botón */
    padding: 0; 
    box-sizing: content-box; 
    text-align: center; /* Para centrar el texto multilínea */
}

.locked-item-wrapper .buy-button {
    /* CORRECCIÓN: El botón debe ser estático para alinearse con flex */
    position: static; /* <-- CAMBIO CLAVE: Fluye con el contenedor flex */
    margin-top: 5px;
    padding: 3px 8px;
    background-color: #f1c40f;
    color: #333;
    border: none;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    z-index: 20; 
    font-weight: bold;
    transition: background-color 0.2s;
}
.locked-item-wrapper .buy-button:hover:not(:disabled) {
    background-color: #f39c12;
}

.locked-item-wrapper .buy-button:disabled {
    background-color: #7f8c8d;
    cursor: not-allowed;
    color: white;
}

/* Monedas del Menú */
#coinsDisplay {
    margin-top: 30px;
    padding: 10px;
    background: #f1c40f;
    border-radius: 6px;
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    display: inline-block;
}

/* ------------------- Leaderboard (Clasificación) ------------------- */
#leaderboard {
    z-index: 10; 
    position: absolute;
    top: 20px;
    right: 20px;
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    padding: 18px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none; 
    color: #34495e;
}

#leaderboard h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #3498db;
    border-bottom: 3px solid #3498db;
    padding-bottom: 8px;
    font-size: 1.5em;
    text-align: center;
}

#leaderList {
    list-style: none;
    padding: 0;
}

#leaderList li {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px dashed #ecf0f1;
    font-size: 1em;
    font-weight: 500;
}

#leaderList li:nth-child(1) { background-color: #f7dc6f; font-weight: bold; }
#leaderList li:nth-child(2) { background-color: #f9e79f; }
#leaderList li:nth-child(3) { background-color: #fcf3cf; }

#leaderList li:last-child {
    border-bottom: none;
}

.player-entry {
    font-weight: bold;
    color: #e74c3c !important; 
    background-color: #fde8e5 !important;
    border-left: 5px solid #e74c3c;
    padding-left: 5px;
}

/* ------------------- Panel Lateral (HUD) ------------------- */
#sidePanel {
    z-index: 10; 
    position: absolute;
    top: 20px;
    left: 20px;
    width: 240px;
    background: rgba(255, 255, 255, 0.95);
    padding: 18px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none; 
    flex-direction: column;
}

#sidePanel h1 {
    font-size: 1.5em;
    color: #3498db;
    border-bottom: 3px solid #3498db;
    padding-bottom: 5px;
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
}

.hud-stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 1em;
    font-weight: 500;
}

.hud-stat span:first-child {
    color: #7f8c8d;
    font-weight: normal;
}

#coinTime {
    margin-top: 15px;
    border-top: 1px solid #bdc3c7;
    padding-top: 15px;
    text-align: center;
}

#coinTime h2 {
    font-size: 1.1em;
    color: #f39c12;
    margin-bottom: 10px;
    border-bottom: none;
    font-weight: bold;
}

#coinCount {
    font-size: 1.2em;
    color: #f39c12;
}

#progressBar {
    width: 100%;
    height: 12px;
    background-color: #ecf0f1;
    border-radius: 6px;
    margin-top: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

#progressBarFill {
    height: 100%;
    width: 0%;
    background-color: #2ecc71;
    transition: width 0.3s linear;
}

#progressText {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-top: 8px;
}

#backToMenuButton {
    margin-top: 20px;
    background-color: #e74c3c;
    color: white;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

#backToMenuButton:hover {
    background-color: #c0392b;
}

/* Temporizador de Fusión */
#fusionTimerDisplay {
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    background: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 30px;
    font-family: Arial, sans-serif;
    z-index: 1000;
    display: none;
    border: 2px solid #e74c3c;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* --- Estilos para el Control de Música --- */
#musicControl {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #bdc3c7;
    text-align: center;
}

#toggleMusicButton {
    background-color: #95a5a6; 
    color: white;
    padding: 10px 18px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
    font-weight: bold;
}

#toggleMusicButton.unmuted {
    background-color: #3498db; 
}

#toggleMusicButton:hover {
    filter: brightness(1.1);
}