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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#game-canvas {
    display: block;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* Fullscreen mode */
.fullscreen-mode #game-canvas,
.mobile-mode #game-canvas {
    border-radius: 0;
    box-shadow: none;
}

.fullscreen-mode #game-screen,
.mobile-mode #game-screen {
    position: absolute;
    inset: 0;
}

/* Mobile mode indicator */
.mobile-mode {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%) !important;
}

/* Menu Screen */
#menu-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, #2d1b69 0%, #11998e 100%);
    padding: 20px;
    z-index: 10;
}

#menu-screen h1 {
    font-size: 2.5rem;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    margin-bottom: 40px;
}

/* Mode selector buttons */
.mode-btn {
    padding: 10px 16px;
    border: 2px solid transparent;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.mode-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

.mode-btn.active {
    opacity: 1;
    border-color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.stats-display {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 25px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat span:last-child {
    font-size: 1.8rem;
    font-weight: bold;
    color: #ffd700;
}

button {
    padding: 15px 50px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(240, 147, 251, 0.4);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(240, 147, 251, 0.6);
}

button:active {
    transform: translateY(0);
}

.controls-hint {
    margin-top: 30px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

/* Guide Screen */
#guide-screen {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30;
    padding: 20px;
}

.guide-content {
    background: #fff;
    color: #333;
    padding: 30px;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
}

.guide-content h2 {
    color: #2d1b69;
    margin-bottom: 15px;
    text-align: center;
}

.guide-content p {
    margin-bottom: 20px;
    line-height: 1.5;
}

.guide-list {
    list-style: none;
}

.guide-list li {
    margin-bottom: 10px;
    padding: 10px;
    background: #f5f6fa;
    border-radius: 10px;
    font-size: 0.9rem;
}

#close-guide-btn {
    margin-top: 20px;
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Game Screen */
#game-screen {
    position: absolute;
    inset: 0;
}

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

#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

#score-display {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

#current-score {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#health-display {
    display: flex;
    gap: 5px;
}

.heart {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
}

.heart.empty {
    opacity: 0.3;
}

#powerups-display {
    display: flex;
    gap: 8px;
}

.active-powerup {
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Upgrade Screen - transparent overlay */
#upgrade-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    padding: 20px;
    z-index: 20;
}

#upgrade-screen h2 {
    color: #fff;
    font-size: 1.8rem;
    margin-bottom: 30px;
}

#upgrade-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 320px;
}

.upgrade-card {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    overflow: visible;
}

.upgrade-card:hover {
    transform: translateX(10px);
    border-color: #ffd700;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
}

.upgrade-card h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.upgrade-card p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.upgrade-rarity {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rarity-common { background: #95a5a6; }
.rarity-rare { background: #3498db; }
.rarity-epic { background: #9b59b6; }
.rarity-legendary { background: linear-gradient(90deg, #f1c40f, #e67e22); }

/* Legendary card glow effect */
.upgrade-card.rarity-legendary {
    background: linear-gradient(135deg, #f1c40f 0%, #e67e22 50%, #f1c40f 100%);
    background-size: 200% 200%;
    animation: legendaryShine 2s ease-in-out infinite;
    border: 2px solid #ffd700;
    box-shadow: 0 0 30px rgba(241, 196, 15, 0.6), 0 0 60px rgba(230, 126, 34, 0.4);
}

.upgrade-card.legendary-glow::before {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 24px;
    animation: sparkle 1s ease-in-out infinite;
}

@keyframes legendaryShine {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.2) rotate(180deg); opacity: 0.8; }
}

/* Epic card style */
.upgrade-card.rarity-epic {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    border: 2px solid #9b59b6;
    box-shadow: 0 0 20px rgba(155, 89, 182, 0.4);
}

/* Rare card style */
.upgrade-card.rarity-rare {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border: 2px solid #3498db;
}

/* Game Over Screen */
#gameover-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, #c0392b 0%, #2c3e50 100%);
    padding: 20px;
    z-index: 15;
}

#gameover-screen h2 {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 30px;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.final-stats {
    background: rgba(255, 255, 255, 0.1);
    padding: 25px 40px;
    border-radius: 20px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
}

.final-stats p {
    color: #fff;
    font-size: 1.2rem;
    margin: 10px 0;
}

.final-stats span {
    color: #ffd700;
    font-weight: bold;
}

#gameover-screen button {
    margin: 10px;
}

#menu-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 420px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
}
