:root {
    --primary-color: #ff4500;
    --secondary-color: #8b0000;
    --background-color: #1a0000;
    --text-color: #fff;
    --button-color: #ff6347;
    --button-hover: #ff8c00;
    --section-bg: rgba(139, 0, 0, 0.3);
}

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

body {
    font-family: 'Arial', sans-serif;
    /* background-color: var(--background-color); /* Remove or keep as fallback if needed */
    color: var(--text-color);
    min-height: 100vh; /* Ensures body covers at least the viewport height */

    /* Background Image & Gradient */
    background-image:
            url('assets/background.jpg'), /* Image URL (ensure path is correct relative to CSS file) */
            radial-gradient(circle, #3a0000, #1a0000); /* Gradient underneath */

    /* Background Image Sizing & Positioning */
    background-size: cover;          /* Scale image to cover entire area, maintain aspect ratio */
    background-position: center center;/* Center the image horizontally and vertically */
    background-repeat: no-repeat;    /* Prevent image tiling */
    background-attachment: fixed;    /* Fix background relative to viewport */

    /* Keep your flexbox centering for content if needed */
    display: flex;
    justify-content: center;
    align-items: center; /* Added align-items for vertical centering of content */
    padding: 20px; /* Add padding back if needed for content spacing */
    box-sizing: border-box; /* Include padding in height calculation */
}

.game-container {
    max-width: 800px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header img {
    width: 483px;
    height: 100px;
}

header h1 {
    font-size: 3rem;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(255, 69, 0, 0.7);
    margin-bottom: 5px;
}

header h2 {
    font-size: 1.5rem;
    color: var(--secondary-color);
    text-shadow: 0 0 5px rgba(139, 0, 0, 0.7);
}

.stats-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--section-bg);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}

.demon-counter {
    font-size: 1.5rem;
    font-weight: bold;
}

#demon-count {
    color: var(--primary-color);
    font-size: 2rem;
}

.rates {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summon-container {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    position: relative;
    z-index: 2;
}

.summon-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    transition: all 0.2s ease;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    animation: pulse 2s infinite;
    background-image:
            url('assets/button-bg.png'), /* Top layer: your transparent PNG */
            radial-gradient(circle, var(--button-color), var(--secondary-color)); /* Bottom layer: your gradient */

    /* Optional: Control how the PNG is displayed */
    background-size: cover; /* Or 'contain', 'auto', '100% 100%' etc. 'cover' makes it fill the button */
    background-position: center center; /* Centers the image */
    background-repeat: no-repeat; /* Prevents the image from tiling */
}

.summon-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.7);
    animation: none;
}

.summon-btn:active {
    transform: scale(0.95);
    background-image:
            url('assets/button-bg-flipped.png'), /* Top layer: Pre-flipped PNG */
            radial-gradient(circle, var(--secondary-color), var(--button-color)); /* Bottom layer: Active state gradient */

    /* Optional: Control how the PNG is displayed (match non-active state) */
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;

    /* Add animation to ensure the button returns to normal state */
    animation: button-press 0.3s forwards;
}

/* Ensure the button-press animation takes precedence over pulse */
.summon-btn:active {
    animation: button-press 0.3s forwards !important;
}

@keyframes button-press {
    0% {
        transform: scale(0.95);
        background-image:
            url('assets/button-bg-flipped.png'),
            radial-gradient(circle, var(--secondary-color), var(--button-color));
    }
    100% {
        transform: scale(1);
        background-image:
            url('assets/button-bg.png'),
            radial-gradient(circle, var(--button-color), var(--secondary-color));
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 0, 0, 0.8);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    }
}

.upgrades-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: -20px; /* Creates overlap with summon button */
    position: relative;
    z-index: 1;
}

.section {
    background-color: var(--section-bg);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}

.section h3 {
    text-align: center;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.items-grid {
    display: grid;
    gap: 10px;
}

.upgrade-item {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* Internet Explorer/Edge */
    user-select: none;         /* Standard syntax */
}

.upgrade-item:hover {
    background-color: rgba(255, 69, 0, 0.2);
}

.upgrade-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.upgrade-icon {
    margin-right: 10px;
    flex-shrink: 0;
}

.upgrade-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.upgrade-name {
    font-weight: bold;
    color: var(--primary-color);
}

.upgrade-description {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.upgrade-cost {
    color: var(--button-color);
    font-weight: bold;
}

/* Tutorial styles */
.tutorial {
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    color: var(--text-color);
    text-align: center;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.5);
    animation: fadeIn 0.5s ease;
}

.tutorial p {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.tutorial button {
    background-color: var(--button-color);
    color: var(--text-color);
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.tutorial button:hover {
    background-color: var(--button-hover);
    transform: scale(1.05);
}

.tutorial.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation for demon spawn */
@keyframes demonSpawn {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

.demon-spawn {
    position: absolute;
    color: var(--primary-color);
    font-weight: bold;
    animation: demonSpawn 1s forwards;
    pointer-events: none;
}

/* Circle of Hell styles */
.circle-container {
    margin-bottom: 20px;
}

.circle-header {
    text-align: center;
    margin-bottom: 15px;
}

.circle-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-top: 5px;
}

.circle-progress-container {
    margin: 15px 0;
}

.circle-progress-bar {
    height: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.circle-progress {
    height: 100%;
    background: linear-gradient(to right, var(--primary-color), var(--button-hover));
    width: 0%;
    transition: width 0.5s ease;
}

.circle-progress-text {
    text-align: center;
    margin-top: 5px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.circle-actions {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.descend-btn {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(139, 0, 0, 0.5);
}

.descend-btn:hover:not(.disabled) {
    background-color: #a00000;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(139, 0, 0, 0.7);
}

.descend-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Reset button styles */
.reset-btn {
    background-color: #444;
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(68, 68, 68, 0.5);
    margin-left: 10px;
}

.reset-btn:hover {
    background-color: #666;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(68, 68, 68, 0.7);
}

/* Circle transition animation */
@keyframes circleTransition {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.circle-transition {
    animation: circleTransition 1s ease;
}

/* Flying lildemon animation */
@keyframes flyIn {
    0% {
        transform: translate(0, 0)  scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-1 * var(--start-x)), calc(-1 * var(--start-y))) rotate(var(--rotate-deg)) scale(0.5);
        opacity: 0;
    }
}

.flying-demon {
    position: absolute;
    width: 60px;
    height: 60px;
    pointer-events: none;
    z-index: 10;
    animation: flyIn 2s forwards;
}

/* Tabs styles */
.upgrades-tabs {
    background-color: var(--section-bg);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
    overflow: hidden;
    margin-bottom: 80px; /* Space for sticky bottom bar */
}

/* Desktop side-by-side layout */
@media (min-width: 769px) {
    .upgrades-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-gap: 0; /* Remove gap as we'll handle spacing with padding */
        background-color: var(--section-bg);
        border-radius: 10px;
        overflow: hidden;
    }

    .tabs-header {
        display: none; /* Hide tabs on desktop */
    }

    .tab-content {
        display: block !important; /* Always show both tabs on desktop */
        padding: 20px;
        max-height: none; /* Remove height restriction */
        overflow-y: visible;
        width: 100%;
        animation: none;
    }

    /* Add a divider between columns */
    #recruiters-tab {
        border-left: 2px solid rgba(139, 0, 0, 0.5);
        padding-left: 20px; /* Add some padding for better spacing */
    }

    /* Add column headers */
    #powerups-tab::before {
        content: "Power Ups";
        display: block;
        font-size: 1.3rem;
        font-weight: bold;
        color: var(--primary-color);
        margin-bottom: 15px;
        text-align: center;
        text-shadow: 0 0 5px rgba(255, 69, 0, 0.5);
    }

    #recruiters-tab::before {
        content: "Recruiters";
        display: block;
        font-size: 1.3rem;
        font-weight: bold;
        color: var(--primary-color);
        margin-bottom: 15px;
        text-align: center;
        text-shadow: 0 0 5px rgba(255, 69, 0, 0.5);
    }

    /* Ensure items grid has proper spacing */
    .items-grid {
        max-height: none; /* Remove any height restrictions */
    }

    /* Add some hover effects for desktop */
    .upgrade-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        transition: all 0.2s ease;
    }
}

/* Mobile tabs layout */
@media (max-width: 768px) {
    .tabs-header {
        display: flex;
        border-bottom: 2px solid rgba(139, 0, 0, 0.5);
    }

    .tab-btn {
        flex: 1;
        background: none;
        border: none;
        padding: 12px;
        color: var(--text-color);
        font-weight: bold;
        cursor: pointer;
        transition: background-color 0.2s;
        font-size: 1.1rem;
    }

    .tab-btn.active {
        background-color: rgba(255, 69, 0, 0.3);
        border-bottom: 3px solid var(--primary-color);
        position: relative;
    }

    .tab-btn.active::after {
        content: '';
        position: absolute;
        bottom: -3px;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid var(--primary-color);
    }

    .tab-content {
        display: none;
        padding: 15px;
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        scroll-behavior: smooth; /* Smooth scrolling on all devices */
    }

    .tab-content.active {
        display: block;
        animation: fadeIn 0.3s ease;
    }
}

/* Sticky bottom bar */
.sticky-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(26, 0, 0, 0.95);
    padding: 10px;
    display: none; /* Hidden by default, shown on mobile */
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    border-top: 2px solid var(--secondary-color);
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
}

/* Desktop only elements */
.desktop-only {
    display: flex;
}

.mobile-stats {
    flex: 1;
}

.sticky-bottom-bar .summon-container {
    margin: 0;
}

.sticky-bottom-bar .summon-btn {
    width: 100px;
    height: 100px;
    font-size: 1.2rem;
    margin: 0;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
    touch-action: manipulation; /* Optimize for touch */
    /* Ensure button returns to normal state after touch */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Mobile styles */
@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }

    .sticky-bottom-bar {
        display: flex;
    }

    .upgrades-container {
        grid-template-columns: 1fr;
        margin-top: 0; /* Remove overlap on mobile */
    }

    .summon-btn {
        width: 150px;
        height: 150px;
    }

    header img {
        width: 100%;
        height: auto;
        max-width: 300px;
    }

    .game-container {
        padding-bottom: 120px; /* Space for sticky bottom bar */
    }

    /* Optimize for portrait mode */
    .circle-container {
        margin-bottom: 15px;
    }

    .circle-progress-bar {
        height: 15px;
    }

    .section h3 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }

    .upgrade-item {
        padding: 12px;
        min-height: 60px; /* Better touch target */
    }

    .circle-actions {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .reset-btn {
        margin-left: 0;
    }

    .tutorial {
        padding: 12px;
        margin-bottom: 15px;
    }

    .tutorial p {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
}

/* Portrait mode specific styles */
@media (orientation: portrait) {
    .tab-content {
        max-height: 50vh;
    }

    .sticky-bottom-bar .summon-btn {
        width: 80px;
        height: 80px;
        font-size: 0.9rem; /* Smaller font size for the SUMMON text */
    }

    .demon-counter {
        font-size: 1.3rem;
    }

    #demon-count, #demon-count-mobile {
        font-size: 1.8rem;
    }

    .upgrade-name {
        font-size: 0.9rem;
    }

    .upgrade-description {
        font-size: 0.75rem;
    }
}
