/* ===== H5 游戏平台 - 通用自适应基础样式 ===== */
/* 适用于所有游戏页面，确保手机浏览器完整显示 */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  width: 100%;
  height: 100%;
  /* 使用 dvh 确保在移动浏览器地址栏变化时正确显示 */
  height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--game-bg, #0f0f1a);
  color: var(--game-text, #ffffff);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
  /* 防止iOS Safari地址栏影响布局 */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.game-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* 头部 - 紧凑布局，最高 8vh */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: min(10px, 2vh) min(15px, 3vw);
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  min-height: 40px;
}

.back-btn {
  color: var(--game-text, #ffffff);
  text-decoration: none;
  font-size: min(14px, 3.5vw);
  padding: min(6px, 1.5vh) min(12px, 3vw);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  flex-shrink: 0;
}

.score-panel {
  display: flex;
  gap: min(15px, 3vw);
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-label {
  font-size: min(11px, 2.5vw);
  color: var(--text-secondary, #a0a0a0);
}

.score-value {
  font-size: min(20px, 4.5vw);
  font-weight: bold;
  color: var(--accent-color, #4ade80);
}

/* 画布区域 - 占据剩余空间 */
.canvas-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: min(8px, 1.5vh);
  overflow: hidden;
  min-height: 0;
}

canvas {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  /* 使用 object-fit 确保画布缩放 */
  max-width: 100%;
  max-height: 100%;
}

/* 控制按钮区域 - 紧凑布局，最高 20vh */
.controls {
  padding: min(10px, 2vh) min(15px, 3vw);
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.control-row {
  display: flex;
  justify-content: center;
  gap: min(8px, 1.5vw);
  margin-bottom: min(6px, 1vh);
}

.control-row:last-child {
  margin-bottom: 0;
}

.control-btn {
  width: min(60px, 15vw);
  height: min(48px, 10vh);
  font-size: min(20px, 5vw);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.control-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}

.control-btn.wide {
  width: min(160px, 40vw);
  font-size: min(16px, 4vw);
}

/* 覆盖层 */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  padding: min(30px, 5vh);
  max-width: 90vw;
}

.overlay-title {
  font-size: min(28px, 7vw);
  margin-bottom: min(15px, 3vh);
}

.overlay-text {
  font-size: min(16px, 4vw);
  color: var(--text-secondary, #a0a0a0);
  margin-bottom: min(25px, 4vh);
}

.start-btn {
  padding: min(14px, 2.5vh) min(36px, 8vw);
  font-size: min(16px, 4vw);
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary-color, #667eea) 0%, var(--primary-dark, #5a67d8) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.start-btn:active {
  transform: scale(0.95);
}
