:root {
  --bg-deep: #060913;
  --bg-panel: rgba(11, 17, 34, 0.9);
  --bg-card: rgba(16, 25, 48, 0.92);
  --border: rgba(82, 229, 255, 0.24);
  --border-strong: rgba(56, 242, 255, 0.55);
  --text-main: #edf4ff;
  --text-sub: #94a8cb;
  --cyan: #38f2ff;
  --blue: #5b8cff;
  --magenta: #ff47b6;
  --purple: #c084fc;
  --gold: #ffcb47;
  --emerald: #3df59b;
  --danger: #ff4d6d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#uiLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hidden {
  display: none !important;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--cyan);
  background: rgba(56, 242, 255, 0.1);
  border: 1px solid rgba(56, 242, 255, 0.35);
  border-radius: 5px;
}

/* ==================== HUD ==================== */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.xp-bar-wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: rgba(8, 13, 28, 0.94);
  border-bottom: 1px solid rgba(56, 242, 255, 0.32);
  z-index: 25;
}

.xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #38f2ff, #6effe8);
  box-shadow: 0 0 12px rgba(56, 242, 255, 0.7);
  transition: width 0.14s ease-out;
}

.hud-level {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #06121e;
  background: linear-gradient(90deg, var(--cyan), #9bfcff);
  box-shadow: 0 2px 12px rgba(56, 242, 255, 0.45);
  font-variant-numeric: tabular-nums;
}

.hud-top-row {
  position: fixed;
  top: 18px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
}

.hud-pilot-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hud-avatar-wrap {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 11px;
  border: 2px solid var(--cyan);
  background: rgba(8, 14, 30, 0.92);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(56, 242, 255, 0.3);
}

.hud-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.hp-dash-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hp-dash-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hp-bar-outer {
  position: relative;
  width: 170px;
  height: 22px;
  border-radius: 7px;
  background: rgba(12, 18, 34, 0.92);
  border: 1px solid rgba(255, 77, 109, 0.45);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hp-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, #e11d48, #ff4d6d, #fb7185);
  transition: width 0.12s ease-out;
}

.hp-text {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  font-variant-numeric: tabular-nums;
}

.dash-badge {
  position: relative;
  min-width: 82px;
  height: 22px;
  padding: 0 9px;
  border-radius: 7px;
  background: rgba(12, 18, 34, 0.92);
  border: 1px solid rgba(56, 242, 255, 0.35);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-badge.ready {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(56, 242, 255, 0.25);
}

.dash-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: rgba(56, 242, 255, 0.24);
}

.dash-text {
  position: relative;
  z-index: 1;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.slots-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slots-row {
  display: flex;
  gap: 4px;
}

.slot-box {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(11, 17, 34, 0.86);
  border: 1px solid rgba(148, 168, 203, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 13px;
  line-height: 1;
}

.slot-box.filled {
  border-color: rgba(56, 242, 255, 0.55);
  background: rgba(18, 32, 60, 0.92);
}

.slot-box.evolved {
  border-color: var(--gold);
  background: linear-gradient(145deg, rgba(66, 44, 12, 0.92), rgba(24, 18, 44, 0.94));
  box-shadow: 0 0 10px rgba(255, 203, 71, 0.4);
}

.slot-lv {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 8.5px;
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 1px 2px #000;
}

.slot-box.evolved .slot-lv {
  color: var(--gold);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 15px;
}

.hud-timer {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 0 14px rgba(56, 242, 255, 0.45);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.hud-wave {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  letter-spacing: 0.04em;
}

.boss-hud {
  margin-top: 6px;
  width: min(340px, 56vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.boss-name {
  font-size: 12px;
  font-weight: 800;
  color: #ff8aa8;
  text-shadow: 0 0 8px rgba(255, 77, 109, 0.6);
}

.boss-bar-outer {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: rgba(18, 8, 18, 0.92);
  border: 1px solid rgba(255, 77, 109, 0.7);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(255, 77, 109, 0.35);
}

.boss-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff2d55, #ff47b6, #ff9f43);
  transition: width 0.08s linear;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.stat-pill {
  height: 32px;
  padding: 0 11px;
  border-radius: 9px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.coin-pill {
  border-color: rgba(255, 203, 71, 0.4);
  color: var(--gold);
}

.lg-pill {
  height: 38px;
  padding: 0 15px;
  font-size: 16px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-main);
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, border-color 0.15s;
}

.icon-btn:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
}

/* ==================== BANNERS & TOASTS ==================== */
.boss-banner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 36px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(60, 8, 28, 0.92), rgba(22, 10, 34, 0.95), rgba(60, 8, 28, 0.92));
  border: 1px solid rgba(255, 77, 109, 0.8);
  box-shadow: 0 0 36px rgba(255, 77, 109, 0.45);
  text-align: center;
  z-index: 40;
  animation: pulseWarn 0.9s ease-in-out infinite alternate;
}

.boss-banner-sub {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #ff99b2;
  font-weight: 700;
}

.boss-banner-title {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  margin-top: 2px;
}

@keyframes pulseWarn {
  from { transform: translateX(-50%) scale(0.98); }
  to { transform: translateX(-50%) scale(1.03); }
}

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 55;
  pointer-events: none;
}

.toast-item {
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(10, 19, 38, 0.94);
  border: 1px solid var(--border-strong);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.2s ease-out;
}

.toast-item.gold {
  border-color: var(--gold);
  color: var(--gold);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== TOUCH CONTROLS ==================== */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.joystick-zone {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 60%;
  height: 55%;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  position: fixed;
  width: 112px;
  height: 112px;
  margin-left: -56px;
  margin-top: -56px;
  border-radius: 50%;
  background: rgba(56, 242, 255, 0.08);
  border: 2px solid rgba(56, 242, 255, 0.4);
  pointer-events: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin-left: -23px;
  margin-top: -23px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 242, 255, 0.85), rgba(56, 242, 255, 0.35));
  box-shadow: 0 0 14px rgba(56, 242, 255, 0.5);
}

.dash-touch-btn {
  position: fixed;
  right: 22px;
  bottom: 28px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: rgba(11, 22, 46, 0.85);
  color: var(--cyan);
  font-weight: 800;
  font-size: 15px;
  pointer-events: auto;
  box-shadow: 0 0 20px rgba(56, 242, 255, 0.3);
}

.dash-touch-btn:active {
  transform: scale(0.94);
}

/* ==================== TITLE SCREEN & ACCOUNT BAR ==================== */
.overlay-screen,
.modal-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.overlay-screen {
  background: radial-gradient(circle at 50% 20%, rgba(20, 42, 92, 0.52), rgba(6, 9, 19, 0.86));
  z-index: 30;
}

.modal-backdrop {
  background: rgba(4, 7, 16, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
}

.title-container {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
}

.account-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(10, 18, 38, 0.84);
  border: 1px solid rgba(56, 242, 255, 0.25);
  backdrop-filter: blur(8px);
}

.account-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}

.account-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.title-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--cyan);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(56, 242, 255, 0.35);
  background: rgba(56, 242, 255, 0.08);
}

.game-title {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(120deg, #ffffff 10%, #38f2ff 50%, #ff47b6 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(56, 242, 255, 0.35));
}

.game-subtitle {
  font-size: 13.5px;
  color: var(--text-sub);
}

.title-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
}

.title-stat-chip {
  font-size: 12px;
  color: var(--text-sub);
  background: rgba(11, 17, 34, 0.84);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
}

.title-stat-chip strong {
  color: var(--text-main);
}

.char-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-sub);
  text-transform: uppercase;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.char-card {
  position: relative;
  text-align: left;
  border-radius: 16px;
  background: linear-gradient(175deg, rgba(16, 26, 52, 0.94), rgba(9, 14, 30, 0.96));
  border: 1px solid rgba(148, 168, 203, 0.24);
  color: var(--text-main);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
}

.char-card:hover {
  transform: translateY(-3px);
  border-color: var(--char-accent, var(--cyan));
}

.char-card.selected {
  border: 1.5px solid var(--char-accent, var(--cyan));
  box-shadow: 0 0 26px rgba(56, 242, 255, 0.26), inset 0 0 18px rgba(56, 242, 255, 0.08);
}

.char-portrait-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #070c1a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.char-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
  transition: transform 0.25s ease;
}

.char-card:hover .char-portrait-img {
  transform: scale(1.04);
}

.char-role-tag {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(6, 11, 24, 0.85);
  border: 1px solid var(--char-accent, var(--cyan));
  color: var(--char-accent, var(--cyan));
  backdrop-filter: blur(4px);
}

.char-body {
  padding: 12px 13px 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.char-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.char-name {
  font-size: 15px;
  font-weight: 800;
}

.char-weapon {
  font-size: 11.5px;
  color: var(--char-accent, var(--cyan));
  font-weight: 700;
}

.char-trait {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.42;
  min-height: 34px;
}

.char-meters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
}

.stat-meter-row {
  display: grid;
  grid-template-columns: 28px 1fr 34px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-sub);
}

.stat-meter-row strong {
  text-align: right;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.stat-meter {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.stat-meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--char-accent, var(--cyan)));
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
}

/* ==================== BUTTONS ==================== */
.btn {
  position: relative;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(22, 34, 64, 0.9);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.14s, filter 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-lg {
  padding: 12px 26px;
  font-size: 15.5px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
}

.btn-3d {
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  color: #ffffff;
  border-color: rgba(56, 242, 255, 0.48);
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.36);
}

.btn-gold {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #160d00;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.35);
}

.btn-secondary {
  background: rgba(20, 32, 60, 0.95);
  border-color: var(--border);
}

.btn-ghost {
  background: rgba(14, 22, 42, 0.8);
  border-color: rgba(148, 168, 203, 0.25);
}

.btn-danger-ghost {
  background: rgba(48, 12, 24, 0.72);
  border-color: rgba(255, 77, 109, 0.4);
  color: #ff8ea3;
}

.coin-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.notify-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

/* ==================== MODAL PANELS ==================== */
.modal-panel {
  width: 100%;
  max-width: 780px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wide-panel {
  max-width: 880px;
}

.pause-panel {
  max-width: 440px;
}

.auth-panel {
  max-width: 460px;
}

.chest-panel {
  max-width: 460px;
  text-align: center;
  align-items: center;
  border-color: var(--gold);
  box-shadow: 0 0 40px rgba(255, 203, 71, 0.28);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--cyan);
}

.gold-text {
  color: var(--gold);
}

.modal-title {
  font-size: 22px;
  font-weight: 900;
  margin-top: 2px;
}

.modal-footer-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
}

.modal-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==================== AUTH & LEADERBOARD ==================== */
.auth-tip {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}

.input-field {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 168, 203, 0.3);
  background: rgba(7, 12, 24, 0.9);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-field:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(56, 242, 255, 0.15);
}

.auth-error {
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(255, 77, 109, 0.14);
  border: 1px solid rgba(255, 77, 109, 0.5);
  color: #ff9cb0;
  font-size: 12.5px;
  font-weight: 600;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-actions .btn {
  flex: 1;
}

.lb-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lb-mode-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(148, 168, 203, 0.14);
  border: 1px solid rgba(148, 168, 203, 0.3);
  color: var(--text-sub);
}

.lb-mode-badge.online {
  background: rgba(61, 245, 155, 0.14);
  border-color: rgba(61, 245, 155, 0.45);
  color: var(--emerald);
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 430px;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 44px 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(15, 24, 48, 0.85);
  border: 1px solid rgba(148, 168, 203, 0.18);
}

.lb-rank {
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.lb-rank-1 { color: #ffcb47; font-size: 16px; }
.lb-rank-2 { color: #e2e8f0; font-size: 15px; }
.lb-rank-3 { color: #fb923c; font-size: 15px; }

.lb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
  object-position: top center;
  border: 1px solid rgba(56, 242, 255, 0.35);
}

.lb-pilot-info {
  min-width: 0;
}

.lb-name {
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lb-victory-tag {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  background: rgba(255, 203, 71, 0.16);
  border: 1px solid rgba(255, 203, 71, 0.45);
  color: var(--gold);
}

.lb-char-sub {
  font-size: 11.5px;
  color: var(--text-sub);
}

.lb-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.lb-stats strong {
  font-size: 14px;
  color: var(--cyan);
}

.lb-stats span {
  font-size: 11.5px;
  color: var(--text-sub);
}

/* ==================== LEVEL UP CARDS ==================== */
.upgrade-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.upgrade-card {
  position: relative;
  text-align: left;
  padding: 16px 14px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid rgba(56, 242, 255, 0.28);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.upgrade-card:hover {
  transform: translateY(-3px);
  border-color: var(--cyan);
  box-shadow: 0 8px 24px rgba(56, 242, 255, 0.24);
}

.upgrade-card.card-passive {
  border-color: rgba(61, 245, 155, 0.35);
}

.upgrade-card.card-passive:hover {
  border-color: var(--emerald);
  box-shadow: 0 8px 24px rgba(61, 245, 155, 0.22);
}

.upgrade-card.card-evolution {
  border: 1.5px solid var(--gold);
  background: linear-gradient(160deg, rgba(64, 42, 12, 0.95), rgba(22, 16, 44, 0.96));
  box-shadow: 0 0 24px rgba(255, 203, 71, 0.32);
}

.upgrade-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.upgrade-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.upgrade-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(56, 242, 255, 0.14);
  color: var(--cyan);
}

.card-passive .upgrade-badge {
  background: rgba(61, 245, 155, 0.14);
  color: var(--emerald);
}

.card-evolution .upgrade-badge {
  background: rgba(255, 203, 71, 0.22);
  color: var(--gold);
}

.upgrade-name {
  font-size: 16px;
  font-weight: 800;
}

.upgrade-desc {
  font-size: 13px;
  color: #cfe0fc;
  line-height: 1.48;
  flex: 1;
}

.upgrade-pair {
  font-size: 11px;
  color: var(--text-sub);
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.upgrade-hotkey {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(148, 168, 203, 0.7);
}

/* ==================== CHEST, STATS & RESULT ==================== */
.chest-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: rgba(255, 203, 71, 0.16);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.chest-desc {
  font-size: 14px;
  color: #d6e4ff;
  line-height: 1.5;
}

.chest-bonus {
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 203, 71, 0.15);
  color: var(--gold);
  font-weight: 800;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-cell {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 24, 48, 0.85);
  border: 1px solid rgba(148, 168, 203, 0.18);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.stat-cell span {
  color: var(--text-sub);
}

.stat-cell strong {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.result-subtitle {
  font-size: 14px;
  color: var(--text-sub);
}

.dps-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dps-breakdown {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dps-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dps-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.dps-bar-bg {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.dps-bar-val {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* ==================== META & CODEX ==================== */
.meta-grid,
.codex-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meta-card,
.codex-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid rgba(148, 168, 203, 0.22);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.meta-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 14px;
}

.meta-lv {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
}

.meta-pips {
  display: flex;
  gap: 4px;
}

.meta-pip {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.meta-pip.filled {
  background: linear-gradient(90deg, #f59e0b, #ffcb47);
  box-shadow: 0 0 8px rgba(255, 203, 71, 0.45);
}

.meta-desc {
  font-size: 12px;
  color: var(--text-sub);
}

.codex-tip {
  font-size: 13px;
  color: var(--text-sub);
}

.codex-tip strong {
  color: var(--gold);
}

.codex-formula {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
  font-weight: 700;
}

.codex-chip {
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.codex-chip.evo {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 203, 71, 0.12);
}

.codex-desc {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.45;
}

/* ==================== RESPONSIVE MOBILE ==================== */
@media (max-width: 720px) {
  .xp-bar-wrap {
    height: 8px;
  }

  .hud-level {
    top: 9px;
    font-size: 11px;
    padding: 1px 10px;
  }

  .hud-top-row {
    top: 28px;
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
    gap: 4px 6px;
  }

  .hud-center {
    order: -1;
    flex-basis: 100%;
    flex-direction: row;
    justify-content: center;
    align-items: baseline;
    gap: 8px;
    margin-top: 0;
  }

  .hud-left {
    gap: 4px;
    max-width: calc(100% - 146px);
  }

  .hud-pilot-row {
    gap: 6px;
  }

  .hud-avatar-wrap {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .hp-dash-row {
    gap: 4px;
  }

  .hp-bar-outer {
    width: 96px;
    height: 19px;
  }

  .hp-text {
    font-size: 10.5px;
  }

  .dash-badge {
    min-width: 54px;
    height: 19px;
    padding: 0 4px;
  }

  .dash-text {
    font-size: 9.5px;
  }

  .slot-box {
    width: 21px;
    height: 21px;
    font-size: 10.5px;
  }

  .hud-timer {
    font-size: 18px;
  }

  .hud-wave {
    font-size: 10px;
  }

  .boss-hud {
    position: fixed;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    width: 76vw;
    margin-top: 0;
  }

  .hud-right {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .stat-pill {
    height: 26px;
    padding: 0 6px;
    font-size: 11px;
    gap: 3px;
  }

  .icon-btn {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .overlay-screen {
    align-items: flex-start;
    padding: 10px;
    overflow-x: hidden;
  }

  .title-container {
    min-width: 0;
    max-width: 100%;
    padding: 8px 4px 24px;
    gap: 12px;
  }

  .account-bar {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 6px;
  }

  .char-grid,
  .upgrade-cards,
  .meta-grid,
  .codex-grid {
    grid-template-columns: 1fr;
  }

  .char-portrait-wrap {
    aspect-ratio: 16 / 9;
  }

  .title-actions {
    width: 100%;
  }

  .title-actions .btn {
    flex: 1 1 46%;
    min-width: 0;
    padding: 10px 8px;
    font-size: 13px;
  }

  .modal-panel {
    padding: 16px;
  }

  .lb-row {
    grid-template-columns: 34px 34px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px 10px;
  }

  .lb-avatar {
    width: 34px;
    height: 34px;
  }

  .result-actions {
    justify-content: stretch;
  }

  .result-actions .btn {
    flex: 1 1 46%;
  }
}
