
/* ═══════════════════════════════════════
   全局样式
   ═══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0a0a1a;
  color: #e0e0e0;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
}

.game-container {
  background: linear-gradient(135deg, #0f0f2a 0%, #1a1a3a 100%);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ═══════════════════════════════════════
   画布
   ═══════════════════════════════════════ */
canvas {
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  background: #0d0d20;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
  image-rendering: pixelated;
  touch-action: none;
}

/* ═══════════════════════════════════════
   HUD / 信息栏
   ═══════════════════════════════════════ */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 8px 8px;
  font-size: 14px;
  color: #8888cc;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-value {
  color: #fff;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.hud-value.score  { color: #ffd700; }
.hud-value.length { color: #4ade80; }
.hud-value.speed  { color: #f472b6; }
.hud-value.level  { color: #60a5fa; }
.hud-value.coins  { color: #22d3ee; }

/* ═══════════════════════════════════════
   按钮
   ═══════════════════════════════════════ */
.btn {
  border: none;
  padding: 8px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  background: linear-gradient(135deg, #3b3b7a, #2a2a5a);
  border: 1px solid rgba(255,255,255,0.08);
}
.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.2);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn-danger  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); }

.controls-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════
   弹窗 / 覆盖层
   ═══════════════════════════════════════ */
.overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 10;
  padding: 20px;
}
.overlay.hidden { display: none; }

/* 登录输入框 */
#loginOverlay input:focus { border-color: #4ade80 !important; }
#loginOverlay input::placeholder { color: #555; }
.account-btn {
  padding: 6px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04); color: #ccc; cursor: pointer; font-size: 13px;
  transition: all 0.15s;
}
.account-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.account-btn.active { border-color: #4ade80; color: #4ade80; background: rgba(74,222,128,0.08); }

.overlay h1 {
  font-size: 36px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255,215,0,0.3);
  margin-bottom: 12px;
}
.overlay h2 {
  font-size: 20px;
  color: #e0e0e0;
  margin-bottom: 8px;
}
.overlay p {
  color: #aaa;
  margin: 4px 0;
  font-size: 15px;
}
.overlay .stats {
  margin: 12px 0;
  text-align: center;
  line-height: 1.8;
}

.menu-btn {
  display: block;
  width: 200px;
  margin: 6px auto;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  background: linear-gradient(135deg, #2a2a5a, #1a1a4a);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.menu-btn:hover { transform: translateY(-1px); filter: brightness(1.2); }
.menu-btn:active { transform: scale(0.98); }
.menu-btn.selected {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #f59e0b;
  box-shadow: 0 0 16px rgba(245,158,11,0.3);
}
.menu-btn.start-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  font-size: 18px;
  padding: 14px;
  margin-top: 12px;
}

.setting-group {
  margin: 8px 0;
}
.setting-label {
  font-size: 13px;
  color: #8888cc;
  text-align: center;
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════
   游戏中心（首页 / 启动器）
   ═══════════════════════════════════════ */
/* 设计 token（沿用全局深色主题） */
#gameCenter {
  --gc-gold:  #ffd700;          /* 主标题 */
  --gc-green: #4ade80;          /* 强调/成功 */
  --gc-blue:  #60a5fa;          /* 次级 */
  --gc-ink:   #0f0f2a;          /* 最深底 */
  --gc-card:  rgba(255,255,255,0.05);
  --gc-line:  rgba(255,255,255,0.09);
  --gc-muted: #8a8aa3;
}
/* 滚动容器：内容超高时在内部滚动，而不是溢出屏幕 */
.center-inner {
  width: 100%;
  max-width: 880px;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 4px;
}
.center-inner::-webkit-scrollbar { width: 6px; }
.center-inner::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* —— Hero —— */
.center-hero { display: flex; align-items: center; gap: 14px; }
.center-hero-mark {
  width: 58px; height: 58px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(74,222,128,0.22), rgba(74,222,128,0.04));
  border: 1px solid rgba(74,222,128,0.35);
  box-shadow: 0 0 26px rgba(74,222,128,0.18);
  animation: heroFloat 3s ease-in-out infinite;
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.center-hero h1 { font-size: 30px; color: var(--gc-gold); margin: 0; text-shadow: 0 0 22px rgba(255,215,0,0.3); }
.center-hero-text p { font-size: 13px; color: var(--gc-muted); margin: 3px 0 0; }

/* —— 公告 —— */
.center-announce {
  width: min(560px, 100%);
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255,215,0,0.08);
  border: 1px solid rgba(255,215,0,0.25);
  color: #fbbf24;
  font-size: 12px;
  line-height: 1.5;
}

/* —— 登录信息条 —— */
.center-userbar {
  display: flex; align-items: center; gap: 10px;
  width: min(640px, 100%);
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--gc-line);
  font-size: 13px;
}
.center-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  font-size: 16px;
}
.center-name { font-weight: 700; color: var(--gc-green); }
.center-meta { flex: 1; min-width: 0; color: var(--gc-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center-btn {
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid rgba(74,222,128,0.4);
  background: rgba(74,222,128,0.08);
  color: var(--gc-green);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.center-btn:hover  { background: rgba(74,222,128,0.18); }
.center-btn:active { transform: scale(0.96); }

/* —— 搜索框 —— */
.center-search {
  display: flex; align-items: center; gap: 8px;
  width: min(640px, 100%);
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--gc-line);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.center-search:focus-within { border-color: var(--gc-green); box-shadow: 0 0 0 3px rgba(74,222,128,0.12); }
.center-search-icon { font-size: 14px; opacity: 0.7; }
.center-search input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: #fff; font-size: 14px;
}
.center-search input::placeholder { color: #666; }
.center-search-clear {
  background: none; border: none; cursor: pointer;
  color: #888; font-size: 12px;
  padding: 4px 6px; border-radius: 6px;
}
.center-search-clear:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* —— 游戏卡片网格 —— */
.game-center-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  width: min(860px, 100%);
}
.game-card {
  --accent: var(--gc-green);
  display: flex; align-items: center; gap: 12px;
  min-height: 68px;
  padding: 12px 14px;
  border: 1px solid var(--gc-line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  color: #fff; font-size: 15px; text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  animation: cardIn 0.35s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.game-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 8px 24px -10px var(--accent);
}
.game-card:active { transform: scale(0.98); }
.game-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.game-card-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.game-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.game-card-name { font-weight: 700; }
.game-card-desc { font-size: 12px; color: var(--gc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-card-high { font-size: 11px; color: #fbbf24; }
.game-card-btn {
  margin-left: auto; flex-shrink: 0;
  font-size: 15px; color: var(--gc-blue);
  opacity: 0.55;
  transition: opacity 0.2s, transform 0.2s;
}
.game-card:hover .game-card-btn { opacity: 1; transform: translateX(3px); }
@media (max-width: 520px) {
  .game-center-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════
   小游戏通用组件
   ═══════════════════════════════════════ */
.mini-btn {
  background: linear-gradient(135deg, #2a2a5a, #1a1a4a);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: filter 0.2s;
}
.mini-btn:hover { filter: brightness(1.2); }

/* 2048 方块 */
.t2048 {
  width: 62px; height: 62px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 22px;
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.t2048.t1  { background: #3b4b8a; }
.t2048.t2  { background: #2d6a4f; }
.t2048.t3  { background: #1b7f5a; }
.t2048.t4  { background: #c58a1e; }
.t2048.t5  { background: #c0701a; }
.t2048.t6  { background: #c0561a; }
.t2048.t7  { background: #a83a2a; }
.t2048.t8  { background: #8f2a3a; }
.t2048.t9  { background: #7a1f3f; }
.t2048.t10 { background: #5f1f52; }
.t2048.t11 { background: #3f1f66; box-shadow: 0 0 14px rgba(180,120,255,0.45); }

/* 扫雷格子 */
.mine-cell {
  width: 34px; height: 34px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(135deg, #2a2a5a, #1f1f44);
  border: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}
.mine-cell:hover { filter: brightness(1.2); }
.mine-cell.mine-open { background: rgba(255,255,255,0.07); }
.mine-cell.mine-flag { color: #f87171; }
.mine-cell.mine-boom { background: rgba(248,113,113,0.35); }

/* 记忆翻牌卡片 */
.mem-card {
  width: 64px; height: 64px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a2a5a, #1a1a4a);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
}
.mem-card:hover { transform: scale(1.05); }
.mem-card.mem-open { background: rgba(255,255,255,0.12); }
.mem-card.mem-done { background: rgba(74,222,128,0.15); border-color: rgba(74,222,128,0.4); cursor: default; transform: none; }

/* 打地鼠洞 */
.whk-hole {
  width: 84px; height: 84px;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 60%, #2a2a5a, #14142e);
  border: 2px solid rgba(255,255,255,0.10);
  color: #fff;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.whk-hole:hover { filter: brightness(1.2); }
.whk-hole.whk-up { background: radial-gradient(circle at 50% 60%, #4a2a4a, #241436); border-color: rgba(251,191,36,0.4); }
.whk-hole.whk-miss { background: radial-gradient(circle at 50% 60%, #6a1a2a, #241436); }

/* ═══════════════════════════════════════
   移动端触控按钮
   ═══════════════════════════════════════ */
.touch-controls {
  display: none;
  padding: 8px 0 4px;
  touch-action: none;
}
.touch-grid {
  display: grid;
  grid-template-columns: 64px 64px 64px;
  grid-template-rows: 64px 64px 64px;
  gap: 4px;
  justify-content: center;
  margin: 0 auto;
}
.touch-btn {
  border: none;
  border-radius: 14px;
  font-size: 24px;
  cursor: pointer;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn:active { background: rgba(255,255,255,0.15); transform: scale(0.95); }
.touch-up    { grid-column: 2; grid-row: 1; }
.touch-down  { grid-column: 2; grid-row: 3; }
.touch-left  { grid-column: 1; grid-row: 2; }
.touch-right { grid-column: 3; grid-row: 2; }
.touch-center {
  grid-column: 2; grid-row: 2;
  font-size: 14px;
  background: rgba(255,255,255,0.03);
  color: #666;
}

/* ═══════════════════════════════════════
   响应式
   ═══════════════════════════════════════ */
@media (pointer: coarse) {
  .touch-controls { display: block; }
}
@media (max-width: 520px) {
  .game-container { padding: 12px; border-radius: 12px; }
  .overlay h1 { font-size: 26px; }
  .menu-btn { width: 160px; padding: 10px; font-size: 14px; }
  .hud { font-size: 12px; padding: 8px 4px; }
}
