/* ===== 肉鴿倖存者 樣式 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f1a;
  --panel: rgba(18, 22, 40, 0.92);
  --panel-border: #2a3358;
  --accent: #ffd54a;
  --hp: #e5484d;
  --xp: #4aa8ff;
  --text: #e8ecff;
  --muted: #8a93bf;
  --atk: #ff7b54;
  --def: #4ad991;
  --util: #b98cff;
}

html, body {
  height: 100%;
  background: #05060c;
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

#game-root { position: relative; width: 100vw; height: 100vh; }

#game-canvas { display: block; width: 100%; height: 100%; background: var(--bg); }

.hidden { display: none !important; }

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

#hud-top {
  position: absolute; top: 0; left: 0; width: 100%;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}

/* 經驗條：貼齊最上緣、整條寬 */
#xp-bar-wrap {
  position: relative; width: 100%; height: 16px;
  background: rgba(0,0,0,0.6); border-bottom: 1px solid var(--panel-border); overflow: hidden;
}
#xp-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #2f7bd6, var(--xp)); transition: width 0.15s; }
#level-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000;
}
#timer { font-size: 30px; font-weight: 800; text-shadow: 0 2px 6px #000; letter-spacing: 2px; margin-top: 2px; }

#hud-left { position: absolute; top: 46px; left: 12px; width: 240px; display: flex; flex-direction: column; gap: 6px; }
#hp-bar-wrap {
  position: relative; width: 100%; height: 22px;
  background: rgba(0,0,0,0.5); border: 1px solid var(--panel-border); border-radius: 6px; overflow: hidden;
}
#hp-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #b3282c, var(--hp)); transition: width 0.1s; }
#hp-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000;
}
#stats-line { display: flex; gap: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
#stats-line span { text-shadow: 0 1px 2px #000; }

#loadout { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.slot {
  width: 34px; height: 34px; border-radius: 6px; background: rgba(0,0,0,0.45);
  border: 1px solid var(--panel-border); display: flex; align-items: center; justify-content: center;
  font-size: 18px; position: relative;
}
.slot .lv {
  position: absolute; bottom: -2px; right: 1px; font-size: 9px; font-weight: 800;
  color: var(--accent); text-shadow: 0 1px 2px #000;
}
.slot.passive { border-color: #445; }

/* ===== 手機浮動搖桿 ===== */
#joy-zone { position: absolute; inset: 0; z-index: 3; touch-action: none; }

#joy-base {
  position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none;
  width: 96px; height: 96px; margin-left: -48px; margin-top: -48px;
  border-radius: 50%; background: rgba(0,0,0,0.35); border: 2px solid var(--panel-border);
}
#joy-stick {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px;
  margin-left: -22px; margin-top: -22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c0, var(--accent));
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#mobile-pause-btn {
  position: absolute; top: 8px; right: 8px; z-index: 6; pointer-events: auto;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: rgba(18,22,40,0.75); border: 1px solid var(--panel-border); color: var(--text);
  font-size: 16px; display: flex; align-items: center; justify-content: center;
}

/* ===== Overlays ===== */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(5, 6, 14, 0.82); backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  text-align: center; padding: 24px; overflow-y: auto;
}
.overlay h1 { font-size: 52px; letter-spacing: 4px; text-shadow: 0 0 24px rgba(255,213,74,0.35); }
.overlay h2 { font-size: 30px; color: var(--accent); }
.subtitle { font-size: 18px; color: var(--muted); letter-spacing: 6px; margin-top: -10px; }
.hint { color: var(--muted); font-size: 15px; line-height: 1.9; }
.meta-hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

.section-label { font-size: 14px; color: var(--muted); letter-spacing: 3px; font-weight: 700; }

/* ===== 選角 ===== */
#char-select {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: min(760px, 94vw); max-height: 46vh; overflow-y: auto; padding: 4px;
}
.char-card {
  pointer-events: auto; cursor: pointer;
  width: 128px; padding: 12px 8px; text-align: center;
  background: var(--panel); border: 2px solid var(--panel-border); border-radius: 12px;
  display: flex; flex-direction: column; gap: 4px; transition: transform 0.08s, border-color 0.08s;
}
.char-card:hover { transform: translateY(-4px); border-color: #4a5788; }
.char-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(255,213,74,0.3);
  background: linear-gradient(180deg, rgba(60,48,10,0.4), var(--panel));
}
.char-card .cc-icon { font-size: 40px; line-height: 1; }
.char-card .cc-name { font-size: 16px; font-weight: 800; }
.char-card .cc-weapon { font-size: 12px; color: var(--xp); font-weight: 600; }
.char-card .cc-trait { font-size: 11px; color: var(--muted); line-height: 1.5; }

.big-btn {
  pointer-events: auto; cursor: pointer;
  padding: 14px 42px; font-size: 20px; font-weight: 800;
  color: #1a1400; background: linear-gradient(180deg, #ffe27a, var(--accent));
  border: none; border-radius: 12px; box-shadow: 0 6px 0 #b8951f, 0 10px 24px rgba(0,0,0,0.5);
  transition: transform 0.06s, box-shadow 0.06s;
}
.big-btn:hover { transform: translateY(2px); box-shadow: 0 4px 0 #b8951f, 0 8px 18px rgba(0,0,0,0.5); }
.big-btn:active { transform: translateY(6px); box-shadow: 0 0 0 #b8951f; }

/* ===== 升級卡 ===== */
#card-row { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.card {
  pointer-events: auto; cursor: pointer;
  width: 210px; min-height: 240px; padding: 18px 16px;
  background: var(--panel); border: 2px solid var(--panel-border); border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  transition: transform 0.08s, border-color 0.08s, box-shadow 0.08s;
}
.card:hover { transform: translateY(-6px); border-color: var(--accent); box-shadow: 0 12px 30px rgba(0,0,0,0.55); }
.card .card-icon { font-size: 46px; line-height: 1; margin-top: 6px; }
.card .card-name { font-size: 19px; font-weight: 800; }
.card .card-tag {
  font-size: 11px; font-weight: 800; padding: 2px 10px; border-radius: 20px; letter-spacing: 1px;
}
.card .card-tag.atk { background: rgba(255,123,84,0.18); color: var(--atk); }
.card .card-tag.def { background: rgba(74,217,145,0.18); color: var(--def); }
.card .card-tag.util { background: rgba(185,140,255,0.18); color: var(--util); }
.card .card-desc { font-size: 13px; color: var(--muted); line-height: 1.6; }
.card .card-lv { font-size: 12px; color: var(--accent); font-weight: 700; margin-top: auto; }

/* 稀有度左邊條 */
.card.rare-common  { border-left: 6px solid #6b7391; }
.card.rare-rare    { border-left: 6px solid #4aa8ff; }
.card.rare-epic    { border-left: 6px solid #b98cff; }
.card.rare-evo     { border: 2px solid var(--accent); border-left: 6px solid var(--accent);
                     box-shadow: 0 0 24px rgba(255,213,74,0.35); background: linear-gradient(180deg, rgba(60,48,10,0.55), var(--panel)); }
.card-tag.evo      { background: rgba(255,213,74,0.2); color: var(--accent); }

/* ===== 次要按鈕 ===== */
.ghost-btn {
  pointer-events: auto; cursor: pointer;
  padding: 10px 26px; font-size: 15px; font-weight: 700;
  color: var(--text); background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border); border-radius: 10px; transition: background 0.1s;
}
.ghost-btn:hover { background: rgba(255,255,255,0.14); }

/* ===== 商店 ===== */
.shop-gold { font-size: 20px; color: var(--text); }
.shop-gold b { color: var(--accent); }
#shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px; width: min(760px, 94vw); max-height: 58vh; overflow-y: auto; padding: 4px;
}
.shop-item {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column; gap: 6px; text-align: left;
}
.shop-item .si-head { display: flex; align-items: center; gap: 8px; }
.shop-item .si-icon { font-size: 26px; }
.shop-item .si-name { font-size: 17px; font-weight: 800; }
.shop-item .si-desc { font-size: 13px; color: var(--muted); }
.shop-item .si-pips { display: flex; gap: 3px; margin: 2px 0; }
.shop-item .pip { width: 14px; height: 8px; border-radius: 2px; background: rgba(255,255,255,0.12); }
.shop-item .pip.on { background: var(--accent); }
.shop-item .si-buy {
  pointer-events: auto; cursor: pointer; margin-top: 4px;
  padding: 8px; font-size: 14px; font-weight: 800; border-radius: 8px; border: none;
  color: #1a1400; background: linear-gradient(180deg, #ffe27a, var(--accent));
}
.shop-item .si-buy:disabled { cursor: not-allowed; filter: grayscale(0.8) brightness(0.7); color: #888; }
.shop-item.maxed { opacity: 0.75; }
.shop-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.shop-note { font-size: 12px; color: var(--muted); max-width: 620px; line-height: 1.7; }
.shop-note b { color: var(--accent); }

#gameover-stats { font-size: 18px; line-height: 2.1; color: var(--text); }
#gameover-stats b { color: var(--accent); }

@media (max-width: 520px) {
  .overlay h1 { font-size: 38px; }
  .card { width: 150px; min-height: 200px; }
}
