* { 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 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none; /* Prevent default touch behaviors */
}
#game-container {
    position: relative;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
    max-width: 100vw;
    max-height: 100vh;
}
#game-canvas {
    display: block;
    touch-action: none;
}

/* Responsive canvas for mobile */
@media (max-width: 1024px) {
    body {
        align-items: flex-start;
        padding: 0;
    }
    #game-container {
        border-radius: 0;
    }
    #game-canvas {
        display: block;
    }
}
#hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}
.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
.hud-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.cash-icon { background: linear-gradient(135deg, #f1c40f, #f39c12); }
.timer-icon { background: linear-gradient(135deg, #3498db, #2980b9); }
.avatar-icon { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.avatar-btn { cursor: pointer; transition: transform 0.1s; pointer-events: auto; }
.avatar-btn:hover { transform: scale(1.1); }
.avatar-btn:active { transform: scale(0.95); }
.star-icon { background: linear-gradient(135deg, #e74c3c, #c0392b); }

/* Avatar Selection Panel */
#avatar-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
#avatar-panel.hidden { display: none; }
#avatar-panel-content {
    background: linear-gradient(135deg, #2c3e50, #1a252f);
    border-radius: 15px;
    padding: 20px;
    border: 3px solid #3498db;
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.5);
}
#avatar-panel-header {
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
#avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 400px;
}
.avatar-option {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.avatar-option:hover {
    background: rgba(255,255,255,0.2);
    border-color: #3498db;
    transform: scale(1.05);
}
.avatar-option.selected {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.3);
}
.avatar-option img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}
.avatar-option-label {
    color: white;
    font-size: 11px;
    margin-top: 2px;
}
#avatar-panel-close {
    color: #7f8c8d;
    font-size: 12px;
    text-align: center;
    margin-top: 15px;
}
#upgrade-toggle {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    background: linear-gradient(135deg, #8e44ad, #6c3483);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-size: 11px;
    cursor: pointer;
    z-index: 60;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease-in-out;
}
#upgrade-toggle:active {
    transform: translateX(-50%) scale(0.95);
}
#upgrade-toggle.hidden {
    display: none;
}
#upgrade-toggle.panel-open {
    bottom: 120px;
}

#upgrade-panel {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 8px;
    background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding-bottom: 10px;
    padding-top: 30px;
    transition: transform 0.3s ease-in-out;
    z-index: 55;
}
#upgrade-panel.collapsed {
    transform: translateY(100%);
}
.upgrade-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.upgrade-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.upgrade-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.upgrade-btn:disabled { opacity: 0.9; cursor: not-allowed; }
.upgrade-btn.locked { opacity: 0.8; background: #555 !important; }
.upgrade-btn.table { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.upgrade-btn.grill { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.upgrade-btn.host { background: linear-gradient(135deg, #3498db, #2980b9); }
.upgrade-btn.cook { background: linear-gradient(135deg, #e67e22, #d35400); }
.upgrade-btn.speed { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.upgrade-btn.runner { background: linear-gradient(135deg, #1abc9c, #16a085); }
.upgrade-btn.expansion { background: linear-gradient(135deg, #8e44ad, #6c3483); }
.upgrade-btn.kitchen { background: linear-gradient(135deg, #c0392b, #922b21); }
.upgrade-btn.quality { background: linear-gradient(135deg, #f39c12, #d68910); }
.upgrade-btn.oven { background: linear-gradient(135deg, #e74c3c, #b03a2e); }
.upgrade-btn.fryer { background: linear-gradient(135deg, #f1c40f, #d4ac0d); }
#milestone-notification {
    position: absolute;
    top: 100px; left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    pointer-events: none;
    display: none;
    animation: pulse 0.5s ease-in-out;
    z-index: 100;
}
@keyframes pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}
#style-indicator {
    background: rgba(0,0,0,0.5);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
}
#style-display.quick-serve { color: #f1c40f; }
#style-display.high-volume { color: #3498db; }
#style-display.fine-dining { color: #e74c3c; }
#instructions {
    position: absolute;
    top: 55px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: #f1c40f;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    pointer-events: none;
    border: 2px solid #f1c40f;
    text-align: center;
    max-width: 90%;
}
#controls-hint {
    position: absolute;
    bottom: 110px; left: 20px;
    background: rgba(0,0,0,0.8);
    color: #ecf0f1;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 11px;
    pointer-events: none;
    line-height: 1.6;
}
.key {
    display: inline-block;
    background: #34495e;
    padding: 2px 6px;
    border-radius: 4px;
    margin: 0 2px;
    font-family: monospace;
}

/* Mobile Touch Controls */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    pointer-events: none;
    z-index: 50;
}
#mobile-controls.hidden {
    display: none;
}

/* Virtual Joystick */
#joystick-container {
    position: absolute;
    bottom: 120px;
    left: 30px;
    width: 120px;
    height: 120px;
    pointer-events: auto;
}
#joystick-base {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}
#joystick-stick {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: 3px solid rgba(255, 255, 255, 0.5);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#joystick-stick.active {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

/* Action Button */
#action-button {
    position: absolute;
    bottom: 140px;
    right: 30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border: 4px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#action-button:active {
    transform: scale(0.9);
    background: linear-gradient(135deg, #27ae60, #229954);
}
#action-button span {
    pointer-events: none;
}

/* Hide keyboard controls on mobile */
@media (max-width: 1024px) {
    #controls-hint {
        display: none;
    }
    #instructions {
        font-size: 11px;
        padding: 6px 12px;
        max-width: 70%;
        top: 10px;
    }
    /* Make HUD more compact on mobile */
    #hud {
        padding: 8px 10px;
    }
    .hud-item {
        font-size: 14px;
        gap: 5px;
    }
    .hud-icon {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
    /* Show toggle button and make upgrade panel collapsible on mobile */
    #upgrade-toggle {
        display: block;
    }
    #upgrade-panel {
        padding: 5px;
        padding-bottom: 5px;
        padding-top: 20px;
    }
    #upgrade-panel.collapsed {
        transform: translateY(100%);
    }
    .upgrade-row {
        gap: 5px;
    }
    .upgrade-btn {
        padding: 8px 8px;
        font-size: 9px;
        min-height: 32px;
    }
}