/* ========================================
   切水果游戏 - PixiJS 版样式
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f0f1a;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* ---- 竖屏时强制视觉横屏（兼容微信等内置浏览器） ---- */
@media (orientation: portrait) and (max-width: 900px) {
  html {
    width: 100vh;
    height: 100vw;
    overflow: hidden;
  }
  body {
    width: 100vh;
    height: 100vw;
    transform: rotate(90deg);
    transform-origin: top left;
    position: absolute;
    top: 0;
    left: 100vw;
    overflow: hidden;
  }
}

/* PixiJS canvas（由 JS 插入 body） */
canvas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  display: block;
}

/* ========================================
   HUD 信息栏
   ======================================== */
.game-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(15, 15, 26, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.hud-center {
  display: flex;
  align-items: center;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-value {
  font-size: 24px;
  font-weight: bold;
  color: #4ecca3;
  line-height: 1;
}

.hud-combo {
  color: #ffd700;
  font-size: 20px;
  transition: transform 0.15s ease;
}

.hud-combo.pulse {
  animation: comboPulse 0.3s ease;
}

.hud-highscore {
  color: #ffd700;
}

/* 模式显示 */
.hud-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(255, 107, 107, 0.15);
  border-radius: 20px;
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.mode-icon {
  font-size: 18px;
}

.mode-name {
  font-size: 13px;
  font-weight: 600;
  color: #ff6b6b;
}

.mode-timer {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  background: #ff6b6b;
  padding: 3px 10px;
  border-radius: 12px;
  min-width: 40px;
  text-align: center;
}

.mode-timer.warning {
  animation: timerFlash 0.5s infinite;
  background: #e74c3c;
}

/* HUD 按钮 */
.hud-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(0);
}

.hud-btn-home {
  background: rgba(231, 76, 60, 0.3);
  border: 1px solid rgba(231, 76, 60, 0.4);
}

.hud-btn-home:hover {
  background: rgba(231, 76, 60, 0.5);
}

/* ========================================
   游戏覆盖层（开始/暂停/结束）
   ======================================== */
.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 15, 26, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  overflow-y: auto;
}

.game-overlay.hidden {
  display: none !important;
}

/* 覆盖层内容 */
.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  gap: 16px;
}

.overlay-title {
  font-size: 42px;
  font-weight: bold;
  color: #ff6b6b;
  text-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
  text-align: center;
  line-height: 1.2;
}

.overlay-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  line-height: 1.6;
}

.overlay-subtitle ul {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

.overlay-subtitle li {
  margin: 6px 0;
  font-size: 13px;
}

.overlay-score {
  font-size: 28px;
  color: #ffd700;
  text-align: center;
  font-weight: bold;
}

/* 覆盖层按钮 */
.overlay-btn {
  padding: 14px 40px;
  font-size: 17px;
  background: #ff6b6b;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
  min-width: 200px;
  text-align: center;
}

.overlay-btn:hover {
  background: #ff5252;
  transform: scale(1.04);
}

.overlay-btn:active {
  transform: scale(0.98);
}

.overlay-btn.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.overlay-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.25);
}

.overlay-btn.arcade {
  background: #4ecca3;
  color: #1a1a2e;
}

.overlay-btn.arcade:hover {
  background: #45b08c;
}

/* 模式选择卡片 */
/* 模式选择：默认左右并排（横屏/视觉横屏） */
.mode-selection {
  display: flex;
  flex-direction: row;
  gap: 16px;
  margin-top: 12px;
  justify-content: center;
}

.mode-card {
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.25s ease;
  width: 260px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

/* 真正的横屏设备（非 CSS 旋转）：左右并排 */
@media (min-aspect-ratio: 1/1) {
  .mode-selection {
    flex-direction: row;
  }
}

/* 竖屏设备（但会被 CSS 旋转成视觉横屏）：也是左右并排，因为旋转后实际是横屏 */

.mode-card:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(4px);
}

.mode-card.classic:hover {
  border-color: #ff6b6b;
}

.mode-card.arcade:hover {
  border-color: #4ecca3;
}

.mode-card-icon {
  font-size: 42px;
  flex-shrink: 0;
}

.mode-card-content {
  flex: 1;
  min-width: 0;
}

.mode-card-title {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 4px;
  white-space: nowrap;
}

.mode-card-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
}

/* 操作说明 */
.controls-info {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-icon {
  font-size: 22px;
  line-height: 1;
}

.control-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   开始界面 - 最高分显示
   ======================================== */
.highscore-display {
  font-size: 16px;
  color: #ffd700;
  text-align: center;
  padding: 8px 20px;
  background: rgba(255, 215, 0, 0.08);
  border-radius: 20px;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.highscore-display .hs-value {
  font-weight: bold;
  font-size: 20px;
  margin-left: 4px;
}

/* ========================================
   游戏结束 - 分数展示
   ======================================== */
.gameover-reason {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  margin-bottom: 4px;
}

.gameover-scores {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  min-width: 220px;
}

.gameover-score-item {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: center;
}

.gameover-score-label {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
}

.gameover-score-value {
  font-size: 28px;
  font-weight: bold;
  color: #ffd700;
}

.gameover-score-value.new-record {
  color: #ff6b6b;
  text-shadow: 0 0 12px rgba(255, 107, 107, 0.6);
  animation: recordPulse 0.6s ease infinite alternate;
}

.new-record-banner {
  font-size: 20px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 16px rgba(255, 215, 0, 0.7);
  animation: recordPulse 0.6s ease infinite alternate;
  text-align: center;
  margin-bottom: 4px;
}

@keyframes recordPulse {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.08); opacity: 1; }
}

/* ========================================
   连击弹出动画
   ======================================== */
.combo-popup {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  font-size: 36px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.8), 0 2px 4px rgba(0,0,0,0.5);
  opacity: 0;
}

.combo-popup.show {
  animation: comboFloat 0.8s ease-out forwards;
}

@keyframes comboFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.8);
  }
  40% {
    opacity: 1;
    transform: translateY(-20px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-60px) scale(1);
  }
}

@keyframes comboPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

@keyframes timerFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   移动端提示
   ======================================== */
.mobile-hint {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   暂停指示器
   ======================================== */
.pause-indicator {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 150;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.3);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  color: #ffd700;
  display: none;
}

.pause-indicator.visible {
  display: block;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 768px) {
  .game-hud {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .hud-left {
    gap: 12px;
  }

  .hud-value {
    font-size: 18px;
  }

  .hud-label {
    font-size: 10px;
  }

  .hud-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .hud-right {
    gap: 8px;
  }

  .overlay-title {
    font-size: 32px;
  }

  .mode-selection {
    flex-direction: row;
    justify-content: center;
  }

  .mode-card {
    width: 220px;
  }

  .controls-info {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
}

@media (max-width: 600px) {
  .mobile-hint {
    display: block;
  }

  .hud-center {
    order: -1;
    width: 100%;
    justify-content: center;
  }

  .game-hud {
    justify-content: center;
  }
}

/* 横屏优化 */
@media (orientation: landscape) and (max-height: 500px) {
  .game-hud {
    padding: 4px 12px;
  }

  .hud-value {
    font-size: 16px;
  }

  .hud-label {
    font-size: 9px;
  }

  .overlay-title {
    font-size: 28px;
  }

  .overlay-btn {
    padding: 10px 30px;
    font-size: 15px;
  }

  .mode-card {
    padding: 12px;
    min-width: 150px;
  }
}
