body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #000;
}

@font-face {
    font-family: 'RPGAwesome';
    src: url('fonts/rpgawesome-webfont.eot');
    src: url('fonts/rpgawesome-webfont.eot?#iefix') format('embedded-opentype'),
        url('fonts/rpgawesome-webfont.woff') format('woff'),
        url('fonts/rpgawesome-webfont.ttf') format('truetype'),
        url('fonts/rpgawesome-webfont.svg#rpg-awesome') format('svg');
    font-weight: normal;
    font-style: normal;
}

.ra {
    font-family: 'RPGAwesome' !important;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas by default */
    display: flex;
    flex-direction: column;
}

/* UI Elements will enable pointer-events */
.ui-element {
    pointer-events: auto;
}

/* Selection Screen */
.selection-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 10;
    pointer-events: auto;
}

.generals-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
    overflow-y: auto;
    max-height: 80vh;
    padding: 20px;
}

.general-card {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 10px;
    padding: 10px;
    width: 200px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.general-card:hover {
    transform: scale(1.05);
    border-color: #ffd700;
}

.general-card img {
    width: 100%;
    height: auto;
    border-radius: 5px;
    margin-bottom: 10px;
}

.general-name {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 5px;
    color: #ffd700;
}

.general-bonus {
    font-size: 0.9em;
    color: #aaa;
}

/* HUD Top Left - General Info */
.general-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

.general-portrait {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #ffd700;
    object-fit: cover;
    object-position: top center;
    background: #000;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.general-name-hud {
    font-size: 1.5em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}


/* HUD Top Right - Buttons */
.hud-buttons-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
    z-index: 50;
}

.hud-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #666;
    color: white;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.hud-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: #ffd700;
    color: #ffd700;
    transform: scale(1.1);
}

.hud-btn.active {
    border-color: #ffd700;
    background: rgba(50, 50, 50, 0.9);
}

/* Request Panel - Top Right (Below Buttons) */
.requests-panel {
    position: absolute;
    top: 80px;
    /* Moved down below buttons */
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 5px;
    width: 250px;
    color: white;
    max-height: 400px;
    overflow-y: auto;
}

.requests-panel h3 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    text-align: center;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

.request-item {
    background: rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 4px;
    border-left: 3px solid #ff4444;
}

.request-item.completed {
    border-left-color: #00ff00;
    opacity: 0.7;
}

.req-title {
    font-weight: bold;
    font-size: 0.95em;
    color: #ffd700;
}

.req-desc {
    font-size: 0.85em;
    margin: 3px 0;
}

.req-reward {
    font-size: 0.8em;
    color: #00ff00;
}

.req-status {
    font-size: 0.8em;
    font-weight: bold;
    text-align: right;
    margin-top: 5px;
    color: #00ff00;
}

.make-btn {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 5px;
    background: #228B22;
    /* ForestGreen */
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
}

.make-btn:hover {
    background: #32CD32;
    /* LimeGreen */
}

/* Exploration Panel - Left (Below General) */
.exploration-panel {
    position: absolute;
    top: 120px;
    /* Below general portrait */
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 5px;
    width: 58px;
    color: white;
}

.exploration-panel h3 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    text-align: center;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

.explore-btn {
    width: 100%;
    margin-bottom: 10px;
    padding: 0;
    background: #444;
    border: 1px solid #666;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    transition: all 0.2s;
}

.explore-btn:hover:not(:disabled) {
    background: #555;
    border-color: #ffd700;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.explore-icon {
    font-size: 2em;
    /* Reduced from 2.5em */
    margin: 2px 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.explore-cost {
    font-size: 0.75em;
    /* Reduced from 0.85em */
    color: #aaa;
    text-align: center;
}

.explore-btn:disabled {
    opacity: 0.5;
    cursor: default;
    background: #333;
    transform: none;
    box-shadow: none;
}

/* Bottom Container */
.bottom-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 90%;
    pointer-events: none;
    /* Container is transparent to clicks */
}

/* Resources Bar */
.resources-bar {
    display: flex;
    gap: 15px;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid #444;
}

.resource-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
    color: white;
}

.res-icon {
    font-size: 1.5em;
    margin-bottom: 2px;
}

.res-val {
    font-weight: bold;
    font-size: 1.1em;
    color: #ffd700;
}

.res-label {
    font-size: 0.8em;
    color: #aaa;
}

/* Building Menu */
.building-menu {
    background: rgba(0, 0, 0, 0.9);
    padding: 10px;
    border-radius: 10px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
    max-width: 100%;
    overflow-x: auto;
}

.building-btn {
    background: #333;
    border: 1px solid #555;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    flex-shrink: 0;
    font-size: 1.1em;
    font-weight: bold;
}

.building-btn:hover:not(.disabled) {
    background: #444;
    border-color: #ffd700;
}

.building-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #444;
}

.building-cost {
    font-size: 0.95em;
    color: #eee;
    margin-top: 5px;
    width: 100%;
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cost-item {
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}


/* Slider Mode Selection Screen */
.selection-screen.slider-mode {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #333 0%, #000 100%);
    overflow: hidden;
}

.carousel-viewport {
    width: 100%;
    height: 60vh;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: relative;
    cursor: grab;
    touch-action: none;
    /* Key for touch drag */
}

.carousel-viewport:active {
    cursor: grabbing;
}

.carousel-track {
    display: flex;
    align-items: center;
    gap: 40px;
    padding-left: 50%;
    /* Start from center */
    /* Transform will be handled by JS */
    will-change: transform;
}

.carousel-card {
    position: relative;
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    opacity: 0.5;
    transform: scale(0.8);
    transition: all 0.3s ease-out;
    user-select: none;
    -webkit-user-drag: none;
}

.carousel-card img {
    -webkit-user-drag: none;
}

.carousel-card.active {
    opacity: 1;
    transform: scale(1.1);
    border-color: #ffd700;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
    z-index: 10;
}

.slider-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 4px solid #ffd700;
    object-fit: cover;
    object-position: top center;
    margin-bottom: 15px;
    pointer-events: none;
}

.slider-info {
    text-align: center;
    pointer-events: none;
}

.slider-info h1 {
    font-size: 1.8em;
    margin: 5px 0;
    color: #ffd700;
}

.slider-desc {
    font-size: 0.9em;
    color: #ddd;
    margin-bottom: 10px;
}

.slider-bonus {
    font-size: 0.85em;
    color: #00ff00;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 5px;
}

.select-btn {
    padding: 15px 40px;
    font-size: 1.5em;
    font-weight: bold;
    color: #000;
    background: linear-gradient(to bottom, #ffd700, #b8860b);
    border: 2px solid #ffd700;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.select-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
    background: linear-gradient(to bottom, #ffe44d, #d4a017);
}

/* Title Screen */
.title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #222 0%, #000 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    pointer-events: auto;
    animation: fadeIn 1s ease-in;
}

.game-logo {
    max-width: 80%;
    max-height: 50vh;
    margin-bottom: 50px;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }

    100% {
        transform: translateY(0px);
    }
}

.start-game-btn {
    padding: 20px 60px;
    font-size: 2.5em;
    /* Very Large */
    font-weight: bold;
    color: #000;
    background: linear-gradient(to bottom, #ffd700, #b8860b);
    border: 4px solid #ffd700;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
    text-transform: uppercase;
    letter-spacing: 5px;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

.start-game-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.8);
    background: linear-gradient(to bottom, #ffe44d, #d4a017);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
    }

    50% {
        box-shadow: 0 0 50px rgba(255, 215, 0, 0.7);
    }

    100% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
    }
}

/* General Profile Modal */
.general-profile-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    pointer-events: auto;
    animation: fadeIn 0.3s ease-out;
}

.profile-container {
    background: linear-gradient(135deg, #1f1f1f 0%, #121212 100%);
    border: 2px solid #ffd700;
    border-radius: 12px;
    padding: 40px;
    width: 900px;
    /* Increased width for PC */
    max-width: 95%;
    height: 850px;
    /* Increased height for PC */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.15), inset 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
    color: #e0e0e0;
    overflow: hidden;
    /* Ensures content stays within the rounded border */
}

.profile-close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    background: none;
    border: none;
    color: #666;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    transition: color 0.2s;
}

.profile-close-btn:hover {
    color: #ffd700;
}

.profile-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 20px;
}

.profile-name {
    font-size: 3rem;
    color: #ffd700;
    margin: 0;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.profile-level {
    font-size: 1.2rem;
    color: #aaa;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-level span {
    color: #fff;
    font-weight: bold;
    font-size: 1.4rem;
}

.profile-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Aligned to top */
    flex: 1;
    position: relative;
    gap: 40px;
    padding: 0 40px;
    /* Keep side padding */
    margin-top: 0;
    padding-top: 0;
}

.gear-column {
    display: flex;
    flex-direction: column;
    gap: 40px;
    width: 120px;
    align-items: center;
}

.gear-slot {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    color: #555;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.gear-slot:hover {
    border-color: #ffd700;
    color: #ffd700;
    background: rgba(255, 215, 0, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.gear-slot::after {
    content: attr(data-label);
    position: absolute;
    bottom: -25px;
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}

.profile-main-image {
    flex: 1;
    /* Takes up remaining space */
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Moved from center to flex-start to remove top space */
    position: relative;
    margin-top: 0;
    padding-top: 0;
    /* Optional: Add a subtle glow behind the character */
}

.profile-main-image::before {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: 0;
}

.profile-main-image img {
    max-height: 85%;
    /* Reduced from 100% to ensure it fits */
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.8));
    z-index: 1;
    transition: transform 0.3s ease;
}

.profile-main-image img:hover {
    transform: scale(1.02);
}

.profile-footer {
    margin-top: 30px;
    padding: 0 40px;
}

.xp-container {
    width: 60%;
    /* Limit width in header */
    margin: 15px auto 0;
    /* Center and add top margin */
    background: #0f0f0f;
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid #333;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #1e3c72 0%, #2a5298 100%);
    width: 0%;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 10px rgba(42, 82, 152, 0.5);
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.5px;
    width: 100%;
    text-align: center;
}

.commanders-area {
    margin-top: 25px;
    text-align: center;
    color: #444;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 15px;
    font-style: italic;
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Generic Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    pointer-events: auto;
    /* Ensure modal captures clicks */
}

.modal-content {
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    border: 1px solid #444;
    border-radius: 10px;
    padding: 20px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-out;
}

.modal-content h2 {
    margin-top: 0;
    color: #ffd700;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.cost-list {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    margin-top: 5px;
}

.cost-list div {
    margin: 5px 0;
    font-size: 0.95em;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.primary-btn {
    background: #ffd700;
    color: #000;
}

.primary-btn:hover {
    background: #fff;
    transform: scale(1.05);
}

.close-btn {
    background: #444;
    color: #fff;
}

.close-btn:hover {
    background: #666;
}

/* Resource Colors */
.icon-solidi {
    color: #ffd700 !important;
}

.icon-wood {
    color: #deb887 !important;
}

.icon-stone {
    color: #d3d3d3 !important;
}

.icon-iron {
    color: #87cefa !important;
}

.icon-food {
    color: #ff6347 !important;
}

/* Exploration UI */
.exploration-panel {
    position: absolute;
    top: 130px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 100;
    pointer-events: auto;

    /* Reset styles as requested */
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
}

.explore-btn {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffd700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
    color: white;
    /* Keeping color: white to ensure icon visibility, as it wasn't explicitly excluded but likely needed */
    margin-bottom: -10px;
}

.explore-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 215, 0, 0.2);
}

.explore-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: #666;
}

.explore-icon {
    font-size: 1.2em;
}

.explore-cost {
    font-size: 0.7em;
    margin-top: 2px;
}

/* Army UI */
.army-btn {
    position: absolute;
    top: 20px;
    right: 300px;
    padding: 10px 20px;
    font-size: 1.2em;
    background: #d32f2f;
    color: white;
    border: 3px solid #b71c1c;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.army-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 20px;
}

.army-grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    background: #3e2723;
    padding: 15px;
    border: 5px solid #5d4037;
    border-radius: 10px;
    margin-bottom: 20px;
}

.army-slot {
    width: 80px;
    height: 80px;
    background: #5d4037;
    border: 2px solid #795548;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.army-slot.over {
    border: 2px dashed #ffeb3b;
}

.army-unit {
    width: 90%;
    height: 90%;
    background: #8d6e63;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: grab;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 10;
}

.unit-icon {
    font-size: 2em;
}

.unit-level {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8em;
    background: #000;
    color: #fff;
    padding: 1px 4px;
    border-radius: 4px;
}

.army-shop {
    display: flex;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;

    /* Scrolling Logic */
    max-width: 90vw;
    overflow-x: auto;
    justify-content: flex-start;
    /* Ensure items start from left when scrolling */
}

/* Custom Scrollbar for Army Shop */
.army-shop::-webkit-scrollbar {
    height: 8px;
}

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

.army-shop::-webkit-scrollbar-thumb {
    background: #d32f2f;
    border-radius: 4px;
}

.shop-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #424242;
    padding: 10px;
    border-radius: 5px;
    width: 100px;
    /* Fixed width */
    min-width: 100px;
    /* Prevent shrinking */
    cursor: pointer;
    transition: transform 0.1s;
    flex-shrink: 0;
    /* Critical for scrolling */
}

.shop-item:hover {
    transform: scale(1.05);
    background: #616161;
}

.shop-item:active {
    transform: scale(0.95);
}

.fight-btn {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 2em;
    background: #d32f2f;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(211, 47, 47, 0.5);
    animation: pulse 2s infinite;
}

.close-army-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
}

/* Battle Overlay */
.battle-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.battle-field {
    width: 800px;
    height: 500px;
    background: #558b2f;
    position: relative;
    overflow: hidden;
    border: 5px solid #33691e;
    box-shadow: 0 0 50px black;
}

.battle-unit {
    position: absolute;
    width: 40px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    transition: transform 0.2s linear, left 0.5s linear, top 0.5s linear;
}

.battle-unit.player {
    color: #4fc3f7;
    filter: drop-shadow(0 0 5px blue);
}

.battle-unit.enemy {
    color: #ef5350;
    filter: drop-shadow(0 0 5px red);
    transform: scaleX(-1);
}

.damage-text {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: 16px;
    pointer-events: none;
    animation: floatUp 1s forwards;
    text-shadow: 1px 1px 0 #000;
}

@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-30px);
        opacity: 0;
    }
}

/* Responsive Styles for General Profile */
@media (max-width: 768px) {
    .profile-container {
        width: 95%;
        height: 95vh;
        padding: 20px;
        overflow-y: auto;
    }

    .profile-header {
        margin-bottom: 20px;
        padding-bottom: 10px;
    }

    .profile-name {
        font-size: 2rem;
    }

    .profile-content {
        flex-direction: column;
        padding: 0 70px;
    }

    .profile-main-image {
        order: -1;
        /* Move image to top */
        height: 50%;
        /* Limit height on mobile */
        width: 100%;
        margin-bottom: 10px;
        align-items: center;
        /* Center image */
    }

    .profile-main-image img {
        max-height: 90%;
        width: auto;
    }

    .gear-column {
        flex-direction: row;
        width: 100%;
        justify-content: center;
        gap: 15px;
    }

    .gear-slot {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }

    .gear-slot::after {
        font-size: 0.6rem;
        bottom: -18px;
    }

    .profile-close-btn {
        top: 10px;
        right: 15px;
        font-size: 2rem;
    }

    .profile-footer {
        margin-top: 20px;
        padding: 0;
    }

    .army-btn {
        right: auto;
        padding: 0;
        top: 120px;
        width: 79px;
        height: 49px;
        font-size: 12px;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 5px;
    }

    .building-btn {
        font-size: 12px;
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "icon cost"
            "name cost";
        align-items: center;
        justify-items: start;
        text-align: left;
        padding: 5px 10px;
        max-width: 264px;
        gap: 2px 10px;
    }

    .building-icon {
        grid-area: icon;
        justify-self: center;
    }

    .building-name {
        grid-area: name;
        justify-self: center;
    }

    .building-cost {
        grid-area: cost;
        justify-self: end;
        justify-content: flex-end;
        text-align: right;
        width: 100%;
    }

    .resources-bar {
        position: static;
        flex-direction: row;
        font-size: 11px;
        /* gap: 8px; */
        padding: 5px;
        width: 100%;
        border-radius: 10px;
        border: 1px solid #444;
        justify-content: center;
        margin-bottom: -12px;
        flex-wrap: wrap;
    }

    .resource-box {
        min-width: 40px;
        margin-bottom: 0;
    }

    .close-army-btn {
        top: 110px;
        right: 200px;
    }

    .exploration-panel {
        top: 180px;
    }

    .fight-btn {
        font-size: 0 !important;
        margin-top: 20px;
        width: 30px;
        padding: 5px 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .fight-btn i {
        font-size: 24px;
    }
}