* {
    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;
    padding: 10px;
    padding-top: 70px; /* Space for fixed header */
}

@media (orientation: landscape) and (max-height: 600px) {
    body {
        padding: 55px 5px 5px 5px;
        align-items: flex-start;
    }
}

/* Header from header.js */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    background: rgba(0,0,0,0.15);
    backdrop-filter: blur(6px);
    z-index: 1100;
    gap: 10px;
    flex-wrap: nowrap;
}

.brand-mark {
    width: 36px;
    height: 36px;
    margin-right: 10px;
}

.app-title {
    font-family: 'Arial', sans-serif;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 0.5px;
    color: #fff;
    background: linear-gradient(135deg, #ffeb3b 0%, #ffffff 40%, #ffeb3b 60%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    flex: 0 0 auto;
}

.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 2px 6px;
    background: transparent;
    border: none;
    border-radius: 8px;
    flex-shrink: 1;
    max-width: 220px;
}

.lang-switcher label {
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.lang-switcher select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 4px 14px 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.85);
    color: #1f2937;
    font-weight: 600;
    font-size: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    cursor: pointer;
    max-width: 160px;
}

.lang-switcher select:focus {
    outline: 2px solid #ffeb3b;
    outline-offset: 2px;
}

.lang-switcher select:hover {
    background: #ffffff;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 15px;
    max-width: 1100px;
    width: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.header h1 {
    font-size: 1.6em;
    color: #667eea;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.back-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.6);
}

.game-info {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.info-item {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 10px 18px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    flex: 1;
    min-width: 100px;
}

.info-label {
    font-size: 0.95em;
    font-weight: bold;
    color: #555;
    display: block;
    margin-bottom: 3px;
}

.info-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
}

/* Botón de Lluvia de Flechas */
.arrow-rain-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: none;
    border-radius: 12px;
    padding: 10px 18px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    min-width: 140px;
}

.arrow-rain-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.6);
}

.arrow-rain-btn.active {
    background: linear-gradient(135deg, #FF4500 0%, #FF6347 100%);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.arrow-rain-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
}

.arrow-rain-icon {
    font-size: 1.5em;
    margin-bottom: 2px;
}

.arrow-rain-name {
    font-size: 0.85em;
    font-weight: bold;
    color: #333;
}

.arrow-rain-cost {
    font-size: 0.9em;
    color: #8B4513;
    font-weight: bold;
    margin-top: 2px;
}

.game-screen {
    position: relative;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 450px;
    cursor: pointer;
}

.start-screen, .game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.start-content, .game-over-content {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.start-content h2, .game-over-content h2 {
    font-size: 2em;
    color: #667eea;
    margin-bottom: 10px;
}

.start-content p {
    font-size: 1.05em;
    color: #555;
    margin-bottom: 12px;
}

.instructions {
    background: rgba(255, 255, 255, 0.7);
    padding: 15px;
    border-radius: 12px;
    margin: 12px 0;
    text-align: left;
}

.instructions h3 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 5px 0;
    font-size: 0.95em;
    color: #555;
}

.start-btn, .restart-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 35px;
    border-radius: 30px;
    font-size: 1.15em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    margin-top: 8px;
}

.start-btn:hover, .restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.hidden {
    display: none !important;
}

.tower-menu {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 12px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.tower-menu h3 {
    color: #667eea;
    margin-bottom: 10px;
    text-align: center;
    font-size: 1.15em;
}

.tower-menu-content {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.tower-buttons-wrapper {
    flex: 1;
    min-width: 0;
}

.tower-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.tower-btn {
    background: white;
    border: 3px solid #667eea;
    border-radius: 15px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

.tower-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    border-color: #764ba2;
}

.tower-btn.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
}

.tower-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tower-icon {
    font-size: 2em;
    margin-bottom: 5px;
}

.tower-name {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.tower-stats {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.tower-btn.selected .tower-stats {
    color: #fff;
}

.tower-cost {
    font-weight: bold;
    font-size: 1em;
    color: #f5576c;
}

.tower-btn.selected .tower-cost {
    color: #ffd700;
}

.upgrade-section {
    flex: 1;
    min-width: 250px;
    padding: 12px;
    border-left: 3px solid rgba(102, 126, 234, 0.5);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.upgrade-section h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
}

#selectedTowerInfo {
    background: white;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

.button-container {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-top: 12px;
}

.upgrade-btn, .sell-btn {
    flex: 1;
    padding: 14px 10px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.upgrade-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.6);
}

.upgrade-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sell-btn {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.sell-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(250, 112, 154, 0.6);
}

.upgrade-btn:disabled, .sell-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 968px) {
    body {
        padding-top: 65px;
    }

    .game-container {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.4em;
    }

    #gameCanvas {
        height: 380px;
    }
}

/* Landscape mobile - mantener diseño tipo desktop */
@media (orientation: landscape) and (max-height: 600px) {
    .game-container {
        padding: 8px;
        max-width: 100%;
        border-radius: 12px;
    }

    .header {
        margin-bottom: 6px;
    }

    .header h1 {
        font-size: 1.1em;
    }

    .back-btn {
        padding: 6px 14px;
        font-size: 0.85em;
    }

    .game-info {
        gap: 6px;
        margin-bottom: 6px;
    }

    .info-item {
        padding: 6px 12px;
        min-width: 85px;
    }

    .info-label {
        font-size: 0.75em;
        margin-bottom: 2px;
    }

    .info-value {
        font-size: 1.1em;
    }

    #gameCanvas {
        height: calc(100vh - 230px);
        min-height: 250px;
    }

    .game-screen {
        margin-bottom: 8px;
    }

    .tower-menu {
        padding: 8px;
    }

    .tower-menu h3 {
        font-size: 0.95em;
        margin-bottom: 6px;
    }

    .tower-buttons {
        gap: 8px;
    }

    .tower-btn {
        padding: 8px;
        min-width: 100px;
    }

    .tower-icon {
        font-size: 1.8em;
        margin-bottom: 4px;
    }

    .tower-name {
        font-size: 0.9em;
        margin-bottom: 3px;
    }

    .tower-stats {
        font-size: 0.75em;
        margin-bottom: 3px;
    }

    .tower-cost {
        font-size: 0.85em;
    }

    .upgrade-section {
        margin-top: 10px;
        padding-top: 10px;
    }

    .upgrade-section h3 {
        font-size: 0.95em;
        margin-bottom: 6px;
    }

    #selectedTowerInfo {
        padding: 8px;
        font-size: 0.85em;
        margin-bottom: 8px;
    }

    .upgrade-btn, .sell-btn {
        padding: 8px;
        font-size: 0.85em;
    }

    .start-content, .game-over-content {
        padding: 15px;
        margin: 5px;
        max-height: 90vh;
        max-width: 400px;
    }

    .start-content h2, .game-over-content h2 {
        font-size: 1.4em;
        margin-bottom: 6px;
    }

    .start-content p {
        font-size: 0.9em;
        margin-bottom: 8px;
    }

    .instructions {
        padding: 10px;
        margin: 8px 0;
    }

    .instructions h3 {
        font-size: 0.95em;
        margin-bottom: 6px;
    }

    .instructions li {
        font-size: 0.8em;
        padding: 3px 0;
    }

    .start-btn, .restart-btn {
        padding: 10px 25px;
        font-size: 0.95em;
    }
}

/* Portrait mobile - diseño vertical tradicional */
@media (orientation: portrait) and (max-width: 768px) {
    body {
        padding: 60px 5px 5px 5px;
    }

    .game-container {
        padding: 10px;
        border-radius: 15px;
    }

    .header h1 {
        font-size: 1.3em;
    }

    .back-btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    #gameCanvas {
        height: 320px;
    }

    .tower-buttons {
        gap: 10px;
    }

    .tower-btn {
        max-width: 100%;
        padding: 12px;
    }

    .start-content, .game-over-content {
        padding: 18px;
        margin: 10px;
        max-height: 80vh;
    }

    .start-content h2, .game-over-content h2 {
        font-size: 1.5em;
        margin-bottom: 8px;
    }

    .start-content p {
        font-size: 0.95em;
        margin-bottom: 10px;
    }

    .instructions {
        padding: 12px;
        margin: 10px 0;
    }

    .instructions h3 {
        font-size: 1em;
    }

    .instructions li {
        font-size: 0.85em;
        padding: 4px 0;
    }

    .start-btn, .restart-btn {
        padding: 10px 28px;
        font-size: 1em;
    }

    .info-item {
        min-width: 90px;
        padding: 8px 12px;
    }

    .info-label {
        font-size: 0.85em;
    }

    .info-value {
        font-size: 1.3em;
    }

    .tower-menu {
        padding: 12px;
    }

    .tower-menu h3 {
        font-size: 1.1em;
    }

    .tower-icon {
        font-size: 2em;
    }
}

@media (orientation: portrait) and (max-width: 480px) {
    body {
        padding: 55px 3px 3px 3px;
    }

    #gameCanvas {
        height: 280px;
    }

    .game-container {
        padding: 8px;
        border-radius: 12px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .header h1 {
        font-size: 1.2em;
    }

    .start-content, .game-over-content {
        padding: 15px;
        margin: 8px;
        max-height: 75vh;
    }

    .start-content h2, .game-over-content h2 {
        font-size: 1.3em;
    }

    .instructions {
        padding: 10px;
    }

    .upgrade-btn, .sell-btn {
        width: 100%;
        margin: 5px 0;
    }

    .tower-buttons {
        flex-direction: row;
        gap: 8px;
    }

    .tower-btn {
        min-width: 90px;
        padding: 10px 8px;
    }

    .tower-name {
        font-size: 0.95em;
    }

    .tower-stats {
        font-size: 0.8em;
    }
}
