/* ==========================================================
   GAME PANEL SYSTEM
   Dark wood + hammered gold — consistent across all panels.
   ========================================================== */

/* ── Overlay backdrop ── */
.game-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.game-overlay.visible { display: flex; }

/* ── Shared visual frame — pixel art 9-patch border ── */
/* Applied to ALL panels. Does NOT set display — each panel manages its own. */
.game-panel,
#map-panel,
#trade-panel,
#leaderboard-panel,
#economy-panel,
#controls-panel,
#left-hud-panel,
#ui-panel,
.equipment-select-modal {
    background: #1a1610;
    border-style: solid;
    border-width: 12px;
    border-image: url('/static/assets/sprites/ui/ui_panel_frame.png') 12 fill / 12px / 0px;
    border-image-width: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85);
    color: #d4c898;
    font-family: Georgia, 'Times New Roman', serif;
    border-radius: 0;
    image-rendering: pixelated;
}

/* Modal panels are flex columns (always visible when shown by overlay) */
.game-panel,
#map-panel,
#trade-panel,
#leaderboard-panel,
#economy-panel,
#controls-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 88vh;
}

/* Equipment modal: hidden by default, flex when .active */
.equipment-select-modal {
    display: none;
    overflow: hidden;
    max-height: 80vh;
}
.equipment-select-modal.active {
    display: flex;
    flex-direction: column;
}

/* Left HUD panel: hidden by default, block when .visible */
#left-hud-panel {
    overflow: auto;
}

/* Inventory panel: visibility controlled by JS via .visible class */
#ui-panel {
    overflow: visible;
}

/* ── Panel header — tiling wood-grain background ── */
.panel-header {
    background-color: #2a2010;
    background-image: url('/static/assets/sprites/ui/ui_panel_header.png');
    background-repeat: repeat-x;
    background-size: auto 100%;
    image-rendering: pixelated;
    border-bottom: none;
    border-radius: 0;
    padding: 9px 14px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 10px;
    position: relative;
}

/* Gold diamond ornament centred behind title text */
.panel-header::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 12px;
    background-image: url('/static/assets/sprites/ui/ui_header_ornament.png');
    background-size: 100% 100%;
    image-rendering: pixelated;
    pointer-events: none;
    opacity: 0.5;
}

/* ── Panel header title (h3 or .game-panel-title inside .panel-header) ── */
.panel-header h3,
.game-panel-title {
    flex: 1;
    margin: 0;
    font-size: 13px;
    color: #e8c878;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: normal;
    font-family: Georgia, serif;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ── Close / collapse buttons ── */
.btn-panel-close {
    background: #2e1810;
    border: 1px solid #8a3020;
    color: #d05040;
    width: 20px;
    height: 20px;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 0;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    font-family: monospace;
    transition: background 0.1s, color 0.1s;
}
.btn-panel-close:hover {
    background: #601808;
    color: #ff7060;
    border-color: #c04030;
}

/* ── Panel body (scrollable content area) ── */
.game-panel-body {
    padding: 12px 14px;
    overflow-y: auto;
    flex: 1;
}

/* Styled scrollbars — global rule covers all scrollable areas */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: #0e0c08; }
::-webkit-scrollbar-thumb { background: #c8a050; border-radius: 0; }

/* ── Thin gold divider ── */
.game-divider {
    border: none;
    border-top: 1px solid #3a3020;
    margin: 8px 0;
}

/* ── Game button (standard) ── */
.btn-game {
    background: #221e14;
    border: 1px solid #c8a050;
    color: #e8c878;
    padding: 5px 12px;
    font-family: Georgia, serif;
    font-size: 12px;
    cursor: pointer;
    border-radius: 0;
    letter-spacing: 0.04em;
    transition: background 0.1s;
}
.btn-game:hover { background: #3a3428; color: #f8d898; }
.btn-game:active { background: #141008; }

/* ── Section sub-header inside panels ── */
.game-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #c8a050;
    margin: 0 0 6px 0;
    padding-bottom: 3px;
    border-bottom: 1px solid #3a3020;
}

/* ── Rail buttons (left icon rail) ── */
.rail-btn {
    background: #221e14 !important;
    border: 1px solid #c8a050 !important;
    border-radius: 0 !important;
    box-shadow: inset 0 1px 0 rgba(232, 200, 120, 0.15);
    transition: background 0.1s, border-color 0.1s;
}
.rail-btn:hover {
    background: #3a3020 !important;
    border-color: #e8c878 !important;
}
.rail-btn.active-tab, .rail-btn.left-hud-open-btn.active {
    background: #3a2c10 !important;
    border-color: #e8c878 !important;
    outline: none !important;
    filter: none !important;
}

/* ── Stat sections inside left-hud-panel ── */
.stat-section {
    border: 1px solid #3a3020 !important;
    border-radius: 0 !important;
    background: #1e1a10 !important;
    box-shadow: none !important;
}

.stat-section:hover {
    transform: none !important;
    box-shadow: none !important;
    border-color: #c8a050 !important;
}

.stat-section h3 {
    font-size: 11px;
    color: #c8a050;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: normal;
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #3a3020;
}

.stat-item span:first-child { color: #a89058; }
.stat-item span:last-child { color: #e8c878; }

/* ── Context menu ── */
#context-menu, #inventory-context-menu {
    background: #1a1610 !important;
    border: 1px solid #c8a050 !important;
    border-radius: 0 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7) !important;
    font-family: Georgia, serif;
}

.context-item {
    color: #d4c898 !important;
    font-size: 12px;
}
.context-item:hover {
    background: #3a3020 !important;
    color: #f8d898 !important;
}

/* ── Combat stance buttons ── */
.combat-stance-btn {
    background: #221e14;
    border: 1px solid #3a3020;
    color: #a89058;
    font-family: Georgia, serif;
    font-size: 10px;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.1s;
}
.combat-stance-btn:hover { background: #3a3020; color: #e8c878; border-color: #c8a050; }
.combat-stance-btn.active { background: #3a2c10; border-color: #c8a050; color: #e8c878; }

/* ==========================================================
   MODAL OVERRIDES — layout/content specifics per modal.
   ========================================================== */

/* ── Kill browser backdrop-filter on overlay wrappers ── */
#map-modal, #trade-modal, #leaderboard-modal,
#economy-modal, #controls-modal, .equipment-modal-backdrop {
    backdrop-filter: none;
}

/* ── Map canvas ── */
#map-canvas {
    display: block;
    margin: 12px;
    border: 2px solid #000;
    box-shadow: inset 0 0 0 1px #c8a050;
    border-radius: 0;
    background: #1a2a10;
    image-rendering: pixelated;
}

/* ── Trade ── */
#trade-panel { width: 780px; max-width: 96vw; }
#trade-gold {
    background: #141008;
    border-bottom: 1px solid #3a3020;
    padding: 5px 14px;
    font-size: 11px;
    color: #a89050;
    flex-shrink: 0;
    display: flex; gap: 16px;
}
#trade-gold span { color: #e8c878; }
.shop-card {
    border-radius: 0;
    border: 1px solid #3a3020;
    background: #1e1a10;
}
.shop-card:hover { border-color: #c8a050; background: #2a2418; }

/* ── Leaderboard ── */
#leaderboard-panel { width: 520px; max-width: 94vw; }
#leaderboard-tabs {
    padding: 8px 10px 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    background: #141008;
    border-bottom: 1px solid #3a3020;
    flex-shrink: 0;
}
.leaderboard-tab {
    background: #1e1a10;
    border: 1px solid #3a3020;
    border-bottom: none;
    color: #a89050;
    font-size: 10px;
    padding: 5px 0;
    cursor: pointer;
    border-radius: 0;
    font-family: Georgia, serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: background 0.1s, color 0.1s;
}
.leaderboard-tab:hover { background: #2a2418; color: #e8c878; }
.leaderboard-tab.active {
    background: #1a1610;
    border-color: #c8a050;
    color: #e8c878;
    box-shadow: 0 2px 0 #1a1610;
}
#leaderboard-meta { padding: 6px 12px; font-size: 10px; color: #8a7858; flex-shrink: 0; }
#leaderboard-table-wrap { overflow-y: auto; flex: 1; padding: 0 10px 10px; }
#leaderboard-table { width: 100%; border-collapse: collapse; font-size: 12px; }
#leaderboard-table th {
    color: #c8a050; font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.08em; padding: 5px 6px;
    border-bottom: 1px solid #3a3020; font-weight: normal; text-align: left;
}
#leaderboard-table td { padding: 5px 6px; color: #d4c898; border-bottom: 1px solid #252015; }
#leaderboard-table tr:hover td { background: #221e14; }

/* ── Economy ── */
#economy-panel { width: 640px; max-width: 95vw; }
#economy-actions {
    padding: 8px 12px; display: flex; gap: 6px;
    background: #141008; border-bottom: 1px solid #3a3020; flex-shrink: 0;
}
#economy-actions button {
    background: #221e14; border: 1px solid #c8a050; color: #e8c878;
    padding: 4px 10px; font-family: Georgia, serif; font-size: 11px;
    cursor: pointer; border-radius: 0;
}
#economy-actions button:hover { background: #3a3428; }
#economy-meta { padding: 5px 12px; font-size: 10px; color: #8a7858; flex-shrink: 0; }
.economy-grid { padding: 8px 10px; flex: 1; overflow-y: auto; }
.economy-card {
    border: 1px solid #3a3020; border-radius: 0;
    background: #1e1a10; padding: 8px 10px; margin-bottom: 8px;
}
.economy-card h4 {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
    color: #c8a050; margin: 0 0 6px 0; font-weight: normal;
    padding-bottom: 4px; border-bottom: 1px solid #3a3020;
}
.economy-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.economy-table td { padding: 3px 4px; color: #d4c898; border-bottom: 1px solid #252015; }

/* ── Equipment select modal ── */
.equipment-select-modal { width: 90%; max-width: 500px; }
.equipment-select-items { padding: 12px; overflow-y: auto; flex: 1; }
.equipment-select-item {
    border-radius: 0; border: 1px solid #3a3020; background: #1e1a10;
    transition: border-color 0.1s, background 0.1s;
}
.equipment-select-item:hover { border-color: #c8a050; background: #2a2418; transform: none; }
.equipment-select-item.equipped { border-color: #c8a050; box-shadow: none; }

/* ── Controls ── */
#controls-panel { max-width: 480px; width: 90vw; }
#controls-body {
    padding: 14px 16px; font-size: 12px; line-height: 1.7;
    color: #d4c898; font-family: Georgia, serif;
}
#controls-body strong {
    color: #e8c878; font-weight: normal;
    text-transform: uppercase; font-size: 10px; letter-spacing: 0.08em;
}
#controls-body ul { margin: 4px 0 8px 0; padding-left: 16px; }
#controls-body li { margin-bottom: 3px; }
#controls-body kbd {
    background: #2a2418; border: 1px solid #c8a050; color: #e8c878;
    padding: 1px 5px; font-size: 11px; font-family: monospace; border-radius: 0;
}
