:root {
  --ink: #140d2b;
  --panel: rgba(24, 15, 44, .88);
  --line: rgba(255, 255, 255, .14);
  --txt: #f6eefc;
  --mut: #b7a6d0;
  --tq: #2ec4b6;      /* فیروزه‌ای */
  --tq-d: #167a72;
  --gold: #e8b84a;    /* زعفرانی */
  --brick: #8b5443;
  --red: #e4572e;
  --good: #3ecf6d;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--txt);
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
  -webkit-user-select: none; user-select: none;
}
canvas#game { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }
.mut { color: var(--mut); }
.small { font-size: 12px; }
b { font-weight: 800; }
kbd {
  font-family: inherit; font-size: 12px; padding: 1px 6px; border-radius: 4px;
  background: rgba(255,255,255,.12); border: 1px solid var(--line);
}

/* ---------- صفحه‌ها و پنل‌ها ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 14px; overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(12,7,26,.35), rgba(12,7,26,.82));
}
.screen.modal { z-index: 30; background: rgba(8, 4, 18, .86); }
#result { z-index: 20; }
.panel {
  width: min(460px, 100%); margin: auto; padding: 22px; border-radius: 18px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cpath d='M22 4l4 8 8-4-4 8 8 4-8 4 4 8-8-4-4 8-4-8-8 4 4-8-8-4 8-4-4-8 8 4z' fill='none' stroke='%232ec4b6' stroke-opacity='.10'/%3E%3C/svg%3E"),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
}
.panel.wide { width: min(1060px, 100%); }
.panel h2 { margin: 0 0 6px; font-size: 22px; }

.logo { text-align: center; margin-bottom: 14px; }
.logo h1 {
  margin: 0; font-size: 42px; font-weight: 800; line-height: 1.2; color: var(--gold);
  text-shadow: 0 2px 0 var(--brick), 0 0 24px rgba(232,184,74,.35);
}
.logo p { margin: 4px 0 0; color: var(--mut); font-size: 14px; }

.card { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.field { display: block; font-size: 13px; color: var(--mut); }
input, select {
  font-family: inherit; font-size: 16px; color: var(--txt); background: rgba(0,0,0,.35);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; margin-top: 4px;
  -webkit-user-select: text; user-select: text;
}
select { cursor: pointer; }
.authrow input { margin-top: 0; }
.modes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.btn.mode.on { background: linear-gradient(180deg, var(--tq), var(--tq-d)); border-color: #55e0d3; color: #04211f; font-weight: 800; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: right; margin: 12px 0; }
.teams.one { grid-template-columns: 1fr; }
.tlist { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 80px; }
.tlist h3 { margin: 0 0 6px; font-size: 14px; }
.tlist h3.blue { color: var(--tq); }
.tlist h3.red { color: #ff8a63; }
.tlist li { list-style: none; padding: 3px 0; font-size: 14px; }
.teamcol { width: min(280px, 34vw); display: flex; flex-direction: column; gap: 4px; }
.teamcol .rowp { display: flex; align-items: center; gap: 6px; }
.teamcol .hpbar { flex: 1; height: 8px; }
.weaponbar {
  position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px;
  pointer-events: none; direction: ltr;
}
.weaponbar span {
  min-width: 28px; text-align: center; font-size: 11px; padding: 4px 5px; border-radius: 8px;
  background: rgba(0,0,0,.55); border: 1px solid var(--line);
}
.weaponbar span.on { border-color: var(--gold); color: var(--gold); }
.weaponbar span b { display: block; font-size: 10px; color: var(--mut); font-weight: 600; }
input:focus { outline: 2px solid var(--tq); outline-offset: 1px; }

.lvlrow { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.xp { flex: 1; height: 9px; background: rgba(0,0,0,.45); border-radius: 9px; overflow: hidden; }
.xp.big { height: 12px; margin: 4px 0 14px; }
.xp i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--tq-d), var(--tq)); transition: width .4s; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.center { justify-content: center; margin: 10px 0; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.chip.gold { color: var(--gold); border-color: rgba(232,184,74,.4); }
.chip.pulse { border-color: var(--tq); color: var(--tq); }

/* ---------- دکمه‌ها ---------- */
.row { display: flex; gap: 10px; margin: 0 0 10px; align-items: stretch; }
.row > * { flex: 1; }
.btn {
  font-family: inherit; font-size: 16px; font-weight: 600; color: var(--txt); cursor: pointer;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.09);
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.16); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--tq), var(--tq-d)); border-color: #55e0d3; color: #04211f; font-weight: 800; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #4fe0d2, var(--tq-d)); }
.btn.gold { background: linear-gradient(180deg, #f0c766, #b78a26); border-color: #ffe08f; color: #2a1c02; font-weight: 800; }
.btn.gold:hover:not(:disabled) { background: linear-gradient(180deg, #f8d67f, #c0942b); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 6px 10px; border-radius: 9px; }
.join { display: flex; gap: 8px; }
.join input { margin: 0; text-align: center; letter-spacing: 4px; text-transform: uppercase; font-weight: 800; }
.join .btn { flex: 0 0 auto; }

.help { font-size: 13px; color: var(--mut); }
.help summary { cursor: pointer; padding: 4px 0; }
.help ul { margin: 6px 0 0; padding-inline-start: 18px; line-height: 1.9; }

.lobby, .result { text-align: center; }
.code {
  font-family: 'Vazirmatn', monospace; font-weight: 800; font-size: 60px; letter-spacing: 12px; color: var(--gold);
  margin: 10px 0 16px; padding: 8px; border: 2px dashed rgba(232,184,74,.5); border-radius: 14px;
}
.bigscore { font-size: 54px; font-weight: 800; letter-spacing: 6px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#hud .top {
  position: absolute; top: 10px; left: 0; right: 0; display: flex; justify-content: center; align-items: flex-start;
  gap: 18px; direction: ltr; padding: 0 12px;
}
.pl { width: min(320px, 32vw); }
.pname { font-weight: 800; font-size: 15px; text-shadow: 0 1px 3px #000; margin-bottom: 4px; direction: rtl; }
#plLeft .pname { text-align: left; }
#plRight .pname { text-align: right; }
.pname.me { color: var(--tq); }
.pname.opp { color: #ff8a63; }
.hpbar { height: 12px; border-radius: 8px; background: rgba(0,0,0,.55); border: 1px solid var(--line); overflow: hidden; }
.hpbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #2fb45f, #7ee08f); transition: width .25s; }
#plRight .hpbar i { margin-left: auto; }
.hpbar i.low { background: linear-gradient(90deg, #d33b2a, #ff7d5a); }
.mid { text-align: center; min-width: 96px; text-shadow: 0 1px 4px #000; }
.score { font-size: 30px; font-weight: 800; line-height: 1; display: flex; gap: 8px; justify-content: center; }
.score em { font-style: normal; color: var(--gold); }
.timer { font-size: 18px; font-weight: 600; margin-top: 2px; }
.round { font-size: 12px; color: var(--mut); }

.ballistics {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px;
  padding: 4px 14px; border-radius: 99px; background: rgba(0,0,0,.5); border: 1px solid var(--line); font-size: 13px; white-space: nowrap;
}
.ballistics b { color: var(--gold); margin-inline-start: 4px; }
#scope { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#cross {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: rgba(255,255,255,.85); box-shadow: 0 0 0 1px rgba(0,0,0,.6);
}
.lockhint {
  position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); padding: 8px 18px; border-radius: 99px;
  background: rgba(0,0,0,.65); border: 1px solid var(--gold); color: var(--gold); font-weight: 600;
}
.wbar { position: relative; width: 120px; height: 8px; border-radius: 6px; background: rgba(255,255,255,.14); direction: ltr; }
.wbar::after { content: ''; position: absolute; left: 50%; top: -3px; width: 2px; height: 14px; background: rgba(255,255,255,.6); }
.wbar i { position: absolute; top: 0; height: 100%; border-radius: 6px; background: var(--tq); width: 0; left: 50%; }
.wval { min-width: 34px; text-align: center; font-weight: 800; }

.bottom { position: absolute; bottom: 16px; left: 16px; display: flex; align-items: center; gap: 12px; direction: ltr; }
.ammo { font-weight: 800; font-size: 22px; text-shadow: 0 1px 4px #000; min-width: 90px; }
.rel { height: 4px; background: rgba(255,255,255,.2); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.rel i { display: block; height: 100%; width: 0; background: var(--gold); }
.breath { width: 130px; height: 8px; background: rgba(0,0,0,.5); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.breath i { display: block; height: 100%; width: 100%; background: #9fd8ff; }
.breath i.lock { background: #ff8a63; }

.banner {
  position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-size: 64px; font-weight: 800;
  text-shadow: 0 3px 0 rgba(0,0,0,.6), 0 0 30px rgba(0,0,0,.6); color: var(--gold);
}
.banner small { display: block; font-size: 22px; color: var(--txt); font-weight: 600; }
.toast {
  position: absolute; top: 108px; left: 50%; transform: translateX(-50%); padding: 6px 16px; border-radius: 99px;
  background: rgba(0,0,0,.6); border: 1px solid var(--line); font-weight: 600;
}
.toast.good { border-color: var(--tq); color: var(--tq); }
.toast.bad { border-color: var(--red); color: #ff8a63; }
.toast.gold { border-color: var(--gold); color: var(--gold); }
.hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255,255,255,.55); transition: opacity 1s; }
.hint.off { opacity: 0; }
#flash { position: absolute; inset: 0; box-shadow: inset 0 0 140px 30px rgba(228,60,40,.0); transition: box-shadow .35s; }
#flash.on { box-shadow: inset 0 0 140px 30px rgba(228,60,40,.75); transition: none; }

.abilityfx {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  transition: opacity .28s;
}
.abilityfx.ghost {
  opacity: 1;
  background: radial-gradient(ellipse at center, rgba(120,230,255,.07), rgba(6,28,42,.42));
  box-shadow: inset 0 0 140px 36px rgba(70, 210, 255, .28);
  animation: abilityPulse 1.7s ease-in-out infinite;
}
.abilityfx.slow {
  opacity: 1;
  background: radial-gradient(ellipse at center, rgba(160,220,255,.05), rgba(20,50,80,.38));
  box-shadow: inset 0 0 120px 28px rgba(120, 200, 255, .3);
}
.abilityfx.tracer {
  opacity: 1;
  box-shadow: inset 0 0 90px 18px rgba(255, 140, 50, .22);
}
.abilityfx.pulse {
  opacity: 1;
  background: radial-gradient(ellipse at center, rgba(255,90,50,.04), rgba(40,10,0,.2));
  box-shadow: inset 0 0 100px 20px rgba(255, 90, 50, .18);
}
.abilityfx.moon {
  opacity: 1;
  box-shadow: inset 0 0 100px 24px rgba(20, 24, 36, .45);
}
.abilitytag {
  position: absolute; top: 118px; left: 50%; transform: translateX(-50%);
  padding: 5px 16px; border-radius: 99px; font-weight: 800; font-size: 13px;
  background: rgba(0,0,0,.62); border: 1px solid var(--line); letter-spacing: .3px;
}
.abilitytag.ghost { color: #9ef6ff; border-color: rgba(158,246,255,.5); }
.abilitytag.slow { color: #b8e8ff; border-color: rgba(160,220,255,.5); }
.abilitytag.tracer { color: #ffb060; border-color: rgba(255,160,70,.5); }
.abilitytag.pulse { color: #ff8a63; border-color: rgba(255,90,50,.5); }
.abilitytag.moon { color: #d0d8e8; border-color: rgba(180,190,210,.4); }
.abilitytag.titan { color: #ffe08a; border-color: rgba(232,184,74,.5); }
.abilityfx.titan {
  opacity: 1;
  box-shadow: inset 0 0 90px 16px rgba(232, 184, 74, .14);
}
@keyframes abilityPulse {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.35) brightness(1.08); }
}
.exit { position: absolute; top: 10px; right: 10px; pointer-events: auto; font-size: 13px; padding: 6px 12px; }

/* ---------- زرادخانه ---------- */
.mhead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.mhead h2 { margin: 0; flex: 1; }
.wgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.wcard { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: rgba(255,255,255,.04); }
.wcard.equipped { border-color: var(--tq); box-shadow: 0 0 0 1px var(--tq) inset; }
.wcard.locked { opacity: .92; }
.wtop { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wtop h3 { margin: 0; font-size: 20px; color: var(--gold); }
.wdesc { font-size: 13px; color: var(--mut); margin: 4px 0 8px; min-height: 36px; }
.wstats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; font-size: 13px; margin-bottom: 10px; }
.wstats span { display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(255,255,255,.1); padding: 2px 0; }
.wstats b { color: var(--txt); }
.up { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(255,255,255,.07); }
.up .lbl { flex: 1; font-size: 13px; line-height: 1.4; }
.up .lbl small { display: block; color: var(--mut); font-size: 11px; }
.pips { display: flex; gap: 3px; direction: ltr; }
.pips i { width: 9px; height: 9px; border-radius: 2px; background: rgba(255,255,255,.14); }
.pips i.on { background: var(--tq); }

/* ---------- درخت مهارت ---------- */
.tree { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 12px; }
.branch h3 { margin: 0 0 8px; text-align: center; font-size: 16px; color: var(--gold); }
.node {
  position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: rgba(255,255,255,.05);
  margin-bottom: 22px;
}
.node:last-child { margin-bottom: 0; }
.node:not(:last-child)::after {
  content: ''; position: absolute; left: 50%; bottom: -22px; width: 2px; height: 22px; background: rgba(255,255,255,.2);
}
.node.open { border-color: rgba(46,196,182,.5); }
.node.maxed { border-color: var(--gold); background: rgba(232,184,74,.1); }
.node.locked { opacity: .5; }
.node h4 { margin: 0 0 3px; font-size: 15px; }
.node p { margin: 0 0 8px; font-size: 12px; color: var(--mut); line-height: 1.6; min-height: 38px; }
.node .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.node .req { font-size: 11px; color: #ff8a63; }

@media (max-width: 720px) {
  .tree { grid-template-columns: 1fr; }
  .logo h1 { font-size: 34px; }
  .banner { font-size: 44px; }
  .pl { width: 30vw; }
  .ballistics { top: 70px; gap: 8px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
