/* MF Battle lobby. Everything is laid out on one landscape stage; --u is 1% of its
   height, so the whole lobby scales with the phone. */
:root {
  --bg0: #07040f;
  --bg1: #120a26;
  --panel: rgba(22, 12, 46, 0.86);
  --card: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.09);
  --ember1: #ff3b6b;
  --ember2: #ff8a3d;
  --violet: #9b5cff;
  --cyan: #22e3ff;
  --gold: #ffc83d;
  --text: #f6f3ff;
  --dim: #a59fc4;
  --u: 4px;
  --pad-l: 16px;
  --pad-r: 16px;
  --pad-t: 12px;
  --pad-b: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg0);
  color: var(--text);
  font-family: 'Cairo', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input { font: inherit; }

#stage {
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 22%, rgba(155, 92, 255, 0.28), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(255, 59, 107, 0.2), transparent 40%),
    linear-gradient(135deg, var(--bg1), var(--bg0) 70%);
}
#stage.rotated { transform-origin: top left; transform: rotate(90deg) translateY(-100%); }

/* Drifting blobs + a faint hex grid, like the arena behind the menu. */
.bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 50% 50%, #000 30%, transparent 85%);
}
.bg i {
  position: absolute;
  border-radius: 50%;
  opacity: 0.55;
  filter: blur(0.3px);
  animation: drift 18s ease-in-out infinite alternate;
}
.bg i:nth-child(1) { width: 14px; height: 14px; left: 12%; top: 70%; background: var(--cyan); }
.bg i:nth-child(2) { width: 9px; height: 9px; left: 30%; top: 18%; background: var(--gold); animation-delay: -4s; }
.bg i:nth-child(3) { width: 18px; height: 18px; left: 64%; top: 80%; background: var(--ember1); animation-delay: -8s; }
.bg i:nth-child(4) { width: 8px; height: 8px; left: 78%; top: 30%; background: #a3ff3a; animation-delay: -2s; }
.bg i:nth-child(5) { width: 11px; height: 11px; left: 46%; top: 56%; background: var(--violet); animation-delay: -6s; }
.bg i:nth-child(6) { width: 7px; height: 7px; left: 90%; top: 62%; background: var(--ember2); animation-delay: -10s; }
.bg i:nth-child(7) { width: 46px; height: 46px; left: 6%; top: 12%; background: radial-gradient(circle at 35% 30%, #c4b5fd, #6d28d9); opacity: 0.25; animation-duration: 26s; }
.bg i:nth-child(8) { width: 64px; height: 64px; left: 84%; top: 8%; background: radial-gradient(circle at 35% 30%, #fda4af, #be123c); opacity: 0.2; animation-duration: 30s; }
@keyframes drift { to { transform: translate(40px, -26px); } }

#screen {
  position: absolute;
  inset: 0;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 2.4);
}

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: calc(var(--u) * 11);
  height: calc(var(--u) * 11);
  min-width: 38px;
  min-height: 38px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: linear-gradient(135deg, var(--violet), var(--ember1));
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 18px;
  overflow: hidden;
  flex: none;
  box-shadow: 0 0 0 3px rgba(255, 200, 61, 0.15);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.me-text { min-width: 0; line-height: 1.25; }
.me-name { font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-weight: 800; font-size: calc(var(--u) * 4.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 36vw; }
.me-sub { font-size: calc(var(--u) * 3); color: var(--dim); }
.me-sub b { color: var(--cyan); }

.wallet { display: flex; align-items: center; gap: 8px; flex: none; }
.coins {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1.5px solid rgba(255, 200, 61, 0.55);
  font-weight: 900;
  font-size: calc(var(--u) * 4.4);
  direction: ltr;
}
.coins img { width: calc(var(--u) * 8); height: calc(var(--u) * 8); min-width: 26px; min-height: 26px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
.round-btn {
  width: calc(var(--u) * 10);
  height: calc(var(--u) * 10);
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--line);
  font-size: calc(var(--u) * 4.4);
}
.round-btn:active { transform: scale(0.94); }
.back-btn { font-size: calc(var(--u) * 3.2); font-weight: 800; padding: 0 12px; border-radius: 999px; width: auto; color: var(--dim); }

.brand {
  font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: calc(var(--u) * 6);
  letter-spacing: 1px;
  direction: ltr;
  background: linear-gradient(90deg, var(--ember1), var(--ember2) 45%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(255, 59, 107, 0.35));
  white-space: nowrap;
}

/* ---------- lobby ---------- */
.lobby { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.05fr 1.25fr 0.95fr; gap: calc(var(--u) * 3); align-items: stretch; }

.showcase { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 1.6); min-height: 0; }
.skin-orb {
  position: relative;
  width: calc(var(--u) * 46);
  height: calc(var(--u) * 46);
  border-radius: 50%;
  animation: bob 3.2s ease-in-out infinite;
}
.skin-orb::before {
  content: '';
  position: absolute;
  inset: -14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(155, 92, 255, 0.45), transparent 65%);
  z-index: -1;
}
.skin-orb svg { width: 100%; height: 100%; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.55)); }
@keyframes bob { 50% { transform: translateY(-6px); } }
.skin-name { font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-weight: 800; font-size: calc(var(--u) * 5.4); line-height: 1; }
.skin-stats { display: flex; gap: 10px; font-size: calc(var(--u) * 3.1); color: var(--dim); }
.skin-stats b { color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); font-size: calc(var(--u) * 3); font-weight: 800; }

.center { display: flex; flex-direction: column; justify-content: center; gap: calc(var(--u) * 2.6); min-height: 0; }
.mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--u) * 2) calc(var(--u) * 3.4);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(34, 227, 255, 0.12), rgba(155, 92, 255, 0.14));
  border: 1.5px solid rgba(34, 227, 255, 0.45);
}
.mode b { font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: calc(var(--u) * 5); line-height: 1; }
.mode small { display: block; color: var(--dim); font-size: calc(var(--u) * 2.9); margin-top: 3px; }
.dot-live { width: 10px; height: 10px; border-radius: 50%; background: #a3ff3a; box-shadow: 0 0 10px #a3ff3a; flex: none; }

.play {
  position: relative;
  overflow: hidden;
  padding: calc(var(--u) * 4.4) 10px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--ember1), var(--ember2));
  box-shadow: 0 10px 0 #9a1d3c, 0 18px 34px rgba(255, 59, 107, 0.4);
  text-align: center;
  transform: translateY(-4px);
  transition: transform 0.12s, box-shadow 0.12s;
}
.play:active { transform: translateY(2px); box-shadow: 0 4px 0 #9a1d3c, 0 10px 20px rgba(255, 59, 107, 0.35); }
.play::after {
  content: '';
  position: absolute;
  top: -40%;
  left: -30%;
  width: 40%;
  height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: rotate(18deg);
  animation: sheen 3.4s ease-in-out infinite;
}
@keyframes sheen { 0%, 60% { left: -40%; } 100% { left: 120%; } }
.play b { display: block; font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: calc(var(--u) * 9); line-height: 1.05; text-shadow: 0 3px 0 rgba(120, 10, 40, 0.5); }
.play small { display: block; font-size: calc(var(--u) * 3); font-weight: 800; opacity: 0.9; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(var(--u) * 2); }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: calc(var(--u) * 2) 6px;
  border-radius: 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  font-weight: 900;
  font-size: calc(var(--u) * 3.4);
}
.tile .ic { font-size: calc(var(--u) * 6.4); line-height: 1.1; }
.tile:active { transform: scale(0.97); }
.tile.t-store { border-color: rgba(255, 200, 61, 0.45); background: linear-gradient(160deg, rgba(255, 200, 61, 0.14), rgba(255, 255, 255, 0.03)); }
.tile.t-skins { border-color: rgba(155, 92, 255, 0.5); background: linear-gradient(160deg, rgba(155, 92, 255, 0.18), rgba(255, 255, 255, 0.03)); }
.tile.t-rank { border-color: rgba(34, 227, 255, 0.45); background: linear-gradient(160deg, rgba(34, 227, 255, 0.14), rgba(255, 255, 255, 0.03)); }

.weekly {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 1.4);
  min-height: 0;
  padding: calc(var(--u) * 2.6);
  border-radius: 18px;
  background: var(--panel);
  border: 1.5px solid var(--line);
}
.weekly h3 { margin: 0; font-size: calc(var(--u) * 3.8); display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.weekly h3 small { font-size: calc(var(--u) * 2.6); color: var(--dim); font-weight: 700; }
.w-row { display: flex; align-items: center; gap: 8px; font-size: calc(var(--u) * 3.1); padding: 4px 6px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); }
.w-row .rk { width: 22px; text-align: center; font-weight: 900; }
.w-row svg { width: calc(var(--u) * 6.4); height: calc(var(--u) * 6.4); min-width: 20px; min-height: 20px; flex: none; }
.w-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-row .vl { font-weight: 900; color: var(--gold); direction: ltr; }
.w-empty { color: var(--dim); font-size: calc(var(--u) * 3); text-align: center; margin: auto 0; line-height: 1.7; }
.link-btn { color: var(--cyan); font-weight: 800; font-size: calc(var(--u) * 3); margin-top: auto; }

/* ---------- panels (store, skins, ranking, settings) ---------- */
.panel {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  background: rgba(7, 4, 15, 0.97);
  animation: panel-in 0.18s ease-out;
}
.panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } }
.p-head { display: flex; align-items: center; gap: 10px; flex: none; margin-bottom: calc(var(--u) * 2.4); }
.p-head h2 { margin: 0; font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: calc(var(--u) * 6.4); flex: 1; line-height: 1; }
.p-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--u) * 30), 1fr)); gap: calc(var(--u) * 2.2); }
.skin-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: calc(var(--u) * 2.4) 8px;
  border-radius: 18px;
  background: var(--card);
  border: 1.5px solid var(--line);
  text-align: center;
}
.skin-card svg { width: calc(var(--u) * 18); height: calc(var(--u) * 18); min-width: 56px; min-height: 56px; }
.skin-card .sn { font-weight: 900; font-size: calc(var(--u) * 3.6); }
.rarity { font-size: calc(var(--u) * 2.6); font-weight: 800; padding: 1px 10px; border-radius: 999px; border: 1px solid currentColor; }
.skin-card.equipped { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(34, 227, 255, 0.25) inset; }
.skin-card.owned .price { display: none; }
.price { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; direction: ltr; color: var(--gold); }
.price img { width: 18px; height: 18px; }
.btn {
  margin-top: 4px;
  padding: 7px 14px;
  border-radius: 12px;
  font-weight: 900;
  font-size: calc(var(--u) * 3.1);
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid var(--line);
  min-width: 70%;
}
.btn-hot { background: linear-gradient(135deg, var(--ember1), var(--ember2)); border-color: transparent; box-shadow: 0 4px 0 #9a1d3c; }
.btn-cyan { background: linear-gradient(135deg, #0ea5e9, var(--cyan)); color: #04121f; border-color: transparent; }
.btn-violet { background: linear-gradient(135deg, #7c3aed, var(--violet)); border-color: transparent; }
.btn[disabled] { opacity: 0.5; }
.btn:active { transform: translateY(1px); }

.tabs { display: flex; gap: 8px; flex: none; margin-bottom: calc(var(--u) * 2); }
.tab { padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-weight: 800; font-size: calc(var(--u) * 3.2); }
.tab.on { background: linear-gradient(135deg, var(--violet), #6d28d9); border-color: transparent; }
.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: calc(var(--u) * 3.4); }
.lb-row .rk { width: 28px; text-align: center; font-weight: 900; font-size: calc(var(--u) * 4); }
.lb-row svg { width: 32px; height: 32px; flex: none; }
.lb-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.lb-row .vl { font-weight: 900; color: var(--gold); direction: ltr; }
.lb-row.me { border-color: var(--cyan); background: rgba(34, 227, 255, 0.08); }
.lb-row.r1 .rk { color: #ffd34d; } .lb-row.r2 .rk { color: #e2e8f0; } .lb-row.r3 .rk { color: #fb923c; }
.lb-foot { flex: none; display: flex; justify-content: space-between; gap: 10px; padding-top: 8px; color: var(--dim); font-size: calc(var(--u) * 3); }
.lb-foot b { color: var(--text); }

.set-list { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 2.2); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(var(--u) * 2.4) calc(var(--u) * 3); border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); }
.set-row .lbl { font-weight: 900; font-size: calc(var(--u) * 3.6); }
.set-row .lbl small { display: block; font-size: calc(var(--u) * 2.7); color: var(--dim); font-weight: 600; }
.switch { position: relative; width: 52px; height: 30px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); flex: none; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch.on { background: linear-gradient(135deg, #16a34a, #a3ff3a); }
.switch.on::after { transform: translateX(-22px); }
.seg { display: flex; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); flex: none; }
.seg button { padding: 5px 10px; border-radius: 9px; font-weight: 800; font-size: calc(var(--u) * 3); color: var(--dim); }
.seg button.on { background: linear-gradient(135deg, var(--violet), #6d28d9); color: #fff; }
.set-wide { grid-column: 1 / -1; }
.controls-btn { width: 100%; padding: calc(var(--u) * 3); border-radius: 16px; font-weight: 900; font-size: calc(var(--u) * 4); background: linear-gradient(135deg, rgba(255, 59, 107, 0.2), rgba(255, 138, 61, 0.2)); border: 1.5px solid rgba(255, 138, 61, 0.55); }

/* ---------- control layout editor ---------- */
.editor { position: absolute; inset: 0; z-index: 20; overflow: hidden; background: #101a2e; }
.editor .field {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
}
.editor.light { background: #e9eef6; }
.editor.light .field { background-image: linear-gradient(rgba(0, 0, 0, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.06) 1px, transparent 1px); }
.ed-hint { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 800; color: #fde68a; background: rgba(0, 0, 0, 0.45); padding: 4px 12px; border-radius: 999px; white-space: nowrap; pointer-events: none; z-index: 2; }
.ctl {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(255, 211, 77, 0.85);
  touch-action: none;
  cursor: grab;
  color: #fff;
  font-weight: 900;
}
.ctl.round { border-radius: 50%; }
.ctl.box { border-radius: 12px; }
.ctl.pill, .ctl.pill-v { border-radius: 999px; }
.ctl.sel { border: 2.5px solid var(--cyan); box-shadow: 0 0 0 4px rgba(34, 227, 255, 0.25); z-index: 3; }
.ctl-label { font-size: 13px; pointer-events: none; text-align: center; padding: 0 4px; }
.ctl[data-id='split'] { background: radial-gradient(circle at 35% 30%, #ff7aa0, var(--ember1)); }
.ctl[data-id='throw'] { background: radial-gradient(circle at 35% 30%, #ffb27a, var(--ember2)); }
.ctl[data-id='double'] { background: radial-gradient(circle at 35% 30%, #c4a2ff, var(--violet)); }
.ctl[data-id='chat'], .ctl[data-id='leaderboard'], .ctl[data-id='minimap'], .ctl[data-id='mass'], .ctl[data-id='zoom'] { background: rgba(10, 16, 34, 0.6); }
.ctl-joy-base { width: 100%; height: 100%; border-radius: 50%; background: rgba(255, 255, 255, 0.12); display: grid; place-items: center; pointer-events: none; }
.ctl-joy-knob { width: 42%; height: 42%; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
.ctl-lb { display: flex; flex-direction: column; gap: 2px; font-size: 11px; width: 100%; padding: 6px 10px; pointer-events: none; text-align: start; }
.ctl-lb b { color: var(--gold); font-size: 12px; }
.ctl-lb i { font-style: normal; color: #cbd5e1; }
.ctl-map { position: relative; width: 84%; height: 84%; border-radius: 8px; background: rgba(255, 255, 255, 0.06); pointer-events: none; }
.ctl-map i { position: absolute; left: 46%; top: 40%; width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); }
.ctl-zoom { display: flex; flex-direction: column; gap: 10px; font-size: 20px; pointer-events: none; }

.ed-panel {
  position: absolute;
  z-index: 5;
  width: 312px;
  max-width: calc(100% - 8px);
  padding: 10px 12px 12px;
  border-radius: 18px;
  background: rgba(37, 99, 235, 0.92);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45);
  touch-action: none;
}
.ed-grip { display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: move; margin-bottom: 6px; }
.ed-grip b { font-size: 14px; }
.ed-grip span { font-size: 11px; opacity: 0.8; }
.ed-line { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; font-weight: 800; }
.ed-line label { width: 74px; flex: none; white-space: nowrap; }
.ed-line input[type='range'] { flex: 1; min-width: 0; accent-color: #fde047; }
.ed-step { width: 30px; height: 30px; border-radius: 9px; background: rgba(0, 0, 0, 0.25); font-weight: 900; flex: none; }
.ed-val { width: 42px; text-align: center; font-weight: 900; direction: ltr; flex: none; }
.ed-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.ed-btns button { padding: 7px 4px; border-radius: 10px; font-weight: 900; font-size: 12px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }
.b-copy { background: #2dd4bf; color: #062a26; }
.b-paste { background: #fbbf24; color: #3a2400; }
.b-reset { background: #f87171; color: #3b0a0a; }
.b-save { background: #4ade80; color: #052e16; grid-column: span 2; }
.b-exit { background: rgba(0, 0, 0, 0.35); color: #fff; }
.ed-min { position: absolute; z-index: 6; bottom: 40px; left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px; background: rgba(37, 99, 235, 0.95); font-weight: 900; font-size: 12px; }

/* ---------- dialogs & toast ---------- */
.dialog-backdrop { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, 0.7); padding: 12px; }
.dialog-backdrop[hidden] { display: none; }
.dialog { width: min(420px, 92%); max-height: 100%; overflow-y: auto; padding: 18px; border-radius: 20px; background: linear-gradient(160deg, #1d1140, #120a26); border: 1.5px solid rgba(155, 92, 255, 0.55); text-align: center; }
.dialog h3 { margin: 0 0 6px; font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: 22px; }
.dialog p { margin: 0 0 10px; color: var(--dim); font-size: 13px; line-height: 1.7; }
.code-box { direction: ltr; font-family: ui-monospace, monospace; font-size: 22px; font-weight: 900; letter-spacing: 2px; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.4); border: 1.5px dashed var(--gold); color: var(--gold); margin-bottom: 10px; user-select: text; -webkit-user-select: text; }
.code-input { width: 100%; direction: ltr; text-align: center; font-size: 20px; font-weight: 900; letter-spacing: 2px; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.4); border: 1.5px solid var(--line); color: #fff; margin-bottom: 10px; text-transform: uppercase; -webkit-user-select: text; user-select: text; }
.dialog .row { display: flex; gap: 8px; justify-content: center; }
.dialog .row .btn { min-width: 0; flex: 1; }
.toast { position: absolute; z-index: 60; bottom: 18px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 40px); padding: 9px 18px; border-radius: 14px; background: rgba(20, 12, 40, 0.95); border: 1.5px solid var(--gold); font-weight: 800; font-size: 13px; text-align: center; }
.toast[hidden] { display: none; }

/* ---------- loading / errors ---------- */
.center-msg { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 460px; }
.center-msg img { width: 74px; height: 74px; animation: bob 2s ease-in-out infinite; }
.center-msg h2 { margin: 0; font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: 26px; }
.center-msg p { margin: 0; color: var(--dim); line-height: 1.7; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--ember1); animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .bg i, .skin-orb, .play::after { animation: none; }
}

/* ---------- weekly heroes (lobby, left) ---------- */
.weekly {
  position: relative;
  overflow: hidden;
  gap: calc(var(--u) * 1.6);
  padding: calc(var(--u) * 2.4) calc(var(--u) * 2.4) calc(var(--u) * 2);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 200, 61, 0.16), transparent 60%),
    linear-gradient(180deg, rgba(40, 20, 80, 0.92), rgba(16, 8, 34, 0.95));
  border: 1.5px solid rgba(255, 200, 61, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 28px rgba(0, 0, 0, 0.35);
}
.w-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.w-head b { font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: calc(var(--u) * 4.4); line-height: 1.1; }
.w-head span { font-size: calc(var(--u) * 2.7); color: var(--gold); font-weight: 800; padding: 1px 8px; border-radius: 999px; background: rgba(255, 200, 61, 0.12); }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: calc(var(--u) * 1); margin-top: calc(var(--u) * 1); }
.pod { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.pod-crown { font-size: calc(var(--u) * 5); line-height: 1; margin-bottom: -4px; animation: bob 2.4s ease-in-out infinite; }
.pod-skin { width: calc(var(--u) * 11); height: calc(var(--u) * 11); min-width: 30px; min-height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: var(--dim); background: rgba(255, 255, 255, 0.05); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12); }
.pod.first .pod-skin { width: calc(var(--u) * 14); height: calc(var(--u) * 14); box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255, 200, 61, 0.45); }
.pod.second .pod-skin { box-shadow: 0 0 0 2.5px #dbe4f0; }
.pod.third .pod-skin { box-shadow: 0 0 0 2.5px #f59e5b; }
.pod.me .pod-skin { box-shadow: 0 0 0 3px var(--cyan), 0 0 16px rgba(34, 227, 255, 0.5); }
.pod-skin svg { width: 100%; height: 100%; }
.pod-name { margin-top: 3px; max-width: 100%; font-size: calc(var(--u) * 2.9); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-val { font-size: calc(var(--u) * 2.7); font-weight: 900; color: var(--gold); direction: ltr; line-height: 1.2; }
.pod-base { width: 100%; margin-top: 4px; border-radius: 10px 10px 4px 4px; display: grid; place-items: center; font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: calc(var(--u) * 4.4); color: #1b1030; }
.pod.first .pod-base { height: calc(var(--u) * 9); background: linear-gradient(180deg, #ffe58a, #f2a900); }
.pod.second .pod-base { height: calc(var(--u) * 6.5); background: linear-gradient(180deg, #f1f5f9, #94a3b8); }
.pod.third .pod-base { height: calc(var(--u) * 5); background: linear-gradient(180deg, #fdba74, #c2410c); }
.pod.empty { opacity: 0.45; }
.weekly .w-row { padding: 3px 8px; }
.weekly .w-row.me { box-shadow: inset 0 0 0 1.5px var(--cyan); }
.weekly .w-empty { margin: 0; font-size: calc(var(--u) * 2.8); }
.w-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; font-size: calc(var(--u) * 2.8); color: var(--dim); }
.w-me b { color: var(--cyan); font-weight: 900; }
.w-all { width: 100%; padding: calc(var(--u) * 1.4); border-radius: 12px; font-weight: 900; font-size: calc(var(--u) * 3); background: rgba(255, 200, 61, 0.12); border: 1px solid rgba(255, 200, 61, 0.35); color: var(--gold); }

/* ---------- the arena ---------- */
.game { position: absolute; inset: 0; z-index: 30; overflow: hidden; touch-action: none; background: #0b0d17; }
.game.light { background: #eef1f7; }
.game-canvas { position: absolute; inset: 0; display: block; }
.g-hud { position: absolute; inset: 0; pointer-events: none; }
.g-ctl { position: absolute; display: grid; place-items: center; pointer-events: auto; color: #fff; font-weight: 900; touch-action: none; user-select: none; }
.g-ctl.round { border-radius: 50%; }
.g-ctl.box { border-radius: 12px; }
.g-ctl.pill, .g-ctl.pill-v { border-radius: 999px; }
.g-ctl[data-id='split'] { background: radial-gradient(circle at 35% 30%, #ff7aa0, var(--ember1)); box-shadow: 0 6px 0 #8e1838, 0 10px 22px rgba(0, 0, 0, 0.35); }
.g-ctl[data-id='throw'] { background: radial-gradient(circle at 35% 30%, #ffb27a, var(--ember2)); box-shadow: 0 5px 0 #8a4210, 0 10px 22px rgba(0, 0, 0, 0.35); }
.g-ctl[data-id='double'] { background: radial-gradient(circle at 35% 30%, #c4a2ff, #6d28d9); box-shadow: 0 4px 0 #3b1580; flex-direction: column; gap: 0; line-height: 1; }
.g-ctl[data-id='double'] small { font-size: 8px; font-weight: 800; opacity: 0.9; }
.g-ctl[data-id='double'].on { background: radial-gradient(circle at 35% 30%, #fff3b0, var(--gold)); color: #3a2400; box-shadow: 0 4px 0 #9a6b00, 0 0 18px rgba(255, 200, 61, 0.7); }
.g-ctl.hit { animation: press 0.16s ease-out; }
@keyframes press { 50% { transform: scale(0.88); } }
.g-ctl[data-id='joystick'] .ctl-joy-base { background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 255, 255, 0.18); }
.g-ctl[data-id='joystick'].active .ctl-joy-base { background: rgba(255, 255, 255, 0.16); }
.g-ctl[data-id='joystick'] .ctl-joy-knob { background: rgba(255, 255, 255, 0.45); transition: transform 0.04s; }
.game.light .g-ctl[data-id='joystick'] .ctl-joy-base { background: rgba(0, 0, 0, 0.08); border-color: rgba(0, 0, 0, 0.15); }
.game.light .g-ctl[data-id='joystick'] .ctl-joy-knob { background: rgba(0, 0, 0, 0.3); }
.g-ctl[data-id='mass'] { background: rgba(10, 12, 30, 0.6); font-size: 14px; pointer-events: none; }
.g-ctl[data-id='leaderboard'] { background: rgba(10, 12, 30, 0.55); align-items: start; pointer-events: none; }
.g-lb { width: 100%; padding: 6px 10px; font-size: 11px; line-height: 1.45; }
.g-lb b { display: block; color: var(--gold); font-size: 12px; margin-bottom: 2px; }
.g-lb ol { list-style: none; margin: 0; padding: 0; }
.g-lb li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #e2e8f0; }
.g-lb li.me { color: var(--cyan); font-weight: 900; }
.g-ctl[data-id='chat'] { background: rgba(10, 12, 30, 0.45); align-items: end; pointer-events: none; }
.g-chat { width: 100%; padding: 6px 10px; font-size: 11px; line-height: 1.5; }
.g-chat b { color: #fff; }
.g-ctl[data-id='minimap'] { background: rgba(10, 12, 30, 0.55); pointer-events: none; }
.g-map { width: 84%; height: 84%; border-radius: 6px; }
.g-ctl[data-id='zoom'] { background: rgba(10, 12, 30, 0.5); flex-direction: column; display: flex; justify-content: space-around; }
.g-zbtn { width: 100%; flex: 1; font-size: 20px; font-weight: 900; color: #fff; }
.game.light .g-ctl[data-id='mass'], .game.light .g-ctl[data-id='leaderboard'], .game.light .g-ctl[data-id='chat'], .game.light .g-ctl[data-id='minimap'], .game.light .g-ctl[data-id='zoom'] { background: rgba(15, 23, 42, 0.62); }
.g-pause { position: absolute; top: calc(var(--pad-t) - 4px); left: calc(var(--pad-l) - 4px); width: 38px; height: 38px; border-radius: 12px; background: rgba(10, 12, 30, 0.6); color: #fff; font-size: 13px; font-weight: 900; pointer-events: auto; border: 1px solid rgba(255, 255, 255, 0.15); }
.g-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(5, 3, 12, 0.55); padding: 10px; }
.g-overlay[hidden] { display: none; }
.g-card { width: min(440px, 94%); max-height: 100%; overflow-y: auto; padding: 16px 18px; border-radius: 22px; text-align: center; background: linear-gradient(160deg, rgba(36, 18, 74, 0.97), rgba(14, 8, 30, 0.97)); border: 1.5px solid rgba(255, 59, 107, 0.5); animation: panel-in 0.2s ease-out; }
.g-card h2 { margin: 2px 0; font-family: 'Baloo Bhaijaan 2', 'Cairo', sans-serif; font-size: 26px; }
.g-card p { margin: 2px 0 8px; color: var(--dim); }
.g-card p b { color: var(--text); }
.g-dead-skin { width: 70px; height: 70px; margin: 0 auto; filter: grayscale(0.4); }
.g-dead-skin svg { width: 100%; height: 100%; }
.g-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 8px; }
.g-stats div { padding: 6px 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); }
.g-stats small { display: block; font-size: 10px; color: var(--dim); }
.g-stats b { font-size: 17px; color: var(--gold); direction: ltr; display: block; }
.g-note { font-size: 11px; }
.g-row { display: flex; gap: 8px; }
.g-row .btn { flex: 1; min-width: 0; }
