/* Responsive adjustments */
@media (max-width: 768px) {
    #battle-log {
        width: 90%;
        max-width: 400px;
        height: 180px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    #fighter-selection {
        width: 95%;
        padding: 1.5rem;
    }
    
    .stats-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .vs-indicator {
        margin: 5px 0;
    }
    
    #battle-stats {
        padding: 8px;
        top: 60px;
    }
    
    .action-buttons {
        flex-wrap: wrap;
        width: 90%;
        max-width: 400px;
        margin-top: 5px;
        position: relative;
        top: auto;
    }
    
    .battle-timer {
        bottom: -35px;
        font-size: 18px;
        padding: 6px 12px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    #header {
        padding: 0.7rem;
    }
    
    #fighter-creation, #fighter-selection, #battle-controls {
        width: 95%;
        padding: 1.5rem;
    }
    
    .fighter-name-input, .stat {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .fighter-name-input label, .stat label {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .ability-buttons {
        justify-content: center;
    }
    
    .ability-button {
        min-width: 100px;
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .battle-stat-row {
        font-size: 0.8rem;
        padding: 3px;
    }
    
    .fighter-battle-stats {
        padding: 6px;
    }
}

@media (max-width: 480px) {
    #battle-log {
        width: 95%;
        height: 150px;
        font-size: 0.9rem;
    }
    
    .action-button {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    #fighter-list {
        grid-template-columns: 1fr;
    }
    
    .battle-timer {
        font-size: 16px;
        padding: 5px 10px;
        bottom: -30px;
    }
    
    #menu-button {
        width: 40px;
        height: 40px;
    }
    
    #menu-button i {
        font-size: 1.2rem;
    }
    
    .fighter-battle-stats h3 {
        font-size: 0.9rem;
        margin-bottom: 4px;
    }
    
    .stat-bar-container {
        height: 14px;
    }
    
    .stat-bar-container span {
        font-size: 0.7rem;
    }
    
    #summary-title {
        font-size: 1.8rem;
    }
    
    .fighter-results {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .player-result, .opponent-result {
        width: 100%;
    }
    
    .summary-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .battle-stat {
        margin-bottom: 4px;
    }
    
    .stat-label {
        min-width: 50px;
        font-size: 0.75rem;
    }
    
    .vs-indicator {
        font-size: 1rem;
        width: 30px;
    }
    
    .vs-indicator::before,
    .vs-indicator::after {
        width: 10px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) {
    button, .action-button, .fighter-card, .ability-button {
        padding: 12px 20px;
    }
    
    .stat input[type="range"] {
        height: 20px;
    }
    
    .stat input[type="range"]::-webkit-slider-thumb {
        width: 25px;
        height: 25px;
    }
    
    input[type="text"] {
        font-size: 16px;
    }
}

/* Ensure modals are properly centered and sized on all devices */
#battle-summary, #fighter-selection, #training-grounds {
    max-height: 90vh;
    overflow-y: auto;
}

/* Improve scrolling experience */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 20, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #4040ff;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #60f0ff;
}

/* Ensure content is accessible when virtual keyboard appears on mobile */
@media (max-height: 600px) {
    #fighter-creation, #fighter-selection {
        top: 0;
        transform: translate(-50%, 0);
        margin-top: 10px;
        max-height: 95vh;
    }
}

/* Prevent text selection for interactive elements */
button, .fighter-card, .action-button, .ability-button {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure proper spacing for battle controls on smaller screens */
@media (max-width: 768px) {
    #battle-controls {
        margin-top: 180px;
    }
}

/* Landscape mode optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    #battle-stats {
        position: absolute;
        top: 50px;
        padding: 5px;
    }
    
    .stats-container {
        flex-direction: row;
        gap: 5px;
    }
    
    .fighter-battle-stats {
        padding: 5px;
    }
    
    .battle-stat {
        margin-bottom: 3px;
    }
    
    .battle-stat-row {
        margin-top: 3px;
        padding: 2px;
    }
    
    .vs-indicator {
        width: 30px;
        font-size: 1rem;
    }
    
    .action-buttons {
        margin-top: 3px;
        padding: 5px;
    }
    
    .battle-timer {
        bottom: -25px;
        font-size: 14px;
        padding: 4px 8px;
    }
}
