* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

:root{
    --ui-padding: clamp(8px, 1.2vw, 20px);
    --ui-radius: 12px;
    --small-font: clamp(12px, 1.1vw, 14px);
    --base-font: clamp(14px, 1.2vw, 16px);
    --large-font: clamp(18px, 2.4vw, 28px);
}

.container {
    width: 100%;
    height: 100vh;
    background: white;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    text-align: center;
    flex-shrink: 0;
    z-index: 100;
    display: none;
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 0.9em;
    opacity: 0.9;
}

/* Pantallas */
.screen {
    display: none;
    padding: 0;
    min-height: 0;
    animation: fadeIn 0.5s ease-in;
    width: 100%;
    height: 100%;
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

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

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

/* Pantalla de Inicio */
#startScreen {
    text-align: center;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
}

#startScreen h2 {
    font-size: 2.5em;
    margin-bottom: 15px;
    color: #667eea;
}

#startScreen > p {
    font-size: 1.2em;
    margin-bottom: 40px;
    color: #666;
}

.character-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 20px;
    max-width: 900px;
}

.character-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 3px solid #667eea;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.character-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.character-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.character-card h3 {
    font-size: 1.3em;
    margin-bottom: 8px;
}

.character-card p {
    font-size: 0.9em;
    margin-bottom: 10px;
    opacity: 0.8;
}

.stats {
    display: block;
    font-size: 0.8em;
    margin-top: 10px;
    font-weight: bold;
}

/* Pantalla de Batalla */
.battle-info {
    text-align: center;
    margin: 0 auto;
    position: absolute;
    top: var(--ui-padding);
    left: var(--ui-padding);
    right: var(--ui-padding);
    z-index: 60;
    background: rgba(0, 0, 0, 0.45);
    padding: calc(var(--ui-padding) / 1.2);
    color: white;
    border-radius: calc(var(--ui-radius) / 2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.battle-info h2 {
    color: white;
    margin: 0;
    font-size: var(--large-font);
}

.battle-info p {
    font-size: var(--small-font);
    margin: 0;
}

.view-toggle {
    display: flex;
    gap: 8px;
}

.view-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: var(--small-font);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.view-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    transform: translateY(-1px);
}

.view-btn:hover {
    background: rgba(255,255,255,0.25);
}

#battleScreen {
    position: relative;
    overflow: hidden;
}

.battle-arena-3d {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    position: absolute;
    top: 0;
    left: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    overflow: hidden;
}

.battle-arena-3d.hidden {
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.battle-arena-2d {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: none;
    background: radial-gradient(circle at top, rgba(102, 126, 234, 0.35), rgba(10, 12, 30, 0.95));
    z-index: 10;
    pointer-events: none;
}

.battle-arena-2d.active {
    display: block;
}

.battle-info-overlay {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 0;
    position: absolute;
    bottom: 110px;
    left: var(--ui-padding);
    right: var(--ui-padding);
    z-index: 50;
    padding: calc(var(--ui-padding) / 1.1);
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.72) 100%);
}

.character-section {
    background: rgba(0, 0, 0, 0.55);
    padding: 10px;
    border-radius: calc(var(--ui-radius) / 1.3);
    border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(4px);
    min-width: 220px;
    max-width: 48%;
}

.player-section {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
}

.enemy-section {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.2);
}

.character-display {
    display: flex;
    gap: 12px;
    align-items: center;
}

.character-icon-large {
    font-size: 3em;
    min-width: 60px;
    text-align: center;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.character-info {
    flex: 1;
}

.character-info h3 {
    font-size: 1em;
    margin-bottom: 5px;
    color: white;
}

.stat-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
}

.stat-label {
    font-weight: bold;
    min-width: 25px;
    font-size: 0.75em;
    color: white;
}

.progress-bar {
    flex: 1;
    height: 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #667eea;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #81c784);
    width: 100%;
    transition: width 0.5s ease;
}

.stats-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    font-weight: bold;
    color: #ccc;
    gap: 5px;
}

.stats-display span {
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Battle Log */
.battle-log {
    display: none;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #667eea;
    border-radius: calc(var(--ui-radius) / 1.2);
    padding: calc(var(--ui-padding) / 1.1);
    margin-bottom: 0;
    max-height: clamp(80px, 18vh, 160px);
    overflow-y: auto;
    position: absolute;
    bottom: calc(var(--ui-padding) + 70px);
    left: calc(var(--ui-padding) + 5px);
    right: calc(var(--ui-padding) + 5px);
    z-index: 55;
    backdrop-filter: blur(6px);
}

.battle-log h4 {
    margin-bottom: 8px;
    color: #667eea;
    font-size: 0.85em;
}

.log-content {
    font-size: 0.8em;
    color: #ccc;
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideIn 0.3s ease;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.damage {
    color: #ff6b6b;
}

.log-entry.heal {
    color: #4caf50;
}

.log-entry.info {
    color: #667eea;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Acciones */
.actions {
    display: flex;
    gap: 10px;
    position: absolute;
    bottom: 20px;
    left: var(--ui-padding);
    right: var(--ui-padding);
    z-index: 60;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
}

.action-btn {
    padding: 10px 12px;
    font-size: var(--small-font);
    border: none;
    border-radius: calc(var(--ui-radius) / 1.2);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    font-weight: 700;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: white;
    min-width: 80px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.action-btn:focus {
    outline: 2px solid rgba(255,255,255,0.12);
    transform: translateY(-3px);
}

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

.btn-text {
    font-size: 0.75em;
}

.attack-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
}

.attack-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.skill-btn {
    background: linear-gradient(135deg, #ffd93d 0%, #ffb72c 100%);
    color: #333;
}

.skill-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 217, 61, 0.4);
}

.heal-btn {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
}

.heal-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.defend-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.defend-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Pantalla de Fin */
#gameOverScreen {
    text-align: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    justify-content: center;
    align-items: center;
}

#gameOverContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 40px;
    border-radius: 20px;
    border: 3px solid #667eea;
    backdrop-filter: blur(10px);
}

#gameOverTitle {
    font-size: 3em;
    margin-bottom: 30px;
    color: #667eea;
    text-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

.game-over-stats {
    background: rgba(102, 126, 234, 0.1);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    border: 2px solid #667eea;
    min-width: 350px;
}

.game-over-stats p {
    font-size: 1.2em;
    margin: 12px 0;
    color: white;
}

#gameOverScreen .action-btn {
    padding: 20px 40px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Responsive */
@media (max-width: 992px) {
    header h1 { font-size: clamp(16px, 3vw, 22px); }
    .battle-info { flex-direction: column; gap: 8px; align-items: flex-start; }
    .battle-info h2 { font-size: clamp(16px, 3.2vw, 22px); }
}

@media (max-width: 720px) {
    .battle-info { left: 8px; right: 8px; padding: 8px; }
    .battle-info h2 { font-size: var(--base-font); }
    .battle-info p { font-size: var(--small-font); }

    .battle-info-overlay { padding: 10px; gap: 8px; }
    .character-section { min-width: 140px; max-width: 48%; }

    .actions { left: 8px; right: 8px; gap: 8px; }
    .action-btn { min-width: 68px; padding: 8px 10px; font-size: 12px; }

    .battle-log { left: 8px; right: 8px; bottom: 110px; max-height: 90px; }
}

@media (max-width: 420px) {
    .battle-info { top: 6px; left: 6px; right: 6px; }
    .action-btn { min-width: 60px; font-size: 11px; }
    .character-section { min-width: 120px; max-width: 100%; }
    .battle-info-overlay { flex-direction: column-reverse; align-items: stretch; }
}
