/* ========== HUD面板（上层） ========== */
.hud-panel {
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
  padding: 6px 10px;
}

/* 第一行：核心属性 + 小地图 */
.hud-row-1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-core-stats {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
}

.hud-stat span {
  font-variant-numeric: tabular-nums;
}

/* 属性颜色区分 */
.hud-stat-hp { color: #ff6b6b; }
.hud-stat-hp span { color: #ff6b6b; }
.hud-stat-atk { color: #ffa94d; }
.hud-stat-atk span { color: #ffa94d; }
.hud-stat-def { color: #74c0fc; }
.hud-stat-def span { color: #74c0fc; }
.hud-stat-key { color: #ffd43b; }
.hud-stat-key span { color: #ffd43b; }
.hud-stat-ykey { color: #ffd43b; }
.hud-stat-ykey span { color: #ffd43b; }
.hud-stat-rkey { color: #ff6b6b; }
.hud-stat-rkey span { color: #ff6b6b; }
.hud-icon-img {
  width: 1.1em;
  height: 1.1em;
  vertical-align: middle;
  object-fit: contain;
  margin-right: 1px;
}
.hud-stat-lv { color: #b197fc; }
.hud-stat-lv span { color: #b197fc; }
.hud-stat-floor { color: var(--gold); }
.hud-stat-floor span { color: var(--gold); }
.hud-stat-gold { color: #ffe066; }
.hud-stat-gold span { color: #ffe066; }
.hud-stat-vision { color: #a9e34b; }
.hud-stat-vision span { color: #a9e34b; }

/* 小地图 - 右上角 */
.minimap {
  width: 64px;
  height: 64px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.minimap-dot {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 1px;
}

.minimap-dot.mm-wall { background: #444; }
.minimap-dot.mm-floor { background: #333; }
.minimap-dot.mm-player {
  background: var(--primary);
  width: 4px;
  height: 4px;
  border-radius: 2px;
  z-index: 2;
}
.minimap-dot.mm-enemy { background: var(--danger); }
.minimap-dot.mm-chest { background: var(--gold); }
.minimap-dot.mm-shop {
  background: #ffa500;
  width: 3px;
  height: 3px;
  border-radius: 1px;
}
.minimap-dot.mm-stairs {
  background: var(--success);
  width: 3px;
  height: 3px;
}
.minimap-dot.mm-portal {
  background: #8a2be2;
  width: 3px;
  height: 3px;
}
.minimap-dot.mm-portal-end {
  background: #ffd700;
  width: 4px;
  height: 4px;
  border-radius: 2px;
}
.minimap-dot.mm-portal-branch {
  background: #00b4d8;
  width: 3px;
  height: 3px;
}
.minimap-dot.mm-pickup {
  background: #69db7c;
  width: 2px;
  height: 2px;
}

/* ========== 地图视口（铺满剩余空间） ========== */
.map-viewport {
  flex: 1;
  overflow: hidden; /* 关键：隐藏溢出，不允许手动滚动，由JS控制 */
  position: relative;
  -webkit-overflow-scrolling: touch;
  background: #0d0d1e;
}

.map-grid {
  display: grid;
  gap: 0px;
  padding: 0;
  position: absolute;
  /* 使用transform代替left/top，GPU加速更流畅 */
  will-change: transform;
  transition: transform 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ========== 地图格子 ========== */
.map-cell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: 0px;
  position: relative;
  cursor: default;
}

.map-cell .cell-content {
  font-size: 22px;
  line-height: 1;
  user-select: none;
}

/* ========== 墙壁样式 ========== */
.map-cell.wall {
  background: linear-gradient(145deg, #3a3a55, #252540);
  border: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 -1px 0 rgba(0,0,0,0.3);
}

.map-cell.wall.wall-pillar {
  border-radius: 4px;
  background: linear-gradient(145deg, #444460, #2a2a44);
}

/* ========== 地板/通道样式 ========== */
.map-cell.floor {
  background: #13132a;
  border: none;
  border-radius: 0;
}

.map-cell.floor.explored { background: #181835; }
.map-cell.floor.visible { background: #1c1c38; }

.map-cell.player {
  background: rgba(74, 144, 217, 0.2);
  box-shadow: 0 0 12px rgba(74, 144, 217, 0.4);
  z-index: 2;
}

/* 柔和的发光动画（不缩放，不晃动） */
.map-cell.player::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 144, 217, 0.3) 0%, transparent 70%);
  animation: playerGlow 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes playerGlow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* ========== 英雄图片精灵 ========== */
.hero-sprite-img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 0 3px rgba(74, 144, 217, 0.6));
  position: relative;
  z-index: 2;
}

.map-cell.enemy { cursor: pointer; }
.map-cell.enemy:hover {
  background: rgba(220, 53, 69, 0.25);
  transform: scale(1.05);
  z-index: 3;
}

/* ========== 怪物图片样式（地图格子内） ========== */
.monster-img {
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.6));
}

.map-cell .monster-img {
  width: 32px !important;
  height: 32px !important;
}

.map-cell .boss-img {
  width: 36px !important;
  height: 36px !important;
  filter: drop-shadow(0 0 4px rgba(255, 68, 68, 0.5));
  animation: bossGlow 2s ease-in-out infinite;
}

@keyframes bossGlow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 68, 68, 0.4)); }
  50% { filter: drop-shadow(0 0 8px rgba(255, 68, 68, 0.8)); }
}

.map-cell.chest { cursor: pointer; }
.map-cell.chest:hover {
  animation: glow 1s ease-in-out infinite;
  transform: scale(1.05);
  z-index: 3;
}

.map-cell.shop-wall {
  cursor: pointer;
  background: linear-gradient(135deg, #3a2a1a, #2a1a0a) !important;
  border: 1px solid rgba(255, 215, 0, 0.4) !important;
  box-shadow: inset 0 0 8px rgba(255, 215, 0, 0.15);
}
.map-cell.shop-wall:hover {
  background: linear-gradient(135deg, #4a3a2a, #3a2a1a) !important;
  border-color: rgba(255, 215, 0, 0.7) !important;
  box-shadow: inset 0 0 12px rgba(255, 215, 0, 0.3), 0 0 6px rgba(255, 215, 0, 0.3);
  transform: scale(1.05);
  z-index: 3;
}
.map-cell.shop-wall .cell-content {
  animation: shopPulse 2s ease-in-out infinite;
}
@keyframes shopPulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.map-cell.stairs {
  cursor: pointer;
  animation: glow 2s ease-in-out infinite;
}
.map-cell.stairs:hover {
  transform: scale(1.08);
  z-index: 3;
}

.map-cell.pickup {
  cursor: pointer;
}
.map-cell.pickup .cell-content {
  animation: pickupBounce 1.5s ease-in-out infinite;
}
@keyframes pickupBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.map-cell.hidden-wall { cursor: pointer; }
.map-cell.hidden-wall:hover {
  background: rgba(100, 100, 200, 0.15);
}

/* 传送门 */
.map-cell.portal {
  background: #1a1a3a;
}

.map-cell.portal-active {
  background: radial-gradient(circle, #2a1a4a, #1a0a2a);
  cursor: pointer;
  border: 1px solid rgba(138, 43, 226, 0.4);
  animation: portalPulse 1.5s ease-in-out infinite;
}

.map-cell.portal-active:hover {
  background: radial-gradient(circle, #3a2a5a, #2a1a3a);
  box-shadow: 0 0 12px rgba(138, 43, 226, 0.6);
  transform: scale(1.08);
  z-index: 3;
}

@keyframes portalPulse {
  0%, 100% { box-shadow: 0 0 4px rgba(138, 43, 226, 0.3); }
  50% { box-shadow: 0 0 10px rgba(138, 43, 226, 0.6); }
}

/* 终点最近传送门 — 金色星辉效果 */
.map-cell.portal-end {
  background: radial-gradient(circle, #3a2a10, #2a1a08);
  cursor: pointer;
  border: 1px solid rgba(255, 215, 0, 0.5);
  animation: portalEndPulse 2s ease-in-out infinite;
}

.map-cell.portal-end .cell-content {
  animation: portalEndStar 2s ease-in-out infinite;
  font-size: 24px;
}

.map-cell.portal-end:hover {
  background: radial-gradient(circle, #4a3a20, #3a2a10);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.6);
  transform: scale(1.08);
  z-index: 3;
}

@keyframes portalEndPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 215, 0, 0.3); }
  50% { box-shadow: 0 0 14px rgba(255, 215, 0, 0.7); }
}

@keyframes portalEndStar {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.1); filter: brightness(1.3); }
}

/* 分支传送门 — 青蓝色效果 */
.map-cell.portal-branch {
  background: radial-gradient(circle, #1a2a3a, #0a1a2a);
  cursor: pointer;
  border: 1px solid rgba(0, 180, 216, 0.4);
  animation: portalBranchPulse 1.8s ease-in-out infinite;
}

.map-cell.portal-branch:hover {
  background: radial-gradient(circle, #2a3a4a, #1a2a3a);
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.6);
  transform: scale(1.08);
  z-index: 3;
}

@keyframes portalBranchPulse {
  0%, 100% { box-shadow: 0 0 4px rgba(0, 180, 216, 0.3); }
  50% { box-shadow: 0 0 10px rgba(0, 180, 216, 0.6); }
}

/* 传送门确认弹窗 */
.portal-modal {
  text-align: center;
  border: 1px solid rgba(138, 43, 226, 0.4) !important;
  background: linear-gradient(135deg, #1a1a3a, #2a1a4a) !important;
  box-shadow: 0 0 30px rgba(138, 43, 226, 0.3);
}

.portal-modal-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: portalPulse 1.5s ease-in-out infinite;
}

.portal-modal-title {
  font-size: 22px;
  font-weight: bold;
  color: #d4a0ff;
  margin-bottom: 10px;
}

.portal-modal-desc {
  font-size: 14px;
  color: #c0b0d8;
  margin-bottom: 8px;
  line-height: 1.5;
}

.portal-modal-info {
  font-size: 15px;
  color: #e8d070;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 16px;
}

.portal-modal-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-portal {
  background: linear-gradient(135deg, #7b2ff7, #9b59b6);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-portal:hover {
  background: linear-gradient(135deg, #9b3ff7, #b569d6);
  box-shadow: 0 0 16px rgba(138, 43, 226, 0.5);
  transform: translateY(-1px);
}

.btn-portal.btn-disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-portal.btn-disabled:hover {
  background: #444;
  box-shadow: none;
  transform: none;
}

.map-cell.fog {
  background: #0d0d1e !important;
}
.map-cell.fog .cell-content {
  display: none;
}

/* ========== 标题界面 ========== */
.title-bg {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #0a0a2e 0%, #1a1a4e 50%, #2a1a3e 100%);
  position: relative;
  overflow: hidden;
}

.title-stars {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

.title-star {
  position: absolute;
  width: 3px; height: 3px;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
  opacity: 0.3;
}

.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1;
  margin-bottom: 40px;
}

.title-icon { font-size: 64px; animation: float 3s ease-in-out infinite; }
.title-text {
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(135deg, #ffd700, #ff8c00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
}
.title-sub {
  font-size: 18px;
  color: var(--text-dim);
  letter-spacing: 6px;
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1;
  min-width: 220px;
}

.title-footer {
  position: absolute;
  bottom: 20px;
  font-size: 12px;
  color: var(--text-dim);
  z-index: 1;
}

/* ========== 难度选择 ========== */
.difficulty-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.diff-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diff-card:hover {
  background: rgba(74, 144, 217, 0.15);
  border-color: var(--primary);
  transform: translateX(5px);
}

.diff-card:active { transform: scale(0.98); }
.diff-icon { font-size: 36px; }
.diff-name { font-size: 18px; font-weight: 700; color: var(--text-bright); }
.diff-desc { font-size: 12px; color: var(--text-dim); line-height: 1.4; }

/* ========== 过关弹窗 ========== */
.floor-clear-modal .floor-clear-title {
  font-size: 28px;
  text-align: center;
  color: var(--gold);
  margin-bottom: 16px;
  animation: victoryBurst 0.6s ease;
}

.floor-clear-content {
  text-align: center;
  margin-bottom: 16px;
  font-size: 15px;
  line-height: 1.8;
}
