/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #1a1a2e;
  color: #eaeaea;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hidden { display: none !important; }

/* ===== 顶部栏 ===== */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: linear-gradient(135deg, #16213e, #0f3460);
  border-bottom: 2px solid #e94560;
  z-index: 10;
  flex-shrink: 0;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #e94560;
  letter-spacing: 2px;
}
#game-info { font-size: 0.85rem; color: #aaa; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.stat-block {
  font-size: 1rem;
  background: rgba(255,255,255,0.08);
  padding: 4px 14px;
  border-radius: 6px;
  white-space: nowrap;
}
.level-badge {
  background: #e94560;
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ===== 主体布局 ===== */
#main-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ===== 商店（模态框内） ===== */
.shop-gold-bar { font-size: 1.1rem; color: #ffd700; text-align: center; margin-bottom: 12px; }
.shop-section-title {
  font-size: 0.85rem; color: #888; margin: 16px 0 8px;
  border-bottom: 1px solid #333; padding-bottom: 4px;
}
.shop-item {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: #1a1a3e; border: 1px solid #333; border-radius: 6px;
  padding: 10px; margin-bottom: 8px; transition: border-color 0.2s;
}
.shop-item.owned { opacity: 0.5; border-color: #555; }
.shop-item-info { flex: 1; min-width: 140px; }
.shop-item-name { font-size: 0.9rem; font-weight: 600; }
.shop-item-desc { font-size: 0.75rem; color: #888; margin: 2px 0; }
.shop-item-price { font-size: 0.85rem; color: #ffd700; }
.shop-buy-btn {
  padding: 6px 16px; background: #e94560; color: #fff;
  border: none; border-radius: 4px; cursor: pointer; font-size: 0.85rem;
  flex-shrink: 0;
}
.shop-buy-btn:hover { background: #ff6b6b; }

/* ===== 画布 ===== */
#cy {
  flex: 1;
  background: radial-gradient(ellipse at center, #1a1a3e 0%, #0d0d1a 100%);
  min-width: 0;
}

/* ===== 背包栏 ===== */
#backpack {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(22, 33, 62, 0.95);
  border: 2px solid #0f3460;
  border-radius: 10px;
  padding: 8px;
  min-width: 180px;
  z-index: 20;
  backdrop-filter: blur(6px);
}
.bp-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 6px;
}
#bp-slots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.bp-slot {
  width: 48px;
  height: 48px;
  background: #0d0d1a;
  border: 2px dashed #333;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #555;
  cursor: default;
  transition: all 0.2s;
  position: relative;
}
.bp-slot.filled {
  border-style: solid;
  border-color: #4a90d9;
  background: rgba(74, 144, 217, 0.12);
  cursor: pointer;
}
.bp-slot.filled:hover {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}
.bp-slot .bp-icon {
  font-size: 1.2rem;
  pointer-events: none;
}
.bp-slot .bp-label {
  position: absolute;
  bottom: 1px;
  font-size: 0.5rem;
  color: #aaa;
  pointer-events: none;
  line-height: 1;
}

/* ===== 提示浮窗 ===== */
#tooltip {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  border: 1px solid #e94560;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
  max-width: 80%;
  text-align: center;
}
#tooltip.hidden { opacity: 0; }

/* ===== 模态框 ===== */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.3s ease;
}
#modal.hidden { opacity: 0; pointer-events: none; }
#modal-content {
  background: linear-gradient(135deg, #16213e, #1a1a3e);
  border: 2px solid #e94560;
  border-radius: 12px;
  padding: 32px;
  min-width: 320px;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
#modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #e94560;
  margin-bottom: 16px;
}
#modal-body {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 24px;
}
#modal-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.modal-btn {
  padding: 8px 20px;
  border: 1px solid #e94560;
  border-radius: 6px;
  background: transparent;
  color: #e94560;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}
.modal-btn:hover {
  background: #e94560;
  color: #fff;
}
.modal-btn.primary { background: #e94560; color: #fff; }
.modal-btn.gold { border-color: #ffd700; color: #ffd700; }
.modal-btn.gold:hover { background: #ffd700; color: #1a1a2e; }

/* ============================= */
/* ===== 移动端适配 ===== */
/* ============================= */

@media (max-width: 768px) {
  /* ---- 顶部栏：两行布局 ---- */
  #topbar {
    flex-direction: column;
    align-items: center;
    padding: 6px 10px 4px;
    gap: 4px;
  }
  .topbar-left {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }
  .topbar-left h1 {
    font-size: 1rem;
    letter-spacing: 1px;
  }
  #game-info {
    font-size: 0.75rem;
  }
  .topbar-right {
    width: 100%;
    justify-content: center;
    gap: 6px;
  }
  .stat-block {
    font-size: 0.78rem;
    padding: 2px 10px;
  }
  .level-badge {
    font-size: 0.78rem;
    padding: 2px 10px;
  }

  /* ---- 背包 ---- */
  #backpack {
    right: 6px;
    bottom: 6px;
    min-width: 140px;
    padding: 6px;
  }
  .bp-slot {
    width: 40px;
    height: 40px;
  }
  .bp-slot .bp-icon {
    font-size: 1rem;
  }
  .bp-header {
    font-size: 0.7rem;
  }

  /* ---- 模态框 ---- */
  #modal-content {
    padding: 20px;
    min-width: 0;
    max-width: 92vw;
    margin: 0 8px;
  }
  #modal-title {
    font-size: 1.05rem;
  }
  #modal-body {
    font-size: 0.9rem;
  }
  #modal-actions {
    flex-direction: column;
    gap: 8px;
  }
  #modal-actions .modal-btn {
    width: 100%;
    text-align: center;
  }

  /* ---- 提示浮窗 ---- */
  #tooltip {
    max-width: 92%;
    font-size: 0.85rem;
    padding: 8px 16px;
    bottom: 70px;
  }

  /* ---- 胜利标题 ---- */
  .win-title {
    font-size: 1.4rem;
  }

  /* ---- 密码输入框 ---- */
  #password-input {
    font-size: 1rem;
    letter-spacing: 4px;
  }

  /* ---- 商店 ---- */
  .shop-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .shop-buy-btn {
    width: 100%;
    text-align: center;
  }
}

/* 小屏手机 (< 400px) 额外收缩 */
@media (max-width: 400px) {
  #topbar {
    padding: 4px 6px 2px;
    gap: 2px;
  }
  .topbar-left h1 {
    font-size: 0.88rem;
  }
  #game-info {
    font-size: 0.65rem;
  }
  .stat-block {
    font-size: 0.65rem;
    padding: 1px 6px;
  }
  .level-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
  }
  .topbar-right {
    gap: 3px;
  }
  #backpack {
    right: 4px;
    bottom: 4px;
    min-width: 120px;
    padding: 4px;
  }
  .bp-slot {
    width: 34px;
    height: 34px;
  }
  .bp-slot .bp-icon {
    font-size: 0.85rem;
  }
}

/* ===== 密码输入 ===== */
#password-input {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 8px;
  background: #0d0d1a;
  border: 2px solid #e94560;
  border-radius: 6px;
  color: #fff;
  margin-bottom: 12px;
  outline: none;
}
#password-input:focus { border-color: #ff6b6b; }

/* ===== 胜利画面 ===== */
.win-title {
  font-size: 2rem;
  text-align: center;
  color: #ffd700;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.win-sub { text-align: center; color: #aaa; margin-top: 8px; }
.win-reward {
  text-align: center;
  color: #ffd700;
  margin-top: 12px;
  font-size: 1.1rem;
}

/* ===== 结算面板 ===== */
.reward-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.reward-table td { padding: 6px 12px; border-bottom: 1px solid #333; }
.reward-table td:last-child { text-align: right; color: #ffd700; }
