/* =====================================================================================
   CREATE A CLASS (loaded last; owns everything inside #pane-loadout)
   Loadouts: the class list on the left; the class's showcase (its primary, large, turning) and its four
   cards. Editor: everything in the class as one list on the left; the gunsmith (preview, bars, numbers,
   what a choice changes) on the right. The pane is laid out by its own width (container queries), so the
   same rules fit the main menu, the pause menu and the private match lobby.
   ===================================================================================== */
#pane-loadout { container: cac / inline-size; }
#pane-loadout .pane-title { display: none; }   /* (the WEAPONS tab already says where you are) */
:where(#pane-loadout button) { font: inherit; color: inherit; }   /* (no weight: every specific rule below wins) */
.cls-view { display: none; }
.cls-view.on { display: grid; }

/* ---------- shared bits ---------- */
#pane-loadout .ico { display: block; flex: none; }
.gthumb { display: block; width: 100%; aspect-ratio: 5 / 2; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.55)); pointer-events: none; }
.gthumb.none { display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: 0.1em; color: var(--mw-faint); }
.pips { display: inline-flex; gap: 4px; vertical-align: middle; }
.pips i { width: 8px; height: 8px; border: 1px solid var(--mw-acc); transform: rotate(45deg); }
.pips i.on { background: var(--mw-acc); }
#pane-loadout .group { margin: 14px 0 6px; }
#pane-loadout .group:first-child { margin-top: 0; }

/* ---------- loadouts ---------- */
#cls-pick { grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 22px; align-items: start; }
.cls-list { display: flex; flex-direction: column; gap: 3px; max-height: min(64vh, 640px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.cls-row { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 9px 12px; background: var(--mw-panel); border: 0; border-left: 3px solid transparent; cursor: pointer; }
.cls-row .cr-n { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 76px; }
.cls-row .cr-w { font-size: 11px; letter-spacing: 0.14em; color: var(--mw-faint); }
.cls-row .cr-eq { position: absolute; right: 10px; top: 11px; font-size: 10px; letter-spacing: 0.2em; color: var(--mw-acc); }
.cls-row.sel { border-left-color: var(--mw-acc); background: var(--mw-panel-2); }
.cls-row:is(:hover, .pad-focus, :focus-visible) { background: var(--mw-sel); color: var(--mw-sel-ink); outline: none; }
.cls-row:is(:hover, .pad-focus, :focus-visible) .cr-w { color: #3a3c3e; }
.cls-row.eq .cr-n::before { content: none; }

.cls-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cls-hero { position: relative; background: radial-gradient(ellipse at 55% 62%, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0) 64%), var(--mw-panel); border: 1px solid var(--mw-line); }
.cls-head { position: absolute; left: 18px; top: 14px; z-index: 1; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.cls-kind { font-size: 11px; letter-spacing: 0.24em; color: var(--mw-acc); }
.cls-name { font-family: var(--display); font-weight: 700; font-size: clamp(24px, 3vw, 36px); letter-spacing: 0.06em; color: #fff; text-transform: uppercase; line-height: 1; }
.cls-slot .gs-view { background: none; border: 0; }
.cls-slot .gs-view canvas { display: block; width: 100%; height: clamp(150px, 28vh, 320px); }

.lc-row { display: grid; grid-template-columns: 1.6fr 1.3fr 1fr 1fr; gap: 6px; }
.lcard { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; text-align: left; padding: 10px 12px 11px; background: var(--mw-panel); border: 0; border-top: 2px solid transparent; }
button.lcard[data-nav] { cursor: pointer; }
.lcard .lc-k { font-size: 10px; letter-spacing: 0.24em; color: var(--mw-faint); }
.lcard .lc-n { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcard .lc-a { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lcard .lc-a small { font-size: 10px; letter-spacing: 0.1em; color: var(--mw-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcard.gun .gthumb { max-height: 84px; margin: 2px 0; }
.lcard.eqc .ico { width: 56px; height: 48px; color: var(--mw-dim); margin: 8px 0 4px; }
.lcard[data-nav]:is(:hover, .pad-focus, :focus-visible) { background: var(--mw-panel-2); border-top-color: var(--mw-acc); outline: none; }
.lcard[data-nav]:is(:hover, .pad-focus, :focus-visible) .lc-k { color: var(--mw-acc); }

.cls-actions { display: flex; gap: 6px; }
.cls-actions .cta { margin: 0; flex: 1.3; font-size: 20px; padding: 12px 18px; clip-path: none; }
.cls-actions .cta.done { filter: none; background: transparent; color: var(--mw-ink); box-shadow: inset 0 0 0 1px var(--mw-line); }
.cls-actions .menu-btn { flex: 1; justify-content: center; text-align: center; font-size: 17px; }
#cls-note { margin: 0; font-size: 13px; color: var(--mw-faint); }

/* ---------- editor ---------- */
#cls-editor { gap: 12px; }
.cls-ebar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cls-ebar .menu-btn { margin: 0; padding: 7px 14px; font-size: 15px; }
.ce-crumbs { flex: 1; min-width: 0; margin: 0; }
.cls-rn { display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: 0.2em; color: var(--mw-faint); }
.cls-rn input { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 0.06em; text-transform: uppercase; width: 220px; padding: 6px 10px; }
.ce-body { display: grid; grid-template-columns: minmax(300px, 440px) minmax(0, 1fr); gap: 20px; align-items: start; }
.ce-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; max-height: min(66vh, 680px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.ce-sec { display: flex; flex-direction: column; gap: 2px; }
.ce-h { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: 0.24em; color: var(--mw-acc); border-bottom: 1px solid var(--mw-line); padding-bottom: 4px; margin-bottom: 4px; }
.ce-h span { font-family: var(--body); font-size: 10px; letter-spacing: 0.18em; color: var(--mw-faint); }

/* a row: icon or picture | label above value | a hint on the right */
.ce-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; padding: 7px 12px 7px 8px; min-height: 50px; background: var(--mw-panel); border: 0; border-left: 3px solid transparent; cursor: pointer; }
.ce-row > .ico, .ce-row > .rprev, .ce-row > .gthumb { grid-row: 1 / 3; }
.ce-row .ico { width: 48px; height: 40px; color: var(--mw-dim); }
.ce-row .rprev { width: 40px; height: 40px; justify-self: center; border-radius: 50%; background: radial-gradient(circle, #2a2d30, #0c0d0e 70%); }
.ce-row .cr-k { grid-column: 2; font-size: 10px; letter-spacing: 0.18em; color: var(--mw-faint); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: end; }
.ce-row .cr-v { grid-column: 2; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: start; }
.ce-row .cr-go { grid-column: 3; grid-row: 1 / 3; font-size: 10px; letter-spacing: 0.2em; color: var(--mw-faint); }
.ce-row.gun { grid-template-columns: 120px minmax(0, 1fr) auto; min-height: 64px; }
.ce-row.gun .gthumb { width: 120px; }
.ce-row.att.empty .cr-v { color: var(--mw-dim); }
.ce-row.att:not(.empty) .ico { color: var(--mw-ink); }
.ce-row.on { border-left-color: var(--mw-acc); background: var(--mw-panel-2); }
.ce-row.on .cr-go { color: var(--mw-acc); }
.ce-row.fixed { cursor: default; opacity: 0.75; }
.ce-row:not(.fixed):is(:hover, .pad-focus, :focus-visible) { background: var(--mw-sel); color: var(--mw-sel-ink); outline: none; }
.ce-row:not(.fixed):is(:hover, .pad-focus, :focus-visible) :is(.ico, .cr-k, .cr-go) { color: #3a3c3e; }
.ce-row.pick .cr-k { white-space: normal; text-transform: none; letter-spacing: 0.03em; font-size: 12px; line-height: 1.25; }
.ce-row.gun.pick .cr-k { text-transform: uppercase; letter-spacing: 0.14em; font-size: 10px; }

.ce-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.ce-tabs button { padding: 7px 12px; background: var(--mw-panel); border: 0; border-bottom: 2px solid transparent; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--mw-dim); cursor: pointer; }
.ce-tabs button.on { color: #fff; border-bottom-color: var(--mw-acc); background: var(--mw-panel-2); }
.ce-tabs button:is(:hover, .pad-focus, :focus-visible) { background: var(--mw-sel); color: var(--mw-sel-ink); outline: none; }

/* ---------- gunsmith panel ---------- */
#gunsmith { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.gs-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--mw-line); padding-bottom: 4px; }
.gs-name { font-family: var(--display); font-weight: 700; font-size: clamp(22px, 2.4vw, 30px); letter-spacing: 0.06em; color: #fff; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-sub { font-size: 11px; letter-spacing: 0.24em; color: var(--mw-acc); flex: none; }
#gunsmith .gs-view { background: radial-gradient(ellipse at 50% 60%, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0) 66%), var(--mw-panel); border: 1px solid var(--mw-line); }
#gunsmith .gs-view canvas { display: block; width: 100%; height: clamp(150px, 26vh, 280px); }
.gs-desc { margin: 0; font-size: 13px; letter-spacing: 0.02em; color: var(--mw-dim); min-height: 1.3em; line-height: 1.4; }
.gs-pc { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.gs-pc span { font-size: 10px; letter-spacing: 0.16em; padding: 3px 7px; }
.gs-pc .pro { color: #8fe08f; background: rgba(111, 211, 111, 0.1); }
.gs-pc .con { color: #ff8f86; background: rgba(255, 77, 77, 0.1); }
.gs-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 22px; padding: 12px 14px; background: var(--mw-panel); border: 1px solid var(--mw-line); }
.gs-stats .stat { display: flex; flex-direction: column; gap: 4px; font-size: 10px; letter-spacing: 0.18em; color: var(--mw-dim); }
.gs-stats .stat i { position: relative; display: block; height: 7px; background: rgba(255, 255, 255, 0.12);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 2px), transparent calc(10% - 2px) 10%); mask: repeating-linear-gradient(90deg, #000 0 calc(10% - 2px), transparent calc(10% - 2px) 10%); }
.gs-stats .stat b { position: absolute; left: 0; top: 0; bottom: 0; background: #ecece8; transition: width .12s; }
.gs-stats .stat em { position: absolute; top: 0; bottom: 0; }
.gs-stats .stat em.up { background: #6fd36f; }
.gs-stats .stat em.down { background: var(--enemy); }
.gs-nums { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; margin-top: 6px; border-top: 1px solid var(--mw-line); padding-top: 8px; }
.gn { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gn span { font-size: 9px; letter-spacing: 0.16em; color: var(--mw-faint); white-space: nowrap; }
.gn b { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: 0.02em; color: #fff; white-space: nowrap; }
.gn b small { font-size: 10px; color: var(--mw-faint); letter-spacing: 0.1em; }
.gn em { font-style: normal; font-size: 11px; letter-spacing: 0.06em; }
.gn em.up { color: #8fe08f; } .gn em.down { color: #ff8f86; }
.gs-facts { grid-column: 1 / -1; font-size: 11px; letter-spacing: 0.16em; color: var(--mw-faint); }
.gs-eq { display: flex; align-items: center; gap: 12px; padding: 7px 12px; background: var(--mw-panel); border: 1px solid var(--mw-line); }
.eq-k { font-size: 10px; letter-spacing: 0.22em; color: var(--mw-faint); white-space: nowrap; }
.eq-k b { color: var(--mw-acc); font-weight: 700; }
.eq-icons { display: flex; gap: 4px; flex-wrap: wrap; }
.eq-icons span { width: 40px; height: 32px; display: grid; place-items: center; border: 1px solid var(--mw-line); color: var(--mw-faint); }
.eq-icons span.mod { color: var(--mw-ink); }
.eq-icons span.hi { border-color: var(--mw-acc); color: var(--mw-acc); }
.eq-icons .ico { width: 30px; height: 26px; }

/* ---------- reticle picker ---------- */
.rp-top { display: flex; gap: 14px; align-items: center; padding: 8px 0; }
.rp-view { width: 112px; height: 112px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: url('../assets/loading/tarsa-1.jpg') center / 340% no-repeat; box-shadow: inset 0 0 26px 10px rgba(0, 0, 0, 0.75); }
.rp-view img { width: 62%; height: 62%; }
.rp-view.scope img, .rp-view.iron img { width: 100%; height: 100%; }
.rp-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rp-info b { font-family: var(--display); font-size: 24px; letter-spacing: 0.06em; color: #fff; text-transform: uppercase; }
.rp-info span { font-size: 11px; letter-spacing: 0.2em; color: var(--mw-acc); text-transform: uppercase; }
.rp-info small { font-size: 12px; color: var(--mw-dim); }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; }
.rptile { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 3px 7px; background: var(--mw-panel); border: 0; cursor: pointer; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.rptile img { width: 44px; height: 44px; background: radial-gradient(circle, #24272a, #0b0c0d 72%); border-radius: 50%; }
.rptile.on { box-shadow: inset 0 0 0 2px var(--mw-acc); color: #fff; }
.rp-cols { display: flex; flex-wrap: wrap; gap: 4px; }
.rpcol { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--mw-panel); border: 0; cursor: pointer; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.rpcol i { width: 12px; height: 12px; border-radius: 50%; }
.rpcol.on { box-shadow: inset 0 0 0 2px var(--mw-acc); color: #fff; }
:is(.rptile, .rpcol):is(:hover, .pad-focus, :focus-visible) { background: var(--mw-sel); color: var(--mw-sel-ink); outline: none; }

/* ---------- narrower panes (pause menu, lobby, small windows, phones) ---------- */
@container cac (max-width: 900px) {
  #cls-pick { grid-template-columns: minmax(170px, 220px) minmax(0, 1fr); gap: 14px; }
  .lc-row { grid-template-columns: 1fr 1fr; }
  .ce-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
  .gs-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 6px; }
}
@container cac (max-width: 640px) {
  #cls-pick { grid-template-columns: minmax(0, 1fr); }
  .cls-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 0 0 4px; gap: 4px; }
  .cls-list .group { display: none; }
  .cls-row { flex: none; width: 150px; }
  .cls-row .cr-n { padding-right: 0; font-size: 15px; }
  .cls-row .cr-eq { position: static; }
  .cls-slot .gs-view canvas { height: 150px; }
  .ce-body { grid-template-columns: minmax(0, 1fr); }
  #gunsmith { order: -1; }
  .ce-main { max-height: none; overflow: visible; }
  #gunsmith .gs-view canvas { height: 140px; }
  .gs-stats { grid-template-columns: 1fr 1fr; gap: 5px 14px; padding: 10px; }
  .cls-rn { flex: 1; } .cls-rn input { width: 100%; }
  .cls-actions .cta { font-size: 17px; }
}

/* ---------- legibility: a solid backdrop behind the whole tab, opaque panels, hover text dark ---------- */
#menu[data-tab="loadout"] { background: linear-gradient(90deg, rgba(7, 8, 9, 0.94) 0%, rgba(7, 8, 9, 0.88) 55%, rgba(7, 8, 9, 0.74) 100%); }
#pane-loadout { --mw-panel: rgba(18, 20, 22, 0.94); --mw-panel-2: rgba(30, 33, 36, 0.97); }
:is(.ce-row, .cls-row):not(.fixed):is(:hover, .pad-focus, :focus-visible) :is(.cr-v, .cr-n) { color: var(--mw-sel-ink); }
.ce-tabs { flex-wrap: nowrap; overflow-x: auto; }
.ce-tabs button { flex: 1 1 auto; padding: 8px 8px; letter-spacing: 0.12em; white-space: nowrap; }
.ce-main > * { flex: none; }   /* (a scrolling column lets its children shrink to nothing otherwise) */
.rptile .at-n { font-size: 10px; letter-spacing: 0.04em; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.rptile { letter-spacing: 0; }
/* short screens (720p and below): a smaller preview so the numbers stay on screen */
@media (max-height: 800px) {
  #gunsmith .gs-view canvas { height: clamp(110px, 17vh, 150px); }
  .gs-stats { gap: 5px 20px; padding: 9px 12px; }
  .gs-nums { margin-top: 3px; padding-top: 6px; }
  .ce-main { max-height: 58vh; }
}
/* in the pause menu (choosing a class mid-match): compact, so Equip is always on screen */
#psec-loadout .cls-slot .gs-view canvas { height: 118px; }
#psec-loadout .cls-name { font-size: 26px; }
#psec-loadout .lc-row { grid-template-columns: 1.4fr 1.2fr 1fr 1fr; }
#psec-loadout .lcard { padding: 7px 9px 8px; }
#psec-loadout .lcard.gun .gthumb { max-height: 54px; }
#psec-loadout .lcard.eqc .ico { width: 40px; height: 34px; margin: 4px 0 2px; }
#psec-loadout .lcard .lc-n { font-size: 14px; }
#psec-loadout .cls-list { max-height: 50vh; }
#psec-loadout #gunsmith .gs-view canvas { height: 110px; }
#psec-loadout .ce-main { max-height: 50vh; }
