/* ===== IntEarth Game Styles ===== */
/* Theme aligned with BrandenOwens.com (earthy/parchment palette) */

:root {
    --bg-primary: #1a1a2e;
    --bg-overlay: rgba(10, 10, 20, 0.85);
    --bg-card: rgba(44, 24, 16, 0.95);
    --text-primary: #f4e4c1;
    --text-secondary: #d4c4a0;
    --accent: #8b4513;
    --accent-hover: #a0522d;
    --gold: #c9a84c;
    --gold-dim: #6b3a0a;
    --danger: #8b2020;
    --success: #2d5a1e;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ===== 3D Viewport ===== */
#game-viewport {
    position: fixed;
    inset: 0;
    z-index: 0;
}

#game-viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ===== 2D Overlay (minimap, effects) ===== */
#overlayCanvas {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

/* Allow clicks on overlay only during gameplay (JS toggles this) */
.hud:not(.hidden) ~ #overlayCanvas,
#overlayCanvas {
    pointer-events: auto;
}

/* ===== Menu Overlays ===== */
.menu-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.menu-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.menu-container {
    background: var(--bg-card);
    border: 2px solid var(--gold-dim);
    border-radius: 12px;
    padding: 3rem 4rem;
    text-align: center;
    min-width: 360px;
    max-width: 500px;
    box-shadow: 0 0 40px rgba(107, 58, 10, 0.3), inset 0 1px 0 rgba(244, 228, 193, 0.1);
}

/* ===== Title ===== */
.game-title {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 2px 8px rgba(201, 168, 76, 0.3);
    margin-bottom: 0.3rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.game-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
}

.dev-warning {
    background: rgba(180, 120, 40, 0.2);
    border: 1px solid rgba(200, 140, 50, 0.5);
    color: #e8b84a;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.pause-title {
    font-size: 2rem;
    color: var(--gold);
    margin-bottom: 2rem;
    letter-spacing: 0.1em;
}

/* ===== Buttons ===== */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.menu-btn {
    display: block;
    width: 100%;
    padding: 0.9rem 2rem;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    background: linear-gradient(180deg, var(--accent-hover), var(--accent));
    border: 1px solid var(--gold-dim);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
}

.menu-btn:hover {
    background: linear-gradient(180deg, #b5642e, var(--accent-hover));
    border-color: var(--gold);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.4);
}

.menu-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.menu-btn-danger {
    background: linear-gradient(180deg, #8b2020, #5a1010);
    border-color: #cc3333;
    color: #ff6666;
    margin-top: 0.8rem;
}

.menu-btn-danger:hover {
    background: linear-gradient(180deg, #aa2a2a, #6a1515);
    border-color: #ff4444;
    color: #ff8888;
}

.menu-btn-link {
    font-size: 0.9rem;
    background: transparent;
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

.menu-btn-link:hover {
    background: rgba(244, 228, 193, 0.05);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* ===== Settings ===== */
.settings-group {
    margin-bottom: 2rem;
    text-align: left;
}

.settings-label {
    display: block;
    margin-bottom: 1.2rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.settings-slider {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
    accent-color: var(--gold);
    cursor: pointer;
}

/* ===== About ===== */
.about-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.about-credit {
    color: var(--gold);
    font-style: italic;
    margin-bottom: 2rem;
}

/* ===== Auth Bar ===== */
.auth-bar {
    margin-bottom: 1.5rem;
    padding: 0.5rem 0.8rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    border: 1px solid rgba(244, 228, 193, 0.08);
}

.auth-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.menu-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: linear-gradient(180deg, #4a3520, #3a2515);
    border-color: var(--gold-dim);
}

.menu-btn-google:hover {
    background: linear-gradient(180deg, #5a4530, #4a3520);
}

.google-icon {
    width: 16px;
    height: 16px;
}

/* ===== Save Slots ===== */
.save-slots-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 400px;
    overflow-y: auto;
}

.save-loading {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.save-slot {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(244, 228, 193, 0.1);
    border-radius: 8px;
    padding: 0.8rem 1rem;
}

.save-slot-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.6rem;
}

.save-slot-label {
    font-weight: 700;
    color: var(--gold);
    font-size: 0.95rem;
}

.save-slot-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.save-slot-actions {
    display: flex;
    gap: 0.5rem;
}

.save-slot-empty {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.5;
    font-style: italic;
}

.slot-btn {
    flex: 1;
    padding: 0.45rem 0.8rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--gold-dim);
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-primary);
}

.slot-btn-load,
.slot-btn-save {
    background: linear-gradient(180deg, var(--accent-hover), var(--accent));
}

.slot-btn-load:hover,
.slot-btn-save:hover {
    background: linear-gradient(180deg, #b5642e, var(--accent-hover));
    border-color: var(--gold);
}

.slot-btn-delete {
    background: transparent;
    border-color: var(--danger);
    color: #cc5555;
    flex: 0;
    padding: 0.45rem 0.6rem;
}

.slot-btn-delete:hover {
    background: rgba(139, 32, 32, 0.3);
}

/* ===== HUD ===== */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    pointer-events: none;
}

.hud.hidden {
    display: none;
}

.hud-top-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.6rem 1.2rem;
    background: rgba(10, 10, 20, 0.75);
    border-bottom: 1px solid var(--gold-dim);
    font-size: 0.9rem;
    pointer-events: auto;
}

.hud-item {
    color: var(--text-secondary);
}

.hud-item strong {
    color: var(--gold);
}

.hud-esc-hint {
    position: fixed;
    bottom: 6rem;
    left: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.5;
    pointer-events: none;
    z-index: 55;
}

/* ===== Auto-Harvest Bar ===== */
.auto-harvest-bar {
    position: fixed;
    left: 0;
    bottom: 170px;
    z-index: 61;
    display: flex;
    gap: 1rem;
    padding: 0.35rem 1rem;
    background: rgba(10, 10, 20, 0.78);
    border: 1px solid var(--gold-dim);
    border-left: none;
    border-bottom: none;
    border-radius: 0 6px 0 0;
    backdrop-filter: blur(4px);
}

.auto-harvest-bar.hidden { display: none; }

/* Task Assignment Popup */
.task-assign-popup {
    position: fixed;
    left: 0;
    bottom: 250px;
    z-index: 70;
    min-width: 220px;
    max-width: 300px;
    background: rgba(10, 10, 20, 0.95);
    border: 1px solid var(--gold-dim);
    border-left: none;
    border-radius: 0 8px 0 0;
    backdrop-filter: blur(6px);
    padding: 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.5);
}
.task-assign-popup.hidden { display: none; }

.task-assign-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.7rem;
    border-bottom: 1px solid var(--gold-dim);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.task-assign-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}
.task-assign-close:hover { color: var(--gold); }

.task-assign-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.3rem 0;
}

.task-assign-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-primary);
    transition: background 0.15s;
}
.task-assign-row:hover {
    background: rgba(180, 160, 100, 0.15);
}

/* Assigned to THIS task — highlighted */
.task-assign-row.assigned {
    background: rgba(60, 140, 42, 0.25);
    color: #8fc97a;
    font-weight: 600;
}
.task-assign-row.assigned .task-assign-dot {
    background: #3a8c2a;
    box-shadow: 0 0 6px rgba(60, 140, 42, 0.6);
}

/* Assigned to a DIFFERENT task — crossed out */
.task-assign-row.other-task {
    opacity: 0.4;
    text-decoration: line-through;
    cursor: default;
}

.task-assign-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    flex-shrink: 0;
}

.task-assign-name {
    flex: 1;
}
.task-assign-info {
    font-size: 0.65rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.stockpile-placement-bar {
    position: fixed;
    left: 0;
    bottom: 140px;
    z-index: 61;
    display: flex;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    background: rgba(10, 10, 20, 0.78);
    border: 1px solid var(--gold-dim);
    border-left: none;
    border-bottom: none;
    border-radius: 0 6px 0 0;
    backdrop-filter: blur(4px);
}
.stockpile-placement-bar.hidden { display: none; }

.stockpile-place-btn {
    background: rgba(40, 35, 20, 0.9);
    color: var(--gold);
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}
.stockpile-place-btn:hover {
    background: rgba(80, 70, 30, 0.9);
}

/* Task label buttons (replaced checkboxes) */
.task-label-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
    font-family: inherit;
}
.task-label-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(200, 170, 80, 0.12);
}
.task-label-btn.active {
    border-color: var(--gold);
    background: rgba(200, 170, 80, 0.18);
    color: var(--gold);
}
.task-label-btn.has-workers {
    border-color: var(--success);
    color: var(--success);
}
.task-label-btn.has-workers:hover {
    background: rgba(74, 143, 63, 0.15);
}
.task-label-icon {
    font-size: 0.7rem;
}
.task-label-count {
    font-size: 0.65rem;
    background: rgba(255,255,255,0.1);
    padding: 0 0.3rem;
    border-radius: 3px;
    min-width: 1rem;
    text-align: center;
}
.task-label-btn.has-workers .task-label-count {
    background: rgba(74, 143, 63, 0.3);
}

.repro-warning {
    font-size: 0.65rem;
    color: #ff6644;
    font-style: italic;
    padding-left: 0.3rem;
}
.repro-warning.hidden { display: none; }

.task-label-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ===== Stockpile Context Menu ===== */
.stockpile-ctx-menu {
    position: fixed;
    z-index: 1100;
    background: rgba(15, 12, 25, 0.95);
    border: 1px solid rgba(200, 170, 100, 0.35);
    border-radius: 6px;
    padding: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 130px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.stockpile-ctx-menu.hidden { display: none; }

.ctx-menu-btn {
    background: rgba(40, 35, 55, 0.8);
    border: 1px solid rgba(200, 170, 100, 0.15);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.ctx-menu-btn:hover:not(:disabled) {
    background: rgba(200, 170, 100, 0.2);
}
.ctx-menu-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.ctx-menu-btn.ctx-danger {
    color: #ff6644;
}
.ctx-menu-btn.ctx-danger:hover:not(:disabled) {
    background: rgba(255, 80, 40, 0.2);
}
.ctx-menu-btn.ctx-active {
    color: #ffaa44;
    border-color: rgba(255, 170, 68, 0.4);
}
.ctx-menu-title {
    color: #c9a84c;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 2px 6px 4px;
    border-bottom: 1px solid rgba(200, 170, 100, 0.2);
    margin-bottom: 2px;
    text-align: center;
}
.ctx-menu-info {
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 2px 6px 4px;
    text-align: center;
}
.ctx-menu-cost {
    color: rgba(200, 200, 200, 0.7);
    font-size: 0.65rem;
    padding: 0 6px 4px;
    text-align: center;
}
.ctx-menu-cost .cost-missing {
    color: #ff6644;
}

/* Emptying pile visual indicator */
.stockpile-emptying-label {
    position: absolute;
    top: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: #ffaa44;
    font-size: 0.6rem;
    white-space: nowrap;
}

/* ===== Stockpile Bar ===== */
.stockpile-bar {
    position: fixed;
    left: 0;
    bottom: 80px;
    z-index: 62;
    display: flex;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(10, 10, 20, 0.82);
    border: 1px solid var(--gold-dim);
    border-left: none;
    border-bottom: none;
    border-radius: 0 6px 0 0;
    backdrop-filter: blur(4px);
}
.stockpile-bar.hidden { display: none; }

.stockpile-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    font-family: inherit;
    color: var(--text-secondary);
    background: rgba(40, 35, 25, 0.8);
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.stockpile-btn:hover {
    color: var(--gold);
    background: rgba(60, 50, 30, 0.9);
    border-color: var(--gold);
}

.stockpile-place-msg {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 0.5rem 1.2rem;
    background: rgba(10, 10, 20, 0.9);
    border: 1px solid var(--gold);
    border-radius: 6px;
    color: var(--gold);
    font-size: 0.9rem;
    pointer-events: none;
}
.stockpile-place-msg.hidden { display: none; }

/* ===== City Panel (bottom bar) ===== */
.city-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(10, 10, 20, 0.88);
    border-top: 1px solid var(--gold-dim);
    padding: 0.6rem 1.2rem 0.4rem;
    backdrop-filter: blur(4px);
    /* Minimap needs to know this height to sit above */
    --panel-height: 7rem;
}

.city-panel.hidden {
    display: none;
}

.city-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    padding-left: 310px;
    text-align: center;
}

.city-status strong {
    color: var(--gold);
}

.building-slots {
    display: flex;
    gap: 1rem;
    overflow: visible;
    padding-bottom: 0.2rem;
    padding-top: 10px;   /* room for badge above cards */
    align-items: flex-end;
}

/* ---- Building Stack Container ---- */
.building-stack {
    position: relative;
    cursor: pointer;
    min-width: 160px;
}
.building-stack .stack-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--gold);
    color: #1a1510;
    font-size: 0.65rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
/* Stacked shadow cards behind the top card */
.building-stack .stack-shadow {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: rgba(44, 24, 16, 0.5);
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: 6px;
    pointer-events: none;
}
.building-stack .stack-shadow:nth-child(1) { transform: translate(3px, -3px); }
.building-stack .stack-shadow:nth-child(2) { transform: translate(6px, -6px); }

/* ---- Fan-out popup (click to toggle) ---- */
.building-stack .stack-fan {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    flex-direction: column;
    gap: 3px;
    padding: 6px;
    z-index: 100;
    min-width: 200px;
    background: rgba(20, 15, 10, 0.95);
    border: 1px solid var(--gold-dim);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.building-stack .stack-fan.open {
    display: flex;
}
.stack-fan .fan-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(40, 30, 18, 0.8);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 5px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.75rem;
    color: var(--text);
}
.stack-fan .fan-card:hover {
    border-color: var(--gold);
    background: rgba(60, 45, 25, 0.9);
}
.fan-card .fan-icon {
    font-size: 1rem;
}
.fan-card .fan-name {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.75rem;
}
.fan-card .fan-hp {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-left: auto;
}

/* ---- Building Card (top card in stack) ---- */
.building-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(44, 24, 16, 0.7);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    min-width: 160px;
    cursor: pointer;
    transition: border-color 0.2s;
    z-index: 3;
}

.building-card:hover {
    border-color: var(--gold);
}

/* Grayed out unowned card */
.building-card.grayed {
    opacity: 0.4;
    border-style: dashed;
    cursor: default;
}
.building-card.grayed:hover {
    border-color: rgba(201, 168, 76, 0.4);
}
.building-card.grayed .building-name {
    color: var(--text-secondary);
}

/* Under construction indicator */
.building-card.constructing {
    border-color: rgba(255, 180, 50, 0.5);
    animation: constructPulse 2s ease-in-out infinite;
}
@keyframes constructPulse {
    0%, 100% { border-color: rgba(255, 180, 50, 0.3); }
    50% { border-color: rgba(255, 180, 50, 0.7); }
}

.building-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.building-info {
    flex: 1;
}

.building-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold);
}

.building-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

/* ===== Settlement Name Input ===== */
.name-input-group {
    margin: 1.5rem 0;
}

.settlement-input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-family: inherit;
    font-size: 1.1rem;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--gold-dim);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: center;
    letter-spacing: 0.05em;
}

.settlement-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.2);
}

.settlement-input.invalid {
    border-color: #cc3333;
    box-shadow: 0 0 12px rgba(204, 51, 51, 0.3);
}

.settlement-input.valid {
    border-color: #4a8a2a;
    box-shadow: 0 0 12px rgba(74, 138, 42, 0.3);
}

.name-feedback {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

.feedback-error {
    color: #cc4444;
}

.feedback-success {
    color: #6aaa3a;
}

/* ===== Stat Allocation ===== */
.stat-allocation {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin: 1.2rem 0;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.stat-label {
    width: 100px;
    text-align: right;
    font-size: 0.9rem;
    color: var(--gold);
    font-weight: bold;
}

.stat-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.15rem;
}

.stat-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--gold-dim);
    background: rgba(30, 30, 50, 0.8);
    color: var(--gold);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.stat-btn:hover:not(:disabled) {
    background: rgba(60, 50, 30, 0.8);
    border-color: var(--gold);
}

.stat-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.stat-value {
    width: 30px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text);
}

.stat-bar-track {
    width: 100px;
    height: 8px;
    background: rgba(30, 30, 50, 0.8);
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: var(--gold);
    transition: width 0.15s;
    border-radius: 3px;
}

.stat-pool-display {
    text-align: center;
    font-size: 1rem;
    color: var(--text);
    margin-top: 0.5rem;
}

.stat-pool-display strong {
    color: var(--gold);
    font-size: 1.2rem;
}

/* ===== Leader Selection ===== */
.leader-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 1rem 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    max-height: 300px;
    overflow-y: auto;
}

.leader-card {
    background: rgba(30, 28, 40, 0.8);
    border: 1px solid var(--gold-dim);
    border-radius: 6px;
    padding: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.leader-card:hover {
    border-color: var(--gold);
    background: rgba(40, 38, 50, 0.9);
}

.leader-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.leader-card-name {
    color: var(--gold);
    font-weight: bold;
    font-size: 1rem;
}

.leader-card-level {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.leader-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.leader-stat-badge {
    background: rgba(80, 60, 40, 0.4);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.leader-list-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 1.5rem;
    font-style: italic;
}

.leader-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.leader-btn {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    background: rgba(44, 24, 16, 0.9);
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.leader-btn:hover {
    border-color: var(--gold);
    background: var(--accent);
}

.leader-btn-danger {
    border-color: var(--danger);
}

.leader-btn-danger:hover {
    background: var(--danger);
    border-color: #aa3030;
}

/* ===== Population Panel ===== */
.hud-pop-clickable {
    cursor: pointer;
    border-bottom: 1px dashed var(--gold-dim);
    transition: border-color 0.2s;
}

.hud-pop-clickable:hover {
    border-color: var(--gold);
}

.pop-panel {
    position: fixed;
    top: 2.6rem;
    width: 380px;
    max-height: 70vh;
    background: rgba(10, 10, 20, 0.94);
    border: 1px solid var(--gold-dim);
    border-radius: 0 0 8px 8px;
    z-index: 150;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.pop-panel.hidden {
    display: none;
}

.pop-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--gold);
    border-bottom: 1px solid var(--gold-dim);
}

.pop-panel-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}

.pop-panel-close:hover {
    color: var(--text);
}

.pop-panel-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Individual citizen card */
.citizen-card {
    background: rgba(30, 28, 40, 0.7);
    border: 1px solid rgba(100, 80, 40, 0.3);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
}

.citizen-info {
    flex-shrink: 0;
    min-width: 70px;
    max-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.citizen-name {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.citizen-tag {
    font-size: 0.6rem;
    color: var(--gold-dim);
    padding: 0.05rem 0.35rem;
    border: 1px solid var(--gold-dim);
    border-radius: 3px;
}

.citizen-status {
    font-size: 0.65rem;
    margin-top: 0.1rem;
}

.citizen-status.idle {
    color: var(--success, #6aaa3a);
}

.citizen-status.busy {
    color: var(--gold);
}

/* Stats grid on the right side of the card */
.citizen-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.citizen-stat-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.citizen-stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    width: 62px;
    text-align: right;
    flex-shrink: 0;
}

.citizen-stat-level {
    font-size: 0.65rem;
    color: var(--gold);
    width: 28px;
    text-align: center;
    flex-shrink: 0;
    font-weight: bold;
}

.citizen-stat-bar {
    flex: 1;
    height: 6px;
    background: rgba(30, 30, 50, 0.8);
    border: 1px solid rgba(100, 80, 40, 0.25);
    border-radius: 3px;
    overflow: hidden;
}

.citizen-stat-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dim), var(--gold));
    border-radius: 2px;
    transition: width 0.3s;
}

/* ===== Busy Toast ===== */
.busy-toast {
    position: fixed;
    top: 3.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(180, 60, 60, 0.9);
    color: #fff;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 200;
}

.busy-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Leaderboard (HUD - top left) ===== */
.leaderboard {
    position: fixed;
    top: 2.8rem;
    right: 0;
    width: 220px;
    background: rgba(10, 10, 20, 0.75);
    border-left: 1px solid var(--gold-dim);
    border-bottom: 1px solid var(--gold-dim);
    border-bottom-left-radius: 8px;
    z-index: 52;
    pointer-events: auto;
}

.leaderboard-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    border-bottom: 1px solid rgba(201, 168, 76, 0.2);
}

.leaderboard-header:hover {
    background: rgba(60, 50, 30, 0.3);
}

.leaderboard-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.leaderboard.collapsed .leaderboard-arrow {
    transform: rotate(0deg);
}

.leaderboard:not(.collapsed) .leaderboard-arrow {
    transform: rotate(90deg);
}

.leaderboard-body {
    padding: 0.2rem 0.6rem 0.5rem;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
    max-height: 300px;
}

.leaderboard.collapsed .leaderboard-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.leaderboard.collapsed .leaderboard-header {
    border-bottom: none;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.15rem 0;
}

.leaderboard-mine {
    color: var(--gold);
    font-weight: 700;
}

.lb-rank {
    width: 1.2em;
    text-align: right;
    color: var(--text-secondary);
    opacity: 0.6;
}

.leaderboard-mine .lb-rank {
    color: var(--gold);
    opacity: 1;
}

.lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.7rem;
}

.leaderboard-empty {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.5;
    font-style: italic;
    padding: 0.2rem 0;
}

/* World Population Stats in pause menu */
.world-pop-stats {
    margin-bottom: 1rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(244, 228, 193, 0.08);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}

.world-pop-header {
    font-size: 0.8rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
    text-align: center;
}

.world-pop-row {
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.world-pop-item {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.world-pop-item strong {
    color: var(--text-primary);
}

.world-pop-icon {
    font-size: 0.7rem;
    margin-right: 0.15rem;
}

/* Leaderboard in pause menu */
.pause-leaderboard {
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(244, 228, 193, 0.08);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}

.pause-leaderboard .leaderboard-header {
    font-size: 0.85rem;
}

.pause-leaderboard .leaderboard-entry {
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.pause-leaderboard .lb-score {
    font-size: 0.8rem;
}

/* ===== Building Health Bars (City Panel) ===== */
.building-hp-bar {
    width: 100%;
    height: 4px;
    background: rgba(40, 40, 40, 0.8);
    border-radius: 2px;
    margin-top: 0.3rem;
    overflow: hidden;
}

.building-hp-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ===== Deer Follow Panel ===== */
.follow-panel {
    position: fixed;
    top: 4rem;
    left: 1rem;
    width: 240px;
    background: rgba(20, 15, 10, 0.92);
    border: 1px solid var(--border);
    border-radius: 6px;
    z-index: 30;
    font-size: 0.78rem;
    color: var(--text);
    pointer-events: auto;
}
.follow-panel.hidden { display: none; }
.follow-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-weight: bold;
    color: var(--gold);
}
.follow-header button {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.2rem;
}
.follow-header button:hover { color: var(--gold); }
.follow-stats {
    padding: 0.4rem 0.6rem;
    line-height: 1.5;
}
.follow-label {
    color: #aaa;
    display: inline-block;
    width: 52px;
}
.follow-log-header {
    padding: 0.25rem 0.6rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: #aaa;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.follow-log {
    max-height: 180px;
    overflow-y: auto;
    padding: 0.3rem 0.6rem;
    font-size: 0.72rem;
    line-height: 1.6;
}
.follow-log .log-entry {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 2px 0;
}
.follow-log .log-time {
    color: #777;
    margin-right: 4px;
}
.follow-log .log-eat { color: #6c6; }
.follow-log .log-move { color: #aaa; }
.follow-log .log-breed { color: #f9a; }
.follow-log .log-baby { color: #fa4; }
.follow-log .log-hunger { color: #f66; }
.follow-log .log-idle { color: #8af; }

/* ===== Building Placement Panel ===== */
.place-building-panel {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    background: rgba(30, 25, 18, 0.95);
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 0;
    min-width: 320px;
    max-width: 420px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
.place-building-panel.hidden { display: none; }
.place-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(201,168,76,0.3);
}
.place-panel-title {
    color: var(--gold);
    font-weight: bold;
    font-size: 0.9rem;
}
.place-panel-header button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}
.place-tier-list {
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.place-tier-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.place-tier-row:hover { background: rgba(201,168,76,0.15); }
.place-tier-row.locked {
    opacity: 0.4;
    cursor: not-allowed;
}
.place-tier-row.locked:hover { background: none; }
.place-tier-name {
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: bold;
}
.place-tier-bonus {
    color: var(--text-secondary);
    font-size: 0.65rem;
}
.place-tier-cost {
    text-align: right;
    font-size: 0.7rem;
    color: var(--gold);
}
.place-tier-cost .cost-missing { color: var(--danger); }
.place-status {
    padding: 4px 12px 8px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
}
/* Placement ghost mode indicator */
.placement-mode-banner {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1300;
    background: rgba(201,168,76,0.9);
    color: #1a1510;
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* ===== Unit Follow Stats Grid ===== */
.unit-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px 8px;
    border-top: 1px solid rgba(201,168,76,0.15);
}
.unit-stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
}
.unit-stat-label {
    width: 65px;
    color: var(--text-secondary);
}
.unit-stat-val {
    width: 22px;
    text-align: right;
    color: var(--gold);
    font-weight: bold;
}
.unit-stat-xp-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}
.unit-stat-xp-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.3s;
}
.follow-log-entry {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 1px 0;
}

/* ===== World Map ===== */
.worldmap-btn {
    position: fixed;
    bottom: 5.5rem;
    right: 1rem;
    z-index: 1000;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--text-secondary);
    background: rgba(40, 35, 25, 0.85);
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    cursor: pointer;
    pointer-events: auto;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.worldmap-btn:hover {
    color: var(--gold);
    background: rgba(60, 50, 30, 0.9);
    border-color: var(--gold);
}
.worldmap-btn.hidden { display: none; }

.worldmap-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}
.worldmap-overlay.hidden { display: none; }

.worldmap-container {
    background: rgba(10, 10, 20, 0.95);
    border: none;
    border-radius: 0;
    padding: 0.5rem;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.worldmap-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--gold-dim);
}

.worldmap-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.worldmap-hint {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.6;
    flex: 1;
}

.worldmap-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}
.worldmap-close:hover { color: var(--gold); }

#worldmap-canvas {
    display: block;
    border-radius: 0;
    cursor: crosshair;
    flex: 0 1 auto;
    max-width: 100%;
    max-height: calc(100vh - 3.5rem);
    object-fit: contain;
}

.building-hp-text {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    opacity: 0.7;
}

/* ===== HUD Settlement Name ===== */
.hud-settlement-name {
    border-right: 1px solid var(--gold-dim);
    padding-right: 1rem;
    margin-right: 0.5rem;
}

.hud-settlement-name strong {
    color: var(--gold);
    letter-spacing: 0.05em;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .menu-container {
        min-width: auto;
        padding: 2rem 1.5rem;
        margin: 1rem;
    }

    .game-title {
        font-size: 2.5rem;
    }
}

/* ===== Unit Selection Box ===== */
.selection-box {
    position: fixed;
    border: 1px solid rgba(100, 255, 100, 0.8);
    background: rgba(100, 255, 100, 0.12);
    pointer-events: none;
    z-index: 50;
    display: none;
}
