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

body {
  font-family: 'Arial', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  /* 移动端优化 */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  /* 防止横向溢出 */
  overflow-x: hidden;
}

body:has(dialog[open]) {
  overflow: hidden;
}

:root {
  --content-max-width: 600px;
  color-scheme: light;

  /* 背景与表面 */
  --bg:              #FFFEF7;
  --surface:         rgba(255, 255, 255, 0.95);
  --surface-solid:   #ffffff;
  --surface-muted:   #f7f4ef;
  --border:          #e5e0d8;
  --border-muted:    #ece8e0;

  /* 文字 */
  --text:            #2c2c2c;
  --text-secondary:  #666;
  --text-muted:      #999;

  /* 主色调 - 天蓝 */
  --primary:         #87CEEB;
  --primary-hover:   #6BB6FF;
  --primary-dark:    #2F4F4F;

  /* 玫瑰粉 */
  --rose:            #c5536b;
  --rose-bg:         #fff5f1;
  --rose-border:     rgba(255, 182, 193, 0.35);

  /* 游戏数值 */
  --score-high:      #3aaa85;
  --score-current:   #4a9eda;
  --stage-bg:        #7fa8c0;

  /* 游戏状态条 */
  --status-bg:       #f0f7ff;
  --status-border:   #87CEEB;
  --status-text:     #2a6da8;

  /* 网格 */
  --grid-bg:         #eae5dd;
  --cell-bg:         #ffffff;
  --cell-border:     #ddd8cf;
  --cell-selected-bg: #ffeaa7;
  --cell-hint-bg:    #a8e6cf;
  --cell-elim-bg:    #f5f2ec;
}

[data-theme="dark"] {
  /* 背景与表面 */
  --bg:              #16161e;
  --surface:         rgba(28, 28, 44, 0.97);
  --surface-solid:   #1e1e2e;
  --surface-muted:   #252538;
  --border:          #38384e;
  --border-muted:    #2e2e42;

  /* 文字 */
  --text:            #e4e4f0;
  --text-secondary:  #9898b0;
  --text-muted:      #5a5a78;

  /* 主色调 - 天蓝（暗色调适配） */
  --primary:         #6ab6d8;
  --primary-hover:   #87CEEB;
  --primary-dark:    #a8d4e8;

  /* 玫瑰粉（暗色调适配） */
  --rose:            #e8809a;
  --rose-bg:         #2a1820;
  --rose-border:     rgba(232, 128, 154, 0.22);

  /* 游戏数值 */
  --score-high:      #4ecaa8;
  --score-current:   #70b8e8;
  --stage-bg:        #36364e;

  /* 游戏状态条 */
  --status-bg:       #1a2232;
  --status-border:   #4a86b0;
  --status-text:     #80b4d8;

  /* 网格 */
  --grid-bg:         #1a1a2c;
  --cell-bg:         #24243a;
  --cell-border:     #36364e;
  --cell-selected-bg: #3e3418;
  --cell-hint-bg:    #1a3028;
  --cell-elim-bg:    #1e1e32;

  color-scheme: dark;
}

/* 自定义滚动条（Webkit） */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
  border: 2px solid var(--surface-muted);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header 样式 */
.site-header {
  width: 100%;
  max-width: var(--content-max-width);
  background: var(--surface);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  position: sticky;
  top: 20px;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
}

.site-title {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--primary-dark);
  margin: 0;
}

.header-nav .lang-switch {
  display: flex;
  align-items: center;
  gap: 0;
}

.header-nav .lang-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9em;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.header-nav .lang-link:hover {
  background: rgba(221, 160, 221, 0.1);
  color: var(--primary-dark);
}

.header-nav .sep {
  color: var(--border);
  font-size: 0.8em;
}

/* Footer 样式 */
.site-footer {
  width: 100%;
  max-width: var(--content-max-width);
  background: var(--surface);
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-top: 40px;
  overflow: hidden;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  padding: 30px 20px;
}

.footer-section h3 {
  font-size: 1.1em;
  color: var(--text);
  margin-bottom: 10px;
}

.footer-section h4 {
  font-size: 0.95em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.footer-section p {
  font-size: 0.85em;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 5px;
}

.footer-section ul {
  list-style: none;
  padding: 0;
}

.footer-section ul li {
  margin-bottom: 4px;
}

.footer-section a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85em;
  transition: color 0.2s ease;
}

.footer-section a:hover {
  color: var(--primary-dark);
}

.copyright {
  font-size: 0.8em !important;
  color: var(--text-muted) !important;
  margin-top: 10px;
}

.footer-bottom {
  background: var(--primary);
  padding: 12px 20px;
  text-align: center;
  color: white;
}

.back-to-top {
  background: none;
  border: none;
  color: white;
  font-size: 0.9em;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.2s ease;
}

.back-to-top:hover {
  opacity: 0.8;
}

.game-container {
  background: var(--surface);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  max-width: var(--content-max-width);
  width: 100%;
  position: relative; /* 为覆盖层提供定位参考 */
  /* 仅游戏区域禁用文字选择 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.challenge-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--rose-bg);
  border: 1px solid var(--rose-border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.challenge-info {
  min-width: 200px;
  flex: 1 1 auto;
}

.challenge-title {
  font-weight: 700;
  font-size: 20px;
  color: var(--rose);
  margin-bottom: 6px;
}

.challenge-status {
  font-size: 14px;
  color: var(--text-secondary);
}

.challenge-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.challenge-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  background: var(--surface-solid);
  color: var(--rose);
  box-shadow: 0 6px 14px rgba(166, 75, 99, 0.15);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.challenge-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(166, 75, 99, 0.25);
  background: var(--surface-solid);
  opacity: 0.92;
}

.challenge-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}

/* 游戏头部 */
.game-header {
  text-align: center;
  margin-bottom: 20px;
}

.score-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-muted);
  padding: 15px 20px;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: bold;
}

.score-display span {
  white-space: nowrap;
}

.high-score {
  color: var(--score-high);
}

.current-score {
  color: var(--score-current);
}

.stage-display {
  background: var(--stage-bg);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* 音效开关按钮 */
.sound-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
  margin-left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
}

.sound-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.sound-toggle:active {
  transform: scale(0.95);
}

/* 主题切换按钮 */
.theme-toggle {
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
}

.theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* 音效图标样式 */
.sound-icon {
  display: inline-block;
  transition: all 0.3s ease;
}

/* 音效关闭时的样式 */
.sound-toggle.muted .sound-icon {
  opacity: 0.4;
  position: relative;
}

.sound-toggle.muted .sound-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120%;
  height: 2px;
  background-color: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* 游戏网格 */
.game-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(20, auto); /* 改为auto，让行高自适应 */
  gap: 3px;
  background: var(--grid-bg);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 20px;
  max-height: 600px; /* 改为max-height，允许内容决定实际高度 */
  overflow-y: auto;
  /* 移动端滚动优化 */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.grid-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cell-bg);
  border: 2px solid transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 20px;
  font-weight: normal;
  cursor: default;
  transition: all 0.2s ease;
  user-select: none;
  width: 100%;
  /* 移动端触摸优化 */
  touch-action: manipulation;
  will-change: transform;
}

/* 数字状态 */
.grid-cell.active {
  color: var(--text);
  background: var(--cell-bg);
  border-color: var(--cell-border);
  cursor: pointer;
}

.grid-cell.eliminated {
  color: var(--text-muted);
  background: var(--cell-elim-bg);
  border-color: var(--border-muted);
  cursor: default;
}

.grid-cell.eliminated:hover {
  transform: none;
  box-shadow: none;
}

.grid-cell.selected {
  background: var(--cell-selected-bg);
  border-color: #fdcb6e;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(253, 203, 110, 0.4);
}

.grid-cell.hint {
  background: var(--cell-hint-bg);
  border-color: #4ecdc4;
  animation: hint-pulse 1s ease-in-out infinite;
}

@keyframes hint-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.grid-cell.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

/* 功能按钮 */
.game-controls {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.control-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.control-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(135, 206, 235, 0.3);
}

.control-btn:active {
  transform: translateY(0);
}

.control-btn:disabled {
  background: var(--stage-bg);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.copy-btn {
  background: var(--primary);
  color: white;
  font-size: 18px;
}

.copy-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(135, 206, 235, 0.3);
}

.btn-text {
  margin: 0 4px;
  font-size: 14px;
}

.copy-count,
.hint-count {
  background: rgba(255, 255, 255, 0.25);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.hint-btn {
  background: #fd7e14;
  color: white;
  font-size: 18px;
}

.hint-btn:hover {
  background: #e8610e;
  box-shadow: 0 4px 12px rgba(253, 126, 20, 0.3);
}

.tutorial-btn {
  background: var(--primary);
  color: white;
  font-size: 16px;
  display: inline-flex;
}

.tutorial-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(135, 206, 235, 0.3);
}

.tutorial-text {
  font-size: 14px;
  margin-left: 4px;
}

/* 游戏状态 */
.game-status {
  text-align: center;
  background: var(--status-bg);
  padding: 15px;
  border-radius: 10px;
  border-left: 4px solid var(--status-border);
}

.game-status p {
  margin: 0;
  font-size: 14px;
  color: var(--status-text);
  font-weight: 500;
}

/* 页脚与扩展内容区域 */
/* Markdown 内容也作为卡片展示（在 .section-card 内） */
.section-card h1,
.section-card h2,
.section-card h3 {
  color: var(--text);
  margin-bottom: 10px;
}

.section-card h3 {
  margin-top: 20px;
  font-size: 15px;
}

.section-card p {
  margin: 8px 0;
}

.section-card ul,
.section-card ol {
  padding-left: 20px;
  margin: 8px 0;
}

.section-card li {
  margin: 5px 0;
  line-height: 1.6;
}

.section-card a {
  color: var(--score-current);
  text-decoration: none;
}

.section-card a:hover {
  text-decoration: underline;
}

/* 折叠内容样式 */
.section-card details {
  margin: 12px 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.section-card summary {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s ease;
}

.section-card summary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.section-card summary::-webkit-details-marker {
  display: none;
}

.section-card summary::after {
  content: '▼';
  font-size: 12px;
  transition: transform 0.3s ease;
}

.section-card details[open] summary::after {
  transform: rotate(180deg);
}

.section-card details .content {
  padding: 16px;
  background: var(--surface-solid);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.section-card details .content h3 {
  color: var(--text);
  margin-top: 20px;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
}

.section-card details .content h3:first-child {
  margin-top: 0;
}

.section-card details .content p {
  color: var(--text-secondary);
  margin: 8px 0;
  line-height: 1.6;
}

.section-card details .content strong {
  color: var(--text);
}

.section-card details .content ul {
  margin: 8px 0 16px 0;
  padding-left: 20px;
}

.section-card details .content li {
  margin: 4px 0;
  line-height: 1.5;
}

/* 隐私页面样式 */
.privacy-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text);
}

.privacy-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--status-border);
}

.privacy-header h1 {
  color: var(--text);
  font-size: 2.5em;
  margin-bottom: 10px;
}

.last-updated {
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 20px;
}

.privacy-nav .back-link {
  display: inline-block;
  background: var(--primary);
  color: var(--on-primary);
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 8px;
  transition: transform 0.2s ease;
}

.privacy-nav .back-link:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.privacy-content {
  margin-bottom: 40px;
}

.privacy-section {
  margin-bottom: 40px;
  background: var(--surface);
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.privacy-section h2 {
  color: var(--text);
  font-size: 1.8em;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.privacy-section h3 {
  color: var(--text);
  font-size: 1.3em;
  margin: 20px 0 10px 0;
}

.privacy-section p {
  margin-bottom: 15px;
  text-align: left;
}

.privacy-section ul {
  margin: 15px 0;
  padding-left: 25px;
}

.privacy-section li {
  margin-bottom: 8px;
}

.privacy-section a {
  color: var(--score-current);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.privacy-section code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--text);
}

.highlight-box, .summary-box {
  background: var(--status-bg);
  border-left: 4px solid var(--status-border);
  padding: 20px;
  margin: 20px 0;
  border-radius: 8px;
}

.highlight-box h3, .summary-box h3 {
  margin-top: 0;
  color: var(--text);
}

.contact-info {
  background: var(--surface-muted);
  padding: 20px;
  border-radius: 8px;
  margin: 15px 0;
}

.contact-info a {
  color: var(--primary-dark);
  text-decoration: none;
}

.contact-info a:hover {
  text-decoration: underline;
}

.privacy-footer {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.footer-nav a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}

.footer-nav a:hover {
  text-decoration: underline;
}

.footer-text {
  margin-top: 10px;
  font-size: 0.9em;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .privacy-container {
    padding: 15px;
  }
  
  .privacy-header h1 {
    font-size: 2em;
  }
  
  .privacy-section {
    padding: 20px;
  }
  
  .privacy-section h2 {
    font-size: 1.5em;
  }
}

/* 可扩展的区块容器（预留：玩法介绍/语言切换/注意事项/更多推荐） */
.page-sections {
  width: 100%;
  max-width: var(--content-max-width);
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.section-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

/* 动画效果 */
@keyframes eliminate {
  0% {
    transform: scale(1);
    opacity: 1;
    background: var(--cell-bg);
  }

  30% {
    transform: scale(1.3);
    opacity: 0.9;
    background: var(--cell-selected-bg);
  }

  70% {
    transform: scale(1.1);
    opacity: 0.6;
    background: #fab1a0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
    background: var(--cell-elim-bg);
    color: var(--text-muted);
  }
}

.eliminating {
  animation: eliminate 0.5s var(--ease-out) forwards;
}

@keyframes row-delete {
  0% {
    opacity: 1;
    transform: scaleY(1);
    background: var(--cell-bg);
  }

  50% {
    opacity: 0.8;
    transform: scaleY(0.8);
    background: var(--cell-hint-bg);
  }

  100% {
    opacity: 0;
    transform: scaleY(0);
    background: var(--cell-hint-bg);
  }
}

.row-deleting {
  animation: row-delete 0.3s var(--ease-out) forwards;
}

@keyframes score-popup {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.8);
  }

  50% {
    opacity: 1;
    transform: translateY(-20px) scale(1.2);
  }

  100% {
    opacity: 0;
    transform: translateY(-40px) scale(1);
  }
}

.score-popup {
  position: absolute;
  color: var(--score-high);
  font-weight: bold;
  font-size: 14px;
  pointer-events: none;
  animation: score-popup 1.5s ease-out forwards;
  z-index: 1000;
}

/* 桌面端弹窗定位（大屏幕） */
@media (min-width: 481px) {
  .result-overlay {
    position: absolute; /* 桌面端使用相对定位 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
  }

  .start-overlay {
    position: absolute; /* 桌面端使用相对定位 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.8); /* 桌面端也需要半透明背景 */
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    padding: 10px; /* 减少body padding */
  }

  .game-container {
    padding: 15px; /* 减少容器padding */
    margin: 5px;
    width: calc(100% - 10px); /* 确保不溢出 */
  }

  .score-display {
    padding: 10px 12px;
    font-size: 14px;
    gap: 8px;
  }

  .game-grid {
    max-height: 500px; /* 改为max-height */
    padding: 8px; /* 减少网格内padding */
    gap: 2px;
  }

  .grid-cell {
    font-size: 18px;
  }

  .control-btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .page-sections {
    margin-top: 14px;
    padding: 12px 15px;
  }
}

@media (max-width: 480px) {
  .header-content {
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }
  
  .site-title {
    font-size: 1.1em;
  }
  
  .header-nav .lang-link {
    font-size: 0.85em;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    gap: 25px;
    padding: 20px 16px;
  }
  
  .footer-section {
    text-align: center;
  }

  body {
    padding: 5px; /* 进一步减少padding */
  }

  .game-container {
    padding: 10px; /* 更少的容器padding */
    margin: 0;
    width: 100%; /* 完全占满可用空间 */
  }

  .game-grid {
    gap: 1px;
    padding: 5px; /* 减少网格内padding */
    max-height: 450px; /* 改为max-height */
    margin-bottom: 15px;
  }

  .grid-cell {
    font-size: 16px; /* 稍微减小字体为小屏幕让路 */
    border-radius: 4px; /* 减小圆角节省空间 */
    min-height: 30px; /* 减小最小高度，确保不重叠 */
    min-width: 30px;
    max-height: 40px; /* 添加最大高度限制 */
  }

  .game-controls {
    gap: 10px; /* 减少按钮间距 */
  }

  .tutorial-btn {
    font-size: 13px;
  }

  .tutorial-text {
    font-size: 11px;
  }

  .control-btn {
    padding: 10px 12px;
    font-size: 13px;
    min-width: 0;
    flex: 1;
    max-width: 100px; /* 减小最大宽度 */
    min-height: 40px;
  }

  .page-sections {
    margin-top: 10px;
    padding: 10px 12px;
  }
}

/* ─── Quality, accessibility and responsive normalization ───────────── */
:root {
  --on-primary: #15313c;
  --stage-text: #142d38;
  --focus-ring: #9f3854;
  --text-muted: #706c65;
  --score-high: #1d6b54;
  --score-current: #1f628d;
  --toast-success: #1f6f55;
  --toast-error: #a5363b;
  --toast-warning: #76520b;
  --toast-info: #24658b;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --on-primary: #102932;
  --stage-text: #f0f0f8;
  --focus-ring: #ff9db5;
  --text-muted: #9d9db5;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Avenir Next", "Segoe UI", "Noto Sans", "Microsoft YaHei", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left));
  font-kerning: normal;
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 12000;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 4px 18px rgba(24, 31, 38, 0.18);
  transform: translateY(-160%);
  transition: transform 150ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

:where(button, a, summary):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.footer-bottom,
.control-btn,
.copy-btn,
.section-card summary,
.language-option.current,
.result-btn.primary,
.start-btn.primary {
  color: var(--on-primary);
}

.stage-display {
  color: var(--stage-text);
  min-height: 44px;
}

.sound-toggle,
.theme-toggle {
  min-width: 44px;
  height: 44px;
  color: var(--stage-text);
  transition: transform 150ms var(--ease-out), background-color 150ms var(--ease-out);
}

.back-to-top {
  min-height: 44px;
  padding: 8px 16px;
  color: var(--on-primary);
}

.game-grid {
  grid-template-rows: none;
  contain: layout paint;
}

.grid-cell {
  appearance: none;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 150ms var(--ease-out), border-color 150ms var(--ease-out), background-color 150ms var(--ease-out), opacity 150ms var(--ease-out);
  will-change: auto;
}

.grid-cell[hidden] {
  display: none;
}

.grid-cell:disabled {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .grid-cell.active:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  }
}

.control-btn,
.challenge-btn,
.result-btn,
.start-btn,
.calendar-close,
.calendar-nav-btn {
  min-height: 44px;
}

.tutorial-btn {
  margin-bottom: 16px;
}

.result-overlay,
.start-overlay,
.calendar-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 20px;
  border: 0;
  border-radius: 0;
  color: var(--text);
}

.result-overlay::backdrop,
.start-overlay::backdrop,
.calendar-overlay::backdrop {
  background: transparent;
}

.result-title,
.start-title {
  line-height: 1.15;
}

.toast {
  backdrop-filter: none;
  transition: transform 250ms var(--ease-out), opacity 200ms var(--ease-out);
}

.toast-success { background: var(--toast-success); }
.toast-error { background: var(--toast-error); }
.toast-warning { background: var(--toast-warning); }
.toast-info { background: var(--toast-info); }

.toast-content,
.toast-close {
  color: #fffdf8;
}

@media (max-width: 768px) {
  body {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .site-header {
    top: max(8px, env(safe-area-inset-top));
  }

  .challenge-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .challenge-btn {
    justify-content: center;
  }

  .challenge-btn:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .challenge-btn {
    flex: initial;
    min-width: 0;
    padding-inline: 10px;
    font-size: 0.8125rem;
  }

  .result-modal,
  .start-modal {
    width: min(100%, 420px);
    max-width: 100%;
    padding: 24px 18px;
  }

  .result-title,
  .start-title {
    font-size: 1.5rem;
  }

  .result-subtitle,
  .result-stat,
  .result-btn,
  .result-btn.secondary,
  .start-btn,
  .start-btn.secondary {
    font-size: 0.875rem;
  }

  .result-btn,
  .result-btn.secondary,
  .start-btn,
  .start-btn.secondary {
    min-height: 44px;
    padding: 10px 14px;
  }

  .game-grid {
    padding: 7px;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* 超小屏幕优化 (iPhone SE等) */
@media (max-width: 360px) {
  body {
    padding: 2px; /* 最小padding */
  }

  /* 超小屏幕弹窗也使用固定定位 */
  .result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.8); /* 确保超小屏幕也有半透明背景 */
  }

  .game-container {
    padding: 8px; /* 最小容器padding */
    margin: 0;
    width: 100%;
  }
  
  .game-grid {
    max-height: 400px; /* 改为max-height */
    gap: 1px;
    padding: 3px; /* 最小网格padding */
  }
  
  .grid-cell {
    font-size: 14px; /* 进一步减小字体 */
    border-radius: 3px;
    min-height: 26px; /* 更小的触摸目标，避免重叠 */
    min-width: 26px;
    max-height: 32px; /* 添加最大高度限制 */
  }
  
  .score-display {
    padding: 8px 10px;
    font-size: 12px;
    gap: 5px;
  }

  /* 移动端音效开关样式 */
  .sound-toggle {
    min-width: 20px;
    height: 20px;
    padding: 2px 4px;
    margin-left: 8px;
    font-size: 14px;
  }

  .control-btn {
    padding: 8px 10px;
    font-size: 12px;
    max-width: 120px; /* 增加最大宽度以容纳文字 */
  }

  /* 超小屏幕（320px以下）隐藏按钮文字 */
  @media (max-width: 320px) {
    .btn-text {
      display: none;
    }
    .control-btn {
      max-width: 80px; /* 隐藏文字后恢复更小宽度 */
    }
  }

  /* 超小屏幕弹窗优化 */
  .result-modal {
    padding: 15px 12px; /* 更小的内边距 */
    max-width: 90%; /* 减小宽度 */
    width: 90%; /* 固定宽度比例 */
  }
  
  .result-title {
    font-size: 18px; /* 更小的标题 */
    margin-bottom: 4px; /* 减小间距 */
  }

  .result-subtitle {
    font-size: 12px; /* 更小的副标题 */
    margin-bottom: 12px; /* 减小间距 */
  }

  .result-stats {
    margin-bottom: 12px; /* 减小间距 */
  }

  .result-stat {
    font-size: 12px; /* 更小的统计信息 */
    margin: 4px 0; /* 减小行间距 */
  }

  .result-stat.highlight {
    font-size: 14px; /* 减小高亮字号 */
  }

  .result-stat.new-record {
    font-size: 15px; /* 减小新纪录字号 */
  }
  
  .result-btn {
    font-size: 12px; /* 更小的按钮字号 */
    padding: 8px 12px; /* 更小的按钮内边距 */
    border-radius: 6px; /* 更小的圆角 */
  }

  .result-btn.secondary {
    font-size: 11px; /* 极小的次要按钮字号 */
    padding: 4px 6px; /* 极小的点击区域 */
  }

  .result-actions {
    gap: 8px; /* 更小的间距 */
  }

  /* 超小屏幕开始弹窗优化 */
  .start-modal {
    padding: 15px 12px; /* 更小的内边距 */
    max-width: 90%; /* 减小宽度 */
    width: 90%; /* 固定宽度比例 */
  }

  .start-logo {
    font-size: 36px; /* 更小的logo */
    margin-bottom: 3px; /* 极小间距 */
  }
  
  .start-title {
    font-size: 22px; /* 更小的标题 */
    margin-bottom: 1px; /* 极小间距 */
  }

  .start-subtitle {
    font-size: 14px; /* 更小的副标题 */
    margin-bottom: 6px; /* 大幅减小间距 */
  }

  .start-welcome {
    font-size: 16px; /* 更小的欢迎文字 */
    margin-bottom: 4px; /* 大幅减小间距 */
  }

  .start-description {
    font-size: 13px; /* 更小的描述文字 */
    margin-bottom: 6px; /* 大幅减小间距 */
  }

  .start-features {
    font-size: 12px; /* 更小的特性文字 */
    margin-bottom: 8px; /* 大幅减小间距 */
    padding: 10px; /* 减小内边距 */
  }

  .start-btn {
    font-size: 14px; /* 更小的按钮字号 */
    padding: 10px 16px; /* 更小的按钮内边距 */
    border-radius: 6px; /* 更小的圆角 */
  }

  .start-btn.secondary {
    font-size: 11px; /* 极小的次要按钮字号 */
    padding: 4px 6px; /* 极小的点击区域 */
  }

  .start-actions {
    gap: 8px; /* 更小的间距 */
  }
}

/* 结算层样式 */
.result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 20px; /* 匹配游戏容器的圆角 */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.result-modal {
  background: var(--surface-solid);
  border-radius: 20px;
  padding: 40px 30px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transform: scale(0.8) translateY(50px);
  animation: modalSlideIn 0.4s ease-out 0.1s forwards;
  /* 确保模态框在overlay中居中 */
  position: relative;
  margin: 0 auto;
}

@keyframes modalSlideIn {
  to {
    transform: scale(1) translateY(0);
  }
}

.result-title {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text);
}

.result-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.result-stats {
  margin-bottom: 30px;
}

.result-stat {
  margin: 12px 0;
  font-size: 16px;
  color: var(--text);
}

.result-stat.highlight {
  font-size: 18px;
  font-weight: bold;
  color: var(--score-current);
}

.result-stat.new-record {
  color: var(--score-high);
  font-size: 20px;
  font-weight: bold;
  animation: recordPulse 1s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.result-btn {
  padding: 15px 25px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.result-btn.primary {
  background: var(--primary);
  color: white;
}

.result-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(135, 206, 235, 0.4);
}

.result-btn.secondary {
  background: transparent;
  color: var(--primary-dark);
  border: none;
  padding: 8px 12px;
  font-size: 14px;
  text-decoration: underline;
  font-weight: normal;
  display: inline-block;
  width: auto;
  align-self: center;
}

.result-btn.secondary:hover {
  background: rgba(221, 160, 221, 0.1);
  color: var(--rose);
  text-decoration: none;
  transform: none;
  box-shadow: none;
}

.calendar-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 3500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.calendar-overlay[hidden] {
  display: none;
}

.calendar-overlay.calendar-open {
  opacity: 1;
  pointer-events: auto;
}

.calendar-container {
  background: var(--surface-solid);
  border-radius: 20px;
  width: min(420px, 90vw);
  padding: 28px 24px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  transform: translateY(18px);
  transition: transform 0.25s ease;
}

.calendar-overlay.calendar-open .calendar-container {
  transform: translateY(0);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar-close,
.calendar-nav-btn {
  border: none;
  background: var(--rose-bg);
  color: var(--rose);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  font-weight: 600;
}

.calendar-close:hover,
.calendar-nav-btn:hover {
  background: var(--rose-bg);
  opacity: 0.85;
  transform: translateY(-1px);
}

.calendar-nav-btn:disabled,
.calendar-nav-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
  pointer-events: none;
}

.calendar-month {
  font-size: 18px;
  font-weight: 700;
  color: var(--rose);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.calendar-weekday {
  text-align: center;
  font-weight: 600;
}

.calendar-grid {
  margin-bottom: 18px;
}

.calendar-day {
  border-radius: 10px;
  padding: 12px 0;
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid var(--rose-border);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-align: center;
}

.calendar-day:disabled,
.calendar-day[disabled],
.calendar-day--disabled {
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.45;
}

.calendar-day:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(191, 116, 138, 0.15);
  opacity: 0.85;
}

.calendar-day--outside {
  opacity: 0.4;
}

.calendar-day--locked,
.calendar-day--future {
  cursor: not-allowed;
  opacity: 0.3;
  transform: none;
  box-shadow: none;
}

.calendar-day--completed {
  background: var(--cell-hint-bg);
  border-color: rgba(84, 149, 103, 0.45);
  color: var(--score-high);
}

.calendar-day--today {
  box-shadow: 0 0 0 2px rgba(255, 155, 102, 0.35);
}

.calendar-day--active {
  box-shadow: 0 0 0 3px rgba(123, 74, 112, 0.45);
}

.calendar-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-item::before {
  content: '●';
  margin-right: 6px;
  font-size: 12px;
}

.legend-item.legend-available::before {
  color: var(--rose);
}

.legend-item.legend-completed::before {
  color: var(--score-high);
}

.legend-item.legend-locked::before {
  color: var(--text-muted);
}

/* 胜利特效 */
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffd700;
  animation: confettiFall 2.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  top: -20px; /* 从容器顶部上方开始 */
  z-index: 4000; /* 高于结果弹窗 */
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0deg);
  }
  20% {
    opacity: 1;
    transform: translateY(100px) translateX(var(--drift, 0px)) rotate(144deg);
  }
  50% {
    opacity: 1;
    transform: translateY(300px) translateX(var(--drift, 0px)) rotate(360deg);
  }
  80% {
    opacity: 1;
    transform: translateY(600px) translateX(var(--drift, 0px)) rotate(576deg);
  }
  95% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(800px) translateX(var(--drift, 0px)) rotate(720deg);
  }
}

.confetti:nth-child(2n) {
  background: #ff6b6b;
  animation-delay: 0.1s;
  animation-duration: 2.6s;
  --drift: -30px;
}

.confetti:nth-child(3n) {
  background: #4ecdc4;
  animation-delay: 0.2s;
  animation-duration: 3.0s;
  --drift: 25px;
}

.confetti:nth-child(4n) {
  background: #45b7d1;
  animation-delay: 0.3s;
  animation-duration: 2.9s;
  --drift: -15px;
}

.confetti:nth-child(5n) {
  --drift: 40px;
}

.confetti:nth-child(6n) {
  --drift: -25px;
}

/* 响应式调整 */
@media (max-width: 480px) {
  /* 移动端弹窗改为固定定位，相对视口居中 */
  .result-overlay {
    position: fixed; /* 改为固定定位 */
    top: 0;
    left: 0;
    width: 100vw; /* 占满视口宽度 */
    height: 100vh; /* 占满视口高度 */
    border-radius: 0; /* 移除圆角，因为覆盖整个视口 */
  }

  .start-overlay {
    position: fixed; /* 开始弹窗也改为固定定位 */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.8); /* 确保移动端也有半透明背景 */
  }

  .result-modal {
    padding: 18px 15px; /* 进一步减少内边距 */
    max-width: 85%; /* 减小最大宽度，确保居中 */
    width: 85%; /* 设置固定宽度比例 */
  }
  
  .result-title {
    font-size: 20px; /* 进一步减小标题字号 */
    margin-bottom: 6px; /* 减少下边距 */
  }

  .result-subtitle {
    font-size: 13px; /* 减小副标题字号 */
    margin-bottom: 15px; /* 减少下边距 */
  }

  .result-stats {
    margin-bottom: 15px; /* 减少下边距 */
  }

  .result-stat {
    font-size: 13px; /* 减小统计信息字号 */
    margin: 6px 0; /* 减少行间距 */
  }

  .result-stat.highlight {
    font-size: 15px; /* 减小高亮字号 */
  }

  .result-stat.new-record {
    font-size: 16px; /* 减小新纪录字号 */
  }
  
  .result-btn {
    font-size: 13px; /* 减小按钮字号 */
    padding: 10px 15px; /* 减少按钮内边距 */
    margin: 0; /* 移除外边距 */
    border-radius: 8px; /* 减小圆角 */
  }

  .result-btn.secondary {
    font-size: 12px; /* 次要按钮更小字号 */
    padding: 6px 8px; /* 更小的点击区域 */
  }

  .result-actions {
    gap: 10px; /* 减少按钮间距 */
  }

  .start-modal {
    padding: 20px 15px; /* 进一步减少内边距 */
    max-width: 85%; /* 与结算弹窗一致的宽度 */
    width: 85%; /* 设置固定宽度比例 */
  }

  .start-logo {
    font-size: 40px; /* 减小logo字号 */
    margin-bottom: 6px; /* 大幅减少间距 */
  }
  
  .start-title {
    font-size: 24px; /* 进一步减小标题字号 */
    margin-bottom: 2px; /* 大幅减少下边距 */
  }

  .start-subtitle {
    font-size: 15px; /* 减小副标题字号 */
    margin-bottom: 8px; /* 大幅减少间距 */
  }

  .start-welcome {
    font-size: 18px; /* 减小欢迎文字 */
    margin-bottom: 6px; /* 大幅减少间距 */
  }

  .start-description {
    font-size: 14px; /* 减小描述文字 */
    margin-bottom: 8px; /* 大幅减少间距 */
  }

  .start-features {
    font-size: 13px; /* 减小特性文字 */
    margin-bottom: 12px; /* 大幅减少间距 */
    padding: 12px; /* 减少内边距 */
  }

  .start-btn {
    font-size: 15px; /* 减小按钮字号 */
    padding: 12px 20px; /* 减小按钮内边距 */
    border-radius: 8px; /* 减小圆角 */
  }

  .start-btn.secondary {
    font-size: 12px; /* 次要按钮更小字号 */
    padding: 6px 8px; /* 更小的点击区域 */
  }

  .start-actions {
    gap: 10px; /* 减小按钮间距 */
  }
}

/* 开始界面样式 */
.start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8); /* 与结算弹窗一致的半透明背景 */
  border-radius: 20px; /* 匹配游戏容器的圆角 */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}

.start-modal {
  background: var(--surface-solid);
  border-radius: 24px;
  padding: 50px 40px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
  transform: scale(0.9) translateY(30px);
  animation: startModalSlideIn 0.6s ease-out 0.2s forwards;
  /* 确保模态框在overlay中居中 */
  position: relative;
  margin: 0 auto;
}

@keyframes startModalSlideIn {
  to {
    transform: scale(1) translateY(0);
  }
}

.start-title {
  font-size: 36px;
  font-weight: bold;
  margin-bottom: 8px;
  color: var(--primary-dark);
}

.start-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 25px;
}

.start-welcome {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}

.start-description {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 25px;
}

.start-description.secondary {
  color: var(--rose);
  margin-bottom: 20px;
}

.start-features {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 35px;
  text-align: left;
  background: var(--surface-muted);
  padding: 20px;
  border-radius: 12px;
  white-space: pre-line;
}

.start-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.start-btn {
  padding: 16px 30px;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.start-btn.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 20px rgba(135, 206, 235, 0.3);
}

.start-btn.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(135, 206, 235, 0.5);
}

.start-btn.secondary {
  background: transparent; /* 透明背景 */
  color: var(--primary-dark); /* 主题色文字 */
  border: none; /* 移除边框 */
  padding: 8px 12px; /* 减小点击区域 */
  font-size: 14px; /* 减小字号 */
  text-decoration: underline; /* 添加下划线表示可点击 */
  font-weight: normal; /* 减轻字重 */
  box-shadow: none; /* 移除阴影 */
  display: inline-block; /* 内容自适应宽度 */
  width: auto; /* 自动宽度 */
  align-self: center; /* 在flex容器中居中 */
}

.start-btn.secondary:hover {
  background: rgba(221, 160, 221, 0.1); /* 轻微背景色 */
  color: #CD853F; /* 深一点的颜色 */
  text-decoration: none; /* hover时移除下划线 */
  transform: none; /* 移除位移效果 */
  box-shadow: none; /* 确保移除阴影 */
}

.start-btn.secondary::before {
  display: none; /* 禁用光效动画 */
}

.start-btn.tertiary {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid var(--rose-border);
  font-weight: 600;
}

.start-btn.tertiary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(187, 85, 109, 0.25);
  opacity: 0.92;
}

.start-btn.ghost {
  background: transparent;
  border: 1px dashed var(--rose-border);
  color: var(--rose);
  font-weight: 600;
}

.start-btn.ghost:hover {
  background: var(--rose-bg);
  transform: none;
}

/* 游戏logo动画效果 */
.start-logo {
  font-size: 48px;
  margin-bottom: 15px;
  animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Toast通知系统样式 */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  max-width: 350px;
  min-width: 280px;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(8px);
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-show {
  transform: translateX(0);
  opacity: 1;
}

.toast-content {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 12px;
  color: white;
  font-size: 14px;
  font-weight: 500;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s, background-color 0.2s;
}

.toast-close:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.1);
}

/* Toast类型样式 */
.toast-success {
  background: #56c497;
}

.toast-error {
  background: #e66a6a;
}

.toast-warning {
  background: #f5c26b;
}

.toast-info {
  background: var(--primary);
}

/* 移动端Toast适配 */
@media (max-width: 480px) {
  .toast {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
    min-width: auto;
    transform: translateY(-100px);
  }
  
  .toast-show {
    transform: translateY(0);
  }
  
  .toast-content {
    padding: 14px 16px;
    font-size: 13px;
  }
}

/* 语言切换组件样式 */
.language-selector {
  margin-top: 16px;
}

.language-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.language-option {
  background: var(--surface-muted);
  border: 2px solid var(--border-muted);
  border-radius: 12px;
  padding: 16px 24px;
  transition: all 0.3s ease;
  text-decoration: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  position: relative;
  overflow: hidden;
}

.language-option:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: var(--surface-solid);
  box-shadow: 0 8px 20px rgba(135, 206, 235, 0.2);
}

.language-option.current {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(135, 206, 235, 0.3);
}

.language-option.current:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.language-native {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .challenge-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .challenge-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }

  .challenge-info {
    min-width: auto;
    width: 100%;
  }

  .challenge-btn {
    padding: 9px 14px;
    font-size: 13px;
  }

  .language-options {
    gap: 10px;
  }
  
  .language-option {
    min-width: 100px;
    padding: 14px 20px;
    font-size: 15px;
  }
  
  .language-native {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .challenge-bar {
    padding: 16px;
  }

  .challenge-title {
    font-size: 18px;
  }

  .challenge-btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .calendar-container {
    width: 92vw;
    padding: 22px 18px;
  }

  .calendar-weekdays {
    font-size: 12px;
  }

  .calendar-day {
    padding: 10px 0;
    font-size: 13px;
  }

  .language-options {
    gap: 8px;
  }
  
  .language-option {
    min-width: 85px;
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .language-native {
    font-size: 15px;
    margin-bottom: 2px;
  }
}

/* Keep this final cascade after legacy mobile rules. */
.result-overlay,
.start-overlay,
.calendar-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 20px;
  border: 0;
  border-radius: 0;
}

.result-overlay::backdrop,
.start-overlay::backdrop,
.calendar-overlay::backdrop {
  background: transparent;
}

.sound-toggle,
.theme-toggle,
.control-btn,
.challenge-btn,
.result-btn,
.start-btn,
.calendar-close,
.calendar-nav-btn {
  min-height: 44px;
}

.sound-toggle,
.theme-toggle {
  min-width: 44px;
  height: 44px;
  color: var(--stage-text);
}

.grid-cell {
  transition: transform 150ms var(--ease-out), border-color 150ms var(--ease-out), background-color 150ms var(--ease-out), opacity 150ms var(--ease-out);
  will-change: auto;
}

.toast-success { background: var(--toast-success); }
.toast-error { background: var(--toast-error); }
.toast-warning { background: var(--toast-warning); }
.toast-info { background: var(--toast-info); }

@media (max-width: 768px) {
  .challenge-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .challenge-btn {
    flex: initial;
    min-width: 0;
    justify-content: center;
  }

  .challenge-btn:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .result-modal,
  .start-modal {
    width: min(100%, 420px);
    max-width: 100%;
    padding: 24px 18px;
  }

  .result-title,
  .start-title {
    font-size: 1.5rem;
  }

  .result-subtitle,
  .result-stat,
  .result-btn,
  .result-btn.secondary,
  .start-btn,
  .start-btn.secondary {
    font-size: 0.875rem;
  }

  .result-btn,
  .result-btn.secondary,
  .start-btn,
  .start-btn.secondary {
    min-height: 44px;
    padding: 10px 14px;
  }
}


/* Original tutorial styles */
/* 教程覆盖层样式 */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 4000;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

body.tutorial-open {
  overflow-y: auto;
}

body.tutorial-open .game-container {
  z-index: 4001;
}

/* 教程高亮格子 */
.tutorial-highlight {
  position: relative;
  z-index: 4001 !important;
  box-shadow: 0 0 0 3px #ffd700, 0 0 20px rgba(255, 215, 0, 0.5) !important;
  animation: tutorial-pulse 2s ease-in-out infinite;
}

@keyframes tutorial-pulse {
  0%, 100% {
    box-shadow: 0 0 0 3px #ffd700, 0 0 20px rgba(255, 215, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 0 5px #ffd700, 0 0 25px rgba(255, 215, 0, 0.8);
  }
}

/* 教程提示框 */
.tutorial-tooltip {
  position: relative;
  width: 100%;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  max-width: none;
  min-width: 0;
  margin-bottom: 18px;
  z-index: 1;
  font-family: inherit;
  overflow: hidden;
}

.tutorial-header {
  background: var(--primary);
  color: var(--on-primary);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tutorial-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
}

.tutorial-progress {
  background: rgba(255, 255, 255, 0.2);
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: bold;
}

.tutorial-content {
  padding: 20px;
  background: var(--surface-solid);
}

.tutorial-content p {
  margin: 0;
  line-height: 1.6;
  font-size: 16px;
  color: var(--text);
}

.tutorial-actions {
  padding: 20px;
  padding-top: 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-solid);
}

.tutorial-nav-actions {
  display: flex;
  gap: 10px;
}

.tutorial-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
  min-height: 44px;
}

.tutorial-btn:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.tutorial-btn.tutorial-btn-primary {
  background: var(--primary) !important;
  color: var(--on-primary);
}

.tutorial-btn.tutorial-btn-primary:hover {
  background: var(--primary-hover) !important;
  transform: translateY(-1px);
}

.tutorial-btn.tutorial-btn-secondary {
  background: var(--surface-muted) !important;
  color: var(--text);
  border: 1px solid var(--border);
}

.tutorial-btn.tutorial-btn-secondary:hover {
  background: var(--border-muted) !important;
  transform: translateY(-1px);
}

.tutorial-btn.tutorial-btn-secondary:disabled:hover {
  background: var(--surface-muted) !important;
  transform: none;
}

.tutorial-btn.tutorial-btn-skip {
  background: transparent !important;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.tutorial-btn.tutorial-btn-skip:hover {
  background: var(--surface-muted) !important;
  transform: translateY(-1px);
}

/* 教程状态时禁用游戏交互 */
.tutorial-active .game-controls button:not(.tutorial-allowed) {
  pointer-events: none;
  opacity: 0.5;
}

.tutorial-active .challenge-actions,
.tutorial-active .stage-display {
  opacity: 0.5;
  pointer-events: none;
}

.tutorial-active .grid-cell:not(.tutorial-highlight):not(.tutorial-allowed) {
  cursor: not-allowed;
  opacity: 0.6;
}

/* 教程中的特殊状态 */
.tutorial-tooltip.tutorial-step-copy {
  /* 复制步骤的特殊样式 */
}

.tutorial-tooltip.tutorial-step-victory {
  /* 胜利步骤的特殊样式 */
}

.tutorial-tooltip.tutorial-step-victory .tutorial-header {
  background: var(--score-high);
}

/* 响应式适配 */
@media (max-width: 600px) {
  .tutorial-tooltip {
    max-width: none;
    min-width: 0;
    margin: 0 0 14px;
  }
  
  .tutorial-header {
    padding: 15px;
  }
  
  .tutorial-header h3 {
    font-size: 16px;
  }
  
  .tutorial-content {
    padding: 15px;
  }
  
  .tutorial-content p {
    font-size: 14px;
  }
  
  .tutorial-actions {
    padding: 15px;
    padding-top: 0;
    align-items: stretch;
  }

  .tutorial-nav-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  
  .tutorial-btn {
    width: 100%;
    margin-bottom: 5px;
  }
}

@media (max-width: 400px) {
  .tutorial-tooltip {
    min-width: 0;
  }
  
  .tutorial-header {
    padding: 12px;
  }
  
  .tutorial-content {
    padding: 12px;
  }
  
  .tutorial-actions {
    padding: 12px;
    padding-top: 0;
  }
}

/* 教程完成后的庆祝效果 */
@keyframes tutorial-celebration {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-5deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  75% { transform: scale(1.1) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.tutorial-victory-animation {
  animation: tutorial-celebration 0.6s ease-in-out;
}

/* 错误点击时的提示效果 */
@keyframes tutorial-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.tutorial-error-shake {
  animation: tutorial-shake 0.3s ease-in-out;
}

/* 教程按钮在主界面中的样式 */
.tutorial-main-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #ffd700;
  color: #333;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 100;
  transition: all 0.2s ease;
}

.tutorial-main-btn:hover {
  background: #ffed4e;
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 600px) {
  .tutorial-main-btn {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
}

/* 隐藏教程按钮的类（在教程进行时使用） */
.tutorial-main-btn.hidden {
  display: none;
}

/* 教程中高亮复制按钮 */
.tutorial-highlight-copy-btn {
  position: relative;
  z-index: 4001 !important;
  box-shadow: 0 0 0 3px #ffd700, 0 0 20px rgba(255, 215, 0, 0.5) !important;
  animation: tutorial-pulse 2s ease-in-out infinite;
}

/* 教程模式标识 */
.tutorial-mode-indicator {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 215, 0, 0.9);
  color: #333;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  z-index: 3999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .tutorial-mode-indicator {
  background: rgba(255, 215, 0, 0.75);
  color: #1a1a1a;
}

@media (prefers-reduced-motion: reduce) {
  .tutorial-highlight,
  .tutorial-victory-animation,
  .tutorial-error-shake,
  .tutorial-highlight-copy-btn {
    animation: none !important;
  }
}

/* 在教程模式下隐藏某些UI元素 */
.tutorial-active .game-header .stage-display {
  opacity: 0.5;
  pointer-events: none;
}

.tutorial-active .game-status {
  opacity: 0.7;
}
