/* ============================================
   公共样式 - 游戏大厅通用
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

:root {
  --primary: #667eea;
  --primary-dark: #5568d3;
  --secondary: #764ba2;
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --text: #e0e0e0;
  --text-muted: #a0a0b0;
  --accent: #00d2ff;
  --success: #00e676;
  --danger: #ff5252;
  --warning: #ffab40;
  --radius: 12px;
}

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: var(--text);
  overflow-x: hidden;
}

/* ===== 游戏大厅首页 ===== */
.game-hall {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.hall-header {
  text-align: center;
  padding: 40px 20px 30px;
}

.hall-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  background: linear-gradient(135deg, #667eea, #00d2ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hall-header p {
  color: var(--text-muted);
  font-size: clamp(0.85rem, 2vw, 1rem);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  padding: 20px 0 60px;
}

.game-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-decoration: none;
  color: var(--text);
  display: block;
}

.game-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 30px rgba(0, 210, 255, 0.2);
}

.game-card-icon {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  position: relative;
  overflow: hidden;
}

.game-card-body {
  padding: 16px;
}

.game-card-body h3 {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.game-card-body p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== 通用游戏页面 ===== */
.game-page {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
}

.game-header {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.game-header h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: var(--accent);
}

.back-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.game-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  width: 100%;
  max-width: 600px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* 游戏信息栏 */
.game-info {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.info-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 5px 14px;
  border-radius: 8px;
  text-align: center;
  min-width: 70px;
}

.info-item .label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 1px;
}

.info-item .value {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent);
}

/* 通用按钮 */
.btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  padding: 8px 22px;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  font-weight: 600;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.95); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

/* 游戏遮罩 */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  z-index: 10;
}

.game-overlay.active { display: flex; }

.game-overlay h3 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.game-overlay p {
  font-size: 1rem;
  margin-bottom: 14px;
  color: var(--text-muted);
}

/* Canvas 容器 */
.canvas-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

canvas {
  display: block;
  border-radius: 8px;
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 移动端控制按钮 */
.touch-controls {
  display: none;
  gap: 8px;
  margin-top: 8px;
  flex-shrink: 0;
}

.touch-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.touch-btn:active {
  background: var(--primary);
}

/* 响应式 */
@media (max-width: 768px) {
  .game-hall { padding: 12px; }
  .game-card-icon { height: 90px; font-size: 2.2rem; }
  .game-grid { gap: 14px; }
}

@media (max-width: 480px) {
  .touch-controls { display: flex; }
  .game-container { padding: 14px; }
  .game-card-icon { height: 80px; font-size: 2rem; }
}
