/* ===========================
   Variables y Reset
   =========================== */
:root {
    --primary-color: #8B4513;
    --secondary-color: #D2691E;
    --gold-color: #FFD700;
    --stone-color: #696969;
    --grass-color: #228B22;
    --sky-color: #87CEEB;
    --victory-color: #4CAF50;
    --defeat-color: #F44336;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background: linear-gradient(to bottom, var(--sky-color) 0%, #B0E0E6 100%);
    height: 100vh;
    user-select: none;
}

/* ===========================
   Pantallas Generales
   =========================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    background: linear-gradient(to bottom, #87CEEB 0%, #B0E0E6 70%, var(--grass-color) 100%);
}

.screen.hidden {
    display: none;
}

/* ===========================
   Pantalla de Inicio
   =========================== */
.menu-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 4px solid var(--primary-color);
    max-width: 500px;
}

.game-title {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-shadow: 3px 3px 0 var(--secondary-color);
    animation: titleBounce 2s infinite;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.subtitle {
    font-size: 1.2rem;
    color: var(--stone-color);
    margin-bottom: 2rem;
}

/* Botones */
.btn-primary, .btn-secondary, .btn-control {
    font-size: 1.3rem;
    padding: 1rem 2rem;
    margin: 0.5rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: var(--shadow);
    display: inline-block;
    min-width: 200px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

.btn-secondary {
    background: var(--stone-color);
    color: white;
}

.btn-secondary:hover {
    background: #808080;
    transform: scale(1.05);
}

.btn-control {
    background: rgba(139, 69, 19, 0.9);
    color: white;
    font-size: 1rem;
    padding: 0.7rem 1.5rem;
    min-width: auto;
}

.btn-control:hover {
    background: rgba(210, 105, 30, 0.9);
}

.btn-primary:active, .btn-secondary:active, .btn-control:active {
    transform: scale(0.95);
}

/* ===========================
   Responsive Mobile
   =========================== */

/* Landscape mobile - diseño compacto */
@media (orientation: landscape) and (max-height: 600px) {
    body {
        padding: 5px;
    }
    
    .hud {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .hud-item {
        padding: 3px 8px;
    }
    
    .hud-label {
        font-size: 0.75rem;
    }
    
    .hud-value {
        font-size: 0.9rem;
    }
    
    .destruction-bar-container {
        height: 12px;
        margin: 3px 0;
    }
    
    .shop-panel {
        padding: 3px;
        font-size: 0.6rem;
        top: 50px;
        left: 3px;
        right: auto;
        max-width: 70px;
        border: 2px solid var(--gold-color);
    }
    
    .shop-title {
        font-size: 0.6rem;
        margin-bottom: 2px;
    }
    
    .shop-items {
        gap: 3px;
        margin-bottom: 3px;
    }
    
    .shop-btn {
        padding: 2px 3px;
        min-width: auto;
        border: 1px solid var(--gold-color);
    }
    
    .projectile-icon {
        font-size: 0.9rem;
        margin-bottom: 1px;
    }
    
    .projectile-name {
        font-size: 0.55rem;
    }
    
    .projectile-price, .projectile-stock {
        font-size: 0.5rem;
        margin-top: 0;
    }
    
    .current-projectile {
        font-size: 0.5rem;
        padding: 2px 3px;
        padding-top: 3px;
        border-top: 1px solid var(--gold-color);
    }
    
    .game-controls {
        bottom: 5px;
    }
    
    .btn-control {
        font-size: 0.8rem;
        padding: 6px 12px;
        min-width: auto;
    }
    
    .menu-container, .tutorial-container, .result-container, .records-container {
        padding: 1.5rem;
        max-width: 90vw;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .btn-primary, .btn-secondary {
        font-size: 1rem;
        padding: 0.6rem 1.5rem;
        min-width: 150px;
    }
    
    .tutorial-step h3 {
        font-size: 1rem;
    }
    
    .tutorial-step p {
        font-size: 0.85rem;
    }
}

/* Portrait mobile - mostrar mensaje de rotación */
@media (orientation: portrait) and (max-width: 768px) {
    #rotateMessage {
        display: flex !important;
    }
}

/* ===========================
   Pantalla de Tutorial
   =========================== */
.tutorial-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 4px solid var(--primary-color);
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.tutorial-container h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.5rem;
}

.tutorial-content {
    text-align: left;
    margin-bottom: 2rem;
}

.tutorial-step {
    background: rgba(135, 206, 235, 0.2);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 10px;
    border-left: 5px solid var(--primary-color);
}

.tutorial-step h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.tutorial-step p {
    color: #333;
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0.5rem 0;
}

.tutorial-step strong {
    color: var(--primary-color);
}

/* ===========================
   Pantalla de Juego
   =========================== */
#gameScreen {
    background: none;
    overflow: hidden;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* HUD */
.hud {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 10;
}

.hud-left, .hud-right {
    display: flex;
    gap: 20px;
}

.hud-item {
    background: rgba(139, 69, 19, 0.9);
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
}

.hud-label {
    margin-right: 5px;
}

.hud-value {
    color: var(--gold-color);
}

/* Barra de Destrucción */
.destruction-bar-container {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    z-index: 10;
}

.destruction-bar {
    width: 100%;
    height: 30px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    overflow: hidden;
    border: 3px solid var(--primary-color);
}

.destruction-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FF6B6B 0%, #FFD700 50%, #4CAF50 100%);
    transition: width 0.5s ease;
    border-radius: 12px;
}

/* Tienda de Proyectiles */
.shop-panel {
    position: absolute;
    top: 120px;
    right: 20px;
    background: rgba(139, 69, 19, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: var(--shadow);
    z-index: 10;
    border: 3px solid var(--gold-color);
}

.shop-title {
    color: var(--gold-color);
    font-size: 1.3rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.shop-btn {
    background: rgba(210, 105, 30, 0.9);
    border: 3px solid var(--gold-color);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: white;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

.shop-btn:hover:not(:disabled) {
    background: rgba(255, 140, 0, 0.9);
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--gold-color);
}

.shop-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.shop-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.projectile-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.projectile-name {
    font-size: 1.1rem;
    margin-bottom: 3px;
}

.projectile-price {
    font-size: 1rem;
    color: var(--gold-color);
}

.projectile-stock {
    font-size: 0.9rem;
    color: #ADD8E6;
    margin-top: 3px;
}

.current-projectile {
    text-align: center;
    color: white;
    font-size: 1rem;
    padding-top: 10px;
    border-top: 2px solid var(--gold-color);
}

.current-projectile span:last-child {
    color: var(--gold-color);
    font-weight: bold;
}

/* Controles del Juego */
.game-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

/* ===========================
   Pantallas de Victoria/Derrota
   =========================== */
.result-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 500px;
}

.result-container.victory {
    border: 5px solid var(--victory-color);
}

.result-container.defeat {
    border: 5px solid var(--defeat-color);
}

.result-title {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.victory .result-title {
    color: var(--victory-color);
    animation: victoryPulse 1s infinite;
}

.defeat .result-title {
    color: var(--defeat-color);
}

@keyframes victoryPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.result-stats {
    background: rgba(135, 206, 235, 0.2);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    text-align: left;
}

.result-stats p {
    font-size: 1.2rem;
    margin: 0.7rem 0;
    color: #333;
}

.result-stats strong {
    color: var(--primary-color);
    font-size: 1.3rem;
}

.total-gold {
    border-top: 2px solid var(--primary-color);
    padding-top: 0.7rem;
    margin-top: 0.7rem;
}

.total-gold strong {
    color: var(--gold-color);
    font-size: 1.5rem;
}

.defeat-message {
    color: var(--defeat-color);
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
}

/* ===========================
   Pantalla de Records
   =========================== */
.records-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 4px solid var(--gold-color);
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.records-container h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.5rem;
}

.records-list {
    margin-bottom: 2rem;
}

.record-item {
    background: rgba(135, 206, 235, 0.2);
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 10px;
    border-left: 5px solid var(--gold-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.record-rank {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    min-width: 40px;
}

.record-info {
    flex: 1;
    margin: 0 1rem;
}

.record-player {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.record-details {
    font-size: 0.9rem;
    color: #666;
}

.record-score {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gold-color);
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .menu-container, .tutorial-container, .result-container, .records-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .hud {
        flex-direction: column;
        gap: 5px;
        padding: 10px;
    }
    
    .hud-left, .hud-right {
        gap: 5px;
    }
    
    .hud-item {
        font-size: 0.9rem;
        padding: 5px 10px;
    }
    
    .shop-panel {
        top: auto;
        bottom: 10px;
        right: 10px;
        left: auto;
        padding: 5px;
        max-width: 180px;
    }
    
    .shop-title {
        font-size: 0.8rem;
        margin-bottom: 5px;
    }
    
    .shop-items {
        flex-direction: row;
        justify-content: space-around;
        gap: 5px;
    }
    
    .shop-btn {
        min-width: 70px;
        padding: 5px;
        font-size: 0.7rem;
    }
    
    .projectile-icon {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }
    
    .game-controls {
        bottom: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn-control {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
    
    .destruction-bar-container {
        width: 200px;
    }
}

/* ===========================
   Animaciones y Efectos
   =========================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s;
}

/* Efectos de partículas y polvo se manejan con Matter.js */
