/* =====================================================
   🎮 像素圣诞动作守护战 — 复古高质感 UI
   ===================================================== */

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #090d24;
  font-family: "Microsoft YaHei", "PingFang SC", "Courier New", monospace;
  color: #f8fafc;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

.pixel-panel {
  background: rgba(15, 23, 48, 0.9);
  border: 3px solid #cbd5e1;
  box-shadow: 0 0 0 3px #0f172a, 0 6px 0 rgba(0, 0, 0, 0.45);
  border-radius: 4px;
}

/* 顶部 HUD */
#hudBar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  flex-wrap: wrap;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wave-badge {
  background: #b91c1c;
  border: 2px solid #fde047;
  color: #fef08a;
  font-size: 13px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 3px;
}

.tree-hp-box {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hp-label {
  font-size: 13px;
  font-weight: 800;
  color: #e2e8f0;
}

.hp-track {
  width: 110px;
  height: 14px;
  background: #1e293b;
  border: 2px solid #94a3b8;
  border-radius: 2px;
  overflow: hidden;
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: width 0.15s ease-out;
}

.stat-pill {
  font-size: 13px;
  color: #cbd5e1;
}

.stat-pill b {
  color: #fde047;
  font-size: 15px;
}

/* Boss 血条 */
.boss-bar-wrap {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  width: min(440px, calc(100% - 28px));
  padding: 8px 14px;
  border-color: #ef4444;
}

.boss-title {
  text-align: center;
  font-size: 14px;
  font-weight: 900;
  color: #fca5a5;
  margin-bottom: 5px;
  text-shadow: 1px 1px 0 #0f172a;
}

.boss-hp-track {
  width: 100%;
  height: 16px;
  background: #1e293b;
  border: 2px solid #f87171;
  overflow: hidden;
}

.boss-hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #dc2626, #f97316, #facc15);
  transition: width 0.12s linear;
}

/* 播报横幅 */
.banner-toast {
  position: absolute;
  top: 122px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.92), rgba(185, 28, 28, 0.92), rgba(15, 23, 42, 0.92));
  border-top: 3px solid #fde047;
  border-bottom: 3px solid #fde047;
  padding: 8px 24px;
  font-size: 15px;
  font-weight: 800;
  color: #fef08a;
  text-shadow: 2px 2px 0 #0f172a;
  white-space: nowrap;
  pointer-events: none;
}

/* 按钮 */
.pixel-btn {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  background: #3b82f6;
  border: 2px solid #e2e8f0;
  box-shadow: 0 3px 0 #0f172a;
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.08s, filter 0.12s;
}

.pixel-btn:hover { filter: brightness(1.1); }
.pixel-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0f172a; }

.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-weather { background: #4338ca; }
.btn-warm { background: #d97706; }
.btn-switch { background: #4f46e5; }
.btn-audio { background: #334155; }
.btn-gold { background: #eab308; color: #1e1b4b; }
.btn-ice { background: #0284c7; }
.btn-red { background: #e11d48; }
.btn-start {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  font-size: 16px;
  padding: 12px 28px;
}

.start-btn-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-chill {
  background: #1e293b;
  border-color: #93c5fd;
  color: #e0f2fe;
  font-size: 14px;
  padding: 12px 16px;
}

/* 底部控制区 & 大招按钮 */
.bottom-controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 22;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
}

.desktop-hint {
  pointer-events: none;
  background: rgba(15, 23, 42, 0.76);
  border: 2px solid rgba(203, 213, 225, 0.45);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  color: #e2e8f0;
}

.desktop-hint kbd {
  background: #334155;
  border: 1px solid #94a3b8;
  padding: 1px 5px;
  border-radius: 3px;
  color: #fde047;
  font-weight: 700;
}

.skill-cluster {
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.flash-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fef08a, #ca8a04);
  border: 3px solid #fff7ae;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.5), 0 4px 0 #0f172a;
  color: #1e1b4b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

.flash-btn.cooldown { filter: grayscale(0.75); }
.flash-icon { font-size: 18px; position: relative; z-index: 2; }
.flash-key { font-size: 10px; font-weight: 900; position: relative; z-index: 2; }

.diff-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.diff-label { font-size: 12px; color: #94a3b8; font-weight: 700; }

.diff-chip {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 800;
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 4px;
  color: #cbd5e1;
  cursor: pointer;
}

.diff-chip.selected {
  background: #991b1b;
  border-color: #fde047;
  color: #fef08a;
}

.skill-btn {
  pointer-events: auto;
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fde047, #ea580c);
  border: 4px solid #fff7ae;
  box-shadow: 0 0 18px rgba(253, 224, 71, 0.55), 0 5px 0 #0f172a;
  color: #1e1b4b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.08s;
}

.skill-btn:active {
  transform: scale(0.94);
}

.skill-btn.cooldown {
  filter: grayscale(0.75);
  box-shadow: 0 4px 0 #0f172a;
}

.skill-cd-mask {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: rgba(15, 23, 42, 0.72);
  pointer-events: none;
}

.skill-icon { font-size: 22px; position: relative; z-index: 2; }
.skill-name { font-size: 12px; font-weight: 900; position: relative; z-index: 2; }
.skill-key  { font-size: 10px; font-weight: 800; color: #fff; background: rgba(15,23,42,0.75); padding: 1px 6px; border-radius: 8px; position: relative; z-index: 2; }

/* 独立悬浮十字方向键（手机/触屏全模式常驻，避开底栏） */
.dpad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.floating-menu {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 28;
  padding: 6px 10px;
  font-size: 13px;
}

.modal-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.close-x {
  background: #334155;
  color: #fff;
  border: 2px solid #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-weight: 800;
  cursor: pointer;
}

.floating-top-right {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 28;
  display: flex;
  gap: 6px;
}

.floating-top-right .pixel-btn {
  padding: 6px 10px;
  font-size: 14px;
}

.floating-dpad {
  position: absolute;
  left: 14px;
  bottom: 76px;
  z-index: 26;
}

.dpad-mid { display: flex; gap: 32px; }

.dpad-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.56);
  border: 2px solid rgba(226, 232, 240, 0.6);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  color: #f8fafc;
  font-size: 16px;
  font-weight: 800;
  touch-action: none;
}

.dpad-btn:active {
  background: rgba(59, 130, 246, 0.85);
  transform: scale(0.95);
}

/* 庆祝模式快捷栏 */
.celebrate-bar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
  justify-content: center;
}

/* 弹窗 */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(7, 11, 26, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  padding: 20px;
  text-align: center;
  max-height: 92vh;
  overflow-y: auto;
}

.welcome-tag {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #93c5fd;
  font-weight: 800;
  margin-bottom: 6px;
}

.start-card h1 {
  font-size: 22px;
  color: #fef08a;
  text-shadow: 2px 2px 0 #0f172a;
  margin-bottom: 8px;
}

.start-desc {
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.65;
  margin-bottom: 14px;
}

/* 双玩法模式卡片 */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 12px;
}

.mode-card {
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 6px;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: transform 0.1s, border-color 0.15s;
}

.mode-card:hover { transform: translateY(-2px); border-color: #93c5fd; }

.mode-card.selected {
  background: #1e3a8a;
  border-color: #fde047;
  box-shadow: 0 0 10px rgba(253, 224, 71, 0.35);
}

.mc-title { font-size: 14px; font-weight: 800; color: #fef08a; }
.mc-desc { font-size: 11px; color: #cbd5e1; line-height: 1.4; }

/* 4 位英雄选择卡片 */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.hero-card {
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 6px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.12s, border-color 0.15s;
}

.hero-card:hover { transform: translateY(-3px); border-color: #93c5fd; }

.hero-card.selected {
  background: #312e81;
  border-color: #fde047;
  box-shadow: 0 0 12px rgba(253, 224, 71, 0.45);
}

.hero-card img {
  height: 68px;
  object-fit: contain;
  image-rendering: pixelated;
}

.hero-card .hc-name { font-size: 13px; font-weight: 800; color: #f8fafc; }
.hero-card .hc-skill { font-size: 11px; color: #fde047; font-weight: 700; }

.selected-skill-info {
  background: rgba(15, 23, 42, 0.75);
  border: 2px solid #475569;
  border-radius: 4px;
  padding: 9px 12px;
  font-size: 13px;
  color: #e2e8f0;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* 通关战绩祝福卡 */
.victory-card {
  background: linear-gradient(180deg, #271a3c, #121833);
  border-color: #fde047;
  text-align: left;
}

.victory-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.rank-stamp {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fde047, #f97316);
  border: 3px solid #fff7ae;
  color: #1e1b4b;
  font-size: 24px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(253, 224, 71, 0.5);
  flex-shrink: 0;
}

.victory-tag { font-size: 11px; font-weight: 800; color: #93c5fd; letter-spacing: 1px; }
.victory-top h2 { font-size: 20px; color: #fef08a; margin-top: 2px; }

.record-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.rec-item {
  background: rgba(15, 23, 42, 0.72);
  border: 2px solid #475569;
  padding: 8px;
  border-radius: 4px;
  text-align: center;
}

.rec-item span { display: block; font-size: 11px; color: #94a3b8; }
.rec-item b { font-size: 15px; color: #fde047; }

.letter-box {
  background: rgba(15, 23, 42, 0.65);
  border: 2px dashed rgba(253, 224, 71, 0.45);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.letter-to { font-size: 14px; font-weight: 800; color: #fca5a5; margin-bottom: 6px; }
.letter-body p { font-size: 13px; line-height: 1.75; color: #f1f5f9; margin-bottom: 8px; }
.letter-sign { text-align: right; font-size: 13px; font-weight: 800; color: #fde047; }

.wish-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(253, 224, 71, 0.35);
}

.wish-saved {
  font-size: 13px;
  font-weight: 800;
  color: #fde047;
  background: rgba(253, 224, 71, 0.12);
  border: 1px solid rgba(253, 224, 71, 0.4);
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 8px;
}

.wish-input-row {
  display: flex;
  gap: 8px;
}

.wish-input {
  flex: 1;
  background: #0f172a;
  border: 2px solid #64748b;
  border-radius: 4px;
  color: #f8fafc;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.wish-input:focus {
  border-color: #fde047;
}

.victory-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.defeat-badge {
  font-size: 22px;
  font-weight: 900;
  color: #fca5a5;
  margin-bottom: 10px;
}

.defeat-card p {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 16px;
}

@media (max-width: 900px), (pointer: coarse) {
  .desktop-hint { display: none; }
  .dpad { display: flex; }
}

@media (max-width: 768px) {
  #hudBar { padding: 5px 8px; gap: 6px; top: 6px; left: 6px; right: 6px; }
  .wave-badge { font-size: 11px; padding: 2px 6px; }
  .hp-label, .stat-pill { font-size: 11px; }
  .hp-track { width: 64px; height: 12px; }
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
  .skill-btn { width: 74px; height: 74px; }
  .flash-btn { width: 48px; height: 48px; }
  .celebrate-bar {
    bottom: 8px;
    left: 8px;
    right: 8px;
    transform: none;
    padding: 6px 8px;
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .celebrate-bar .pixel-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 8px;
    font-size: 11px;
  }
}

/* 手机横屏全屏专属紧凑布局 */
@media (max-height: 500px) {
  .modal-card { padding: 12px 14px; max-height: 94dvh; }
  .start-card h1 { font-size: 17px; margin-bottom: 4px; }
  .welcome-tag { display: none; }
  .mode-grid { margin: 6px 0 8px; }
  .mode-card { padding: 6px 8px; }
  .mc-title { font-size: 12px; }
  .mc-desc { font-size: 10px; }
  .hero-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 6px; }
  .hero-card { padding: 4px 2px; }
  .hero-card img { height: 42px; }
  .selected-skill-info { padding: 5px 8px; font-size: 11px; margin-bottom: 8px; }
  .btn-start, .btn-chill { padding: 7px 14px; font-size: 13px; }
  .floating-dpad { bottom: 14px; left: 12px; }
  .dpad-btn { width: 38px; height: 38px; font-size: 14px; }
  .dpad-mid { gap: 26px; }
  .skill-btn { width: 68px; height: 68px; }
  .flash-btn { width: 44px; height: 44px; }
  .celebrate-bar { bottom: 8px; padding: 5px 8px; gap: 5px; }
  .celebrate-bar .pixel-btn { padding: 4px 8px; font-size: 11px; }
}
