/* ================================================================
   HUD : Resource bar, right panel, status bar
   Right panel is 160px fixed on the right side. Resource bar and
   status bar stop at right: 160px to avoid overlapping the panel.
   ================================================================ */

:root {
    --hud-topbar-height: 33px;
    --hud-right-panel-width: 160px;
    --hud-right-panel-gap: 12px;
}

/* ----- Top bar menu ----- */
.wc-top-bar-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--hud-topbar-height) !important;
    min-height: var(--hud-topbar-height) !important;
    max-height: var(--hud-topbar-height) !important;
    overflow: visible;
    z-index: 60;
    font-family: "Trebuchet MS", Verdana, sans-serif;
}

.wc-top-bar-shell {
    position: relative;
    display: flex;
    align-items: center;
    height: var(--hud-topbar-height);
    min-height: var(--hud-topbar-height);
    padding: 0 calc(var(--hud-right-panel-width) + var(--hud-right-panel-gap)) 0 14px;
    border-bottom: 2px solid #6a4f1a;
    background-image:
        linear-gradient(to bottom, rgba(20, 14, 4, 0.82), rgba(40, 28, 8, 0.78)),
        url('/game/assets/ui/human/top_resource_bar.png');
    background-repeat: repeat-x, repeat-x;
    background-size: auto var(--hud-topbar-height), auto var(--hud-topbar-height);
    background-position: 0 0, 0 0;
    box-shadow: inset 0 -1px 0 rgba(243, 193, 75, 0.15);
}

.wc-top-bar-groups {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    height: 100%;
    min-width: 0;
    overflow: visible;
    scrollbar-width: none;
    white-space: nowrap;
}

.wc-top-bar-groups::-webkit-scrollbar {
    display: none;
}

.wc-menu-group {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    height: 100%;
    overflow: visible;
}

.wc-menu-label {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: rgba(34, 27, 14, 0.78);
    color: #f2e1b2;
    padding: 3px 12px;
    height: 100%;
    box-sizing: border-box;
    font-size: 12px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.wc-menu-label:hover {
    background: rgba(102, 74, 33, 0.95);
    border-color: rgba(128, 96, 43, 0.85);
}

.wc-menu-label:focus,
.wc-menu-group.is-open > .wc-menu-label {
    border-color: rgba(128, 96, 43, 0.85);
}

.wc-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    margin: 0;
    padding: 8px 0;
    list-style: none;
    border: 1px solid rgba(133, 107, 59, 0.95);
    background: rgba(21, 13, 7, 0.97);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
    z-index: 120;
    overflow: hidden;
    border-top: 0;
    border-radius: 0 0 4px 4px;
    display: block;
}

.wc-menu-dropdown > li {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    float: none;
    clear: both;
}

.wc-menu-dropdown[hidden] {
    display: none !important;
}

.wc-menu-group.is-open > .wc-menu-dropdown,
.wc-menu-group:focus-within > .wc-menu-dropdown {
    display: block !important;
}

.wc-menu-item,
.wc-menu-button {
    display: block;
    width: 100%;
    padding: 8px 14px;
    box-sizing: border-box;
    color: #f2e1b2;
    font-size: 13px;
    text-decoration: none;
    text-align: left;
    white-space: nowrap;
    background: transparent;
    border: 0;
    float: none;
    line-height: 1.25;
}

.wc-menu-item:hover,
.wc-menu-button:hover {
    background: rgba(91, 63, 25, 0.9);
}

.wc-menu-item--disabled {
    color: #857c69;
    cursor: not-allowed;
}

.wc-menu-item--disabled:hover {
    background: transparent;
}

/* ----- Top resource bar ----- */
.resource-bar {
    position: fixed;
    top: calc(var(--hud-topbar-height) + 6px);
    left: 12px;
    right: calc(var(--hud-right-panel-width) + var(--hud-right-panel-gap));
    min-height: 33px;
    z-index: 58;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 14px;
    padding: 0;
    color: #f3e2b1;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
    user-select: none;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

.resource-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: rgba(18, 12, 4, 0.68);
    border: 1px solid rgba(243, 193, 75, 0.42);
    border-radius: 4px;
    min-width: 86px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(1px);
}

.resource-icon {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

.resource-icon-mat {
    color: #f3c14b;
    font-size: 20px;
}

.resource-icon-emoji {
    font-size: 18px;
    line-height: 20px;
}

.resource-value {
    color: #fff8d2;
    min-width: 38px;
}

/* ----- Right panel ----- */
#right-panel {
    position: fixed;
    top: var(--hud-topbar-height);
    right: 0;
    bottom: 0;
    width: var(--hud-right-panel-width);
    z-index: 55;
    display: flex;
    flex-direction: column;
    background-color: rgba(15, 10, 4, 0.82);
    border-left: 2px solid #6a4f1a;
    overflow: hidden;
}

/* ----- Minimap (lives inside #right-panel, no longer fixed itself) ----- */
.hud-minimap-frame {
    width: 100%;
    flex-shrink: 0;
    background: #234c1f;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.6);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    padding: 10px 8px 6px;
    box-sizing: border-box;
    border-bottom: 2px solid #6a4f1a;
}

.hud-minimap-frame.is-hidden {
    display: none;
}

#minimap {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    cursor: crosshair;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

/* ----- Portrait / selection info ----- */
.hud-portrait-frame {
    flex-shrink: 0;
    padding: 8px 6px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    border-bottom: 2px solid #6a4f1a;
    background: rgba(0, 0, 0, 0.25);
    min-height: 64px;
}

.hud-portrait-img {
    width: 54px;
    height: 38px;
    flex-shrink: 0;
    background-color: #0d0a06;
    background-repeat: no-repeat;
    background-position: 0 0;
    border: 1px solid #6a4f1a;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
}

.hud-portrait-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 2px;
}

#hud-selection-name {
    color: #fff8d2;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: bold;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-selection-stats {
    color: #d8c990;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 10px;
    line-height: 1.3;
    white-space: pre-line;
    overflow: hidden;
}

.hud-selection-stats span {
    display: block;
}

.hud-hp-bar-container {
    width: 100%;
    height: 6px;
    background-color: #1a0f00;
    border: 1px solid #4a3810;
    border-radius: 2px;
    margin-top: 2px;
    box-sizing: border-box;
}

.hud-hp-bar {
    height: 100%;
    background-color: #4cd137; /* Default green */
    width: 100%;
    transition: width 0.2s ease-out, background-color 0.2s ease-out;
}

/* ----- Command frame : houses build toolbar and context buttons ----- */
.hud-command-frame {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 6px;
    overflow: hidden;
}

/* ----- Discreet status text ----- */
.hud-status-line {
    display: contents;
}

@media (max-width: 960px) {
    .wc-top-bar-shell {
        padding: 0 12px;
    }

    .resource-bar {
        right: 12px;
    }
}

/* ── Tab-lease blocking overlay ─────────────────────────────────────────── */

.wc-tab-lease-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.88);
}

.wc-tab-lease-overlay[hidden] {
    display: none;
}

.wc-tab-lease-modal {
    width: min(480px, calc(100vw - 32px));
    padding: 28px 36px 32px;
    color: #f5f3ff;
    background:
        linear-gradient(135deg, rgba(230, 241, 205, 0.18), rgba(255, 255, 255, 0) 24%),
        linear-gradient(315deg, rgba(0, 0, 0, 0.22), rgba(255, 255, 255, 0) 28%),
        repeating-linear-gradient(90deg, rgba(22, 34, 31, 0.18) 0 5px, rgba(255, 255, 255, 0.04) 5px 11px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 4px, rgba(0, 0, 0, 0.10) 4px 13px),
        #3a4d44;
    border: 4px solid #c9d2be;
    box-shadow: inset 0 0 0 3px #31453f, inset 0 0 0 7px rgba(184, 201, 180, 0.46), 0 8px 0 #151b24, 0 0 0 2px #1b241f;
    font-family: "Courier New", monospace;
    text-align: center;
    image-rendering: pixelated;
}

.wc-tab-lease-modal h2 {
    margin: 0 0 14px;
    color: #f5d27a;
    font-size: 22px;
    font-weight: 900;
    line-height: 1.2;
    text-shadow: 2px 2px 0 #25332e;
}

.wc-tab-lease-modal p {
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.5;
    color: #d4cfe8;
}

.wc-tab-lease-use-here {
    display: inline-block;
    padding: 9px 28px;
    background: #5a7a2e;
    border: 3px solid #a8c76a;
    box-shadow: inset 0 0 0 2px #2e4010, 0 4px 0 #1b2a08;
    color: #f5f3ff;
    font-family: "Courier New", monospace;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-transform: uppercase;
}

.wc-tab-lease-use-here:hover {
    background: #6e9636;
    border-color: #c6e880;
}

.wc-tab-lease-use-here:active {
    transform: translateY(2px);
    box-shadow: inset 0 0 0 2px #2e4010, 0 2px 0 #1b2a08;
}

/* ── Game menu overlay ──────────────────────────────────────────────────── */

.wc-modal-overlay {
    position: fixed;
    top: 33px;
    right: 160px;
    bottom: 38px;
    left: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.72);
}

.wc-modal-overlay[hidden] {
    display: none;
}

.wc-game-menu-modal {
    width: min(560px, calc(100vw - 32px));
    padding: 18px 42px 32px;
    color: #f5f3ff;
    background:
        linear-gradient(135deg, rgba(230, 241, 205, 0.24), rgba(255, 255, 255, 0) 24%),
        linear-gradient(315deg, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0) 28%),
        repeating-linear-gradient(90deg, rgba(22, 34, 31, 0.18) 0 5px, rgba(255, 255, 255, 0.04) 5px 11px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 4px, rgba(0, 0, 0, 0.10) 4px 13px),
        #657d72;
    border: 4px solid #c9d2be;
    box-shadow: inset 0 0 0 3px #31453f, inset 0 0 0 7px rgba(184, 201, 180, 0.46), 0 8px 0 #151b24, 0 0 0 2px #1b241f;
    font-family: "Courier New", monospace;
    text-align: center;
    image-rendering: pixelated;
}

.wc-game-menu-modal h2 {
    margin: 0 0 18px;
    color: #f5f3ff;
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-shadow: 2px 2px 0 #25332e;
}

.wc-game-menu-panel[hidden] {
    display: none;
}

.wc-game-menu-modal button {
    width: 100%;
    min-height: 54px;
    margin: 0 0 12px;
    color: #f9f7ff;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.10)), #28284f;
    border: 4px solid #1d1d3f;
    box-shadow: inset 0 0 0 2px #565f88, inset 0 -4px 0 rgba(0, 0, 0, 0.28), 0 3px 0 #111226;
    font-family: "Courier New", monospace;
    font-size: 30px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-shadow: 2px 2px 0 #121224;
    cursor: pointer;
}

.wc-game-menu-modal button:hover,
.wc-game-menu-modal button:focus {
    border-color: #d8dfc8;
    outline: none;
}

.wc-game-menu-modal button:active {
    transform: translateY(2px);
    box-shadow: inset 0 0 0 2px #565f88, inset 0 -2px 0 rgba(0, 0, 0, 0.28), 0 1px 0 #111226;
}

.wc-game-menu-modal button span {
    color: #fff200;
}

.wc-menu-row {
    display: flex;
    gap: 14px;
}

.wc-menu-row button {
    flex: 1 1 0;
}

.wc-menu-row-actions {
    margin-top: 20px;
}

.wc-menu-return {
    margin-top: 22px !important;
}

.wc-game-menu-copy {
    margin: 0 0 18px;
    color: #ecf0e1;
    font-size: 15px;
    line-height: 1.45;
}

.wc-menu-helper-list,
.wc-objectives-list {
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.wc-menu-helper-list li,
.wc-objectives-list li {
    margin: 0 0 10px;
    padding: 10px 14px;
    color: #f9f7ff;
    font-size: 15px;
    line-height: 1.35;
    background: rgba(9, 14, 35, 0.42);
    border: 2px solid rgba(201, 210, 190, 0.35);
}

.wc-menu-helper-list strong,
.wc-objectives-list strong {
    color: #fff200;
}

.wc-objectives-empty {
    color: #ecf0e1;
    font-size: 15px;
    line-height: 1.45;
    margin: 0;
}

.wc-objectives-summary {
    margin-top: 14px;
    padding: 10px 14px;
    color: #fff8d2;
    text-align: left;
    background: rgba(9, 14, 35, 0.42);
    border: 2px solid rgba(201, 210, 190, 0.35);
}

.wc-objectives-summary p {
    margin: 0 0 6px;
    font-size: 14px;
}

.wc-objectives-summary p:last-child {
    margin-bottom: 0;
}

body.game-menu-open #main {
    filter: brightness(0.62);
}

@media (max-width: 720px) {
    .wc-modal-overlay {
        right: 0;
        padding: 12px;
    }

    .wc-game-menu-modal {
        padding: 16px 18px 24px;
    }

    .wc-menu-row {
        flex-direction: column;
        gap: 0;
    }

    .wc-game-menu-modal button {
        min-height: 48px;
        font-size: 24px;
    }
}

#hud-status {
    position: fixed;
    left: 12px;
    bottom: 8px;
    z-index: 80;
    display: inline-block;
    color: #fff8d2;
    max-width: min(560px, calc(100vw - 220px));
    padding: 4px 8px;
    background: rgba(10, 7, 3, 0.42);
    border-radius: 3px;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.82;
    box-shadow: inset 0 0 0 1px rgba(243, 193, 75, 0.14);
}

.hud-status-flash {
    animation: hud-flash 0.6s ease-out;
}

@keyframes hud-flash {
    0%   { color: #ffe58f; text-shadow: 0 0 6px rgba(243, 193, 75, 0.9); }
    100% { color: #fff8d2; text-shadow: none; }
}

/* ----- Misc ----- */
.build-btn-disabled {
    opacity: 0.45;
    filter: grayscale(0.8);
    cursor: not-allowed;
}
.build-btn-disabled:hover {
    border-color: #6a4f1a;
    box-shadow: none;
}

/* The map sits below the top bar and to the left of the right panel. */
body {
    padding-top: 33px;
    padding-right: 160px;
    box-sizing: border-box;
}

@media (max-width: 960px) {
    .resource-bar {
        top: 37px;
        left: 8px;
        right: 8px;
        justify-content: flex-start;
        gap: 8px;
    }

    .resource-cell {
        min-width: 72px;
        padding: 3px 8px;
    }

    #hud-status {
        left: 8px;
        bottom: 6px;
        max-width: calc(100vw - 24px);
        font-size: 10px;
    }
}

/* ----- Gold harvesting visuals ----- */
.peasant-carrying-gold {
    filter: drop-shadow(0 0 3px #f3c14b) drop-shadow(0 0 1px #fff8d2);
}

.gold-floater {
    position: absolute;
    z-index: 50;
    color: #ffe58f;
    font-family: 'monospace';
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #1a0f00, 0 0 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    animation: gold-floater-rise 1.1s ease-out forwards;
    white-space: nowrap;
}

@keyframes gold-floater-rise {
    0%   { transform: translateY(0);    opacity: 0; }
    15%  { transform: translateY(-4px); opacity: 1; }
    100% { transform: translateY(-22px); opacity: 0; }
}

/* ----- Stone harvesting visuals ----- */
.stone-floater {
    position: absolute;
    z-index: 50;
    color: #c8bea0;
    font-family: 'monospace';
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #1a1200, 0 0 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    animation: gold-floater-rise 1.1s ease-out forwards;
    white-space: nowrap;
}

/* ----- Wood harvesting visuals ----- */
.lumber-floater {
    position: absolute;
    z-index: 50;
    color: #7ec850;
    font-family: 'monospace';
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #0a1f00, 0 0 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    animation: gold-floater-rise 1.1s ease-out forwards;
    white-space: nowrap;
}
