:root {
  --ink: #f3ecdd;
  --muted: #a69fb6;
  --dim: #6c6580;
  --panel: rgba(16, 13, 24, 0.84);
  --panel-solid: #15121e;
  --line: rgba(243, 236, 221, 0.14);
  --accent: #f2c66d;
  --accent-ink: #1a1408;
  --t0: #2ee6b8;
  --t1: #ff4d6a;
  --hp: #4fe08f;
  --danger: #ff5a6e;
  --arc: #b77cff;
  --display: 'Teko', 'Rajdhani', system-ui, sans-serif;
  --ui: 'Rajdhani', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0b0a10; color: var(--ink);
  font-family: var(--ui); font-weight: 600;
  user-select: none; -webkit-user-select: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#overlay { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hidden { display: none !important; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 0.35em; margin: 0 0.1em;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.06); font-family: var(--ui); font-size: 0.85em; text-align: center;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--display); font-size: 26px; letter-spacing: 0.06em; line-height: 1;
  padding: 12px 34px 8px; color: var(--ink); background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line); cursor: pointer; text-transform: uppercase;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: background 0.15s, transform 0.15s, color 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: #ffd788; }
.btn.ghost { background: transparent; }
.btn.small { font-size: 20px; padding: 8px 20px 5px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; }
#loading { background: #0b0a10; flex-direction: column; gap: 18px; z-index: 50; }
.loader-mark { width: 42px; height: 42px; border: 3px solid var(--accent); transform: rotate(45deg); animation: spin 1.4s linear infinite; }
.loader-text { color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
@keyframes spin { to { transform: rotate(405deg); } }

#menu { background: radial-gradient(ellipse at 50% 60%, rgba(11, 10, 16, 0) 0%, rgba(11, 10, 16, 0.75) 75%); }
.menu-inner { text-align: center; padding: 16px; }
.logo-mark {
  width: 54px; height: 54px; margin: 0 auto 6px; border: 3px solid var(--accent); transform: rotate(45deg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.logo {
  font-family: var(--display); font-weight: 600; font-size: clamp(72px, 14vw, 168px); line-height: 0.9;
  margin: 18px 0 0; letter-spacing: 0.08em; color: var(--ink);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 10px 30px rgba(0, 0, 0, 0.5);
}
.tagline { color: var(--muted); font-size: 20px; margin: 4px 0 34px; letter-spacing: 0.04em; }
.menu-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--line); padding: 26px 30px; backdrop-filter: blur(10px); }
#howto { position: absolute; max-width: 820px; width: calc(100% - 32px); z-index: 2; }
#howto h2 { font-family: var(--display); font-size: 40px; margin: 0 0 6px; font-weight: 500; }
#howto h4 { margin: 14px 0 4px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; font-size: 15px; }
#howto p { margin: 4px 0; color: #d6cfe0; font-weight: 500; line-height: 1.4; }
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 18px; }
.keys { list-style: none; padding: 0; margin: 6px 0; line-height: 2.1; font-weight: 500; }

/* ---------- Hero select ---------- */
#select { background: rgba(9, 8, 14, 0.72); backdrop-filter: blur(4px); overflow-y: auto; align-items: flex-start; }
.select-inner { width: min(1180px, 100% - 32px); margin: 40px auto; }
.select-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 20px; }
.select-head h2 { font-family: var(--display); font-weight: 500; font-size: 52px; margin: 0; letter-spacing: 0.05em; }
#hero-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.hero-card {
  position: relative; background: var(--panel); border: 1px solid var(--line); padding: 20px 20px 16px; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s; overflow: hidden;
}
.hero-card:hover { transform: translateY(-3px); border-color: rgba(243, 236, 221, 0.3); }
.hero-card.sel { border-color: var(--hc); background: linear-gradient(180deg, color-mix(in srgb, var(--hc) 14%, transparent), var(--panel) 60%); }
.hc-top { display: flex; gap: 14px; align-items: center; }
.hc-glyph {
  width: 64px; height: 64px; flex: none; display: grid; place-items: center; font-size: 34px; color: var(--hc);
  border: 2px solid var(--hc); transform: rotate(45deg);
}
.hc-glyph span { transform: rotate(-45deg); }
.hc-name { font-family: var(--display); font-size: 44px; line-height: 0.85; font-weight: 500; }
.hc-role { color: var(--hc); text-transform: uppercase; letter-spacing: 0.14em; font-size: 14px; }
.hc-blurb { color: #cfc8da; font-weight: 500; line-height: 1.4; font-size: 15px; min-height: 63px; }
.hc-stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 10px 0 12px; }
.pips { display: flex; gap: 4px; }
.pips i { width: 26px; height: 6px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: var(--hc); }
.hc-weapon { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.hc-weapon b { color: var(--ink); }
.hc-abils { display: grid; gap: 6px; }
.hc-ab { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; font-size: 14px; }
.hc-ab .g { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--hc); background: rgba(255, 255, 255, 0.04); }
.hc-ab .n { color: var(--ink); }
.hc-ab .n small { color: var(--accent); margin-left: 6px; letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; }
.hc-ab .d { color: var(--muted); font-weight: 500; line-height: 1.3; }
.select-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 20px; }
.diff { display: flex; align-items: center; gap: 12px; }
.label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px; }
.seg { display: flex; border: 1px solid var(--line); }
.seg button {
  font-family: var(--ui); font-weight: 700; font-size: 15px; padding: 8px 16px; background: transparent; color: var(--muted);
  border: 0; cursor: pointer; letter-spacing: 0.05em;
}
.seg button.on { background: var(--ink); color: #120f19; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#topbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 2px; }
.team-score { display: flex; align-items: center; gap: 12px; padding: 6px 16px 5px; background: var(--panel); min-width: 150px; }
.team-score.t0 { justify-content: flex-end; border-bottom: 3px solid var(--t0); }
.team-score.t1 { border-bottom: 3px solid var(--t1); }
.team-score .num { font-family: var(--display); font-size: 40px; line-height: 1; }
.team-score .tname { text-transform: uppercase; letter-spacing: 0.12em; font-size: 13px; color: var(--muted); }
.t0 .num { color: var(--t0); } .t1 .num { color: var(--t1); }
.clockbox { display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(8, 7, 12, 0.9); padding: 6px 18px 6px; min-width: 96px; }
#clock { font-family: var(--display); font-size: 32px; line-height: 1; }
#wave-timer { font-size: 11px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
#objectives { position: absolute; top: 66px; left: 50%; transform: translateX(-50%); display: flex; gap: 22px; }
.obj-team { display: flex; gap: 6px; align-items: center; }
.obj-pip { width: 12px; height: 12px; transform: rotate(45deg); border: 2px solid currentColor; }
.obj-pip.alive { background: currentColor; }
.obj-pip.core { width: 15px; height: 15px; }
.obj-pip.shield { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25); }

#minimap { position: absolute; top: 12px; right: 12px; width: 140px; height: 292px; background: rgba(10, 9, 16, 0.78); border: 1px solid var(--line); }
#killfeed { position: absolute; top: 14px; right: 164px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.kf { background: var(--panel); padding: 4px 10px 2px; font-size: 15px; display: flex; gap: 8px; align-items: center; animation: kfIn 0.2s ease-out; transition: opacity 0.4s; }
.kf .x { color: var(--muted); font-size: 12px; }
.kf.me { box-shadow: inset 0 0 0 1px var(--accent); }
@keyframes kfIn { from { transform: translateX(20px); opacity: 0; } }

#toast { position: absolute; top: 24%; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: 40px; letter-spacing: 0.06em; text-align: center; opacity: 0; transition: opacity 0.3s; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7); white-space: nowrap; }
#toast.show { opacity: 1; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --gap: 6px; }
#crosshair i { position: absolute; background: rgba(255, 255, 255, 0.92); box-shadow: 0 0 2px rgba(0, 0, 0, 0.9); transition: transform 0.06s; }
#crosshair .c-t, #crosshair .c-b { width: 2px; height: 8px; left: -1px; }
#crosshair .c-l, #crosshair .c-r { height: 2px; width: 8px; top: -1px; }
#crosshair .c-t { bottom: var(--gap); } #crosshair .c-b { top: var(--gap); }
#crosshair .c-l { right: var(--gap); } #crosshair .c-r { left: var(--gap); }
#crosshair .dot { position: absolute; width: 2px; height: 2px; left: -1px; top: -1px; background: #fff; }
#hitmark { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; opacity: 0; }
#hitmark::before, #hitmark::after { content: ''; position: absolute; left: 10px; top: -2px; width: 2px; height: 26px; background: #fff; transform: rotate(45deg); clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%, 0 65%, 100% 65%, 100% 100%, 0 100%); }
#hitmark::after { transform: rotate(-45deg); }
#hitmark.on { animation: hm 0.18s ease-out; }
#hitmark.head::before, #hitmark.head::after { background: #ff6a3d; }
@keyframes hm { from { opacity: 1; transform: scale(1.3); } to { opacity: 0; transform: scale(1); } }

#reload-bar { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); width: 90px; height: 4px; background: rgba(0, 0, 0, 0.5); }
#reload-fill { height: 100%; background: var(--accent); width: 0; }
#reload-bar span { position: absolute; top: 7px; left: 0; right: 0; text-align: center; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }

#vitals { position: absolute; left: 20px; bottom: 20px; width: 340px; }
.hero-tag { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.glyph { width: 42px; height: 42px; display: grid; place-items: center; font-size: 22px; border: 2px solid var(--hc, var(--accent)); color: var(--hc, var(--accent)); transform: rotate(45deg); background: rgba(0, 0, 0, 0.35); }
.glyph > * { transform: rotate(-45deg); }
#hud-name { font-family: var(--display); font-size: 30px; line-height: 0.9; }
#hud-level { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.hpbar { position: relative; height: 26px; background: rgba(10, 9, 16, 0.8); border: 1px solid var(--line); overflow: hidden; }
#hp-fill, #hp-ghost { position: absolute; left: 0; top: 0; bottom: 0; }
#hp-ghost { background: #ffd9a0; opacity: 0.6; transition: width 0.5s 0.25s; }
#hp-fill { background: linear-gradient(180deg, #6ff0a5, #33b56c); }
#hp-fill.low { background: linear-gradient(180deg, #ff8a8a, #d23b4f); }
#hp-text { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 10px; font-size: 17px; text-shadow: 0 1px 2px #000; }
.xpbar { height: 4px; background: rgba(10, 9, 16, 0.8); margin-top: 3px; }
#xp-fill { height: 100%; background: var(--accent); width: 0; }
.vit-sub { display: flex; justify-content: space-between; margin-top: 7px; gap: 8px; }
#dash-pips { display: flex; gap: 4px; align-items: center; }
#dash-pips i { width: 22px; height: 6px; background: rgba(255, 255, 255, 0.14); }
#dash-pips i.on { background: #9fd8ff; }
#buffs { display: flex; gap: 6px; }
.buff { font-size: 12px; padding: 1px 8px; background: rgba(255, 154, 60, 0.2); border: 1px solid rgba(255, 154, 60, 0.6); text-transform: uppercase; letter-spacing: 0.06em; }

#abilities { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 10px; }
.ab { position: relative; width: 64px; height: 64px; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.ab .ag { font-size: 30px; color: var(--hc, var(--accent)); }
.ab .ak { position: absolute; left: 4px; top: 1px; font-size: 13px; color: var(--muted); }
.ab .acd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(5, 4, 8, 0.78); height: 0; }
.ab .at { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 30px; }
.ab.ult { border-color: rgba(242, 198, 109, 0.5); }
.ab.locked .ag { opacity: 0.2; }
.ab.locked::after { content: 'LV 3'; position: absolute; bottom: 2px; font-size: 11px; color: var(--muted); letter-spacing: 0.1em; }
.ab.ready { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.ab.flash { animation: abf 0.25s; }
@keyframes abf { 0% { background: rgba(255, 90, 110, 0.5); } }
.ab-name { position: absolute; bottom: -2px; left: 0; right: 0; text-align: center; font-size: 10px; letter-spacing: 0.04em; color: var(--muted); display: none; }

#weapon { position: absolute; right: 20px; bottom: 20px; text-align: right; }
.ammo { font-family: var(--display); line-height: 0.85; }
#ammo-cur { font-size: 64px; }
#ammo-cur.low { color: var(--danger); }
#ammo-max { font-size: 30px; color: var(--muted); margin-left: 4px; }
#weapon-name { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; margin: 2px 0 10px; }
.shards { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); padding: 4px 14px 1px; font-family: var(--display); font-size: 32px; line-height: 1; color: #bfefff; }
.gem { width: 12px; height: 12px; background: #7fe7ff; transform: rotate(45deg); box-shadow: 0 0 10px #7fe7ff; display: inline-block; }
#shop-hint { margin-top: 8px; font-size: 14px; color: var(--accent); opacity: 0; transition: opacity 0.2s; }
#shop-hint.on { opacity: 1; }

#vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px rgba(255, 30, 50, 0.9); opacity: 0; transition: opacity 0.4s; }
#respawn { position: absolute; left: 50%; top: 32%; transform: translateX(-50%); text-align: center; background: var(--panel); padding: 20px 40px; border-top: 3px solid var(--danger); }
.rs-title { font-family: var(--display); font-size: 48px; line-height: 1; }
#rs-by { color: var(--muted); margin: 4px 0 8px; }
.rs-timer { font-size: 22px; }
.rs-timer span { font-family: var(--display); font-size: 34px; color: var(--accent); }
.rs-hint { margin-top: 8px; font-size: 14px; color: var(--muted); }

/* ---------- Shop ---------- */
#shop { position: fixed; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; background: rgba(6, 5, 10, 0.55); }
.shop-inner { width: min(1060px, 100% - 32px); max-height: calc(100% - 32px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); padding: 20px 24px; }
.shop-head { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; flex-wrap: wrap; }
.shop-head h2 { font-family: var(--display); font-weight: 500; font-size: 46px; margin: 0; line-height: 1; }
.shop-shards { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 34px; color: #bfefff; }
#shop-status { flex: 1; color: var(--danger); font-size: 15px; }
#shop-status.ok { color: var(--hp); }
#shop-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.shop-col h3 { margin: 0 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--cc); border-bottom: 2px solid var(--cc); padding-bottom: 4px; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 11px 7px; margin-bottom: 7px; cursor: pointer;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); transition: background 0.12s;
}
.item:hover { background: rgba(255, 255, 255, 0.1); }
.item .in { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.item .in::before, .slot.full::before { content: ''; flex: none; width: 7px; height: 7px; background: var(--cc); transform: rotate(45deg); }
.item .ic { display: flex; align-items: center; gap: 6px; color: #bfefff; font-family: var(--display); font-size: 22px; line-height: 1; }
.item .ic .gem { width: 8px; height: 8px; }
.item .id { grid-column: 1 / -1; font-size: 13px; color: var(--muted); font-weight: 500; }
.item.poor .ic { color: var(--danger); }
.item.poor { opacity: 0.6; }
.item.owned { opacity: 0.45; cursor: default; border-left-color: var(--dim); }
.item.owned .ic::after { content: 'owned'; font-family: var(--ui); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.item.owned .ic .gem, .item.owned .ic .cost { display: none; }
.shop-owned { margin-top: 12px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
#owned-slots { display: flex; gap: 6px; flex-wrap: wrap; }
.slot { width: 98px; height: 44px; border: 1px dashed var(--line); font-size: 12px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 2px 4px; line-height: 1.1; }
.slot.full { border-style: solid; gap: 6px; background: rgba(255, 255, 255, 0.05); cursor: context-menu; }

/* ---------- Scoreboard ---------- */
#scoreboard { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 12; width: min(820px, 100% - 32px); background: var(--panel); border: 1px solid var(--line); padding: 16px 20px; backdrop-filter: blur(8px); }
.sb-team h3 { margin: 6px 0; font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase; }
.sb-table { width: 100%; border-collapse: collapse; font-size: 16px; margin-bottom: 10px; }
.sb-table th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; padding: 4px 8px; }
.sb-table td { padding: 6px 8px; border-top: 1px solid var(--line); }
.sb-table tr.me td { background: rgba(242, 198, 109, 0.1); }
.sb-table td.dead { color: var(--dim); }
.sb-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Pause / End ---------- */
#pause { background: rgba(6, 5, 10, 0.6); z-index: 25; }
.pause-panel { display: flex; flex-direction: column; gap: 14px; min-width: 320px; }
.pause-panel h2, .end-panel h1 { font-family: var(--display); font-weight: 500; margin: 0; font-size: 56px; line-height: 1; }
.opt { display: grid; grid-template-columns: 1fr; gap: 4px; color: var(--muted); font-size: 15px; }
.opt input[type=range] { width: 100%; accent-color: var(--accent); }
.opt.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.opt.check input { accent-color: var(--accent); width: 18px; height: 18px; }
#end { background: rgba(6, 5, 10, 0.6); z-index: 25; }
.end-panel { width: min(820px, 100% - 32px); text-align: center; }
.end-panel h1 { font-size: 110px; letter-spacing: 0.08em; }
#end-sub { color: var(--muted); margin: 0 0 14px; font-size: 18px; }
#end-board { text-align: left; }
.end-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

@media (max-width: 760px) {
  .howto-grid { grid-template-columns: 1fr; }
  #shop-cols { grid-template-columns: 1fr; }
  #killfeed { display: none; }
  #vitals { width: 220px; }
}
