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

/* 移动端触屏基础：去点击灰框、防下拉刷新/橡皮筋、可点击元素禁用双击缩放延迟 */
html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; }
a, button, select, .btn, .num-btn, .op-btn, .card, .cell, .game-card { touch-action: manipulation; }

/* 护眼童趣主题：暖色低亮度底、降饱和柔和配色、更大更圆的控件
   游戏页（浅色）统一走这套变量；大厅 .lobby-page 自带深色覆盖，不受影响 */
:root {
  --primary: #3d6594;      /* 柔和暖蓝，替代高饱和 #1976d2 */
  --primary-dark: #335780;
  --bg: #f5efe1;           /* 暖米色背景，替代冷灰 */
  --panel: #fdfaf1;        /* 暖白面板，替代刺眼纯白 */
  --text: #4a4039;         /* 暖深棕灰，替代近黑 */
  --border: #e6dcc4;       /* 暖边框 */
  --shadow: 0 4px 14px rgba(140, 100, 40, 0.09);  /* 暖色柔影 */
}

body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* 通用按钮 */
.btn {
  padding: 10px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 15px; cursor: pointer; transition: background .15s, opacity .15s;
  background: var(--panel);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-check { background: #43a047; color: #fff; border-color: #43a047; }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: #efe6cf; }
  .btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
  .btn-check:hover:not(:disabled) { background: #388e3c; }
}
.btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-row { display: grid; gap: 8px; }

.badge {
  display: inline-block; min-width: 18px; padding: 0 6px;
  background: rgba(120, 90, 40, 0.10); border-radius: 10px;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.btn.active .badge { background: rgba(255, 255, 255, 0.3); }

/* 通用控件 */
.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-label { font-size: 13px; color: #7a6f5c; }
select {
  padding: 8px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 15px; background: var(--panel); cursor: pointer;
}
.stats { display: flex; flex-direction: column; gap: 8px; }
.stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #f0e9d6; border-radius: 10px;
}
.stat-label { color: #7a6f5c; font-size: 14px; }
.stat-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.title { font-size: 28px; font-weight: 700; text-align: center; }
.hints-tip { font-size: 12px; color: #9a8d76; text-align: center; line-height: 1.6; }

/* 模态弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--panel); padding: 32px 40px; border-radius: 18px;
  text-align: center; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.modal-content h2 { margin-bottom: 12px; }
.modal-content p { margin-bottom: 20px; font-size: 18px; }

/* toast */
.toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: #4a4039; color: #fff; padding: 12px 24px;
  border-radius: 12px; font-size: 15px; z-index: 200;
}
.toast.hidden { display: none; }

/* ===================== 大厅首页 ===================== */
/* body.lobby-page 覆盖基础 body 的居中与浅色背景，仅首页生效，不影响数独页 */
.lobby-page {
  display: block;
  padding: 0;
  background: #0b0d1f;
  color: #e8ebff;
  overflow-x: hidden;
}

.lobby {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 64px 24px;
  overflow: hidden;
}

/* 流动极光背景 + 网格 */
.lobby-aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.55;
  animation: float 16s ease-in-out infinite;
}
.blob-1 { width: 480px; height: 480px; background: #4f8cff; top: -120px; left: -80px; }
.blob-2 { width: 420px; height: 420px; background: #9b5cff; bottom: -100px; right: -60px; animation-delay: -5s; }
.blob-3 { width: 360px; height: 360px; background: #ff5ca8; top: 45%; left: 55%; animation-delay: -10s; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(40px,-30px) scale(1.08); }
  66% { transform: translate(-30px,25px) scale(0.96); }
}

/* 头部 */
.lobby-header {
  position: relative; z-index: 1; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  animation: rise .7s cubic-bezier(.2,.7,.3,1) both;
}
.lobby-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px; font-size: 13px; letter-spacing: 1px; color: #c9d4ff;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.lobby-title {
  font-size: clamp(36px, 6vw, 60px); font-weight: 800; line-height: 1.1;
  letter-spacing: -0.02em; color: #fff;
}
.lobby-title .grad {
  background: linear-gradient(100deg, #6fb0ff, #b07bff 50%, #ff7ac6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lobby-subtitle { font-size: clamp(14px, 2vw, 17px); color: #9aa3c9; max-width: 520px; }
.lobby-features { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.feature {
  font-size: 12.5px; color: #aeb6da; padding: 5px 12px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
}

/* 卡片列表 */
.game-list {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px; width: 100%; max-width: 760px;
}
.game-card {
  position: relative; display: flex; flex-direction: column; gap: 18px;
  padding: 32px 28px 26px; min-height: 248px;
  text-decoration: none; color: inherit; cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.10); border-radius: 22px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  overflow: hidden;
  transition: transform .3s cubic-bezier(.2,.7,.3,1), border-color .3s, box-shadow .3s;
  animation: rise .7s cubic-bezier(.2,.7,.3,1) both;
}
.game-card:nth-child(2) { animation-delay: .1s; }
/* 顶部渐变光条 */
.game-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .9;
}
/* 悬停高光扫过 */
.card-shine {
  position: absolute; top: 0; left: -60%; width: 50%; height: 100%;
  background: linear-gradient(110deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: skewX(-18deg); transition: left .6s ease; pointer-events: none;
}
@media (hover: hover) {
  .game-card:hover {
    transform: translateY(-8px); border-color: rgba(255,255,255,0.22);
    box-shadow: 0 20px 50px -12px var(--accent);
  }
  .game-card:hover .card-shine { left: 130%; }
  .game-card:hover .game-icon { transform: scale(1.12) rotate(-4deg); }
}

.game-icon {
  font-size: 52px; line-height: 1; width: 76px; height: 76px;
  display: grid; place-items: center; border-radius: 20px;
  background: radial-gradient(circle at 30% 30%, var(--accent), transparent 70%);
  box-shadow: 0 8px 24px -6px var(--accent);
  transition: transform .3s cubic-bezier(.2,.7,.3,1);
}
.game-body { display: flex; flex-direction: column; gap: 6px; }
.game-name { font-size: 24px; font-weight: 700; color: #fff; }
.game-desc { font-size: 14px; color: #9aa3c9; }
.game-meta { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.game-tag {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; color: #fff;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.game-tag.soon {
  color: #ffd089; background: rgba(255,176,32,0.14); border: 1px solid rgba(255,176,32,0.3);
}
.game-play {
  font-size: 14px; font-weight: 600; color: var(--accent);
  transition: transform .3s, letter-spacing .3s;
}
@media (hover: hover) {
  .game-card:hover .game-play { transform: translateX(4px); letter-spacing: .02em; }
}

/* 禁用态 */
.game-card.disabled { cursor: not-allowed; opacity: 0.72; filter: saturate(.7); }
@media (hover: hover) {
  .game-card.disabled:hover { transform: none; border-color: rgba(255,255,255,0.10); box-shadow: none; }
  .game-card.disabled:hover .game-icon { transform: none; }
}
.game-card.disabled .game-play { color: #9aa3c9; }

/* 底部 */
.lobby-footer {
  position: relative; z-index: 1; font-size: 13px; color: #6f77a3;
  letter-spacing: 1px; animation: rise .7s cubic-bezier(.2,.7,.3,1) .2s both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 520px) {
  .lobby { gap: 36px; padding: 48px 18px; }
  .game-card { padding: 26px 22px 22px; min-height: 220px; }
  .game-icon { width: 64px; height: 64px; font-size: 44px; }
}

/* 无障碍：尊重“减弱动效” */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 返回大厅链接 */
.back-link { font-size: 13px; color: var(--primary); text-decoration: none; align-self: flex-start; }
@media (hover: hover) {
  .back-link:hover { text-decoration: underline; }
}
