:root {
  --txt: #e8ecff;
  --mut: #9aa3c7;
  --stroke: #232a45;
  --accent: #b21f2d;
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: #050204;
  color: var(--txt);
  height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

/* ============================================
   ROTATE OVERLAY — portrait blocker on touch
   ============================================ */
.rotateOverlay {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: #050204;
  color: var(--txt);
  place-items: center;
  font-size: 18px; text-align: center;
}
.rotateContent { padding: 40px; }
.rotateIcon { font-size: 48px; margin-bottom: 16px; }
/* Show on touch devices in portrait */
@media (orientation: portrait) {
  body[data-input="touch"] .rotateOverlay { display: grid; }
}

/* ============================================
   DESKTOP TOPBAR — visible only on desktop
   ============================================ */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(10, 12, 18, 0.85);
  backdrop-filter: blur(10px);
  flex-wrap: wrap; font-size: 11px;
  flex-shrink: 0;
}
body[data-input="touch"] .topbar { display: none; }
.topbarRight { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.metaPill { font-size: 11px; }
.connWrap { display: inline-flex; align-items: center; gap: 6px; }
.brand { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: #22c55e; box-shadow: 0 0 12px rgba(34,197,94,0.7);
  transition: background 0.3s, box-shadow 0.3s;
}
.dot.conn-green { background: #22c55e; box-shadow: 0 0 12px rgba(34,197,94,0.7); }
.dot.conn-yellow { background: #eab308; box-shadow: 0 0 12px rgba(234,179,8,0.7); }
.dot.conn-red { background: #ef4444; box-shadow: 0 0 12px rgba(239,68,68,0.7); }
.title { font-weight: 700; letter-spacing: 0.2px; font-size: 13px; }
.hint { font-size: 12px; color: var(--mut); }

/* ============================================
   LAYOUT CONTAINERS
   ============================================ */
.wrap {
  display: grid; grid-template-columns: 1fr;
  gap: 0; padding: 0; max-width: 100%; margin: 0 auto;
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
body[data-input="touch"] .wrap { min-height: 100vh; }
.card {
  position: relative;
  height: 100%;
  display: flex; flex-direction: column;
  border: 1px solid var(--stroke); border-radius: 0;
  overflow: hidden; background: rgba(18, 22, 36, 0.7);
}
body[data-input="touch"] .card { height: 100vh; border: none; }
.gameViewport { flex: 1 1 auto; position: relative; min-height: 0; }
#c { display: block; width: 100%; height: 100%; background: #070912; image-rendering: auto; }

/* ============================================
   PILLS / BUTTONS (shared)
   ============================================ */
.pill {
  padding: 4px 8px; border: 1px solid var(--stroke); border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.04), rgba(10,12,18,0.85));
  white-space: nowrap; font-size: 11px;
}
.pill span { color: var(--txt); font-weight: 700; font-variant-numeric: tabular-nums; }
.hpPill { min-width: 0; }
.pingPill { font-size: 10px; font-variant-numeric: tabular-nums; transition: color .3s; }
.hpValue { display: inline; }
.pill.pulse { animation: pillPulse 0.6s ease-out; }
.pill.xpGlow {
  box-shadow: 0 0 6px rgba(255,230,80,0.4), 0 0 12px rgba(255,200,60,0.2);
  border-color: rgba(255,220,80,0.5);
  animation: xpPulse 1.2s ease-in-out infinite;
}
@keyframes xpPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255,230,80,0.3), 0 0 12px rgba(255,200,60,0.15); }
  50% { box-shadow: 0 0 10px rgba(255,230,80,0.5), 0 0 18px rgba(255,200,60,0.3); }
}
@keyframes pillPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,210,60,0.6); }
  50% { box-shadow: 0 0 12px 4px rgba(255,210,60,0.4); }
  100% { box-shadow: none; }
}
.btn {
  appearance: none; border: 1px solid #2b3357;
  background: rgba(124, 92, 255, 0.16); color: var(--txt);
  padding: 8px 12px; border-radius: 12px; font-weight: 700; cursor: pointer;
}
.btn:hover { background: rgba(124, 92, 255, 0.22); }
.btn:active { transform: translateY(1px); }
.hudBtn { padding: 4px 8px; font-size: 11px; }
.hudMetaBtn { padding: 4px 8px; font-size: 11px; }

/* ============================================
   MODALS
   ============================================ */
.modal {
  position: fixed; inset: 0; display: none; place-items: center;
  background: rgba(0,0,0,0.55); z-index: 50; padding: 14px;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.modal.show { display: grid; }
.modalBox {
  width: min(400px, 92vw); max-height: 90vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch; border-radius: 18px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(18,22,36,0.95), rgba(12,16,28,0.95));
  padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modalBox::-webkit-scrollbar { display: none; }
.modalBox h2 { margin: 0 0 10px; font-size: 20px; }
.authLabel { font-size: 13px; font-weight: 700; color: var(--txt); display: block; margin-bottom: 4px; }
.authInput {
  width: 100%; padding: 10px 12px; border-radius: 12px;
  border: 1px solid #2b3357; background: rgba(10,12,18,0.6);
  color: var(--txt); font-size: 16px; margin-bottom: 12px;
}
.authError { color: #ff6b6b; font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.authError:not(:empty) { padding: 8px 10px; background: rgba(255,80,80,0.15); border-radius: 8px; border: 1px solid rgba(255,100,100,0.4); }
.authSubmit { width: 100%; margin-top: 8px; }

/* ============================================
   LEADERBOARD - Premium UI
   ============================================ */
.lbModalBox {
  max-width: 480px; padding: 0 !important; overflow: hidden;
  background: linear-gradient(180deg, rgba(16,20,38,0.97), rgba(10,13,24,0.97)) !important;
  border: 1px solid rgba(124,92,255,0.25) !important;
}
.lbHeader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid rgba(124,92,255,0.12);
  background: linear-gradient(90deg, rgba(124,92,255,0.08), transparent);
}
.lbTitleRow { display: flex; align-items: center; gap: 8px; }
.lbTrophy { font-size: 22px; }
.lbTitle { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: 0.3px; }
.lbCloseX {
  appearance: none; border: none; background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5); font-size: 22px; width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.lbCloseX:hover { background: rgba(255,80,80,0.2); color: #ff6b6b; }
.lbTabs {
  display: flex; gap: 0; padding: 0; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  border-bottom: 1px solid rgba(124,92,255,0.1);
}
.lbTabs::-webkit-scrollbar { display: none; }
.lbTab {
  appearance: none; border: none; background: transparent;
  color: rgba(200,210,255,0.5); font-size: 12px; font-weight: 700;
  padding: 10px 14px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: all 0.2s;
  flex: 1; text-align: center; min-width: 0;
}
.lbTab::before { content: attr(data-icon); margin-right: 4px; font-size: 13px; }
.lbTab:hover { color: rgba(200,210,255,0.8); background: rgba(124,92,255,0.05); }
.lbTab.active {
  color: #c4b5fd; border-bottom-color: #7c5cff;
  background: linear-gradient(180deg, rgba(124,92,255,0.1), transparent);
}
.lbList {
  max-height: 340px; overflow-y: auto; padding: 4px 0;
  scrollbar-width: thin; scrollbar-color: rgba(124,92,255,0.3) transparent;
}
.lbList::-webkit-scrollbar { width: 4px; }
.lbList::-webkit-scrollbar-thumb { background: rgba(124,92,255,0.3); border-radius: 4px; }
.lbRow {
  display: flex; align-items: center; padding: 8px 16px; gap: 10px;
  transition: background 0.15s; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.lbRow:hover { background: rgba(124,92,255,0.06); }
.lbRank {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 800; font-size: 12px; flex-shrink: 0;
  background: rgba(255,255,255,0.04); color: rgba(200,210,255,0.5);
}
.lbRow.top1 .lbRank { background: linear-gradient(135deg, #ffd700, #ffaa00); color: #1a1200; font-size: 14px; box-shadow: 0 0 12px rgba(255,215,0,0.3); }
.lbRow.top2 .lbRank { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); color: #1a1a1a; }
.lbRow.top3 .lbRank { background: linear-gradient(135deg, #cd7f32, #b06820); color: #1a1200; }
.lbName {
  flex: 1; font-size: 13px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; color: rgba(220,225,255,0.9);
}
.lbRow.top1 .lbName { color: #ffd700; }
.lbRow.top2 .lbName { color: #dcdcdc; }
.lbRow.top3 .lbName { color: #cd9b5a; }
.lbScore {
  font-size: 13px; font-weight: 700; color: rgba(200,210,255,0.7);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.lbRow.top1 .lbScore { color: #ffd700; }
.lbRow.top2 .lbScore { color: #dcdcdc; }
.lbRow.top3 .lbScore { color: #cd9b5a; }
.lbLoading { padding: 40px; text-align: center; color: rgba(200,210,255,0.4); font-size: 13px; }
.lbEmpty { padding: 40px; text-align: center; color: rgba(200,210,255,0.35); font-size: 13px; }
.lbRowHdr {
  display: flex; align-items: center; padding: 6px 16px; gap: 10px;
  font-size: 10px; font-weight: 700; color: rgba(200,210,255,0.3);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(124,92,255,0.08);
}
.lbRowHdr span:first-child { width: 28px; text-align: center; }
.lbRowHdr span:nth-child(2) { flex: 1; }
.lbRowHdr span:last-child { text-align: right; }

/* Leaderboard mobile touch overrides */
body[data-input="touch"] .lbModalBox { max-width: 96vw; }
body[data-input="touch"] .lbHeader { padding: 12px 14px 8px; }
body[data-input="touch"] .lbTrophy { font-size: 18px; }
body[data-input="touch"] .lbTitle { font-size: 15px; }
body[data-input="touch"] .lbTab { padding: 8px 8px; font-size: 11px; }
body[data-input="touch"] .lbTab::before { font-size: 11px; }
body[data-input="touch"] .lbList { max-height: 50vh; }
body[data-input="touch"] .lbRow { padding: 6px 12px; gap: 8px; }
body[data-input="touch"] .lbRank { width: 24px; height: 24px; font-size: 11px; border-radius: 6px; }
body[data-input="touch"] .lbRow.top1 .lbRank { font-size: 12px; }
body[data-input="touch"] .lbName { font-size: 12px; }
body[data-input="touch"] .lbScore { font-size: 12px; }
body[data-input="touch"] .lbRowHdr { padding: 4px 12px; font-size: 9px; }

.joinBox .hint { margin-bottom: 14px; }
.joinModalBox { width: min(420px, 92vw); }
.joinDesc { margin: 0 0 16px; line-height: 1.4; }
.joinFormRow { margin-bottom: 14px; }
.joinFormRow .authLabel { margin-bottom: 6px; }
.joinFormRow .authInput { margin-bottom: 0; }
.joinStatusText { min-height: 22px; margin-bottom: 10px; }
.joinFooter { margin-top: 16px; margin-bottom: 0; }

/* Login Overlay — fullscreen popup, shown only when not logged in */
.loginOverlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; justify-content: center; align-items: center;
  background: radial-gradient(ellipse at center, rgba(12,16,30,.98), rgba(4,6,14,.99));
}
.loginOverlay.hidden { display: none; }
.loginBox {
  width: min(400px, 90vw);
  border-radius: 20px; border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(20,24,44,.97), rgba(12,16,28,.97));
  padding: 36px 30px; box-shadow: 0 24px 80px rgba(0,0,0,.7);
  text-align: center;
}
.loginTitle { margin: 0 0 6px; font-size: 34px; font-weight: 900; background: linear-gradient(135deg, #a78bfa, #60a5fa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.loginSub { margin: 0 0 28px; color: var(--mut); font-size: 14px; }
.loginFormRow { margin-bottom: 12px; }
.loginFormRow .authInput { width: 100%; box-sizing: border-box; }
.loginBtn { flex: 1; padding: 12px 20px; font-size: 15px; font-weight: 700; }
.loginBtnAlt { opacity: 0.75; }
.loginBtnAlt:hover { opacity: 1; }

/* Start Menu — shown after login */
.startMenu { display: none; width: 100%; max-width: 440px; margin: 0 auto; padding: 30px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.startMenu.show { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.startMenuInner {
  width: 100%;
  border-radius: 20px; border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(18,22,42,.97), rgba(10,14,26,.97));
  padding: 32px 28px; box-shadow: 0 24px 80px rgba(0,0,0,.6);
  text-align: center;
}
.startTitle { margin: 0 0 4px; font-size: 32px; font-weight: 900; background: linear-gradient(135deg, #a78bfa, #60a5fa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.startSub { margin: 0 0 24px; color: var(--mut); font-size: 14px; }
.startSub strong { color: var(--txt); }
.startSection { margin-bottom: 20px; text-align: left; }
.startFormRow { margin-bottom: 10px; }
.startFormRow .authInput { width: 100%; box-sizing: border-box; }
.startButtons { display: flex; flex-direction: column; gap: 10px; }
.startButtonRow { display: flex; gap: 10px; }
.startButtonRow .startBtn { flex: 1; }
.startBtn { padding: 10px 16px; font-size: 14px; }
.startPlayBtn { width: 100%; padding: 14px 20px; font-size: 18px; font-weight: 800; background: linear-gradient(135deg, rgba(100,80,220,.8), rgba(60,100,240,.8)); border: 1px solid rgba(130,110,255,.5); }
.startPlayBtn:hover { background: linear-gradient(135deg, rgba(120,100,240,.9), rgba(80,120,255,.9)); }
.startLogoutBtn { width: 100%; padding: 8px; font-size: 12px; opacity: 0.6; background: rgba(255,80,80,.15); border: 1px solid rgba(255,80,80,.3); }
.startLogoutBtn:hover { opacity: 1; }

/* Legacy lobby (keep for compatibility) */
.lobbyView { display: none; }
.lobbyView.show { display: block; }
.gameCard { display: none; }
.gameCard.show { display: flex; }

/* Choices / Shop / Skin / Hotkey */
.choices { display: grid; gap: 10px; margin-top: 10px; }
.choice { text-align: left; padding: 10px 12px; border-radius: 14px; border: 1px solid #2b3357; background: rgba(10,12,18,.35); cursor: pointer; }
.choice:hover { background: rgba(124,92,255,.12); }
.choice .name { font-weight: 800; color: var(--txt); display: flex; justify-content: space-between; gap: 10px; }
.choice .desc { font-size: 12px; color: var(--mut); margin-top: 4px; line-height: 1.35; }
.inventoryLine { font-size: 13px; color: var(--txt); padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08); background: rgba(10,12,18,.35); }
.choice .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.14); color: #cfd6ff; background: rgba(255,255,255,.06); white-space: nowrap; }
.levelUpSub { margin: 0 0 10px; }
.levelUpSectionTitle { margin: 8px 0 6px; font-weight: 800; }
.rarityBadge { font-size: 10px; padding: 2px 6px; border-radius: 6px; text-transform: uppercase; background: rgba(255,255,255,.1); color: var(--mut); }
.choice.rarity-common { border-left: 3px solid rgba(160, 170, 190, 0.5); }
.choice.rarity-uncommon .rarityBadge { color: #7dffb3; }
.choice.rarity-rare { border-left: 3px solid rgba(80, 140, 255, 0.7); }
.choice.rarity-rare .rarityBadge { color: #65c7ff; }
.choice.rarity-epic { border-left: 3px solid rgba(180, 80, 255, 0.8); background: rgba(120, 60, 180, 0.08); }
.choice.rarity-epic .rarityBadge { color: #ab7aff; }
.choice.rarity-legendary { border-left: 3px solid rgba(255, 190, 40, 0.85); background: rgba(180, 130, 40, 0.08); animation: legendaryChoicePulse 2s ease-in-out infinite; }
.choice.rarity-legendary .rarityBadge { color: #ffbe28; font-weight: 700; }
@keyframes legendaryChoicePulse {
  0%, 100% { background: rgba(180, 130, 40, 0.08); }
  50% { background: rgba(180, 130, 40, 0.14); }
}
.catBadge { font-size: 10px; padding: 2px 6px; border-radius: 6px; color: var(--mut); background: rgba(255,255,255,.06); }
.shopItems { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.shopItem { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px; border-radius: 12px; border: 1px solid var(--stroke); background: rgba(10,12,18,.4); }
.shopItemName { font-weight: 700; color: var(--txt); }
.shopItemMeta { font-size: 12px; color: var(--mut); }
.shopItemBuy { flex-shrink: 0; }
.shopItemBuy:disabled { opacity: 0.6; cursor: not-allowed; }
/* Character grid (replaces old skinGrid) */
/* Character modal needs wider box for 4-column grid */
#skinModal .modalBox { width: min(720px, 94vw); }
.skinGrid, .charGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.charPagination { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 12px; }
.charPageInfo { color: var(--mut); font-size: 13px; }
.charTile { padding: 8px; border-radius: 12px; border: 2px solid var(--stroke); background: rgba(10,12,18,.5); cursor: pointer; text-align: center; font-size: 12px; color: var(--txt); display: flex; flex-direction: column; gap: 2px; align-items: center; min-height: 120px; justify-content: center; overflow: hidden; }
.charTile:hover { background: rgba(124,92,255,.12); border-color: rgba(124,92,255,.4); }
.charTile.selected { border-color: #7dffb3; background: rgba(125,255,179,.10); box-shadow: 0 0 12px rgba(125,255,179,.2); }
.charTile.locked { opacity: .55; cursor: default; }
.charTile.locked:hover { background: rgba(10,12,18,.5); border-color: var(--stroke); }
.charTile.rarity-rare { border-color: rgba(79,164,255,.3); }
.charTile.rarity-epic { border-color: rgba(192,101,255,.3); }
.charTile.rarity-legendary { border-color: rgba(255,184,51,.35); }
.charRarity { font-size: 10px; font-weight: 800; letter-spacing: .5px; }
.charEmoji { font-size: 32px; line-height: 1; }
.charName { font-weight: 700; font-size: 13px; }
.charDesc { font-size: 11px; color: var(--mut); line-height: 1.3; }
.charMods { font-size: 10px; color: #8fa8ff; }
.charShards { font-size: 10px; color: #ffb833; }
.charUpgradeBtn { font-size: 11px; padding: 3px 8px; margin-top: 2px; }
/* Shop roll section */
.shopDivider { padding: 8px 0 4px; font-weight: 800; font-size: 13px; color: var(--txt); border-top: 1px solid var(--stroke); margin-top: 8px; }
.shopRollItem { background: rgba(192,101,255,.08); border: 1px solid rgba(192,101,255,.25); border-radius: 10px; }
.rollBtn { background: linear-gradient(180deg, rgba(192,101,255,.3), rgba(192,101,255,.15)); }
.rollBtn:hover { background: linear-gradient(180deg, rgba(192,101,255,.4), rgba(192,101,255,.2)); }
.rollResult { min-height: 24px; padding: 6px 0; font-size: 13px; text-align: center; color: var(--txt); }
.hotkeySlots { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.hotkeyRow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--stroke); background: rgba(10,12,18,.4); }
.hotkeyRow label { flex: 0 0 70px; font-weight: 700; color: var(--txt); }
.hotkeyRow .hotkeyKey { flex: 1; max-width: 80px; padding: 8px; text-align: center; text-transform: uppercase; font-weight: 700; border-radius: 8px; border: 1px solid #2b3357; background: rgba(10,12,18,.6); color: var(--txt); }
.hotkeyRow .btn { flex-shrink: 0; }

/* ── Settings Modal ── */
.settingsSection { margin-bottom: 16px; }
.settingsSectionTitle { font-size: 13px; color: var(--acc); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.settingsRow { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--stroke); background: rgba(10,12,18,.4); margin-bottom: 6px; }
.settingsLabel { font-weight: 600; color: var(--txt); font-size: 13px; }
.settingsToggleGroup { display: flex; gap: 4px; }
.settingsToggleBtn { padding: 5px 14px; font-size: 12px; border-radius: 8px; transition: background .15s, color .15s; }
.settingsToggleBtn.active { background: var(--acc) !important; color: #fff !important; border-color: var(--acc) !important; }
.settingsHotkeyRow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--stroke); background: rgba(10,12,18,.4); margin-bottom: 5px; }
.settingsHotkeyRow .shLabel { flex: 0 0 80px; font-weight: 600; color: var(--txt); font-size: 12px; }
.settingsHotkeyRow .shKey { flex: 1; max-width: 60px; padding: 6px; text-align: center; text-transform: uppercase; font-weight: 700; font-size: 13px; border-radius: 8px; border: 1px solid #2b3357; background: rgba(10,12,18,.6); color: var(--txt); cursor: pointer; transition: border-color .15s; }
.settingsHotkeyRow .shKey:hover { border-color: var(--acc); }
.settingsHotkeyRow .shKey.capturing { border-color: #fbbf24; color: #fbbf24; animation: capturePulse .8s ease-in-out infinite; }
@keyframes capturePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(251,191,36,.3); } 50% { box-shadow: 0 0 8px 3px rgba(251,191,36,.4); } }

/* ── Death Screen (Kill Cam) ── */
.deathModalOverlay.show { background: radial-gradient(ellipse at center, rgba(60,0,0,.35) 0%, rgba(10,0,0,.55) 100%); animation: deathFadeIn .6s ease-out; pointer-events: auto; }
@keyframes deathFadeIn { from { opacity: 0; } to { opacity: 1; } }
.deathModalContent { max-width: 440px; width: 92%; background: linear-gradient(180deg, rgba(40,8,8,.88) 0%, rgba(15,5,5,.92) 100%); border: 1px solid rgba(255,50,50,.3); border-radius: 16px; padding: 28px 24px 20px; box-shadow: 0 0 60px rgba(255,0,0,.2), 0 0 120px rgba(255,0,0,.08), inset 0 1px 0 rgba(255,255,255,.06); text-align: center; animation: deathSlideUp .5s ease-out; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes deathSlideUp { from { transform: translateY(30px) scale(.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.deathSkullIcon { font-size: 48px; margin-bottom: 4px; filter: drop-shadow(0 0 16px rgba(255,60,60,.6)); animation: skullPulse 2s ease-in-out infinite; }
@keyframes skullPulse { 0%,100% { transform: scale(1); filter: drop-shadow(0 0 16px rgba(255,60,60,.6)); } 50% { transform: scale(1.08); filter: drop-shadow(0 0 24px rgba(255,60,60,.8)); } }
.deathTitle { font-size: 28px; font-weight: 900; color: #ff3333; text-transform: uppercase; letter-spacing: 6px; margin: 0 0 4px; text-shadow: 0 0 20px rgba(255,50,50,.6), 0 2px 4px rgba(0,0,0,.8); }
.deathDivider { width: 60%; height: 2px; margin: 10px auto 14px; background: linear-gradient(90deg, transparent, rgba(255,60,60,.5), transparent); }
.deathRecapBox { margin: 8px 0 12px; padding: 12px 14px; border-radius: 12px; background: rgba(255,30,30,.06); border: 1px solid rgba(255,60,60,.15); text-align: left; }
.deathRecapTitle { font-size: 10px; color: #ff8080; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; font-weight: 700; }
.deathRecapRow { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.04); }
.deathRecapRow:last-child { border-bottom: none; }
.deathRecapRow .drSource { color: #e8d0d0; font-weight: 600; text-transform: capitalize; }
.deathRecapRow .drDmg { color: #ff5555; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.deathRecapTotal { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,80,80,.2); display: flex; justify-content: space-between; font-size: 14px; font-weight: 800; }
.deathRecapTotal .drLabel { color: #ff8080; }
.deathRecapTotal .drVal { color: #ff3333; font-size: 16px; }
.deathRecapXp { margin-top: 6px; font-size: 12px; color: #fbbf24; text-align: center; padding: 4px 8px; background: rgba(251,191,36,.08); border-radius: 6px; }
.deathStatsRow { display: flex; justify-content: center; gap: 16px; margin: 10px 0 6px; font-size: 11px; color: rgba(255,255,255,.5); }
.deathStatsRow span { display: flex; align-items: center; gap: 4px; }
.deathRespawnHint { font-size: 13px; color: rgba(255,255,255,.45); margin-top: 10px; animation: respawnPulse 1.5s ease-in-out infinite; }
@keyframes respawnPulse { 0%,100% { opacity: .45; } 50% { opacity: .8; } }
.deathRunSummary { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.deathRunSummary .deathRunTitle { font-size: 10px; color: #8899bb; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; font-weight: 700; }
.deathRunSummary .deathRunGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.deathRunSummary .deathRunStat { padding: 6px 8px; border-radius: 8px; background: rgba(10,12,18,.4); border: 1px solid rgba(255,255,255,.06); font-size: 12px; color: rgba(255,255,255,.5); }
.deathRunSummary .deathRunStat b { color: var(--txt); font-weight: 700; }
.deathContinueBtn { margin-top: 14px; background: linear-gradient(135deg, #4ade80, #22c55e); border: 1px solid rgba(74,222,128,.4); font-size: 15px; font-weight: 700; padding: 12px 36px; letter-spacing: 1px; text-transform: uppercase; color: #0a0c12; cursor: pointer; border-radius: 10px; transition: transform .15s, box-shadow .15s; display: none; }
.deathContinueBtn:hover { transform: scale(1.04); box-shadow: 0 0 20px rgba(74,222,128,.3); }
.deathContinueBtn.show { display: inline-block; animation: deathBtnAppear .4s ease-out; }
@keyframes deathBtnAppear { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.deathRespawnBtn { margin-top: 12px; background: linear-gradient(135deg, #ff3333, #cc1111); border: 1px solid rgba(255,80,80,.3); font-size: 14px; font-weight: 700; padding: 10px 28px; letter-spacing: 1px; text-transform: uppercase; }

/* ── Friends ── */
.friendsAddRow { display: flex; gap: 6px; margin-bottom: 6px; }
.friendRow { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--stroke); background: rgba(10,12,18,.4); margin-bottom: 4px; }
.friendDot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.friendDot.online { background: #4ade80; box-shadow: 0 0 4px #4ade80; }
.friendDot.offline { background: #555; }
.friendName { flex: 1; font-weight: 600; color: var(--txt); font-size: 12px; }
.friendMeta { font-size: 10px; color: var(--mut); margin-right: 6px; }
.friendBtn { padding: 3px 8px; font-size: 10px; border-radius: 6px; cursor: pointer; border: 1px solid var(--stroke); background: rgba(10,12,18,.4); color: var(--txt); }
.friendBtn:hover { border-color: var(--acc); }
.friendBtn.danger { color: #ff6666; border-color: rgba(255,60,60,.3); }
.friendBtn.accept { color: #4ade80; border-color: rgba(74,222,128,.3); }

.stat { padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,.1); background: rgba(10,12,18,.35); color: var(--mut); font-size: 12px; }
.stat b { color: var(--txt); }

/* Lobby teleport overlay */
.lobbyTpOverlay {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 50; padding: 16px 32px; border-radius: 12px;
  background: rgba(10,12,18,.85); border: 1px solid #3b5998;
  color: #e8ecff; font-size: 1.25rem; font-weight: 700;
  text-align: center; pointer-events: none;
  animation: lobbyTpPulse 1s ease-in-out infinite;
}
@keyframes lobbyTpPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ============================================
   MOBILE CONTROLS OVERLAY
   ============================================ */
.mobileControls {
  display: block; position: absolute; inset: 0;
  pointer-events: none; z-index: 10;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.mobileControls > * { pointer-events: auto; }
.mobileControls .joyWrap, .mobileControls .skillBtns { touch-action: none; }

/* Desktop: hide mobile-only elements */
body[data-input="desktop"] .joyWrap { display: none; }
body[data-input="desktop"] .mHudStrip { display: none; }
body[data-input="desktop"] .mMenuBtn { display: none; }
body[data-input="desktop"] .mChatBtn { display: none; }
body[data-input="desktop"] .mChatPopup { display: none !important; }
body[data-input="desktop"] .mMenuDrawer { display: none !important; }
body:not([data-touch-capable]) .mobileTalkBtn { display: none !important; }
body:not([data-touch-capable]) .mobileInvBtn { display: none !important; }
/* Desktop: show desktop chat panel */
body[data-input="desktop"] .chatPanelDesktop { display: flex; }
body[data-input="touch"] .chatPanelDesktop { display: none; }

/* ============================================
   MOBILE HUD STRIP — top-left, minimal
   ============================================ */
.mHudStrip {
  position: absolute;
  top: 6px; left: calc(6px + var(--safe-left));
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(6, 8, 16, 0.7);
  border-radius: 10px;
  border: 1px solid rgba(40, 50, 80, 0.5);
  font-size: 11px; font-weight: 600;
  color: var(--txt);
  pointer-events: none;
  z-index: 12;
}
.mDot { width: 8px; height: 8px; flex-shrink: 0; }
.mHudItem { white-space: nowrap; }

/* ============================================
   MINIMAP — top-right corner, compact
   ============================================ */
.minimap {
  position: absolute;
  top: 6px; right: calc(6px + var(--safe-right));
  width: 100px; height: 100px;
  border-radius: 10px;
  border: 1px solid rgba(40, 50, 80, 0.6);
  background: rgba(6, 8, 16, 0.7);
  pointer-events: none; z-index: 11;
}
/* Desktop: larger minimap */
body[data-input="desktop"] .minimap {
  width: 160px; height: 160px; top: 8px; left: 8px; right: auto;
}

/* ============================================
   UTILITY BUTTONS — right side column under minimap
   ============================================ */
.mMenuBtn, .mChatBtn {
  position: absolute;
  right: calc(6px + var(--safe-right));
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(40, 50, 80, 0.7);
  background: rgba(10, 12, 18, 0.8);
  color: var(--txt); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 12;
}
.mMenuBtn { top: 112px; }
.mChatBtn { top: 154px; }

.mobileInvBtn {
  position: absolute;
  right: calc(48px + var(--safe-right));
  top: 112px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(40, 50, 80, 0.7);
  background: rgba(10, 12, 18, 0.8);
  color: var(--txt); font-size: 11px; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 12;
}
body[data-input="desktop"] .mobileInvBtn { top: 8px; right: 8px; }

.mobileTalkBtn {
  position: absolute;
  right: calc(48px + var(--safe-right));
  top: 148px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(100, 200, 255, 0.6);
  background: rgba(30, 70, 120, 0.7);
  color: var(--txt); font-size: 11px; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 12;
}
.mobileTalkBtn:active { background: rgba(100, 200, 255, 0.4); }

/* ============================================
   JOYSTICK — bottom-left, large for thumb
   ============================================ */
.joyWrap {
  position: absolute;
  left: calc(16px + var(--safe-left));
  bottom: calc(20px + var(--safe-bottom));
  width: 120px; height: 120px;
  touch-action: none;
}
body[data-input="touch"] .joyWrap {
  width: 110px; height: 110px;
  left: calc(14px + var(--safe-left));
  bottom: calc(16px + var(--safe-bottom));
}
.joyBase {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.08), rgba(0,0,0,.25));
  border: 2px solid rgba(124, 92, 255, 0.4);
}
.joyStick {
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 46px; margin-left: -23px; margin-top: -23px;
  border-radius: 50%;
  background: rgba(124, 92, 255, 0.5);
  border: 2px solid rgba(180, 160, 255, 0.7);
  transform: translate(0, 0);
  transition: transform 0.05s ease-out;
}
body[data-input="touch"] .joyStick {
  width: 42px; height: 42px; margin-left: -21px; margin-top: -21px;
}

/* ============================================
   SKILL BUTTONS — bottom-right, 2x2 + auto row
   ============================================ */
.skillBtns {
  position: absolute;
  right: calc(14px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 8px;
  touch-action: none;
}
.mobileSkillBtn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(40, 50, 80, 0.8);
  background: radial-gradient(circle at 30% 20%, rgba(80, 90, 130, 0.45), rgba(10, 12, 18, 0.92));
  color: var(--txt); font-size: 10px; font-weight: 600;
  cursor: pointer; touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  position: relative; overflow: hidden;
}
.mobileSkillBtn:active { background: rgba(124, 92, 255, 0.4); }
.mobileSkillBtn .skillLabel { font-size: 8px; color: rgba(220, 230, 255, 0.7); }
.mobileSkillBtn .skillKey { font-size: 11px; font-weight: 700; color: rgba(230, 240, 255, 0.9); }
.autoBtn .skillLabel { font-size: 8px; }
.autoBtn .skillKey { font-size: 9px; }
.autoBtn[aria-pressed="true"] {
  border-color: rgba(69, 247, 161, 0.7);
  background: radial-gradient(circle at 30% 20%, rgba(90, 210, 170, 0.6), rgba(8, 18, 18, 0.92));
}

/* Desktop: larger skill buttons */
body[data-input="desktop"] .skillBtns { gap: 10px; right: 20px; bottom: 24px; }
body[data-input="desktop"] .mobileSkillBtn { width: 76px; height: 76px; font-size: 11px; }
body[data-input="desktop"] .mobileSkillBtn .skillLabel { font-size: 10px; }
body[data-input="desktop"] .mobileSkillBtn .skillKey { font-size: 13px; }

/* Skill cooldown overlay */
.mobileSkillBtn .cooldownMask {
  position: absolute; inset: 2px;
  pointer-events: none; z-index: 1;
  border-radius: 50%;
  background: rgba(4,6,12,0.75);
  clip-path: none;
}
.mobileSkillBtn .cooldownTime {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8); z-index: 2;
}
body[data-input="desktop"] .mobileSkillBtn .cooldownTime { font-size: 18px; }
.mobileSkillBtn.cooling {
  filter: saturate(0.7);
  border-color: rgba(60,60,80,0.6);
}
.mobileSkillBtn.ready {
  box-shadow: 0 0 14px rgba(69,247,161,0.35), 0 4px 12px rgba(0,0,0,0.5);
  animation: skillReady 0.4s ease-out;
}
@keyframes skillReady {
  0% { transform: scale(1.15); box-shadow: 0 0 24px rgba(69,247,161,0.6); }
  100% { transform: scale(1); }
}
/* ─── Skill rarity visual indicators ─── */
.mobileSkillBtn.rarity-common { border-color: rgba(160, 170, 190, 0.7); }
.mobileSkillBtn.rarity-common.ready { box-shadow: 0 0 10px rgba(160, 170, 190, 0.3), 0 4px 12px rgba(0,0,0,0.5); }
.mobileSkillBtn.rarity-rare { border-color: rgba(80, 140, 255, 0.8); background: radial-gradient(circle at 30% 20%, rgba(60, 80, 160, 0.5), rgba(10, 12, 18, 0.92)); }
.mobileSkillBtn.rarity-rare.ready { box-shadow: 0 0 14px rgba(80, 140, 255, 0.4), 0 4px 12px rgba(0,0,0,0.5); }
.mobileSkillBtn.rarity-epic { border-color: rgba(180, 80, 255, 0.85); background: radial-gradient(circle at 30% 20%, rgba(120, 60, 180, 0.5), rgba(15, 8, 22, 0.92)); }
.mobileSkillBtn.rarity-epic.ready { box-shadow: 0 0 16px rgba(180, 80, 255, 0.45), 0 4px 12px rgba(0,0,0,0.5); }
.mobileSkillBtn.rarity-legendary { border-color: rgba(255, 190, 40, 0.9); background: radial-gradient(circle at 30% 20%, rgba(180, 130, 40, 0.55), rgba(20, 14, 4, 0.92)); }
.mobileSkillBtn.rarity-legendary.ready { box-shadow: 0 0 18px rgba(255, 190, 40, 0.5), 0 4px 12px rgba(0,0,0,0.5); animation: skillReadyLegendary 1.5s ease-in-out infinite; }
@keyframes skillReadyLegendary {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 190, 40, 0.5), 0 4px 12px rgba(0,0,0,0.5); }
  50% { box-shadow: 0 0 28px rgba(255, 210, 60, 0.7), 0 4px 16px rgba(0,0,0,0.5); }
}
.mobileSkillBtn .rarityDot {
  position: absolute; top: 3px; right: 3px;
  width: 6px; height: 6px; border-radius: 50%;
  z-index: 3;
}
.rarity-rare .rarityDot { background: #508cff; }
.rarity-epic .rarityDot { background: #b450ff; }
.rarity-legendary .rarityDot { background: #ffbe28; }

/* ============================================
   MENU DRAWER — expandable utility panel
   ============================================ */
.mMenuDrawer {
  position: absolute;
  top: 50%; right: calc(48px + var(--safe-right));
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: rgba(10, 12, 18, 0.92);
  border-radius: 12px;
  border: 1px solid rgba(40, 50, 80, 0.7);
  z-index: 20;
}
.mDrawerBtn {
  padding: 8px 16px; font-size: 13px;
  white-space: nowrap; min-width: 90px;
}
.mDrawerClose {
  background: rgba(255, 60, 60, 0.2);
  border-color: rgba(255, 80, 80, 0.4);
}

/* ============================================
   CHAT — collapsible popup on mobile, panel on desktop
   ============================================ */
/* Desktop chat panel */
.chatPanelDesktop {
  position: absolute;
  bottom: 10px; left: 10px;
  width: 320px; max-height: 220px;
  display: none; flex-direction: column;
  z-index: 15;
  background: rgba(8, 10, 20, 0.88);
  border-radius: 12px;
  border: 1px solid rgba(50, 65, 110, 0.45);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(80, 100, 160, 0.08);
  overflow: hidden;
}

/* Gameplay ad placeholder slots */
.adSlot {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 24, 0.95);
  color: rgba(120, 140, 180, 0.6);
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 600;
  border: 1px dashed rgba(60, 80, 120, 0.3);
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
  overflow: hidden;
  box-sizing: border-box;
  /* Desktop: 728x90 leaderboard */
  height: 90px;
  min-height: 90px;
  max-height: 90px;
}
/* Mobile: 320x100 large mobile banner */
body[data-input="touch"] .adSlot {
  height: 100px;
  min-height: 50px;
  max-height: 100px;
}
/* Very small screens: 320x50 */
@media (max-height: 500px) {
  .adSlot {
    height: 50px;
    min-height: 50px;
    max-height: 50px;
  }
}
.adContent {
  width: 728px;
  height: 90px;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
body[data-input="touch"] .adContent {
  width: 320px;
  height: 100px;
}
@media (max-height: 500px) {
  .adContent {
    height: 50px;
  }
}
.adPlaceholderText {
  color: rgba(120, 140, 180, 0.4);
  font-size: 12px;
  letter-spacing: 1px;
}
.adSlotTop { border-bottom: 1px solid rgba(40, 50, 80, 0.4); }
.adSlotBottom { border-top: 1px solid rgba(40, 50, 80, 0.4); }
.adSlotLobby { border-bottom: 1px solid rgba(40, 50, 80, 0.4); }
.adSlotLobby.hidden { display: none; }

/* Interstitial Ad Overlay */
.interstitialOverlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.interstitialBox {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 20px; max-width: 380px; width: 90%;
  text-align: center;
}
.interstitialHeader {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.interstitialTimer {
  font-size: 13px; color: #ff8080; font-weight: 700;
  background: rgba(255,60,60,.12); padding: 4px 12px; border-radius: 999px;
}
.interstitialSkip {
  font-size: 12px; font-weight: 700; color: var(--txt);
  background: rgba(124,92,255,.2); border: 1px solid rgba(124,92,255,.4);
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
  transition: background .15s;
}
.interstitialSkip:hover { background: rgba(124,92,255,.35); }
.interstitialContent {
  width: 100%; min-height: 200px;
  background: rgba(10,12,18,.5); border: 1px dashed rgba(255,255,255,.12);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.interstitialHint {
  font-size: 11px; color: var(--mut); margin: 0;
}

/* Quest UI buttons */
.lobbyQuestRow .lobbyBtn {
  font-size: 13px;
  padding: 8px 18px;
  background: rgba(30, 40, 70, 0.8);
  border: 1px solid rgba(80, 100, 160, 0.4);
}
.lobbyQuestRow .lobbyBtn:hover {
  background: rgba(50, 65, 110, 0.9);
  border-color: rgba(100, 130, 200, 0.6);
}

/* Mobile team emote button */
.mTeamEmoteBtn {
  position: absolute; top: calc(6px + var(--safe-top)); right: calc(190px + var(--safe-right));
  background: rgba(6,8,16,.8); border: 1px solid rgba(40,50,80,.6); border-radius: 8px;
  color: var(--txt); font-size: 16px; padding: 4px 8px; cursor: pointer; z-index: 10;
  touch-action: manipulation;
}
.teamEmotePopup {
  position: absolute; top: calc(36px + var(--safe-top)); right: calc(140px + var(--safe-right));
  background: rgba(6,8,16,.95); border: 1px solid rgba(40,50,80,.7); border-radius: 10px;
  z-index: 22; display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; max-width: 220px;
}
.teamEmoteItem {
  background: rgba(40,50,80,.4); border: 1px solid rgba(60,80,120,.4); border-radius: 6px;
  color: var(--txt); font-size: 12px; padding: 4px 8px; cursor: pointer; touch-action: manipulation;
}
.teamEmoteItem:active { background: rgba(80,100,160,.5); }

/* Mobile chat popup */
.mChatPopup {
  position: absolute;
  bottom: calc(60px + var(--safe-bottom));
  left: calc(140px + var(--safe-left));
  right: calc(140px + var(--safe-right));
  max-height: 220px; min-width: 220px;
  display: flex; flex-direction: column;
  background: rgba(8, 10, 20, 0.92);
  border-radius: 12px;
  border: 1px solid rgba(50, 65, 110, 0.45);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(80, 100, 160, 0.08);
  z-index: 20;
  overflow: hidden;
}
/* On very small landscape screens, expand chat more */
@media (max-width: 700px) {
  .mChatPopup {
    left: calc(100px + var(--safe-left));
    right: calc(100px + var(--safe-right));
  }
}
/* Chat stays anchored at bottom; shrink max-height when keyboard likely open */
.mChatCloseBtn {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 6px; border: 1px solid rgba(255, 80, 80, 0.25);
  background: rgba(255, 60, 60, 0.15);
  color: rgba(255, 120, 120, 0.8); font-size: 11px;
  cursor: pointer; z-index: 1;
  display: flex; align-items: center; justify-content: center;
}

/* Shared chat styles */
.chatLog {
  flex: 1 1 auto; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(50, 65, 110, 0.25);
  font-size: 12px; color: var(--txt); line-height: 1.55;
  max-height: 140px;
  min-height: 50px;
  scrollbar-width: thin;
  scrollbar-color: rgba(60,70,110,.4) transparent;
}
.chatLog::-webkit-scrollbar { width: 4px; }
.chatLog::-webkit-scrollbar-track { background: transparent; }
.chatLog::-webkit-scrollbar-thumb { background: rgba(60,70,110,.4); border-radius: 2px; }
.chatLog::-webkit-scrollbar-thumb:hover { background: rgba(80,95,140,.6); }
.chatLog:empty::before {
  content: 'No messages yet.';
  color: rgba(120, 130, 160, 0.5); font-style: italic; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  height: 40px;
}
.chatMsg { margin-bottom: 4px; word-break: break-word; padding: 2px 0; }
.chatMsg .chatSender { font-weight: 600; color: #7daaff; margin-right: 2px; }
.chatMsg .chatTime { color: rgba(120,130,160,.55); font-size: 9px; margin-left: 6px; }
.chatMsg.chatSystem { color: var(--mut); font-style: italic; font-size: 11px; }
.chatInputRow {
  display: flex; gap: 0; align-items: stretch;
  padding: 8px 8px;
}
.chatChannelBtn {
  padding: 7px 10px; font-size: 10px; font-weight: 700;
  border-radius: 8px 0 0 8px;
  border: 1px solid rgba(50, 65, 110, 0.45);
  border-right: none;
  background: rgba(20, 28, 50, 0.7); color: #8ea3ff;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.chatChannelBtn:hover { background: rgba(30, 40, 70, 0.8); }
.chatChannelBtn.team { background: rgba(6,182,212,.12); color: #06b6d4; border-color: rgba(6,182,212,.35); }
.chatInput {
  flex: 1; padding: 7px 12px;
  border-radius: 0;
  border: 1px solid rgba(50, 65, 110, 0.45);
  border-left: none; border-right: none;
  background: rgba(12, 15, 25, 0.6);
  color: var(--txt); font-size: 13px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.chatInput::placeholder { color: rgba(120, 130, 160, 0.45); font-size: 12px; }
.chatInput:focus { background: rgba(15, 18, 30, 0.75); border-color: rgba(100, 140, 255, 0.4); }
.chatInput, .chatSendBtn, .chatChannelBtn { touch-action: manipulation; }
.chatSendBtn {
  padding: 7px 14px; font-size: 11px; font-weight: 600;
  border-radius: 0 8px 8px 0;
  border: 1px solid rgba(50, 65, 110, 0.45);
  border-left: none;
  background: rgba(60, 90, 180, 0.25); color: #8ea3ff;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.chatSendBtn:hover { background: rgba(60, 90, 180, 0.4); color: #aac4ff; }

/* ============================================
   MOBILE RESPONSIVE — phones (landscape)
   Typical phone landscape: 640-900w x 300-450h
   ============================================ */

/* ── TOUCH DEVICES: Global compact overrides ── */
body[data-input="touch"] .loginOverlay {
  align-items: center;
  padding: 8px;
}
body[data-input="touch"] .loginBox {
  padding: 14px 18px;
  border-radius: 14px;
  max-height: 95vh;
  overflow-y: auto;
}
body[data-input="touch"] .loginTitle { font-size: 20px; margin-bottom: 2px; }
body[data-input="touch"] .loginSub { font-size: 10px; margin-bottom: 10px; }
body[data-input="touch"] .loginFormRow { margin-bottom: 5px; }
body[data-input="touch"] .loginFormRow .authInput {
  padding: 6px 10px; font-size: 14px; margin-bottom: 2px; border-radius: 8px;
}
body[data-input="touch"] .loginBtn { padding: 8px 14px; font-size: 13px; }

/* ── Start menu: center & compact on touch ── */
body[data-input="touch"] .startMenu {
  max-width: 380px;
  padding: 6px 10px;
}
body[data-input="touch"] .startMenu.show {
  min-height: auto;
  align-items: center;
  justify-content: center;
}
body[data-input="touch"] .startMenuInner {
  padding: 12px 16px;
  border-radius: 14px;
}
body[data-input="touch"] .startTitle { font-size: 18px; margin-bottom: 1px; }
body[data-input="touch"] .startSub { font-size: 10px; margin-bottom: 8px; }
body[data-input="touch"] .startSection { margin-bottom: 6px; }
body[data-input="touch"] .startFormRow { margin-bottom: 4px; }
body[data-input="touch"] .startFormRow .authInput {
  padding: 5px 10px; font-size: 13px; border-radius: 8px;
}
body[data-input="touch"] .startPlayBtn { padding: 8px 12px; font-size: 14px; }
body[data-input="touch"] .startBtn { padding: 5px 8px; font-size: 11px; }
body[data-input="touch"] .startLogoutBtn { padding: 4px; font-size: 9px; }
body[data-input="touch"] .startButtons { gap: 5px; }
body[data-input="touch"] .startButtonRow { gap: 5px; }

/* ── Gameplay: Ad slots much smaller on touch ── */
body[data-input="touch"] .adSlot {
  height: 40px;
  min-height: 32px;
  max-height: 40px;
}
body[data-input="touch"] .adContent {
  width: 320px;
  height: 40px;
}
body[data-input="touch"] .adPlaceholderText { font-size: 9px; }

/* ── Joystick: smaller on touch ── */
body[data-input="touch"] .joyWrap {
  width: 80px; height: 80px;
  left: calc(10px + var(--safe-left));
  bottom: calc(10px + var(--safe-bottom));
}
body[data-input="touch"] .joyStick {
  width: 32px; height: 32px;
  margin-left: -16px; margin-top: -16px;
}
body[data-input="touch"] .joyBase {
  border-width: 1.5px;
}

/* ── Skill buttons: compact on touch ── */
body[data-input="touch"] .skillBtns {
  gap: 5px;
  right: calc(8px + var(--safe-right));
  bottom: calc(8px + var(--safe-bottom));
}
body[data-input="touch"] .mobileSkillBtn {
  width: 40px; height: 40px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
body[data-input="touch"] .mobileSkillBtn .skillLabel { font-size: 6px; }
body[data-input="touch"] .mobileSkillBtn .skillKey { font-size: 9px; }
body[data-input="touch"] .autoBtn .skillKey { font-size: 7px; }

/* ── HUD strip: compact ── */
body[data-input="touch"] .mHudStrip {
  font-size: 9px;
  padding: 2px 8px;
  gap: 5px;
  top: 4px;
  left: calc(4px + var(--safe-left));
  border-radius: 8px;
}
body[data-input="touch"] .mDot { width: 6px; height: 6px; }

/* ── Minimap: bigger on mobile ── */
body[data-input="touch"] .minimap {
  width: 100px; height: 100px;
  top: 4px; right: calc(4px + var(--safe-right));
  border-radius: 10px;
}

/* ── Menu, Chat, Bag, Talk buttons: big touch targets ── */
body[data-input="touch"] .mMenuBtn,
body[data-input="touch"] .mChatBtn {
  width: 42px; height: 42px;
  font-size: 17px;
  border-radius: 10px;
  right: calc(4px + var(--safe-right));
}
body[data-input="touch"] .mMenuBtn { top: 110px; }
body[data-input="touch"] .mChatBtn { top: 158px; }

body[data-input="touch"] .mobileInvBtn {
  right: calc(50px + var(--safe-right));
  top: 110px;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 10px;
}
body[data-input="touch"] .mobileTalkBtn {
  right: calc(50px + var(--safe-right));
  top: 158px;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 10px;
}

/* ── Menu drawer: compact ── */
body[data-input="touch"] .mMenuDrawer {
  right: calc(36px + var(--safe-right));
  padding: 6px;
  gap: 4px;
}
body[data-input="touch"] .mDrawerBtn {
  padding: 5px 10px;
  font-size: 11px;
  min-width: 70px;
}

/* ── Chat popup: compact ── */
body[data-input="touch"] .mChatPopup {
  bottom: calc(50px + var(--safe-bottom));
  left: calc(100px + var(--safe-left));
  right: calc(100px + var(--safe-right));
  max-height: 140px;
}
body[data-input="touch"] .chatLog { max-height: 80px; font-size: 10px; padding: 8px 10px; }
body[data-input="touch"] .chatInput { font-size: 11px; padding: 6px 10px; }
body[data-input="touch"] .chatSendBtn { padding: 6px 10px; font-size: 9px; }
body[data-input="touch"] .chatChannelBtn { padding: 6px 8px; font-size: 9px; }
body[data-input="touch"] .chatInputRow { padding: 6px 6px; }

/* ── Modals on touch: compact ── */
body[data-input="touch"] .modal { padding: 4px; }
body[data-input="touch"] .modalBox {
  padding: 10px 12px;
  border-radius: 12px;
  max-height: 88vh;
}
body[data-input="touch"] .modalBox h2 { font-size: 15px; margin-bottom: 5px; }

/* Shop compact */
body[data-input="touch"] .shopItems { gap: 5px; margin: 5px 0; }
body[data-input="touch"] .shopItem { padding: 6px 8px; gap: 6px; border-radius: 8px; }
body[data-input="touch"] .shopItemName { font-size: 12px; }
body[data-input="touch"] .shopItemMeta { font-size: 9px; }
body[data-input="touch"] .shopItemBuy { padding: 4px 8px; font-size: 10px; }
body[data-input="touch"] .shopDivider { padding: 3px 0 1px; font-size: 10px; margin-top: 3px; }
body[data-input="touch"] .shopRollItem { padding: 6px 8px; }
body[data-input="touch"] .rollBtn { padding: 4px 8px; font-size: 10px; }
body[data-input="touch"] .rollResult { font-size: 10px; padding: 3px 0; }

/* Choices compact */
body[data-input="touch"] .choices { gap: 5px; margin-top: 5px; }
body[data-input="touch"] .choice { padding: 5px 8px; border-radius: 8px; }
body[data-input="touch"] .choice .name { font-size: 12px; }
body[data-input="touch"] .choice .desc { font-size: 9px; }

/* Hotkeys: hide entirely on touch devices (skills use on-screen buttons) */
body[data-input="touch"] #hotkeyModal { display: none !important; }
body[data-input="touch"] #btnHotkeys,
body[data-input="touch"] #mBtnHotkeys,
body[data-input="touch"] [data-action="hotkeys"] { display: none !important; }

/* Lobby teleport overlay */
body[data-input="touch"] .lobbyTpOverlay { padding: 8px 16px; font-size: 0.9rem; }

/* Inventory line */
body[data-input="touch"] .inventoryLine { font-size: 10px; padding: 5px 7px; }

/* ── Character grid on touch: responsive columns ── */
body[data-input="touch"] .skinGrid,
body[data-input="touch"] .charGrid {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
body[data-input="touch"] #skinModal .modalBox { width: min(520px, 94vw); }
body[data-input="touch"] .charTile {
  min-height: 70px; padding: 4px; border-radius: 8px;
}
body[data-input="touch"] .charEmoji { font-size: 20px; }
body[data-input="touch"] .charName { font-size: 10px; }
body[data-input="touch"] .charDesc { font-size: 8px; line-height: 1.2; }
body[data-input="touch"] .charMods { font-size: 8px; }
body[data-input="touch"] .charRarity { font-size: 7px; }
body[data-input="touch"] .charPagination { margin-top: 5px; }
body[data-input="touch"] .charPagination .btn { padding: 3px 8px; font-size: 10px; }

/* Team emote */
body[data-input="touch"] .mTeamEmoteBtn { font-size: 13px; padding: 2px 6px; }

/* ── Extra compact for very small height (< 340px, e.g. old iPhones) ── */
@media (max-height: 340px) {
  body[data-input="touch"] .adSlot { height: 28px; min-height: 28px; max-height: 28px; }
  body[data-input="touch"] .adContent { height: 28px; }
  body[data-input="touch"] .joyWrap { width: 64px; height: 64px; }
  body[data-input="touch"] .joyStick { width: 26px; height: 26px; margin-left: -13px; margin-top: -13px; }
  body[data-input="touch"] .mobileSkillBtn { width: 34px; height: 34px; }
  body[data-input="touch"] .mobileSkillBtn .skillLabel { font-size: 5px; }
  body[data-input="touch"] .mobileSkillBtn .skillKey { font-size: 8px; }
  body[data-input="touch"] .minimap { width: 72px; height: 72px; }
  body[data-input="touch"] .mMenuBtn { top: 80px; width: 34px; height: 34px; }
  body[data-input="touch"] .mChatBtn { top: 118px; width: 34px; height: 34px; }
  body[data-input="touch"] .mobileInvBtn { top: 80px; }
  body[data-input="touch"] .mobileTalkBtn { top: 118px; }
}

/* ── Narrow width: 2-col character grid ── */
@media (max-width: 560px) {
  body[data-input="touch"] .skinGrid,
  body[data-input="touch"] .charGrid { grid-template-columns: repeat(2, 1fr); }
  body[data-input="touch"] #skinModal .modalBox { width: min(360px, 94vw); }
}

/* ── Very narrow screens (portrait phones that bypass blocker) ── */
@media (max-width: 480px) {
  .loginBox { width: min(340px, 95vw); padding: 16px 14px; }
  .loginTitle { font-size: 22px; }
  .startMenuInner { padding: 14px 12px; }
  .startTitle { font-size: 20px; }
  .modalBox { width: min(340px, 95vw); padding: 12px; }
  #skinModal .modalBox { width: min(340px, 95vw); }
  .skinGrid, .charGrid { grid-template-columns: repeat(2, 1fr); }
}
