/* Existing Styles... */

/* Main Menu */
.main-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #2d3748 0%, #171923 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    pointer-events: auto;
}

.game-title {
    font-size: 5rem;
    font-weight: 900;
    background: linear-gradient(to right, #e53e3e, #d69e2e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 50px;
    letter-spacing: 5px;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 300px;
}

.menu-btn {
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 800;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.start-btn {
    background: #48bb78;
    color: white;
    box-shadow: 0 4px 0 #2f855a;
}

.start-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.shop-btn {
    background: #4299e1;
    color: white;
    box-shadow: 0 4px 0 #2b6cb0;
}

.shop-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.back-btn {
    background: #718096;
    color: white;
    margin-top: 30px;
    width: 200px;
}

.total-coins {
    margin-top: 40px;
    font-size: 1.5rem;
    color: #ffd700;
    font-weight: 700;
}

/* Shop Screen */
.shop-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a202c;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 50px;
    z-index: 5001;
    pointer-events: auto;
    overflow-y: auto;
}

.shop-title {
    font-size: 3rem;
    color: white;
    margin-bottom: 20px;
}

.shop-coins {
    font-size: 1.5rem;
    color: #ffd700;
    margin-bottom: 40px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1000px;
}

.shop-item {
    background: #2d3748;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #4a5568;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.shop-item.affordable {
    border-color: #48bb78;
}

.shop-item-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.shop-item-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 5px;
}

.shop-item-desc {
    font-size: 0.9rem;
    color: #a0aec0;
    margin-bottom: 15px;
    flex-grow: 1;
}

.shop-item-lvl {
    font-size: 0.8rem;
    color: #63b3ed;
    margin-bottom: 10px;
}

.buy-btn {
    background: #d69e2e;
    color: #1a202c;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: 800;
    cursor: pointer;
    width: 100%;
}

.buy-btn:disabled {
    background: #4a5568;
    color: #718096;
    cursor: not-allowed;
}

/* Rest of the previous CSS... */
/* Main UI Layer - Covers entire screen but lets clicks through */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    /* Allows clicking on canvas behind UI */
    z-index: 10;
    overflow: hidden;
}

/* XP Bar Container - Centered Top */
.hud-top {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    min-width: 300px;
    max-width: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

.xp-container {
    flex-grow: 1;
    height: 24px;
    background: rgba(23, 25, 35, 0.8);
    border: 2px solid #4a5568;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.xp-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4299e1, #63b3ed);
    border-radius: 8px;
    transition: width 0.3s ease-out;
}

.level-badge {
    position: static;
    background: #2b6cb0;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 16px;
    border: 2px solid #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

/* Stats Container - Top Right Corner */
.stats-container {
    position: absolute;
    top: 20px;
    right: 30px;
    display: flex;
    flex-direction: column;
    /* Stack vertically if needed, or row */
    gap: 10px;
    align-items: flex-end;
    pointer-events: none;
}

.stat-item {
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 8px;
    color: #e2e8f0;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Upgrade Overlay - Full Screen Center */
.upgrade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: auto;
    /* Catch clicks */
}

.upgrade-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

/* Upgrade Cards */
.cards-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.upgrade-card {
    width: 220px;
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    border: 2px solid #4a5568;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    user-select: none;
}

.upgrade-card:hover {
    transform: translateY(-5px);
    border-color: #63b3ed;
    box-shadow: 0 10px 25px rgba(66, 153, 225, 0.2);
}

.card-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.card-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    text-align: center;
}

.card-desc {
    font-size: 14px;
    color: #a0aec0;
    text-align: center;
    line-height: 1.4;
}

/* Rarity Colors */
.upgrade-card.common {
    border-top: 4px solid #a0aec0;
}

.upgrade-card.rare {
    border-top: 4px solid #4299e1;
}

.upgrade-card.epic {
    border-top: 4px solid #9f7aea;
    box-shadow: 0 0 15px rgba(159, 122, 234, 0.2);
}

.upgrade-card.legendary {
    border-top: 4px solid #ecc94b;
    box-shadow: 0 0 20px rgba(236, 201, 75, 0.3);
}

/* Game Over Screen */
.game-over-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #171923;
    padding: 40px;
    border-radius: 16px;
    border: 2px solid #e53e3e;
    text-align: center;
    z-index: 2000;
    display: none;
    pointer-events: auto;
    box-shadow: 0 0 50px rgba(229, 62, 62, 0.4);
}

.game-over-title {
    font-family: 'Inter', sans-serif;
    font-size: 48px;
    font-weight: 900;
    color: #e53e3e;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.restart-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
}

.restart-btn:hover {
    background: #c53030;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}