#arbitrageDialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 20, 0.95);
    padding: 15px;
    border: 2px solid #ffd700;
    border-radius: 8px;
    width: 600px;
    max-height: 400px;
    overflow-y: auto;
    color: #ffd700;
    display: none;
    z-index: 9999;
}
#arbitrageDialog table {
    width: 100%;
    font-size: 0.85em;
}
body {
    margin:0;
    overflow:hidden;
    background:#000;
    font-family:sans-serif;
}
#info, #debug {
    position:absolute;
    left:10px;
    background:rgba(0,0,0,0.5);
    color:#fff;
    padding:8px 12px;
    border-radius:6px;
    font-size:13px;
    z-index:10;
}
#debug {
    bottom:10px;
    max-width:360px;
    white-space:pre-wrap;
    color:#0f0;
    display: none; /* Hidden by default, shown via console logs */
}
#cityDialog {
    position: absolute;
    top: 210px; /* Positioned below the minimap! */
    right: 15px;
    width: 320px;
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid #ffd700;
    border-radius: 8px;
    color: white;
    padding: 15px;
    display: none;
    z-index: 999999;
    pointer-events: auto;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}
#cityDialog button {
    background: rgba(15, 15, 15, 0.9);
    color: #ffd700;
    border: 1px solid #ffd700;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
#cityDialog button:hover {
    background: #ffd700;
    color: #000;
}
.fast-travel-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20,20,20,0.95);
    padding: 20px;
    border-radius: 12px;
    color: #fff;
    width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 9999;
}
.fast-travel-dialog button {
    width: 100%;
    margin: 6px 0;
    padding: 10px;
    background: #2a6df4;
    border: none;
    border-radius: 6px;
    color: white;
    font: 15px;
    cursor: pointer;
}
.fast-travel-dialog button:hover {
    background: #1f54c7;
}
.hidden {
    display: none;
}

/* Unified UI Container */
#uiContainer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; /* Allow clicking through to 3D canvas */
    z-index: 1000;
}
#topBar {
    position: absolute;
    top: 15px; left: 15px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}
.ui-btn {
    background: rgba(15, 15, 15, 0.9);
    color: #ffd700;
    border: 1px solid #ffd700;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.ui-btn:hover {
    background: #ffd700;
    color: #000;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Left Panel: Stats & Chat */
#leftPanel {
    position: absolute;
    bottom: 15px; left: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}
#statsContainer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(10, 10, 10, 0.8);
    padding: 10px 15px;
    border: 1px solid #ffd700;
    border-radius: 8px;
    width: 220px;
    display: none; /* Shown only in City View */
}
.stat-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}
.stat-label {
    color: #ffd700;
    font-weight: bold;
    font-size: 12px;
    width: 35px;
}
.stat-bar-container {
    flex: 1;
    height: 12px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #ffd700;
    border-radius: 6px;
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    transition: width 0.2s ease-out;
}

/* Global Chat Panel (Transparent by default, opaque on hover!) */
#chatPanel {
    width: 380px;
    height: 220px;
    background: rgba(10, 10, 10, 0.25); /* Highly transparent */
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    opacity: 0.6;
    transition: all 0.3s ease;
}
#chatPanel:hover {
    background: rgba(10, 10, 10, 0.85); /* Opaque on hover */
    border-color: #ffd700;
    opacity: 1.0;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}
#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    color: #fff;
    font-size: 13px;
    line-height: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-msg {
    word-break: break-word;
}
.chat-msg-system {
    color: #ffd700;
    font-weight: bold;
}
.chat-msg-user {
    color: #66ccff;
    font-weight: bold;
}
#chatInputContainer {
    border-top: 1px solid #ffd700;
    padding: 8px 12px;
    background: rgba(5, 5, 5, 0.9);
}
#chatInput {
    width: 100%;
    border: none;
    background: transparent;
    color: #fff;
    outline: none;
    font-size: 13px;
}

/* Right Panel: RPG & Boat Panels (Positioned directly above tab buttons!) */
#rightPanel {
    position: absolute;
    bottom: 65px; right: 15px; /* Anchored above bottom-right buttons */
    width: 320px;
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid #ffd700;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    display: none; /* Shown only when logged in */
}
#tabButtons {
    position: absolute;
    bottom: 15px; right: 15px; /* Anchored in bottom-right corner */
    display: flex;
    gap: 8px;
    pointer-events: auto;
    z-index: 1001;
}
.tab-btn {
    padding: 8px;
    background: rgba(15, 15, 15, 0.9);
    border: 1px solid #ffd700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}
.tab-btn:hover, .tab-btn.active {
    background: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}
.tab-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: grayscale(100%) brightness(0.8);
    transition: all 0.2s;
}
.tab-btn:hover .tab-icon, .tab-btn.active .tab-icon {
    filter: none;
    transform: scale(1.1);
}
#tabContent {
    padding: 15px;
    overflow-y: auto;
    max-height: 50vh; /* Adjusted to fit above buttons */
}
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}
.panel-title {
    color: #ffd700;
    margin-top: 0;
    margin-bottom: 12px;
    border-bottom: 1px dashed rgba(255, 215, 0, 0.3);
    padding-bottom: 4px;
    font-size: 14px;
}

/* Equipment Grid */
#equipmentGrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.rpg-slot {
    height: 65px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px dashed rgba(255, 215, 0, 0.4);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #555;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 4px;
    box-sizing: border-box;
}
.rpg-slot:hover {
    border-color: #ffd700;
    color: #ffd700;
}
.rpg-slot.equipped {
    color: #ffd700;
    border: 1px solid #ffd700;
    background: rgba(255, 215, 0, 0.1);
    font-weight: bold;
}

/* RPG Inventory Grid */
.rpg-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.rpg-item {
    aspect-ratio: 1;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 10px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    padding: 4px;
    box-sizing: border-box;
}
.rpg-item:hover {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.05);
}
.rpg-item-qty {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 9px;
    color: #ffd700;
    font-weight: bold;
}

/* RPG Shop Dialog */
#shopDialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 15, 15, 0.95);
    border: 2px solid #ffd700;
    border-radius: 8px;
    width: 600px;
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    color: #ffd700;
    display: none;
    z-index: 100000;
    box-shadow: 0 0 25px rgba(0,0,0,0.8);
}
.shop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed rgba(255, 215, 0, 0.2);
}
.shop-btn {
    background: #ffd700;
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 11px;
    transition: background 0.2s;
}
.shop-btn:hover {
    background: #ffea00;
}

/* Context Menu Items */
.context-menu-item {
    padding: 8px 20px;
    cursor: pointer;
    transition: background 0.2s;
}
.context-menu-item:hover {
    background: rgba(255, 215, 0, 0.15);
}

/* Minimap Container (Positioned at Top-Right Corner!) */
#miniMapContainer {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 320px;
    height: 180px;
    z-index: 1001;
    pointer-events: auto;
    display: none; /* Shown only in City View */
}
