/* ── hud.css — HUD header, left HUD bars, avatar panel, portrait, character stats ── */

  /* ── HUD HEADER ── */
  #hud-top {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: linear-gradient(180deg, rgba(8,8,6,0.97) 0%, rgba(8,8,6,0.6) 100%);
    border-bottom: 1px solid var(--border);
  }

  #game-title {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 4px;
    color: var(--amber);
    text-shadow: 0 0 12px var(--amber);
  }

  #game-title span {
    color: var(--rust);
    text-shadow: 0 0 8px var(--rust);
  }

  /* ── LEFT HUD (Avatar + Vertical Bars) ── */
  #left-hud {
    position: fixed;
    top: 42px;
    left: 0;
    z-index: 101;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 12px;
    background: linear-gradient(180deg, rgba(8,8,6,0.97) 0%, rgba(8,8,6,0.75) 100%);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  #avatar-box {
    width: 64px;
    height: 64px;
    background: var(--bg3);
    /* rank border as outer shadow — keeps image clean, no inset line artifact */
    box-shadow: 0 0 0 3px #6b6b6b;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: box-shadow 0.35s;
    flex-shrink: 0;
  }

  /* Faction background layer inside HUD avatar box */
  #avatar-bg-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 20%;
    z-index: 0;
    filter: brightness(0.6) saturate(0.7);
    overflow: hidden;
  }

  #avatar-box:active { opacity: 0.8; }

  #avatar-hat-layer {
    position: absolute;
    top: -8px;
    left: 0; right: 0;
    text-align: center;
    font-size: 22px;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
  }

  #avatar-img-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 1;
  }

  #avatar-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
  }

  #avatar-glasses-layer {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 15px;
    pointer-events: none;
    z-index: 3;
  }

  .avatar-edit-hint {
    font-size: 7px;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-align: center;
    line-height: 1;
  }

  /* Vertical stat bars */
  #left-bars {
    display: flex;
    gap: 8px;
    align-items: flex-end;
  }

  .vbar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
  }

  .vbar-label {
    font-family: 'Oswald', sans-serif;
    font-size: 8px;
    color: var(--text);
    letter-spacing: 2px;
  }

  .vbar-track {
    width: 12px;
    height: 80px;
    background: var(--bg3);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
  }

  .vbar-fill {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    transition: height 0.2s ease;
  }

  #hp-fill { background: linear-gradient(0deg, #8b0000, #e83232); }
  #rad-fill { background: linear-gradient(0deg, #1a5c18, #4ade44); }

  .vbar-val {
    font-size: 8px;
    color: var(--text-dim);
    text-align: center;
  }

  .vbar-val.danger { color: var(--danger); animation: blink 1s infinite; }
  .vbar-val.warning { color: #f5c842; }

  /* ── AVATAR PANEL ── */
  #avatar-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(0,0,0,0.75);
    display: none;
    align-items: flex-start;  /* panel anchors to top of overlay (below header) */
    justify-content: center;
    padding-top: 44px;    /* clears the HUD header */
    padding-bottom: 56px; /* clears the bottom nav  */
  }

  #avatar-overlay.open { display: flex; }

  #avatar-panel {
    background: var(--bg2);
    border: 1px solid var(--amber);
    border-bottom: none;
    width: 100%;
    max-width: 540px;
    height: 100%;      /* fill header→nav gap; overlay padding constrains it */
    max-height: none;
    display: flex;
    flex-direction: column;
    animation: panelReveal 0.22s ease;
  }

  #avatar-panel-header {
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 8px;
  }

  #avatar-panel-title {
    font-family: 'Oswald', sans-serif;
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--amber);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
  }

  #avatar-panel-title span {
    color: var(--text);
  }

  #avatar-panel-body {
    overflow-y: auto;
    padding: 16px;
    flex: 1;
    position: relative;
  }

  /* Portrait (left) + stats panel (right) side-by-side layout */
  #avatar-preview-area {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 12px;
  }

  /* XP bar section — sits below the portrait+stats row */
  #profile-xp-section {
    padding: 12px 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
  }

  /* ── Portrait preview box: faction bg + character overlay + rank border ── */
  #avatar-preview-box {
    width: 200px;
    height: 268px;
    position: relative;
    overflow: hidden;
    /* rank border rendered as outer box-shadow so it sits OUTSIDE the image area,
       preventing the visible "line" artifact that border creates inside overflow:hidden */
    box-shadow: 0 0 0 3px #6b6b6b, 0 0 16px rgba(107,107,107,0.5);
    flex-shrink: 0;
    background: var(--bg3);
    transition: box-shadow 0.35s;
  }

  /* Faction background layer — sits beneath character */
  #avatar-preview-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 30%;
    z-index: 0;
    filter: brightness(0.65) saturate(0.75);
  }

  /* Character PNG overlay */
  #avatar-preview-img-wrap {
    position: absolute;
    inset: 0;
    z-index: 1;
  }
  #avatar-preview-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
  }

  /* Hat floats above the box */
  #avatar-preview-hat {
    position: absolute;
    top: -14px;
    left: 0; right: 0;
    text-align: center;
    font-size: 34px;
    line-height: 1;
    z-index: 3;
    pointer-events: none;
  }

  /* Glasses sit over the face */
  #avatar-preview-glasses {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 26px;
    z-index: 2;
    pointer-events: none;
  }

  /* Rank strip hidden — rank is shown in the stats panel instead */
  #avatar-preview-rank-strip { display: none; }

  /* ── Character stats panel — sits to the right of the portrait ── */
  #avatar-stats-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .xp-bar-wrap  { margin-bottom: 10px; }
  .xp-bar-meta  { display:flex; justify-content:space-between; font-family:'Share Tech Mono',monospace; font-size:10px; color:var(--text-dim); margin-bottom:3px; }
  .xp-bar-track { height:5px; background:#1a1a1a; border-radius:2px; overflow:hidden; }
  .xp-bar-fill  { height:100%; background:var(--amber); border-radius:2px; transition:width .4s ease; }
  .xp-bar-xp    { font-family:'Share Tech Mono',monospace; font-size:10px; color:var(--text-dim); text-align:center; margin-top:3px; }

  .stat-rank-badge {
    display: inline-block;
    font-family: 'Oswald', sans-serif;
    font-size: 13px;
    letter-spacing: 3px;
    color: #6b6b6b;
    border: 1px solid #6b6b6b;
    padding: 3px 10px;
    margin-bottom: 8px;
    transition: color 0.35s, border-color 0.35s;
  }

  .stat-meta-label {
    font-size: 12px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    line-height: 1.9;
  }

  .stat-meta-label span {
    color: var(--text);
  }

  .stat-divider {
    height: 1px;
    background: var(--border);
    margin: 9px 0;
  }

  /* 2-column grid for paired stat cells */
  .stat-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
  }

  /* Single-column stat stack — used in profile portrait sidebar */
  .stat-grid-1col {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .stat-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
  }

  .stat-cell-label {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
  }

  .stat-cell-value {
    font-family: 'Oswald', sans-serif;
    font-size: 17px;
    letter-spacing: 1px;
    color: var(--amber);
    line-height: 1;
  }

  /* Legacy single-row style kept for any inline rows */
  .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 4px;
    padding: 2px 0;
  }

  .stat-row-label {
    font-size: 11px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .stat-row-dots {
    flex: 1;
    border-bottom: 1px dotted rgba(58,50,32,0.5);
    margin: 0 4px 4px;
    min-width: 8px;
  }

  .stat-row-value {
    font-family: 'Oswald', sans-serif;
    font-size: 15px;
    letter-spacing: 1px;
    color: var(--amber);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .stat-row-value.dimmed { color: var(--text-dim); }
  .stat-row-value.live-hp { color: var(--danger); }
  .stat-row-value.live-rad { color: var(--rad); }

  /* Character thumb in the picker grid */
  .avatar-char-thumb {
    width: 52px;
    height: 60px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background: var(--bg);
  }
  .avatar-char-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
  }

  .avatar-section-title {
    font-family: 'Oswald', sans-serif;
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--text-dim);
    margin: 14px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }

  .avatar-options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .avatar-option {
    width: 66px;
    padding: 8px 4px 6px;
    background: var(--bg3);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .avatar-option:active { border-color: var(--amber-dim); }
  .avatar-option.selected { border-color: var(--amber); background: rgba(232,137,12,0.08); }
  .avatar-option-icon { font-size: 24px; line-height: 1; }

  .avatar-option-label {
    font-size: 7px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-align: center;
    text-transform: uppercase;
    line-height: 1.2;
  }

  .avatar-option.selected .avatar-option-label { color: var(--amber); }

  .avatar-option-swatch {
    width: 22px;
    height: 22px;
    border: 2px solid currentColor;
  }
