/* ============================================
   RISE OF CASTLES - BATTLE SIMULATOR
   Mobile-First Responsive Design
   ============================================ */

/* ===== CSS RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== ROOT VARIABLES ===== */
:root {
    /* Colors */
    --primary: #ff6b35;
    --primary-dark: #e55a2a;
    --secondary: #004e89;
    --secondary-dark: #003a6b;
    
    --attacker: #ff4444;
    --attacker-light: #ff6666;
    --defender: #4488ff;
    --defender-light: #6699ff;
    
    --bg-dark: #1a1a1a;
    --bg-medium: #2a2a2a;
    --bg-light: #3a3a3a;
    --bg-card: #2d2d2d;
    
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    
    --border: #444444;
    --shadow: rgba(0, 0, 0, 0.3);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ===== BASE STYLES ===== */
body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0a0a0a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: var(--spacing-md);
    line-height: 1.6;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 100%;
    margin: 0 auto;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px var(--shadow);
}

.header h1 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--spacing-sm);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 300;
}

/* ===== BATTLE SETUP ===== */
.battle-setup {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* ===== SIDE SECTIONS ===== */
.side {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: 0 4px 20px var(--shadow);
}

.side-title {
    font-size: 1.3rem;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.attacker-title {
    color: var(--attacker);
}

.defender-title {
    color: var(--defender);
}

.icon {
    font-size: 1.5rem;
}

/* ===== SQUAD ROW ===== */
.squad-row {
    background: var(--bg-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.row-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.clear-btn:hover {
    background: #ff4444;
    border-color: #ff4444;
    color: white;
}

/* ===== INPUT GROUPS ===== */
.squad-inputs {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== FORM CONTROLS ===== */
select,
input[type="number"] {
    width: 100%;
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-family);
    transition: all 0.2s;
    min-height: 44px; /* Touch-friendly */
}

select:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

/* ===== HERO STATS ===== */
.hero-stats {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: none;
}

.hero-stats.visible {
    display: block;
}

.hero-stats .stat-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
}

.hero-stats .stat-label {
    color: var(--text-secondary);
}

.hero-stats .stat-value {
    color: var(--primary);
    font-weight: 600;
}

/* ===== VS DIVIDER ===== */
.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md) 0;
}

.vs-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    background: var(--bg-card);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 10px var(--shadow);
}

/* ===== ACTION BUTTONS ===== */
.actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.btn {
    flex: 1;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    min-height: 50px; /* Touch-friendly */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

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

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-medium);
    border-color: var(--primary);
}

/* ===== RESULTS SECTION ===== */
.results {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-top: var(--spacing-xl);
    box-shadow: 0 4px 20px var(--shadow);
}

.results-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: var(--spacing-lg);
    color: var(--primary);
}

.winner-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
}

.winner-icon {
    font-size: 2rem;
}

.winner-text {
    font-size: 1.3rem;
    font-weight: bold;
}

.results-summary {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.summary-card {
    flex: 1;
    background: var(--bg-light);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
}

.summary-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.summary-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary);
}

.results-details {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.detail-side {
    background: var(--bg-light);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
}

.detail-side h3 {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.detail-stats {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs);
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--primary);
}

/* ===== BATTLE LOG ===== */
.battle-log {
    background: var(--bg-dark);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.battle-log h3 {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.log-content {
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.log-content::-webkit-scrollbar {
    width: 8px;
}

.log-content::-webkit-scrollbar-track {
    background: var(--bg-medium);
    border-radius: var(--radius-sm);
}

.log-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: var(--radius-sm);
}

.log-entry {
    padding: var(--spacing-xs) 0;
    border-bottom: 1px solid var(--border);
}

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

.log-round {
    color: var(--primary);
    font-weight: bold;
    margin-top: var(--spacing-md);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: var(--spacing-lg);
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* ===== RESPONSIVE - TABLET (768px+) ===== */
@media (min-width: 768px) {
    body {
        padding: var(--spacing-lg);
    }
    
    .container {
        max-width: 1400px;
    }
    
    .header h1 {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.1rem;
    }
    
    .battle-setup {
        flex-direction: row;
        gap: var(--spacing-xl);
    }
    
    .side {
        flex: 1;
    }
    
    .vs-divider {
        flex-direction: column;
        padding: 0 var(--spacing-md);
    }
    
    .vs-text {
        writing-mode: vertical-rl;
        text-orientation: mixed;
    }
    
    .squad-inputs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-md);
    }
    
    .input-group:last-child {
        grid-column: 1 / -1;
    }
    
    .results-details {
        flex-direction: row;
    }
    
    .detail-side {
        flex: 1;
    }
}

/* ===== RESPONSIVE - DESKTOP (1024px+) ===== */
@media (min-width: 1024px) {
    .header h1 {
        font-size: 3rem;
    }
    
    .squad-inputs {
        grid-template-columns: 2fr 2fr 1fr;
    }
    
    .input-group:last-child {
        grid-column: auto;
    }
    
    .btn {
        font-size: 1.1rem;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}
