/* 怪物弹珠 - 游戏样式 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700;900&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background: #0a0010;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  font-family: 'Noto Sans SC', 'PingFang SC', sans-serif;
}

#app {
  position: relative;
  width: 480px;
  height: 800px;
}

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

/* 背景星星动画 */
#starfield {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* UI 覆盖层 */
#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* 标题屏幕 */
#title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1a0030 0%, #060010 100%);
  z-index: 100;
  gap: 24px;
}

.title-logo {
  text-align: center;
}

.title-logo h1 {
  font-size: 52px;
  font-weight: 900;
  background: linear-gradient(135deg, #ff9a3c, #ff4f8b, #c478ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(200, 100, 255, 0.5));
  letter-spacing: 4px;
}

.title-logo p {
  color: #9966cc;
  font-size: 16px;
  margin-top: 8px;
  letter-spacing: 2px;
}

.title-monsters {
  display: flex;
  gap: 16px;
}

.title-monster-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
  animation: float 3s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(150, 100, 255, 0.4);
}

.title-monster-icon:nth-child(2) { animation-delay: 0.5s; }
.title-monster-icon:nth-child(3) { animation-delay: 1s; }
.title-monster-icon:nth-child(4) { animation-delay: 1.5s; }

.title-monster-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.btn-start {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: white;
  border: none;
  padding: 16px 48px;
  font-size: 20px;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  pointer-events: all;
  letter-spacing: 2px;
  box-shadow: 0 0 30px rgba(150, 50, 255, 0.5), 0 4px 15px rgba(0,0,0,0.5);
  transition: all 0.2s;
  font-family: 'Noto Sans SC', sans-serif;
  animation: pulse-btn 2s ease-in-out infinite;
}

.btn-start:hover {
  transform: scale(1.05);
  box-shadow: 0 0 50px rgba(200, 100, 255, 0.7), 0 4px 20px rgba(0,0,0,0.5);
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 0 30px rgba(150, 50, 255, 0.5), 0 4px 15px rgba(0,0,0,0.5); }
  50% { box-shadow: 0 0 50px rgba(200, 100, 255, 0.8), 0 4px 20px rgba(0,0,0,0.5); }
}

.title-info {
  color: rgba(180, 140, 255, 0.7);
  font-size: 13px;
  text-align: center;
  line-height: 1.8;
}

/* 胜利/失败屏幕 */
#result-screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 20px;
}

#result-screen.show { display: flex; }

.result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.result-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.result-title {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px currentColor);
}

.result-title.win { color: #fbbf24; }
.result-title.lose { color: #ef4444; }

.result-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 16px;
  margin-bottom: 32px;
}

.btn-retry {
  background: linear-gradient(135deg, #059669, #0284c7);
  color: white;
  border: none;
  padding: 14px 40px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  pointer-events: all;
  letter-spacing: 2px;
  box-shadow: 0 0 20px rgba(5, 150, 105, 0.4);
  transition: all 0.2s;
  font-family: 'Noto Sans SC', sans-serif;
}

.btn-retry:hover { transform: scale(1.05); }

/* 响应式适配 */
@media (max-height: 820px) {
  #app {
    transform-origin: top center;
    transform: scale(0.9);
  }
}

@media (max-width: 500px) {
  #app {
    width: 100vw;
    height: 100vh;
    transform: none;
  }
  #gameCanvas {
    width: 100%;
    height: 100%;
  }
}

/* ===== 主菜单 ===== */
#menu-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 20%, #1a0a00 0%, #07030a 100%);
  gap: 18px; z-index: 100; padding: 20px;
}
.menu-logo h1 {
  font-size: 48px; font-weight: 900; text-align: center;
  background: linear-gradient(135deg, #ffe066, #ff8800, #cc4400);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 18px rgba(255,160,0,0.6)); letter-spacing: 4px;
}
.menu-logo p { color: #cc8844; font-size: 14px; text-align: center; margin-top: 4px; letter-spacing: 2px; }
.menu-info { text-align: center; }
.menu-player-name { font-size: 22px; font-weight: 700; color: #ffe066; }
.menu-stage-info, .menu-hero-count { font-size: 13px; color: rgba(200,160,80,0.8); margin-top: 4px; }
.menu-heroes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.menu-hero-icon {
  width: 56px; height: 56px; border-radius: 50%; overflow: hidden;
  border: 2px solid #cc8844; box-shadow: 0 0 12px rgba(200,140,0,0.4);
  animation: float 3s ease-in-out infinite; background: #1a0a00;
  display: flex; align-items: center; justify-content: center; color: #ffe066; font-size: 18px;
}
.menu-hero-icon:nth-child(2){animation-delay:.4s}
.menu-hero-icon:nth-child(3){animation-delay:.8s}
.menu-hero-icon:nth-child(4){animation-delay:1.2s}
.menu-hero-icon:nth-child(5){animation-delay:1.6s}
.menu-hero-icon img { width: 100%; height: 100%; object-fit: cover; }
.menu-hint { color: rgba(200,160,80,0.5); font-size: 12px; text-align: center; }
.btn-primary {
  background: linear-gradient(135deg, #cc6600, #8a3300);
  color: #ffe066; border: none; padding: 14px 44px; font-size: 18px; font-weight: 700;
  border-radius: 50px; cursor: pointer; letter-spacing: 2px; width: 220px;
  box-shadow: 0 0 24px rgba(200,120,0,0.5), 0 4px 12px rgba(0,0,0,0.5);
  transition: all .2s; font-family: 'Noto Sans SC', sans-serif;
  animation: pulse-btn 2s ease-in-out infinite;
}
.btn-primary:hover { transform: scale(1.05); }
.btn-secondary {
  background: rgba(60,30,0,0.7); color: #cc8844; border: 1.5px solid #cc6600;
  padding: 11px 44px; font-size: 16px; font-weight: 700; border-radius: 50px;
  cursor: pointer; letter-spacing: 2px; width: 220px; transition: all .2s;
  font-family: 'Noto Sans SC', sans-serif;
}
.btn-secondary:hover { background: rgba(100,50,0,0.8); }

/* ===== 游戏界面 ===== */
#game-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: stretch;
}
#gameCanvas {
  display: block;
  flex: 1;
  width: 100%;
  touch-action: none;
  min-height: 0;
}
/* 底部工具栏：返回按鈕，独立在 canvas 下方 */
.game-toolbar {
  display: flex; align-items: center; justify-content: flex-start;
  height: 40px; padding: 0 12px;
  background: rgba(5,2,10,0.95);
  border-top: 1px solid rgba(200,140,0,0.2);
  flex-shrink: 0;
}
.btn-back {
  background: rgba(60,30,0,0.85);
  color: #cc8844; border: 1px solid #cc6600; padding: 5px 14px;
  font-size: 12px; border-radius: 16px; cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  transition: background .2s;
}
.btn-back:hover { background: rgba(100,50,0,0.9); }

/* ===== 阵容管理界面 ===== */
#roster-screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #07030a 0%, #0d0500 100%);
  z-index: 100; overflow-y: auto; padding: 0 0 16px;
}
.roster-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid rgba(200,140,0,0.2);
}
.roster-header h2 { font-size: 20px; font-weight: 700; color: #ffe066; }
.roster-slots-section { padding: 12px 16px 0; }
.section-label { font-size: 13px; color: rgba(200,140,80,0.7); margin-bottom: 10px; padding: 0 16px; }
.roster-slots { display: flex; gap: 10px; justify-content: center; padding: 0 16px; }
.roster-slot {
  width: 74px; height: 88px; border-radius: 10px; border: 2px dashed rgba(200,160,0,0.3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; background: rgba(20,10,0,0.5);
  overflow: hidden; gap: 4px;
}
.roster-slot:hover { border-style: solid; background: rgba(40,20,0,0.7); }
.roster-slot img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; }
.slot-name { font-size: 11px; color: #ffe066; text-align: center; font-weight: 600; }
.slot-empty { font-size: 24px; color: rgba(200,160,0,0.25); font-weight: 300; }
.roster-detail {
  margin: 12px 16px; padding: 14px; border-radius: 12px; min-height: 120px;
  background: rgba(20,10,0,0.6); border: 1px solid rgba(200,140,0,0.2);
}
.detail-hint { color: rgba(200,160,80,0.4); text-align: center; padding: 24px 0; font-size: 13px; }
.detail-name { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.detail-title { font-size: 12px; color: rgba(200,160,80,0.7); margin-bottom: 6px; }
.detail-desc  { font-size: 12px; color: rgba(255,255,255,0.7); margin-bottom: 8px; line-height: 1.5; }
.detail-stats { display: flex; gap: 16px; font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 10px; }
.detail-skills { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.skill-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px;
  background: rgba(0,0,0,0.3); border-left: 3px solid currentColor;
}
.skill-badge { font-size: 10px; padding: 2px 5px; border-radius: 4px; font-weight: 700; white-space: nowrap; }
.active-badge { background: rgba(255,140,0,0.3); color: #ffaa44; }
.friend-badge { background: rgba(100,200,100,0.3); color: #66dd88; }
.skill-name { font-size: 13px; font-weight: 700; color: #fff; flex: 1; }
.skill-lv   { font-size: 11px; font-weight: 700; white-space: nowrap; }
.skill-desc { font-size: 10px; color: rgba(255,255,255,0.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.btn-add-roster, .btn-remove-roster {
  width: 100%; padding: 8px; border-radius: 8px; font-size: 14px; font-weight: 700;
  cursor: pointer; border: none; font-family: 'Noto Sans SC', sans-serif; transition: all .2s;
}
.btn-add-roster    { background: linear-gradient(135deg, #cc6600, #8a3300); color: #ffe066; }
.btn-remove-roster { background: rgba(60,20,0,0.6); color: #cc4444; border: 1px solid #cc4444; }
.roster-hero-list {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 0 16px;
}
.roster-hero-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border-radius: 10px; border: 2px solid #444;
  background: rgba(20,10,0,0.5); cursor: pointer; transition: all .2s; position: relative;
}
.roster-hero-card:hover { background: rgba(60,30,0,0.7); }
.roster-hero-card.selected { background: rgba(80,40,0,0.8); box-shadow: 0 0 12px currentColor; }
.roster-hero-card.locked { opacity: 0.4; cursor: default; }
.roster-hero-card img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.2); }
.roster-hero-name   { font-size: 11px; font-weight: 700; text-align: center; line-height: 1.2; }
.roster-hero-rarity { font-size: 10px; text-align: center; }
.roster-lock { position: absolute; top: 4px; right: 4px; font-size: 14px; }
