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

body {
    font-family: Arial, sans-serif;
    background-color: #2c3e50;
    overflow: hidden;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Status Bar */
#statusBar {
    background-color: #34495e;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #2c3e50;
    min-height: 60px;
}

#blueTeamInfo {
    background-color: #3498db;
}

#redTeamInfo {
    background-color: #e74c3c;
}

.team-info {
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    user-select: none;
}

.team-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-weight: bold;
}

.gold-icon {
    width: 20px;
    height: 20px;
}

.battle-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.battle-btn:hover {
    background-color: #c0392b;
}

.battle-btn.active {
    background-color: #27ae60;
}

.clear-btn {
    background-color: #95a5a6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.clear-btn:hover {
    background-color: #7f8c8d;
}

/* Game Canvas */
#gameCanvas {
    background-color: #2c3e50;
    border: 2px solid #34495e;
    flex: 1;
    cursor: crosshair;
}

/* Unit Bar */
#unitBar {
    background-color: #34495e;
    padding: 15px 20px;
    border-top: 3px solid #2c3e50;
    min-height: 120px;
    max-width: 100%;
    overflow-x: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.team-switch-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background-color 0.3s;
}

.team-switch-btn:hover {
    background-color: #2980b9;
}

.unit-types {
    display: flex;
    flex-direction: row;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: #bdc3c7 #ecf0f1;
    position: relative;
}

/* Custom scrollbar for webkit browsers */
.unit-types::-webkit-scrollbar {
    height: 8px;
}

.unit-types::-webkit-scrollbar-track {
    background: #ecf0f1;
    border-radius: 4px;
}

.unit-types::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

.unit-types::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* Fade effect on edges to indicate scrollability */
.unit-types::before,
.unit-types::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    z-index: 1;
}


.unit-type {
    background-color: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    padding: 10px;
    width: 120px;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    flex-shrink: 0;
    white-space: normal;
}

.unit-type:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.unit-type.selected {
    border-color: #e74c3c;
    background-color: #fdf2f2;
}

.unit-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.unit-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #2c3e50;
    font-weight: bold;
}

.unit-stat img {
    width: 16px;
    height: 16px;
}

.unit-img {
    width: 50px;
    height: 70px;
    margin-bottom: auto;
    margin-top: auto;
}

.unit-info {
    display: flex;
    flex-direction: row;
    gap: 5px;
}

.unit-type:hover {
    opacity: 1;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 12px;
}

.stat-row img {
    width: 16px;
    height: 16px;
}

/* Responsive design for very wide screens */
@media (min-width: 1400px) {
    .unit-types {
        max-width: 1200px;
        margin: 0 auto;
    }
}

@media (min-width: 1800px) {
    .unit-types {
        max-width: 1400px;
    }
}

/* Popup */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.popup.hidden {
    display: none;
}

.popup-content {
    background-color: #34495e;
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    border: 3px solid #2c3e50;
}

.popup-content h2 {
    margin-bottom: 15px;
    color: #e74c3c;
}

.close-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 20px;
    font-size: 16px;
    transition: background-color 0.3s;
}

.close-btn:hover {
    background-color: #2980b9;
}

/* Life Bar */
.life-bar {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 6px;
    background-color: #e74c3c;
    border: 1px solid #2c3e50;
    border-radius: 3px;
    overflow: hidden;
}

.life-bar-fill {
    height: 100%;
    background-color: #27ae60;
    transition: width 0.3s;
}

/* Unit Generation Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #34495e;
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 3px solid #2c3e50;
}

.modal-header {
    background-color: #2c3e50;
    padding: 20px;
    border-radius: 9px 9px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: white;
    margin: 0;
    font-size: 24px;
}

.modal-header .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.modal-header .close-btn:hover {
    background-color: #e74c3c;
}

.modal-body {
    padding: 30px;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    color: white;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 16px;
}

.input-group input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #3498db;
    border-radius: 6px;
    background-color: white;
    color: #2c3e50;
    font-size: 14px;
    cursor: pointer;
}

.input-group input[type="file"]:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.input-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #3498db;
    border-radius: 6px;
    background-color: white;
    color: #2c3e50;
    font-size: 14px;
    font-family: Arial, sans-serif;
    resize: vertical;
    min-height: 80px;
}

.input-group textarea:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.image-preview {
    margin-top: 15px;
    text-align: center;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #3498db;
    border-radius: 6px;
    background-color: #ecf0f1;
}

.image-preview img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.image-preview.empty {
    color: #7f8c8d;
    font-style: italic;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.generate-btn {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
    min-width: 150px;
}

.generate-btn:hover {
    background-color: #229954;
}

.generate-btn:disabled {
    background-color: #7f8c8d;
    cursor: not-allowed;
}

.cancel-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
    min-width: 100px;
}

.cancel-btn:hover {
    background-color: #c0392b;
}

.status-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    min-height: 20px;
}

.status-message.success {
    background-color: #d5f4e6;
    color: #27ae60;
    border: 1px solid #27ae60;
}

.status-message.error {
    background-color: #fadbd8;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.status-message.loading {
    background-color: #d6eaf8;
    color: #3498db;
    border: 1px solid #3498db;
}

/* Add Unit Button */
.add-unit-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #27ae60;
    color: white;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
    z-index: 3000;
}

.add-unit-btn:hover {
    background-color: #229954;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.add-unit-btn:active {
    transform: scale(0.95);
}
