* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;  /* 移除移动端点击高亮 */
}
body {
  background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);  /* 科技蓝主题 */
  color: #333;
  padding-bottom: 40px;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;  /* 禁止微信自动调整字体 */
  text-size-adjust: 100%;
}

/* 游戏页面特殊样式 - 保留紫色主题 */
body.game-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}
.title {
  text-align: center;
  margin: 30px 0;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  font-size: clamp(24px, 5vw, 32px);  /* 响应式字体 */
}
.subtitle {
  text-align: center;
  margin-bottom: 30px;
  color: rgba(255,255,255,0.9);
  font-size: clamp(14px, 3vw, 16px);  /* 响应式字体 */
}
.btn {
  display: inline-block;
  padding: clamp(6px, 1.5vw, 8px) clamp(12px, 3vw, 20px);  /* 缩小约50% */
  background: #c93737;
  color: #fff;
  border: none;
  border-radius: 6px;  /* 缩小圆角 */
  font-size: clamp(12px, 2.5vw, 14px);  /* 缩小字体 */
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);  /* 缩小阴影 */
  min-height: 32px;  /* 减小最小高度 */
  line-height: 1.5;  /* 优化行高 */
  -webkit-touch-callout: none;
  user-select: none;
}
.btn:hover {
  background: #a82c2c;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.btn:active {
  transform: translateY(0) scale(0.98);
  opacity: 0.9;
}
.btn-secondary {
  background: #409eff;
}
.btn-secondary:hover {
  background: #337ecc;
}
.btn-light {
  background: rgba(255,255,255,0.9);
  color: #333;
}
.btn-light:hover {
  background: #fff;
}
.btn-success {
  background: #67c23a;
}
.btn-success:hover {
  background: #529b2e;
}
.card {
  background: white;
  border-radius: 12px;
  padding: clamp(15px, 3vw, 20px);  /* 响应式内边距 */
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.text-center { text-align: center; }
.flex { display: flex; }
.jc-between { justify-content: space-between; }
.align-center { align-items: center; }
.mt20 { margin-top: 20px; }
.mb20 { margin-bottom: 20px; }
input, select {
  width: 100%;
  padding: clamp(10px, 2vw, 12px);  /* 响应式内边距 */
  border: 1px solid #ddd;
  border-radius: 6px;
  margin: 8px 0;
  font-size: clamp(14px, 3vw, 15px);  /* 响应式字体 */
  transition: border-color 0.3s;
  -webkit-appearance: none;  /* 移除iOS默认样式 */
}
input:focus, select:focus {
  outline: none;
  border-color: #409eff;
}
input:disabled {
  background: #f5f5f5;
}
.error-msg {
  color: #f56c6c;
  font-size: 12px;
  margin-top: 4px;
}
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  table-layout: fixed;  /* 固定表格布局，确保全宽 */
}
table th, table td {
  padding: 12px;
  border: 1px solid #eee;
  text-align: center;
  word-break: break-word;  /* 允许文字换行 */
  overflow-wrap: break-word;
}
table th {
  background: #f8f9fa;
  font-weight: 600;
}
table tr:hover {
  background: #f5f7fa;
}
.highlight-row {
  background: #e1f3d8 !important;
  font-weight: bold;
}

/* Canvas游戏容器 */
.game-canvas-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.game-canvas-container canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* 答题弹窗 */
.quiz-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.quiz-modal.active {
  display: flex;
}
.quiz-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.quiz-content p {
  font-size: 18px;
  margin-bottom: 20px;
  line-height: 1.6;
}
.quiz-content .btn {
  margin: 0 8px;
  min-width: 60px;   /* 缩小最小宽度 */
  max-width: 140px;  /* 限制最大宽度 */
  width: auto;       /* 根据内容自适应 */
  flex: none;        /* 不伸展 */
  padding: 4px 10px; /* 缩小内边距 */
  font-size: 11px;   /* 缩小字体 */
}

/* 记忆游戏卡片 */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
  max-width: 800px;
  margin: 20px auto;
}
.memory-card {
  aspect-ratio: 4/5;
  perspective: 1000px;
  cursor: pointer;
}
.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}
.memory-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}
.memory-card-front, .memory-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  padding: 10px;
  text-align: center;
}
.memory-card-front {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 32px;
}
.memory-card-back {
  background: white;
  border: 2px solid #409eff;
  transform: rotateY(180deg);
}
.memory-card.matched .memory-card-back {
  border-color: #67c23a;
  background: #f0f9ff;
}

/* 响应式适配 */
@media (max-width: 1024px) {
  .container {
    max-width: 95%;
    padding: 15px;
  }
  .title {
    font-size: clamp(24px, 4vw, 28px);
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: 70px;  /* 底部导航适配 */
  }
  
  .container {
    padding: 10px;
  }
  
  .title {
    font-size: clamp(20px, 5vw, 24px);
    margin: 15px 0;
  }
  
  .subtitle {
    font-size: clamp(12px, 3vw, 14px);
    margin-bottom: 15px;
  }
  
  .flex {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;  /* 手机端全宽 */
    margin: 5px 0;
    font-size: 13px;  /* 缩小字体 */
    padding: 8px 16px;  /* 缩小内边距 */
    min-height: 36px;  /* 适中高度 */
  }
  
  .card {
    padding: 15px;
    margin-bottom: 15px;
  }
  
  table {
    font-size: 12px;
    width: 100%;  /* 确保表格全宽 */
    display: table;  /* 改为table显示 */
  }
  
  .table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;  /* iOS平滑滚动 */
  }
  
  table th, table td {
    padding: 8px 6px;
    font-size: 13px;
  }
  
  table th {
    font-size: 12px;
    padding: 6px 4px;
  }
  
  .memory-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  
  .memory-card-front, .memory-card-back {
    font-size: 12px;
    padding: 5px;
  }
  
  .quiz-content {
    padding: 15px 12px;
    width: 95%;
  }
  
  .quiz-content p {
    font-size: 13px;
  }
  
  .quiz-content .btn {
    margin: 4px 6px;
    min-width: 50px;
    max-width: 120px;
    padding: 3px 8px;
    font-size: 10px;
  }
  
  /* 底部导航适配 */
  .bottom-nav {
    padding: 8px 0;
  }
  
  .nav-icon {
    font-size: 20px;
  }
  
  .nav-text {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 8px;
  }
  
  .title {
    font-size: clamp(18px, 6vw, 22px);
    margin: 12px 0;
  }
  
  .subtitle {
    font-size: 12px;
    margin-bottom: 12px;
  }
  
  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  
  .memory-card-front, .memory-card-back {
    font-size: 11px;
    padding: 3px;
  }
  
  .memory-card-front {
    font-size: 20px !important;
  }
  
  table {
    font-size: 11px;
  }
  
  table th, table td {
    padding: 6px 4px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .card {
    padding: 12px;
    border-radius: 8px;
  }
}

/* 超小屏幕适配 */
@media (max-width: 375px) {
  .title {
    font-size: 18px;
  }
  
  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }
  
  .nav-text {
    font-size: 10px;
  }
}

/* 底部导航栏 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 999;
  border-top: 1px solid #eee;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #999;
  padding: 5px 20px;
  transition: all 0.3s;
  min-width: 80px;
}
.nav-item:hover {
  color: #409eff;
}
.nav-item.active {
  color: #409eff;
}
.nav-icon {
  font-size: 24px;
  margin-bottom: 4px;
}
.nav-text {
  font-size: 12px;
  font-weight: 500;
}
body {
  padding-bottom: 80px;
}