/* Endless Dodge 游戏样式 - 保持原有全屏体验 */

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  color: #fff;
}

body {
  background: 
    linear-gradient(135deg, #0a0a2e 0%, #16213e 50%, #0f0f23 100%),
    radial-gradient(circle at 30% 30%, rgba(0, 191, 255, 0.15) 0%, transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(255, 0, 150, 0.1) 0%, transparent 50%),
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60"><defs><pattern id="grid" width="60" height="60" patternUnits="userSpaceOnUse"><path d="M 60 0 L 0 0 0 60" fill="none" stroke="rgba(0,191,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23grid)"/></svg>');
  background-size: 100% 100%, 100% 100%, 100% 100%, 60px 60px;
  display: flex;
  flex-direction: column;
  min-height: calc(var(--vh, 1vh) * 100);
}

header {
  text-align: center;
  padding: 0.5rem;
  flex-shrink: 0;
}

header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  background: linear-gradient(135deg, #00bfff, #ff0096, #00ff88);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 3s ease infinite;
  text-shadow: 0 0 20px rgba(0, 191, 255, 0.5);
  letter-spacing: 1px;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

header p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  margin: 0.3rem 0 0 0;
  text-shadow: 0 0 10px rgba(0, 191, 255, 0.3);
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  padding: 0.5rem;
  box-sizing: border-box;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(135deg, #0a0a2e 0%, #16213e 50%, #0f0f23 100%),
    radial-gradient(circle at 30% 30%, rgba(0, 191, 255, 0.15) 0%, transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(255, 0, 150, 0.1) 0%, transparent 50%);
  border: 2px solid rgba(0, 191, 255, 0.3);
  border-radius: 12px;
  box-shadow: 
    0 0 30px rgba(0, 0, 0, 0.7),
    inset 0 0 50px rgba(0, 191, 255, 0.05);
  box-sizing: border-box;
}

footer {
  text-align: center;
  padding: 0.5rem;
  flex-shrink: 0;
}

.play-btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: linear-gradient(135deg, #ff6b00, #ff9800, #ffc107);
  border-radius: 50px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  box-shadow: 
    0 4px 15px rgba(255, 107, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.play-btn:hover {
  background: linear-gradient(135deg, #e65100, #f57c00, #ff8f00);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 
    0 8px 25px rgba(255, 107, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* 移动端优化 - 全面提升 */
@media (max-width: 768px) {
  /* 基础布局优化 */
  header {
    padding: 0.2rem 0.5rem;
    min-height: auto;
  }
  
  header h1 {
    font-size: 1.3rem;
    margin: 0;
    line-height: 1.2;
  }
  
  header p {
    font-size: 0.75rem;
    margin: 0.2rem 0 0 0;
    opacity: 0.9;
  }
  
  main {
    padding: 0.2rem;
    flex: 1;
    min-height: 0;
  }
  
  footer {
    padding: 0.2rem;
    min-height: auto;
  }
  
  .play-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.7rem;
    border-radius: 25px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Canvas 移动端优化 */
  canvas {
    border-radius: 8px;
    border-width: 1px;
    /* 确保触摸区域最大化 */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
}

/* 超小屏幕优化 (iPhone SE等) */
@media (max-width: 375px) and (max-height: 667px) {
  body {
    font-size: 14px;
  }
  
  header {
    padding: 0.1rem 0.3rem;
  }
  
  header h1 {
    font-size: 1.1rem;
  }
  
  header p {
    font-size: 0.7rem;
  }
  
  main {
    padding: 0.1rem;
  }
  
  footer {
    padding: 0.1rem;
  }
  
  .play-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.65rem;
    min-height: 28px;
  }
}

/* 横屏模式优化 */
@media (max-width: 1024px) and (orientation: landscape) {
  body {
    flex-direction: row;
  }
  
  header {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    width: auto;
    min-width: 120px;
    padding: 0.3rem;
    flex-shrink: 0;
  }
  
  header h1 {
    font-size: 1rem;
    writing-mode: horizontal-tb;
  }
  
  header p {
    font-size: 0.7rem;
    writing-mode: horizontal-tb;
    margin: 0.3rem 0;
  }
  
  main {
    flex: 1;
    padding: 0.3rem;
  }
  
  footer {
    writing-mode: vertical-rl;
    width: auto;
    min-width: 80px;
    padding: 0.3rem;
    flex-shrink: 0;
  }
  
  .play-btn {
    writing-mode: horizontal-tb;
    padding: 0.3rem 0.5rem;
    font-size: 0.6rem;
  }
}

/* 触摸优化 - 防止双击缩放等 */
canvas {
  -ms-touch-action: none;
  touch-action: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* 防止页面滚动和缩放 */
body {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

html {
  touch-action: none;
  overscroll-behavior: none;
}

footer {
  text-align: center;
  padding: 1rem;
}

/* 动态隐藏头部与底部以最大化画布 */
.hidden { display: none !important; }

/* 成就弹窗容器 */
.achievement-container {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.achievement-toast {
  min-width: 180px;
  max-width: 240px;
  background: linear-gradient(135deg, rgba(0,191,255,0.9), rgba(255,0,150,0.85));
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4), 0 0 8px rgba(0,191,255,0.5);
  animation: toast-in 0.4s ease forwards;
  position: relative;
  overflow: hidden;
}
.achievement-toast::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(#ffd700,#ff6b00);
  box-shadow: 0 0 6px rgba(255,215,0,0.8);
}
.achievement-toast strong { font-size: 13px; }
.achievement-toast.fade-out { animation: toast-out 0.6s ease forwards; }

@keyframes toast-in { from { transform: translateX(40px); opacity:0; } to { transform: translateX(0); opacity:1; } }
@keyframes toast-out { to { transform: translateX(40px); opacity:0; } }

.play-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: #ff5722;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.2s, transform 0.2s;
}

.play-btn:hover {
  background: #e64a19;
  transform: scale(1.05);
}