:root {
  --navy: #050815;
  --panel: rgba(7, 18, 37, 0.86);
  --cyan: #20d9ff;
  --cyan-soft: rgba(32, 217, 255, 0.18);
  --pink: #ff2da6;
  --lime: #9dff24;
  --text: #edfbff;
  --muted: #86a6b7;
  --danger: #ff526b;
  --safe-top: max(10px, env(safe-area-inset-top));
  --safe-right: max(12px, env(safe-area-inset-right));
  --safe-bottom: max(10px, env(safe-area-inset-bottom));
  --safe-left: max(12px, env(safe-area-inset-left));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; height: 100dvh; overflow: hidden; }
body {
  margin: 0;
  background: var(--navy);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.entry-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 30%, rgba(255,45,166,.22), transparent 25%),
    radial-gradient(circle at 75% 70%, rgba(32,217,255,.22), transparent 30%),
    linear-gradient(rgba(32,217,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32,217,255,.045) 1px, transparent 1px),
    #050815;
  background-size: auto, auto, 42px 42px, 42px 42px, auto;
}
.entry-screen::before,
.entry-screen::after {
  content: "";
  position: absolute;
  width: 45vw;
  height: 45vw;
  border: 1px solid rgba(32,217,255,.18);
  transform: rotate(45deg);
  border-radius: 70px;
}
.entry-screen::before { right: -32vw; top: -23vw; }
.entry-screen::after { left: -34vw; bottom: -24vw; border-color: rgba(255,45,166,.17); }
.entry-card {
  position: relative;
  z-index: 2;
  width: min(430px, 92vw);
  padding: 26px 30px 22px;
  border: 1px solid rgba(79, 226, 255, 0.3);
  border-radius: 28px;
  background: linear-gradient(155deg, rgba(11, 24, 47, .96), rgba(5, 9, 21, .94));
  box-shadow: 0 28px 100px rgba(0,0,0,.5), 0 0 55px rgba(32,217,255,.08), inset 0 1px rgba(255,255,255,.08);
  text-align: center;
}
.eyebrow { color: var(--cyan); font-size: 12px; letter-spacing: .08em; font-weight: 700; }
.entry-card h1 { margin: 2px 0 4px; font-size: clamp(34px, 8vw, 54px); font-weight: 900; letter-spacing: -.05em; }
.entry-card h1 span { color: var(--cyan); text-shadow: 0 0 24px rgba(32,217,255,.48); }
.entry-card p { margin: 0 auto 16px; max-width: 340px; color: #9cb7c5; font-size: 13px; line-height: 1.85; }
.entry-card small { display: block; margin-top: 13px; color: #688696; font-size: 11px; }
.field-label { display: block; margin: 0 3px 6px; color: #c6dae4; text-align: right; font-size: 12px; font-weight: 600; }
.text-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(105, 173, 198, .25);
  border-radius: 14px;
  outline: none;
  background: rgba(3, 10, 23, .78);
  color: white;
  padding: 0 15px;
  text-align: right;
  transition: border-color .2s, box-shadow .2s;
}
.text-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(32,217,255,.1); }
.text-input::placeholder { color: #557180; }
.entry-actions { margin-top: 12px; }
.button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  font-weight: 800;
}
.button.primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #09b7e2, #20d9ff);
  color: #02101c;
  box-shadow: 0 10px 30px rgba(32,217,255,.2);
}
.button.primary:active { transform: scale(.98); }
.button.secondary { flex: 0 0 92px; background: rgba(32,217,255,.12); border: 1px solid rgba(32,217,255,.35); color: var(--cyan); }
.divider { height: 25px; display: flex; align-items: center; gap: 10px; color: #607e8e; font-size: 11px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: rgba(128,180,200,.14); }
.join-row { display: flex; direction: ltr; gap: 8px; }
.room-input { direction: ltr; text-align: center; text-transform: uppercase; letter-spacing: .24em; font-weight: 800; }
.entry-error { min-height: 18px; margin-top: 7px; color: #ff7890; font-size: 12px; }
.fullscreen-entry {
  min-height: 34px;
  margin-top: 2px;
  border: 0;
  background: transparent;
  color: #82aab9;
  font-size: 11px;
}
.fullscreen-entry:hover { color: var(--cyan); }
.brand-mark { position: absolute; width: min(75vw, 760px); height: min(75vw, 760px); opacity: .15; }
.brand-mark i { position: absolute; inset: 0; border: 2px solid var(--cyan); border-radius: 40%; transform: rotate(45deg); }
.brand-mark i:nth-child(2) { inset: 12%; border-color: var(--pink); animation: spin 28s linear infinite reverse; }
.brand-mark i:nth-child(3) { inset: 25%; animation: spin 22s linear infinite; }
@keyframes spin { to { transform: rotate(405deg); } }

.game-screen { position: fixed; inset: 0; overflow: hidden; background: #030611; direction: ltr; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud-card {
  border: 1px solid rgba(67, 217, 255, .38);
  background: linear-gradient(145deg, rgba(8,24,46,.84), rgba(3,10,23,.78));
  box-shadow: 0 10px 30px rgba(0,0,0,.25), inset 0 1px rgba(255,255,255,.05);
  backdrop-filter: blur(9px);
}
.hud-top {
  position: fixed;
  z-index: 5;
  top: var(--safe-top);
  left: var(--safe-left);
  right: var(--safe-right);
  height: 45px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  direction: ltr;
}
.hud-top > * { pointer-events: auto; }
.health-box { height: 39px; min-width: 218px; border-radius: 11px 4px 11px 4px; display: flex; align-items: center; gap: 8px; padding: 0 11px; }
.lives { min-width: 48px; color: #ff4f82; font-size: 14px; letter-spacing: 2px; text-shadow: 0 0 10px rgba(255,79,130,.8); direction: ltr; }
.lives .lost { color: #40505c; text-shadow: none; }
.health-track { width: 96px; height: 8px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.health-track i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #0ba6ff, #39f1ff); box-shadow: 0 0 13px var(--cyan); transition: width .16s, background .2s; }
.health-box b { width: 27px; font-size: 11px; color: #ccf8ff; }
.round-box { position: absolute; top: 0; left: 50%; transform: translateX(-50%); min-width: 116px; border-radius: 4px 4px 13px 13px; text-align: center; padding: 2px 18px 5px; }
.round-box span { display: block; color: #7cb0c4; font-size: 9px; line-height: 1.2; }
.round-box strong { font-size: 18px; letter-spacing: .05em; }
.score-button { min-width: 72px; height: 39px; border-radius: 4px 11px 4px 11px; color: white; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 0 12px; }
.score-button span { color: #8ab2c2; font-size: 10px; }
.score-button strong { color: var(--cyan); font-size: 17px; }

.scoreboard { position: fixed; z-index: 9; top: calc(var(--safe-top) + 47px); right: var(--safe-right); width: min(245px, 40vw); border-radius: 14px; padding: 10px; direction: rtl; transform: translateX(calc(100% + 28px)); opacity: 0; transition: .2s ease; pointer-events: none; }
.scoreboard.open { transform: translateX(0); opacity: 1; pointer-events: auto; }
.score-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 6px; border-bottom: 1px solid rgba(111,203,230,.17); font-size: 12px; }
.score-head button { width: 26px; height: 26px; border: 0; background: transparent; font-size: 22px; }
.scoreboard ol { list-style: none; padding: 3px 0 0; margin: 0; }
.scoreboard li { display: grid; grid-template-columns: 23px 11px 1fr 46px 28px; gap: 6px; align-items: center; min-height: 30px; border-bottom: 1px solid rgba(111,203,230,.09); font-size: 11px; }
.scoreboard li.me { background: rgba(32,217,255,.08); color: var(--cyan); }
.scoreboard .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.scoreboard .score-lives { color: #ff6f9c; font-style: normal; font-size: 10px; white-space: nowrap; }

.room-tools { position: fixed; z-index: 5; top: calc(var(--safe-top) + 50px); left: var(--safe-left); display: flex; align-items: center; gap: 6px; direction: ltr; }
.room-tools span, .mini-button { min-height: 28px; padding: 0 10px; border: 1px solid rgba(66,202,237,.22); border-radius: 8px; background: rgba(4,13,29,.66); color: #89adbc; font-size: 9px; backdrop-filter: blur(6px); }
.room-tools span { display: flex; align-items: center; direction: rtl; }
.mini-button { color: var(--cyan); }
.icon-only { width: 30px; padding: 0; font-size: 15px; }
.room-tools .weapon-badge { color: #ffd45e; border-color: rgba(255,212,94,.25); }

.center-message { position: fixed; z-index: 7; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(470px, 66vw); padding: 16px 20px; border: 1px solid rgba(32,217,255,.31); border-radius: 18px; background: rgba(3,9,22,.82); text-align: center; direction: rtl; backdrop-filter: blur(10px); transition: opacity .2s; }
.center-message:empty, .center-message.off { opacity: 0; pointer-events: none; }
.center-message strong { display: block; font-size: 17px; }
.center-message span { display: block; margin: 3px 0 10px; color: #83a6b6; font-size: 10px; }
.center-message .button { min-height: 38px; font-size: 12px; }
.weapon-chooser { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.weapon-chooser button { min-height: 62px; padding: 8px; border: 1px solid rgba(255,207,77,.3); border-radius: 12px; background: linear-gradient(145deg, rgba(66,46,10,.65), rgba(12,19,34,.9)); color: #ffe590; }
.weapon-chooser button:active { transform: scale(.96); border-color: #ffd45e; }
.weapon-chooser b { display: block; font-size: 11px; }
.weapon-chooser small { display: block; margin-top: 3px; color: #9eb1bb; font-size: 8px; line-height: 1.5; }
.toast { position: fixed; z-index: 12; left: 50%; bottom: 18%; transform: translate(-50%, 18px); padding: 7px 14px; border: 1px solid rgba(32,217,255,.25); border-radius: 99px; background: rgba(3,10,22,.8); color: #cff9ff; font-size: 10px; opacity: 0; pointer-events: none; transition: .2s; direction: rtl; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

.touch-pad { position: fixed; z-index: 6; width: 142px; height: 142px; display: grid; place-items: center; touch-action: none; }
.move-pad { left: var(--safe-left); bottom: var(--safe-bottom); }
.right-controls { position: fixed; z-index: 6; right: var(--safe-right); bottom: var(--safe-bottom); width: 162px; height: 182px; pointer-events: none; }
.aim-pad { right: 0; bottom: 0; pointer-events: auto; }
.pad-ring { position: relative; width: 116px; height: 116px; border: 2px solid rgba(59,219,255,.45); border-radius: 50%; background: radial-gradient(circle, rgba(32,217,255,.16), rgba(12,50,75,.09) 55%, rgba(4,12,25,.35)); box-shadow: 0 0 28px rgba(32,217,255,.09), inset 0 0 18px rgba(32,217,255,.08); }
.pad-ring::before, .pad-ring::after { content: ""; position: absolute; background: rgba(32,217,255,.13); }
.pad-ring::before { width: 2px; height: 66%; top: 17%; left: 50%; }
.pad-ring::after { height: 2px; width: 66%; left: 17%; top: 50%; }
.pad-knob { position: absolute; z-index: 2; width: 47px; height: 47px; left: calc(50% - 23.5px); top: calc(50% - 23.5px); border: 2px solid rgba(151,242,255,.8); border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(126,239,255,.56), rgba(14,145,196,.55)); box-shadow: 0 0 18px rgba(32,217,255,.45); transform: translate(0,0); }
.fire-ring { border-color: rgba(255,45,166,.48); background: radial-gradient(circle, rgba(255,45,166,.17), rgba(60,13,55,.08) 56%, rgba(4,12,25,.35)); }
.fire-ring .pad-knob { border-color: rgba(255,167,220,.9); background: radial-gradient(circle at 35% 30%, rgba(255,167,220,.62), rgba(212,18,129,.58)); box-shadow: 0 0 20px rgba(255,45,166,.42); }
.fire-ring b { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); color: rgba(255,255,255,.55); font-size: 8px; }
.ability-row { position: absolute; top: 0; right: 8px; display: flex; gap: 9px; pointer-events: auto; }
.ability { position: relative; width: 48px; height: 48px; overflow: hidden; border: 1px solid rgba(32,217,255,.45); border-radius: 50%; background: rgba(5,22,41,.78); color: var(--cyan); font-size: 24px; box-shadow: 0 0 14px rgba(32,217,255,.08); }
.ability:active { transform: scale(.92); }
.ability span { position: relative; z-index: 2; }
.ability i { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; height: 0%; background: rgba(1,6,16,.75); transition: height .1s linear; }
.ability.cooling { color: #66818c; border-color: rgba(100,130,140,.25); }

.rotate-notice { display: none; }
@media (orientation: portrait) and (max-width: 800px) {
  .rotate-notice { position: fixed; z-index: 100; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; background: radial-gradient(circle, #0c2942, #040712 65%); text-align: center; }
  .rotate-notice strong { font-size: 20px; }
  .rotate-notice span { color: var(--muted); font-size: 12px; }
  .rotate-icon { font-size: 55px; color: var(--cyan); text-shadow: 0 0 20px var(--cyan); animation: tilt 1.4s ease-in-out infinite alternate; }
  @keyframes tilt { from { transform: rotate(-35deg); } to { transform: rotate(35deg); } }
}

@media (max-height: 460px) {
  .entry-screen { padding: 8px; }
  .entry-card { width: min(600px, 86vw); padding: 13px 23px 11px; }
  .entry-card h1 { font-size: 31px; }
  .entry-card p { margin-bottom: 7px; line-height: 1.45; }
  .text-input, .button { min-height: 38px; }
  .entry-actions { margin-top: 7px; }
  .divider { height: 20px; }
  .entry-card small { margin-top: 5px; }
  .touch-pad { width: 126px; height: 126px; }
  .pad-ring { width: 104px; height: 104px; }
  .right-controls { width: 146px; height: 166px; }
  .ability { width: 43px; height: 43px; }
  .center-message { padding: 11px 15px; }
  .weapon-chooser button { min-height: 52px; }
}

@media (max-width: 760px) and (orientation: landscape) {
  .health-box { min-width: 184px; }
  .health-track { width: 66px; }
  .room-tools .weapon-badge { display: none; }
  .weapon-chooser { gap: 5px; }
  .weapon-chooser button { padding: 5px; }
}

@media (pointer: fine) and (min-width: 900px) {
  .touch-pad, .right-controls { opacity: .58; }
}
