/* ─── Character HUD (top-left) ─── */
.char-hud {
    position: fixed;
    top: clamp(6px, 1.5vmin, 12px);
    left: clamp(6px, 1.5vmin, 12px);
    display: none;
    align-items: center;
    gap: clamp(4px, 1vmin, 8px);
    z-index: var(--z-hud);
    pointer-events: none;
}

.char-hud.active {
    display: flex;
}

/* Portrait circle */
.char-portrait {
    width: clamp(36px, 7vmin, 60px);
    height: clamp(36px, 7vmin, 60px);
    border-radius: 50%;
    border: 2px solid #daa520;
    background: rgba(15, 15, 25, 0.85);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.6), inset 0 0 4px rgba(218, 165, 32, 0.15);
    overflow: hidden;
    flex-shrink: 0;
    pointer-events: auto;
}

.char-portrait canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Stat bars */
.char-bars {
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.4vmin, 4px);
}

.char-bar-row {
    display: flex;
    align-items: center;
}

.char-bar-track {
    width: clamp(80px, 16vmin, 140px);
    height: clamp(10px, 2vmin, 16px);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    overflow: hidden;
    position: relative;
}

.char-bar-fill {
    height: 100%;
    transition: width 0.15s linear;
    border-radius: 7px;
}

.char-bar-fill.hp {
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 40%), var(--bar-hp);
}

.char-bar-fill.hunger {
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 40%), var(--bar-hunger);
}

.char-bar-fill.stamina {
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 40%), var(--bar-stamina);
}

/* Low bar flash */
@keyframes bar-flash-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.char-bar-fill.low {
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 40%), #e04040 !important;
    animation: bar-flash-red 0.8s ease-in-out infinite;
}

.char-bar-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(7px, 1.2vmin, 10px);
    font-weight: bold;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    letter-spacing: 0.3px;
}

/* ─── Minimap camera controls (top-right, below minimap) ─── */
.minimap-controls {
    position: fixed;
    top: 220px; /* below minimap */
    right: 8px;
    display: none;
    gap: clamp(2px, 0.5vmin, 4px);
    z-index: 8000;
}

.minimap-controls.active {
    display: flex;
}

.mini-ctrl-btn {
    width: clamp(24px, 4vmin, 34px);
    height: clamp(24px, 4vmin, 34px);
    background: rgba(15, 15, 25, 0.85);
    border: 1px solid rgba(218, 165, 32, 0.4);
    border-radius: 4px;
    color: #daa520;
    font-size: clamp(12px, 2vmin, 18px);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
}

.mini-ctrl-btn:hover {
    background: rgba(218, 165, 32, 0.2);
    border-color: #daa520;
}

.mini-ctrl-btn:active {
    transform: scale(0.92);
}

/* ─── Placement toolbar (building placement mode) ─── */
.placement-btn {
    padding: 10px 18px;
    background: rgba(15, 15, 25, 0.9);
    border: 2px solid rgba(218, 165, 32, 0.5);
    border-radius: 6px;
    color: #e8c860;
    font-size: 16px;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.placement-btn:active {
    transform: scale(0.93);
}
.placement-confirm {
    background: rgba(46, 125, 50, 0.8);
    border-color: #4caf50;
    color: #fff;
}
.placement-cancel {
    background: rgba(183, 28, 28, 0.8);
    border-color: #e53935;
    color: #fff;
}

/* ─── Action buttons (bottom-center) ─── */
.action-buttons {
    position: fixed;
    bottom: clamp(6px, 1.5vmin, 14px);
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: clamp(4px, 1.2vmin, 12px);
    z-index: var(--z-hud);
}

.action-buttons.active {
    display: flex;
}

.action-btn {
    width: clamp(38px, 7vmin, 60px);
    height: clamp(38px, 7vmin, 60px);
    border-radius: 50%;
    background: rgba(15, 15, 25, 0.85);
    border: 2px solid rgba(218, 165, 32, 0.35);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    transition: all 0.15s;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.action-btn:hover {
    background: rgba(218, 165, 32, 0.15);
    border-color: #daa520;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.action-btn:active {
    transform: translateY(0) scale(0.94);
}

.action-btn.active {
    background: rgba(232, 162, 58, 0.25);
    border-color: #daa520;
    box-shadow: 0 0 10px rgba(218, 165, 32, 0.3);
}

.action-icon {
    font-size: clamp(14px, 2.8vmin, 22px);
    line-height: 1;
}

.action-label {
    font-size: clamp(6px, 1vmin, 9px);
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1;
}

.action-btn:hover .action-label {
    color: #daa520;
}

/* ─── Player name labels ─── */
.player-name-label {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-main);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    will-change: transform;
}

/* ─── Player list overlay (Tab) ─── */
.player-list {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: clamp(200px, 30vmin, 280px);
    max-width: clamp(260px, 40vmin, 360px);
    max-height: 60vh;
    background: rgba(15, 15, 25, 0.92);
    border: 2px solid rgba(218, 165, 32, 0.5);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
    z-index: 9500;
    display: none;
    flex-direction: column;
    overflow: hidden;
    pointer-events: none;
}

.player-list.active {
    display: flex;
}

.player-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(6px, 1.2vmin, 12px) clamp(8px, 1.6vmin, 16px);
    border-bottom: 1px solid rgba(218, 165, 32, 0.25);
}

.player-list-title {
    font-size: clamp(11px, 1.6vmin, 14px);
    font-weight: 700;
    color: #daa520;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.player-list-count {
    font-size: clamp(10px, 1.4vmin, 13px);
    font-weight: 600;
    color: #e8c860;
    background: rgba(218, 165, 32, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

.player-list-body {
    padding: 6px 0;
    overflow-y: auto;
    max-height: calc(60vh - 44px);
}

.player-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(3px, 0.6vmin, 6px) clamp(8px, 1.6vmin, 16px);
    font-size: clamp(10px, 1.4vmin, 13px);
    color: var(--text-primary);
}

.player-list-row:hover {
    background: rgba(218, 165, 32, 0.06);
}

.player-list-row-self .player-list-name {
    color: #daa520;
    font-weight: 600;
}

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

.player-list-ping {
    font-size: clamp(9px, 1.2vmin, 12px);
    color: #888;
    margin-left: 12px;
    flex-shrink: 0;
}

/* ─── Network indicator (top-right, below minimap controls) ─── */
.net-indicator {
    position: fixed;
    top: 256px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(218, 165, 32, 0.25);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: monospace;
    font-size: 11px;
    color: #ccc;
    z-index: 8000;
    pointer-events: none;
}

.net-indicator.disconnected {
    border-color: rgba(231, 76, 60, 0.5);
}

.net-indicator-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.net-bar {
    width: 4px;
    border-radius: 1px;
    background: #333;
    transition: background 0.3s;
}

.net-bar[data-bar="1"] { height: 4px; }
.net-bar[data-bar="2"] { height: 7px; }
.net-bar[data-bar="3"] { height: 10px; }
.net-bar[data-bar="4"] { height: 14px; }

.net-indicator-ping {
    color: #aaa;
    min-width: 32px;
    text-align: right;
}

.net-indicator-sep {
    color: #555;
}

.net-indicator-players {
    color: #daa520;
}

.net-indicator-players::after {
    content: ' online';
    color: #888;
}
