body {
    margin: 0;
    overflow: hidden;
    background-color: #2c3e50;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Overlay for Connection / Server Full Message */
#overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(44, 62, 80, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-width: 400px;
}

.overlay-content h1 {
    color: #e74c3c;
    margin-top: 0;
}

.overlay-content p {
    color: #34495e;
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    margin: 5px;
    transition: background 0.3s;
}

button:hover {
    background: #2980b9;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas */
    z-index: 10;
}

.top-bar {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    pointer-events: auto; /* Enable clicking on user info */
}

.user-info {
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
}


.timer-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 5px 10px;
    border-radius: 10px;
    margin-left: 10px;
    font-family: monospace;
    font-size: 15px;
}

canvas {
    display: block;
}

/* Glassmorphism panel base */
.glass-panel {
    background: rgba(20, 25, 45, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    pointer-events: auto; /* Re-enable pointer events for UI */
    color: white;
}

/* Chat Box */
#chatBox {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 350px;
    height: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chatLog {
    flex-grow: 1;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

#chatLog::-webkit-scrollbar {
    width: 6px;
}
#chatLog::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.chat-message {
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(0,0,0,0.2);
    word-break: break-word;
    animation: fadeIn 0.3s ease-in-out;
}

.chat-message.system {
    color: #4ade80;
    font-weight: 600;
}

.chat-message.me {
    color: #60a5fa;
}

.chat-message.npc {
    color: #f472b6;
}

#chatInputArea {
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#chatInput {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    outline: none;
    transition: background 0.2s;
}

#chatInput:focus {
    background: rgba(255, 255, 255, 0.2);
}

#chatInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Inventory & Shop Panel */
#inventoryPanel, #shopPanel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 320px;
    max-height: 450px;
    padding: 15px;
    z-index: 1000;
    background: rgba(20, 25, 45, 0.9);
    border: 2px solid #3498db;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.5);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

#closeInventory, #closeShop {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.2s;
    padding: 0;
    margin: 0;
}

#closeInventory:hover, #closeShop:hover {
    color: white;
    background: none;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.inventory-grid::-webkit-scrollbar {
    width: 6px;
}

.inventory-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.inventory-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 5px;
}

.inventory-tabs .tab {
    background: none;
    border: none;
    color: #bdc3c7;
    cursor: pointer;
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.inventory-tabs .tab:hover {
    color: white;
}

.inventory-tabs .tab.active {
    background: rgba(52, 152, 219, 0.4);
    color: white;
    font-weight: bold;
}

.slot {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
}

.slot:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
}

/* Interaction Tooltip */
.glass-badge {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: white;
}

#interactionTooltip {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    pointer-events: none;
    animation: bounce 2s infinite ease-in-out;
}

#interactionTooltip span {
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 5px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseWarning {
    0% { background-color: rgba(255, 255, 255, 0.15); box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.7); }
    50% { background-color: rgba(230, 126, 34, 0.8); box-shadow: 0 0 15px 5px rgba(230, 126, 34, 0.4); }
    100% { background-color: rgba(255, 255, 255, 0.15); box-shadow: 0 0 0 0 rgba(230, 126, 34, 0); }
}

.time-warning {
    animation: pulseWarning 2s infinite !important;
    border: 1px solid #e67e22 !important;
    color: #ffd700 !important;
}


/* --- RESTORED CSS CLASSES --- */

#monitoringHUD {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 250px;
    padding: 15px;
    z-index: 1000;
}

.hud-header {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #3498db;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 5px;
}

.hud-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.stat-label {
    color: #bdc3c7;
}

.stat-value {
    font-weight: bold;
    color: #fff;
}

.bottom-right-box {
    position: absolute;
    bottom: 20px;
    right: 360px;
    background: rgba(20, 25, 45, 0.8);
    border: 2px solid #f1c40f;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
    border-radius: 12px;
    padding: 10px 20px;
    color: white;
    z-index: 1000;
    text-align: right;
}

.stock-title {
    font-size: 12px;
    color: #bdc3c7;
}

.stock-amount {
    font-size: 18px;
    font-weight: bold;
    color: #f1c40f;
}

#photoBoothPanel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    max-height: 80vh;
    padding: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#photoBoothPanel.hidden {
    display: none !important;
}

#npcInteractionMenu {
    position: absolute;
    background: rgba(20, 25, 45, 0.9);
    border: 1px solid #3498db;
    border-radius: 8px;
    padding: 10px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#npcInteractionMenu.hidden {
    display: none !important;
}

#oxLobbyPanel, #oxQuestionOverlay, #oxExplanationOverlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
}

.ox-lobby, .ox-question, .ox-explanation {
    background: rgba(20, 25, 45, 0.95);
    border: 2px solid #e74c3c;
    border-radius: 15px;
    padding: 25px;
    color: white;
    text-align: center;
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.5);
}

.hidden {
    display: none !important;
}


/* --- RESTORED MOBILE CONTROLS --- */

#mobileControls {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; /* Let touches pass through where there are no controls */
    z-index: 5000;
}

#mobileControls:not(.hidden) {
    display: block !important;
}

#joystickZone {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 120px;
    height: 120px;
    pointer-events: auto;
}

#joystickBase {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    backdrop-filter: blur(5px);
}

#joystickKnob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.mobile-shortcut {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(20, 25, 45, 0.7);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.mobile-shortcut:active {
    background: rgba(255, 255, 255, 0.3);
}

#actionButtonZone {
    position: absolute;
    bottom: 30px;
    right: 30px;
    pointer-events: auto;
}

#btnActionJump {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(46, 204, 113, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

#btnActionJump:active {
    background: rgba(46, 204, 113, 0.9);
    transform: scale(0.95);
}

@media (min-width: 769px) {
    #mobileControls {
        display: none !important;
    }
}
