/* ============================================================================
   MONEY RUN - STYLES
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

:root {
    --bg-dark: #1a1a2e;
    --accent-red: #e63946;
    --accent-green: #2ecc71;
    --accent-gold: #f1c40f;
    --text-white: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --panel-bg: rgba(20, 20, 40, 0.95);
    --panel-border: rgba(255, 255, 255, 0.1);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    touch-action: none;
}

.hidden {
    display: none !important;
}

/* ============================================================================
   GAME CONTAINER & CANVAS
   ============================================================================ */

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ============================================================================
   MAIN MENU
   ============================================================================ */

#main-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #2d1f3d 0%, #1a1a2e 50%, #0d0d1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.menu-content {
    text-align: center;
    color: var(--text-white);
    padding: 20px;
}

.game-title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 30px;
    line-height: 1.1;
    text-shadow: 0 4px 20px rgba(230, 57, 70, 0.5);
}

.game-title span {
    color: var(--accent-red);
    font-size: 56px;
}

.menu-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
}

.stat-value.coin-value {
    color: var(--accent-gold);
}

/* Buttons */
.btn {
    display: block;
    width: 220px;
    padding: 18px 30px;
    margin: 12px auto;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-play {
    background: linear-gradient(135deg, var(--accent-green) 0%, #27ae60 100%);
    color: white;
    box-shadow: 0 6px 0 #1e8449, 0 10px 30px rgba(46, 204, 113, 0.3);
}

.btn-play:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #1e8449, 0 5px 15px rgba(46, 204, 113, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    box-shadow: 0 6px 0 #1a5276, 0 10px 30px rgba(52, 152, 219, 0.3);
}

.btn-secondary:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #1a5276;
}

.btn-tertiary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

.btn-tertiary:active {
    background: rgba(255, 255, 255, 0.2);
}

.btn-share {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    box-shadow: 0 6px 0 #6c3483, 0 10px 30px rgba(155, 89, 182, 0.3);
}

.btn-share:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #6c3483;
}

.btn-other-games {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    color: white;
    box-shadow: 0 6px 0 #a04000, 0 10px 30px rgba(230, 126, 34, 0.3);
}

.btn-other-games:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #a04000;
}

.btn-reset {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 6px 0 #922b21, 0 10px 30px rgba(231, 76, 60, 0.3);
}

.btn-reset:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #922b21;
}

.btn-danger {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 2px solid rgba(231, 76, 60, 0.3);
    box-shadow: none;
    font-size: 14px;
    padding: 12px 20px;
    width: auto;
}

.menu-options {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.option-btn {
    width: 50px;
    height: 50px;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn.muted {
    opacity: 0.4;
}

/* ============================================================================
   GAME HUD
   ============================================================================ */

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    pointer-events: none;
    z-index: 50;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-score {
    background: var(--panel-bg);
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
}

.hud-score span:first-child {
    font-size: 36px;
    font-weight: 800;
    color: white;
}

.score-label {
    font-size: 18px;
    color: var(--text-muted);
    margin-left: 4px;
}

.hud-coins {
    background: var(--panel-bg);
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.coin-icon {
    color: var(--accent-gold);
    font-size: 20px;
    text-shadow: 0 0 10px var(--accent-gold);
}

.hud-coins span:last-child {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-gold);
}

.hud-multiplier {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 800;
    color: var(--accent-green);
    text-shadow: 0 0 20px var(--accent-green);
    animation: perfect-pop 0.6s ease-out forwards;
}

@keyframes perfect-pop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.hud-shield {
    position: absolute;
    top: 80px;
    left: 20px;
    font-size: 28px;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.hud-shield.active {
    opacity: 1;
    animation: shield-pulse 1s ease-in-out infinite;
}

@keyframes shield-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================================================
   TOUCH CONTROLS
   ============================================================================ */

#touch-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    display: flex;
    z-index: 40;
    pointer-events: auto;
}

.touch-zone {
    flex: 1;
    height: 100%;
}

.touch-left {
    /* Visual feedback on tap handled by JS */
}

.touch-right {
    /* Visual feedback on tap handled by JS */
}

/* Joystick */
.joystick-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 45;
    pointer-events: auto;
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.joystick-knob {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(200, 200, 200, 0.6) 100%);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.05s ease-out;
}

.joystick-knob.active {
    background: linear-gradient(135deg, var(--accent-green) 0%, #27ae60 100%);
    border-color: var(--accent-green);
}

/* ============================================================================
   TAP TO START
   ============================================================================ */

#tap-to-start {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
}

#tap-to-start span {
    font-size: 28px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 6px;
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

/* ============================================================================
   GAME OVER
   ============================================================================ */

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.gameover-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 30px 40px;
    text-align: center;
    color: white;
    min-width: 320px;
    max-width: 90%;
    animation: slide-up 0.4s ease-out;
}

@keyframes slide-up {
    0% { transform: translateY(50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.gameover-panel h2 {
    font-size: 36px;
    color: var(--accent-red);
    margin-bottom: 25px;
    text-shadow: 0 0 20px rgba(230, 57, 70, 0.5);
}

.gameover-stats {
    margin-bottom: 25px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 16px;
    border-bottom: 1px solid var(--panel-border);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row.highlight {
    color: var(--accent-gold);
    font-weight: 700;
}

.stat-row.total {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent-green);
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid var(--panel-border);
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gameover-buttons .btn {
    width: 100%;
    margin: 0;
}

/* ============================================================================
   UPGRADES SCREEN
   ============================================================================ */

#upgrades-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #2d1f3d 0%, #1a1a2e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

.upgrades-panel {
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 25px;
    color: white;
    overflow-y: auto;
}

.upgrades-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--panel-border);
}

.upgrades-header h2 {
    font-size: 28px;
    letter-spacing: 2px;
}

.upgrades-coins {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-gold);
}

.upgrades-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.upgrade-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.upgrade-info {
    flex: 1;
}

.upgrade-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upgrade-icon {
    font-size: 20px;
}

.upgrade-level {
    font-size: 12px;
    color: var(--accent-green);
    background: rgba(46, 204, 113, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

.upgrade-level.maxed {
    color: var(--accent-gold);
    background: rgba(241, 196, 15, 0.2);
}

.upgrade-desc {
    font-size: 13px;
    color: var(--text-muted);
}

.upgrade-btn {
    background: linear-gradient(135deg, var(--accent-gold) 0%, #d4a00a 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.upgrade-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    cursor: not-allowed;
}

.upgrade-btn.maxed {
    background: rgba(46, 204, 113, 0.2);
    color: var(--accent-green);
}

.upgrades-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--panel-border);
}

/* ============================================================================
   COIN POPUP
   ============================================================================ */

#coin-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    font-weight: 800;
    color: var(--accent-gold);
    text-shadow: 0 0 20px var(--accent-gold);
    pointer-events: none;
    z-index: 100;
    animation: coin-pop 0.5s ease-out forwards;
}

@keyframes coin-pop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -80%) scale(1); opacity: 0; }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 400px) {
    .game-title {
        font-size: 36px;
    }

    .game-title span {
        font-size: 42px;
    }

    .btn {
        width: 180px;
        padding: 15px 25px;
        font-size: 18px;
    }

    .gameover-panel {
        padding: 20px 25px;
        min-width: 280px;
    }

    .upgrades-panel {
        padding: 20px;
    }
}

@media (max-height: 600px) {
    .menu-stats {
        margin-bottom: 25px;
    }

    .btn {
        padding: 14px 25px;
        margin: 8px auto;
    }

    .game-title {
        margin-bottom: 20px;
    }
}
