/* ==========================================
   Loop Legends - Style Sheet
   ========================================== */

/* Reset and Base Styles */
* {
    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 */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 1200px;
    max-height: 900px;
}

/* Canvas */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a2e 0%, #0f0f1a 100%);
    border: 3px solid #4a9eff;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(74, 158, 255, 0.3);
}

/* Screen Containers */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

/* Overlays (Pause, Level Up) */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 20;
}

.overlay.hidden {
    display: none;
}

/* Typography */
.game-title {
    font-size: 3.5rem;
    font-weight: bold;
    color: #4a9eff;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.8),
                 0 0 40px rgba(74, 158, 255, 0.4);
    margin-bottom: 10px;
    animation: title-pulse 2s ease-in-out infinite;
}

.game-subtitle {
    font-size: 1.3rem;
    color: #888;
    margin-bottom: 30px;
}

.screen-title {
    font-size: 3rem;
    font-weight: bold;
    color: #ff6b6b;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
    margin-bottom: 30px;
}

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

/* Stats Display */
.stats-display {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px 40px;
    border-radius: 12px;
    border: 2px solid rgba(74, 158, 255, 0.3);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.stat-label {
    font-size: 1.2rem;
    color: #aaa;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
}

.new-record {
    font-size: 1.5rem;
    color: #4ade80;
    font-weight: bold;
    animation: record-glow 0.5s ease-in-out infinite alternate;
}

@keyframes record-glow {
    from { text-shadow: 0 0 10px rgba(74, 222, 128, 0.5); }
    to { text-shadow: 0 0 20px rgba(74, 222, 128, 1); }
}

/* Button Styling */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.btn {
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #4a9eff 0%, #0066cc 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5aaeff 0%, #0077dd 100%);
    box-shadow: 0 5px 25px rgba(74, 158, 255, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, #666 0%, #444 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #777 0%, #555 100%);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Controls Info */
.controls-info {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.controls-info h3 {
    color: #4a9eff;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.controls-info p {
    color: #888;
    margin: 8px 0;
    font-size: 1rem;
}

/* Shop Styling */
.shop-stats {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: #ffd700;
    font-weight: bold;
}

.upgrades-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 10px;
}

.upgrade-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.upgrade-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 215, 0, 0.6);
}

.upgrade-info {
    flex: 1;
}

.upgrade-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 5px;
}

.upgrade-description {
    color: #888;
    font-size: 0.95rem;
}

.upgrade-level {
    color: #4ade80;
    font-size: 0.9rem;
    margin-top: 5px;
}

.upgrade-cost {
    font-size: 1.3rem;
    color: #ffd700;
    font-weight: bold;
    min-width: 100px;
    text-align: center;
}

.upgrade-buy-btn {
    padding: 10px 25px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #ffd700 0%, #ff9500 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.upgrade-buy-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

.upgrade-buy-btn:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
}

/* Game HUD */
#game-hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    z-index: 5;
    padding: 15px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
}

#game-hud.hidden {
    display: none;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-label {
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
}

/* Progress Bars */
.bar-bg {
    width: 150px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.3s ease;
}

.health-bar {
    background: linear-gradient(90deg, #ff6b6b 0%, #ff4444 100%);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.xp-bar {
    background: linear-gradient(90deg, #ffd700 0%, #ff9500 100%);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.bar-text {
    color: #fff;
    font-size: 0.9rem;
    font-weight: bold;
    min-width: 80px;
    text-align: right;
}

/* Time and Coins Display */
.time-display,
.coins-display,
.difficulty-display {
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 15px;
    border-radius: 6px;
    margin-left: auto;
}

.time-display {
    order: 10;
}

.difficulty-display {
    margin-left: 0;
}

/* Level Up Overlay */
.upgrade-choices {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 20px;
}

.upgrade-choice {
    background: rgba(74, 158, 255, 0.1);
    border: 3px solid #4a9eff;
    padding: 25px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.upgrade-choice:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: #7bc4ff;
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(74, 158, 255, 0.3);
}

.upgrade-choice .upgrade-name {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.upgrade-choice .upgrade-description {
    font-size: 1rem;
    line-height: 1.5;
}

/* Game Over Stats */
.gameover-stats {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.05);
    padding: 30px 50px;
    border-radius: 12px;
    border: 2px solid rgba(255, 107, 107, 0.3);
}

#new-record-display {
    text-align: center;
}

#new-record-display.hidden {
    display: none;
}

/* Floating Text */
#floating-text-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

.floating-text {
    position: absolute;
    font-weight: bold;
    font-size: 1.2rem;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
}

.floating-text.xp {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.floating-text.damage {
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.8);
}

.floating-text.heal {
    color: #4ade80;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.8);
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

/* Scrollbar Styling */
.upgrades-container::-webkit-scrollbar,
.upgrade-choices::-webkit-scrollbar {
    width: 8px;
}

.upgrades-container::-webkit-scrollbar-track,
.upgrade-choices::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.upgrades-container::-webkit-scrollbar-thumb,
.upgrade-choices::-webkit-scrollbar-thumb {
    background: #4a9eff;
    border-radius: 4px;
}

.upgrades-container::-webkit-scrollbar-thumb:hover,
.upgrade-choices::-webkit-scrollbar-thumb:hover {
    background: #5aaeff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }

    .screen-title {
        font-size: 2rem;
    }

    .stats-display,
    .gameover-stats {
        padding: 20px;
        width: 90%;
    }

    .button-group {
        width: 90%;
    }

    .btn {
        padding: 12px 30px;
        font-size: 1.1rem;
    }

    .hud-item {
        font-size: 0.9rem;
    }

    .bar-bg {
        width: 100px;
    }

    #game-hud {
        gap: 10px;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2rem;
    }

    .stat-label,
    .stat-value {
        font-size: 1rem;
    }

    .hud-label {
        font-size: 0.9rem;
    }
}
