/* ============================================================
   Sprint 3.C：排行榜 drawer 样式 + HUD level chip
   ============================================================ */
#levelChip.level-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #422e00;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(245, 158, 11, .3);
  transition: transform .3s ease;
}
#levelChip.level-up-flash {
  animation: levelUpPulse 1.2s ease;
}
@keyframes levelUpPulse {
  0%   { transform: scale(1); box-shadow: 0 1px 3px rgba(245, 158, 11, .3); }
  30%  { transform: scale(1.25); box-shadow: 0 0 20px rgba(251, 191, 36, .9); }
  60%  { transform: scale(1.1);  box-shadow: 0 0 12px rgba(251, 191, 36, .6); }
  100% { transform: scale(1); box-shadow: 0 1px 3px rgba(245, 158, 11, .3); }
}

/* -------- 排行榜 drawer -------- */
.rank-panel-content {
  padding: 12px 14px 20px;
  color: #f8fafc;
}
.rank-scope-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  padding-bottom: 8px;
}
.rank-tab {
  flex: 1;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .15);
  background: rgba(255, 255, 255, .05);
  color: #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s;
}
.rank-tab:hover { background: rgba(255, 255, 255, .12); }
.rank-tab.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.rank-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 55vh;
  overflow-y: auto;
}
.rank-empty {
  padding: 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}
.rank-item {
  display: grid;
  grid-template-columns: 34px 30px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 8px;
  font-size: 13px;
  transition: background .2s;
}
.rank-item:hover { background: rgba(255, 255, 255, .08); }
.rank-item.is-me {
  background: linear-gradient(90deg, rgba(251, 191, 36, .18) 0%, rgba(139, 92, 246, .12) 100%);
  border-color: rgba(251, 191, 36, .5);
  box-shadow: 0 0 12px rgba(251, 191, 36, .2);
}
.rank-item.is-me .rank-name em {
  color: #fbbf24;
  font-style: normal;
  font-weight: 700;
  margin-left: 4px;
}
.rank-medal { font-size: 16px; text-align: center; font-weight: 700; }
.rank-avatar { font-size: 22px; text-align: center; line-height: 1; }
.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.rank-level {
  padding: 2px 6px;
  background: rgba(99, 102, 241, .3);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #c7d2fe;
}
.rank-xp {
  font-variant-numeric: tabular-nums;
  color: #fbbf24;
  font-weight: 600;
  font-size: 12px;
}
.rank-me {
  margin-top: 10px;
  padding: 10px;
  background: rgba(251, 191, 36, .1);
  border: 1px dashed rgba(251, 191, 36, .4);
  border-radius: 8px;
}
.rank-me-inner {
  display: grid;
  grid-template-columns: 34px 30px 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.rank-me-tip {
  margin: 6px 0 0;
  font-size: 11px;
  color: #fde68a;
  text-align: center;
}
.rank-tip {
  margin-top: 10px;
  padding: 6px 8px;
  background: rgba(99, 102, 241, .1);
  border-radius: 6px;
  font-size: 11px;
  color: #a5b4fc;
  text-align: center;
}

/* -------- 学生档案 chip（Sprint 3.D-1）-------- */
.student-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(99, 102, 241, .18);
  border: 1px solid rgba(139, 92, 246, .4);
  color: #e0e7ff;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: background .2s;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.student-profile-chip:hover { background: rgba(99, 102, 241, .3); }
.student-profile-chip .avatar {
  font-size: 16px;
  line-height: 1;
}

/* -------- Sprint 3.D-2：移动端&平板 右手攻击按钮组 -------- */
/* v6.2.2：收紧到 hover:none AND coarse（避免 PC 触屏一体机误命中） */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  /* touch-controls 强制显示、左右手分栏 —— 不再等 body.game-started */
  #touchControls.touch-controls {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    display: flex !important;
    align-items: flex-end;
    justify-content: space-between;
    z-index: 45;
    pointer-events: none; /* 摇杆/按钮各自 auto */
  }
  #touchControls .joystick-base,
  #touchControls .mobile-actions,
  #touchControls .mobile-actions button {
    pointer-events: auto;
  }
  /* 左手摇杆区加大一点，方便拇指够到 */
  #touchControls .joystick-base { width: 116px; height: 116px; }
  #touchControls .joystick-knob { width: 52px; height: 52px; }
  /* ⭐ 关键修复：joystick-base 是 floating 时脱离 flex 流，
     导致 mobile-actions 变成 flex 唯一子元素贴左。
     方案：直接 fixed 定位钉右下角，不再受父容器 flex 影响。 */
  #touchControls .mobile-actions {
    position: fixed !important;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    left: auto !important;
    margin-left: auto;
    display: grid !important;
    /* v6.2.1：全部战斗按钮平时可见（拳/踢/闪避/跳 + BOSS）= 5 键 2 列布局 */
    grid-template-columns: repeat(2, 68px);
    grid-auto-rows: 68px;
    gap: 10px;
    z-index: 46;
  }
  #touchControls .mobile-actions button {
    min-width: 68px;
    min-height: 68px;
    padding: 0;
    font-size: 22px;
    border-radius: 50%;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    touch-action: manipulation;
  }
  #touchControls .mobile-actions button small {
    display: block;
    font-size: 10px;
    margin-top: 2px;
    opacity: .85;
  }
  /* 主攻击更醒目 */
  #mobileAttackBtn.attack-btn {
    background: radial-gradient(circle at 30% 30%, #f97316 0%, #dc2626 80%);
    color: #fff;
  }
  #mobileKickBtn.kick-btn {
    background: radial-gradient(circle at 30% 30%, #a855f7 0%, #7c3aed 80%);
    color: #fff;
  }
  #mobileDodgeBtn.dodge-btn {
    background: radial-gradient(circle at 30% 30%, #10b981 0%, #059669 80%);
    color: #fff;
  }
  #mobileJumpBtn.jump-btn {
    background: radial-gradient(circle at 30% 30%, #3b82f6 0%, #2563eb 80%);
    color: #fff;
  }
  /* dock 让位给右手按钮，别遮挡 —— v6.2 提高避免 AI/BOSS/攻击 3 按钮竖排（=226px）覆盖
     v6.2.7：top 190→60，避免 4 颗 dock-btn(60px)+3gap = 270px 高度溢出被裁 */
  .utility-dock {
    top: calc(60px + env(safe-area-inset-top, 0px));
    bottom: calc(260px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    align-items: flex-start;
  }
  /* 战斗中攻击按钮组变 2 列 3 行（宽度增大高度不变），dock 可以下移一点 */
  body.in-combat .utility-dock {
    bottom: calc(240px + env(safe-area-inset-bottom, 0px));
  }
  /* dock-rail 允许纵向滚动兜底（如按钮 >4 个也不裁） */
  .utility-dock .dock-rail {
    max-height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    padding: 2px;
  }
  .utility-dock .dock-rail::-webkit-scrollbar { display: none; }
}

/* 更窄的手机 <=430px（iPhone Pro Max 竖屏及以下）—— 按钮再瘦一点 */
@media (max-width: 430px) {
  #touchControls .joystick-base { width: 96px; height: 96px; }
  #touchControls .mobile-actions {
    grid-template-columns: repeat(2, 60px);
    grid-auto-rows: 60px;
    gap: 8px;
  }
  #touchControls .mobile-actions button {
    min-width: 60px;
    min-height: 60px;
    font-size: 20px;
  }
}
