/* ============================================
   像素格斗 - 全局样式
   ============================================ */

/* --- CSS 变量 --- */
:root {
  --bg-dark: #1a1a2e;
  --bg-mid: #16213e;
  --bg-light: #0f3460;
  --neon-purple: #e94560;
  --neon-cyan: #00d4ff;
  --neon-green: #39ff14;
  --neon-yellow: #f0e68c;
  --white: #f0f0f0;
  --gray: #666;
  --dark-gray: #333;
  --black: #0a0a0a;
  --pixel-size: 4px;
  --font-pixel: 'Press Start 2P', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--black);
  font-family: var(--font-pixel);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

/* --- 游戏容器 --- */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
}

/* --- Canvas 背景 --- */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* --- 屏幕层 --- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   开始菜单
   ============================================ */
#menu-screen {
  padding: 20px;
}

.menu-title-area {
  text-align: center;
  margin-bottom: 40px;
}

.menu-title {
  font-size: 28px;
  color: var(--neon-purple);
  text-shadow:
    0 0 10px var(--neon-purple),
    0 0 20px var(--neon-purple),
    0 0 40px var(--neon-purple);
  animation: titleGlow 2s ease-in-out infinite;
  letter-spacing: 8px;
  line-height: 1.5;
}

.menu-subtitle {
  font-size: 10px;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan);
  letter-spacing: 6px;
  margin-top: 8px;
  opacity: 0.8;
}

@keyframes titleGlow {
  0%, 100% {
    text-shadow:
      0 0 10px var(--neon-purple),
      0 0 20px var(--neon-purple),
      0 0 40px var(--neon-purple);
  }
  50% {
    text-shadow:
      0 0 20px var(--neon-purple),
      0 0 40px var(--neon-purple),
      0 0 60px var(--neon-purple),
      0 0 80px var(--neon-cyan);
  }
}

/* 标题装饰像素线 */
.menu-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.menu-divider::before,
.menu-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--neon-cyan) 0px,
    var(--neon-cyan) 4px,
    transparent 4px,
    transparent 8px
  );
}

.menu-divider-icon {
  color: var(--neon-cyan);
  font-size: 12px;
  animation: blinker 1s step-end infinite;
}

@keyframes blinker {
  50% { opacity: 0; }
}

/* 菜单按钮 */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 320px;
}

.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 12px;
  padding: 16px 24px;
  border: none;
  cursor: pointer;
  position: relative;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 3px;
  background: var(--bg-mid);
  outline: none;
  transition: all 0.1s ease;
  /* 像素边框效果 */
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
}

.pixel-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--neon-cyan);
  opacity: 0.3;
  clip-path: inherit;
  transition: opacity 0.2s;
}

.pixel-btn:hover::before,
.pixel-btn:active::before {
  opacity: 1;
}

.pixel-btn:hover {
  background: var(--bg-light);
  transform: scale(1.03);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.pixel-btn:active {
  transform: scale(0.97);
  transition: transform 0.05s;
}

.pixel-btn.accent {
  background: var(--neon-purple);
  animation: pulseBtn 2s ease-in-out infinite;
}

.pixel-btn.accent::before {
  border-color: var(--neon-yellow);
}

@keyframes pulseBtn {
  0%, 100% { box-shadow: 0 0 10px rgba(233, 69, 96, 0.4); }
  50% { box-shadow: 0 0 25px rgba(233, 69, 96, 0.7); }
}

.pixel-btn.secondary {
  background: transparent;
  border: 2px solid var(--gray);
}

.pixel-btn.secondary:hover {
  border-color: var(--neon-cyan);
  background: rgba(0, 212, 255, 0.1);
}

/* 底部信息 */
.menu-footer {
  position: absolute;
  bottom: 20px;
  text-align: center;
  font-size: 7px;
  color: var(--gray);
  letter-spacing: 2px;
  opacity: 0.6;
}

/* ============================================
   弹窗（存档管理 / 设置）
   ============================================ */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  background: rgba(10, 10, 10, 0.85);
  overflow-y: auto;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-header {
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 20px;
}

.modal-title {
  font-size: 14px;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
  letter-spacing: 4px;
}

.back-btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--gray);
  background: none;
  border: 2px solid var(--gray);
  padding: 8px 16px;
  cursor: pointer;
  clip-path: polygon(
    3px 0, calc(100% - 3px) 0,
    100% 3px, 100% calc(100% - 3px),
    calc(100% - 3px) 100%, 3px 100%,
    0 calc(100% - 3px), 0 3px
  );
  transition: all 0.2s;
}

.back-btn:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}

/* --- 存档槽位 --- */
.save-slots {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.save-slot {
  background: var(--bg-mid);
  padding: 16px;
  border: 2px solid var(--dark-gray);
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
  transition: border-color 0.2s, box-shadow 0.2s;
}

.save-slot.active {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.save-slot.empty {
  opacity: 0.5;
}

.slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slot-number {
  font-size: 9px;
  color: var(--neon-yellow);
  letter-spacing: 2px;
}

.slot-status {
  font-size: 8px;
  color: var(--neon-green);
}

.slot-body {
  margin-bottom: 10px;
}

.slot-name {
  font-size: 11px;
  color: var(--white);
  margin-bottom: 4px;
  letter-spacing: 2px;
}

.slot-info {
  font-size: 8px;
  color: var(--gray);
  letter-spacing: 1px;
}

.slot-progress-bar {
  height: 8px;
  background: var(--dark-gray);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.slot-progress-fill {
  height: 100%;
  background: var(--neon-green);
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--neon-green);
}

.slot-actions {
  display: flex;
  gap: 10px;
}

.slot-btn {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 8px 12px;
  border: none;
  cursor: pointer;
  color: var(--white);
  letter-spacing: 1px;
  clip-path: polygon(
    3px 0, calc(100% - 3px) 0,
    100% 3px, 100% calc(100% - 3px),
    calc(100% - 3px) 100%, 3px 100%,
    0 calc(100% - 3px), 0 3px
  );
  transition: all 0.15s;
  flex: 1;
  text-align: center;
}

.load-btn {
  background: var(--bg-light);
}

.load-btn:hover {
  background: var(--neon-cyan);
  color: var(--black);
}

.save-btn {
  background: var(--neon-purple);
}

.save-btn:hover {
  box-shadow: 0 0 15px rgba(233, 69, 96, 0.5);
}

.delete-btn {
  background: var(--dark-gray);
}

.delete-btn:hover {
  background: #cc3333;
}

.empty-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.slot-empty-icon {
  font-size: 20px;
  color: var(--gray);
  margin-bottom: 4px;
  font-family: var(--font-pixel);
}

.slot-empty-text {
  font-size: 9px;
  color: var(--gray);
  letter-spacing: 2px;
}

/* ============================================
   设置
   ============================================ */
.settings-content {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 10px;
  color: var(--white);
  letter-spacing: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-value {
  font-size: 9px;
  color: var(--neon-cyan);
}

/* 像素滑块 */
.pixel-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  background: var(--dark-gray);
  outline: none;
  clip-path: polygon(
    3px 0, calc(100% - 3px) 0,
    100% 3px, 100% calc(100% - 3px),
    calc(100% - 3px) 100%, 3px 100%,
    0 calc(100% - 3px), 0 3px
  );
}

.pixel-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--neon-cyan);
  cursor: pointer;
  clip-path: polygon(
    3px 0, calc(100% - 3px) 0,
    100% 3px, 100% calc(100% - 3px),
    calc(100% - 3px) 100%, 3px 100%,
    0 calc(100% - 3px), 0 3px
  );
  box-shadow: 0 0 10px var(--neon-cyan);
}

.pixel-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--neon-cyan);
  border: none;
  cursor: pointer;
  clip-path: polygon(
    3px 0, calc(100% - 3px) 0,
    100% 3px, 100% calc(100% - 3px),
    calc(100% - 3px) 100%, 3px 100%,
    0 calc(100% - 3px), 0 3px
  );
}

/* ============================================
   Toast 提示
   ============================================ */
#toast {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--white);
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid var(--neon-cyan);
  padding: 12px 24px;
  letter-spacing: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
  text-align: center;
  max-width: 90%;
}

#toast.show {
  opacity: 1;
}

/* ============================================
   战斗界面
   ============================================ */
.battle-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.battle-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.battle-back-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 20;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--gray);
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid var(--gray);
  padding: 6px 12px;
  cursor: pointer;
  clip-path: polygon(
    3px 0, calc(100% - 3px) 0,
    100% 3px, 100% calc(100% - 3px),
    calc(100% - 3px) 100%, 3px 100%,
    0 calc(100% - 3px), 0 3px
  );
  transition: all 0.2s;
}

.battle-back-btn:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}

/* 触控按钮区域 */
.battle-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 8px 12px 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7) 30%);
}

.battle-controls-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.battle-btn {
  font-family: var(--font-pixel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid;
  cursor: pointer;
  padding: 10px 6px;
  min-width: 64px;
  min-height: 56px;
  transition: all 0.08s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
}

.battle-btn:active {
  transform: scale(0.9);
}

.battle-btn-icon {
  font-size: 16px;
  margin-bottom: 3px;
  font-family: sans-serif;
}

.battle-btn-label {
  font-size: 8px;
  letter-spacing: 1px;
}

/* 攻击按钮 */
.attack-btn {
  background: rgba(233, 69, 96, 0.3);
  border-color: var(--neon-purple);
  color: var(--white);
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
}

.attack-btn:active {
  background: rgba(233, 69, 96, 0.7);
  box-shadow: 0 0 20px rgba(233, 69, 96, 0.6);
}

/* 防御按钮 */
.defend-btn {
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--neon-cyan);
  color: var(--white);
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
}

.defend-btn:active {
  background: rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
}

/* 跳跃按钮 */
.jump-btn {
  background: rgba(57, 255, 20, 0.2);
  border-color: var(--neon-green);
  color: var(--white);
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
}

.jump-btn:active {
  background: rgba(57, 255, 20, 0.5);
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.6);
}

/* 冲刺按钮 */
.dash-btn {
  background: rgba(240, 230, 140, 0.2);
  border-color: var(--neon-yellow);
  color: var(--white);
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
}

.dash-btn:active {
  background: rgba(240, 230, 140, 0.5);
  box-shadow: 0 0 20px rgba(240, 230, 140, 0.6);
}

/* 大招按钮 */
.ultimate-btn {
  background: rgba(155, 89, 182, 0.3);
  border-color: #9b59b6;
  color: var(--white);
  min-width: 80px;
  min-height: 48px;
  padding: 8px 24px;
  clip-path: polygon(
    4px 0, calc(100% - 4px) 0,
    100% 4px, 100% calc(100% - 4px),
    calc(100% - 4px) 100%, 4px 100%,
    0 calc(100% - 4px), 0 4px
  );
  animation: ultimatePulse 2s ease-in-out infinite;
}

.ultimate-btn:active {
  background: rgba(155, 89, 182, 0.7);
  box-shadow: 0 0 25px rgba(155, 89, 182, 0.7);
}

@keyframes ultimatePulse {
  0%, 100% { box-shadow: 0 0 8px rgba(155, 89, 182, 0.3); }
  50% { box-shadow: 0 0 20px rgba(155, 89, 182, 0.6); }
}

/* ============================================
   响应式 - 桌面端居中模拟手机
   ============================================ */
@media (min-width: 481px) {
  #game-container {
    border-left: 4px solid var(--dark-gray);
    border-right: 4px solid var(--dark-gray);
    box-shadow: 0 0 60px rgba(0, 212, 255, 0.1);
  }
}

/* 横屏适配 */
@media (orientation: landscape) and (max-height: 500px) {
  .menu-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .pixel-btn {
    font-size: 9px;
    padding: 10px 16px;
  }

  .menu-title {
    font-size: 22px;
  }

  .menu-title-area {
    margin-bottom: 16px;
  }
}