/* Estilos Generales y de Pantallas */
:root { --dark-wood: #654321; --light-wood: #a1887f; --parchment: #fdf6e3; --parchment-dark: #f3eacb; --accent-orange: #d35400; --accent-blue: #2980b9; --accent-green: #27ae60; --accent-red: #c0392b; --accent-purple: #8e44ad; }
html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
body { font-family: 'Arial', sans-serif; background-color: #3d2c21; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; padding: 10px; }
#game-container { width: 100%; max-width: 450px; height: 800px; max-height: 95vh; background-color: var(--parchment); border: 5px solid var(--dark-wood); border-radius: 15px; box-shadow: 0 10px 20px rgba(0,0,0,0.3); text-align: center; display: flex; flex-direction: column; overflow: hidden; }
.screen { display: none; flex-direction: column; height: 100%; padding: 15px; overflow-y: auto; }
.screen.active { display: flex; }
.btn { background-color: var(--accent-orange); color: white; padding: 15px 30px; border: none; border-radius: 10px; font-size: 1.2em; cursor: pointer; transition: background-color 0.3s; margin-top: 20px; }
.btn:hover { filter: brightness(1.1); }
.btn-secondary { background-color: var(--dark-wood); color: white; font-size: 1em; padding: 12px 24px; }

/* Pantalla de Inicio */
.start-header { display: flex; justify-content: center; align-items: center; gap: 20px; margin-bottom: 15px; }
.header-sprite { width: 50px; height: 50px; }
.lore-box { background-color: var(--parchment-dark); border: 2px dashed var(--light-wood); padding: 10px; border-radius: 10px; margin-bottom: 15px; font-size: 0.9em; }
.lore-box h2 { margin-top: 0; font-size: 1.2em; }
.lore-box a { color: var(--dark-wood); font-weight: bold; }
.start-controls {
    margin-bottom: 10px;
    display: flex; /* Activa Flexbox */
    flex-direction: column; /* Apila los elementos verticalmente */
    align-items: center; /* Centra los elementos horizontalmente */
    gap: 5px; /* Añade un espacio de 10px entre los botones */
}
/* MODIFICADO: Ajuste para que quepan 4 opciones cómodamente */
#operations-selection { margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; justify-content: center; gap: 10px; font-size: 1em; }
.error-message { color: var(--accent-red); height: 20px; font-weight: bold; }
.high-score-box { margin-top: 20px; font-size: 0.9em; }
#high-score-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
#high-score-table th, #high-score-table td { border: 1px solid var(--light-wood); padding: 5px; }
#high-score-table th { background-color: #e4d5b7; }

/* Pantalla de Nombre */
#name-entry-screen { justify-content: center; }
#player-initial-name-input { padding: 10px; font-size: 1.2em; border: 2px solid var(--light-wood); border-radius: 5px; width: 90%; max-width: 400px; text-align: center; margin-bottom: 20px; }
.navigation-buttons { display: flex; justify-content: center; gap: 15px; margin-top: 15px; }

/* Pantalla de Combate */
#combat-screen { padding: 0; position: relative; justify-content: flex-start; }
#enemy-background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: contain; background-repeat: no-repeat; background-position: center 60%; z-index: 0; transition: all 0.5s ease; }
#enemy-background::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to top, rgba(0,0,0,0.7) 20%, rgba(0,0,0,0.2) 60%, rgba(0,0,0,0.7) 100%); }
.combat-hud, #timer-bar-container, .combat-main, .combat-controls { position: relative; z-index: 1; width: 100%; }
.combat-hud { display: flex; justify-content: space-between; padding: 10px; color: white; text-shadow: 1px 1px 2px black; }
.hud-panel { display: flex; flex-direction: column; align-items: center; background-color: rgba(0,0,0,0.5); border-radius: 8px; padding: 8px; font-size: 0.9em; min-height: 110px; }
.hud-left, .hud-right { width: 38%; }
.hud-center { width: 20%; justify-content: center; font-size: 0.8em; }
.hud-center div:first-child { font-weight: bold; font-size: 1.1em; }
.hud-panel h2 { margin: 0 0 5px 0; font-size: 1.2em; word-break: break-word; line-height: 1.1; height: 2.2em; display: flex; align-items: center; justify-content: center; }
.health-bar { width: 100%; height: 18px; background-color: #555; border: 1px solid #999; border-radius: 5px; overflow: hidden; margin-bottom: 5px; }
.health-fill { height: 100%; transition: width 0.5s ease-in-out; }
#player-health-fill { background-color: var(--accent-green); }
#enemy-health-fill { background-color: var(--accent-red); }
.stat-line { margin-top: 3px; display: flex; align-items: center; justify-content: center; width: 100%; }
.btn-tiny { padding: 2px 6px; font-size: 0.8em; margin-left: 5px; background-color: var(--accent-green); color: white; border: none; border-radius: 3px; cursor: pointer; }
.btn-tiny:disabled { background-color: #7f8c8d; }
#timer-bar-container { padding: 0 10px; margin: 10px 0; position: relative; }
#timer-bar { width: 100%; height: 20px; background-color: var(--accent-blue); border-radius: 10px; transition: width 0.1s linear; border: 1px solid rgba(255,255,255,0.5); }
#timer-text { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: white; font-weight: bold; text-shadow: 1px 1px 2px black; }
.combat-main { flex-grow: 1; display: flex; justify-content: center; align-items: center; }
#problem-area { background-color: rgba(0,0,0,0.6); padding: 15px 20px; border-radius: 10px; color: white; text-shadow: 1px 1px 2px black; }
#problem-area h2 { margin: 0; font-size: 2em; }
.combat-controls { padding: 15px; margin-top: auto; }
#answer-area { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#answer-area .btn { width: 100%; margin: 0; font-size: 1.1em; padding: 15px 10px; background-color: var(--accent-blue); }

/* Animaciones de Combate */
.shake { animation: shake 0.5s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
#enemy-background.defeated { animation: fadeOut 0.8s forwards; }
@keyframes fadeOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.5) rotate(-15deg); } }
#floating-score { position: absolute; top: 50%; left: 50%; transform: translateX(-50%); font-size: 2.5em; font-weight: bold; color: #f1c40f; text-shadow: 2px 2px #c0392b; pointer-events: none; opacity: 0; z-index: 10; }
#floating-score.show { animation: floatUp 1s forwards; }
@keyframes floatUp { 0% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -100px); } }
#combo-display { position: absolute; bottom: 25%; left: 50%; transform: translateX(-50%); font-size: 1.8em; font-weight: bold; color: var(--accent-orange); text-shadow: 1px 1px 2px white; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
#combo-display.show { opacity: 1; }

/* Pantallas de Recompensa y Fin de Juego */
#perk-screen, #game-over-screen, #victory-screen, #boss-victory-screen { justify-content: center; }
#skill-selection { display: flex; flex-direction: column; align-items: center; gap: 15px; margin-top: 20px; width: 100%; }
.skill-btn { width: 90%; max-width: 350px; background-color: var(--accent-purple); display: flex; align-items: center; justify-content: center; gap: 10px; }
.skill-btn span { font-size: 1.5em; }
.save-score-form { margin-top: 20px; width: 100%; }
#game-over-player-name-input, #victory-player-name-input { padding: 10px; font-size: 1em; border: 2px solid var(--light-wood); border-radius: 5px; width: 80%; }
.boss-victory-text { font-size: 1.1em; margin: 15px 0; }
.boss-victory-heal { font-size: 1.3em; font-weight: bold; color: var(--accent-green); animation: pulse 1.5s infinite; }
.end-screen-sprite { margin-bottom: 20px; }

/* Estilos para el checkbox de adulto */
.adult-check-container {
    margin: 15px 0;
    padding: 10px;
    background-color: var(--parchment-dark);
    border-radius: 8px;
    display: inline-block;
}
.adult-check-container label {
    font-size: 0.9em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
#is-adult-checkbox {
    width: 18px;
    height: 18px;
}

/* Estilos para las pestañas del Salón de la Fama */
.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}
.tab-btn {
    padding: 8px 16px;
    font-size: 1em;
    border: 2px solid var(--dark-wood);
    background-color: var(--light-wood);
    color: white;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: none;
}
.tab-btn.active {
    background-color: var(--parchment-dark);
    color: var(--dark-wood);
    font-weight: bold;
    transform: translateY(2px);
}
.tab-btn:not(.active):hover {
    filter: brightness(1.2);
}