:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --border-strong: #374151;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --success: #16a34a;
  --cell-size: 40px;
  --mine-cell: 28px;
  --puzzle-tile: 80px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* 顶栏占位（游戏导航 + 工具栏行） */
  --top-bar-offset: 5.75rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Top bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* —— 顶部游戏导航菜单 —— */
.game-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.game-nav-bar {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.site-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.8rem clamp(0.75rem, 3vw, 1.25rem);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.site-brand__logo {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  display: block;
}

.site-brand__title {
  line-height: 1.2;
}

.lang-switcher {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  align-self: center;
  padding: 0  clamp(0.75rem, 3vw, 1.25rem) 0 0.5rem;
}

.lang-select {
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.35rem 1.75rem 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 7.25rem;
  max-width: 9.5rem;
  line-height: 1.3;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
}

.lang-select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.game-nav-inner {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0 0.5rem;
}

.game-nav-list {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, transparent, #000 20px, #000 calc(100% - 20px), transparent);
}

.game-nav-list::-webkit-scrollbar {
  display: none;
}

.game-nav-item {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  padding: 0.8rem 1.05rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.game-nav-item::after {
  content: '';
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.22s ease;
}

.game-nav-item:hover {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.07);
}

.game-nav-item:hover::after {
  transform: scaleX(0.55);
}

.game-nav-item:focus-visible {
  outline: none;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.game-nav-item.active {
  color: var(--primary);
  font-weight: 600;
}

.game-nav-item.active::after {
  transform: scaleX(1);
}

.game-nav-item.active:hover {
  background: rgba(37, 99, 235, 0.1);
}

.game-nav-item.active:hover::after {
  transform: scaleX(1);
}

/* —— 工具栏 + 状态栏 —— */
.top-bar-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  min-width: 0;
  padding: 0.55rem 1rem 0.65rem;
  background: var(--bg);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.top-bar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  min-width: 0;
}

.game-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.top-bar-controls .status-bar {
  flex: 0 1 auto;
  margin-left: auto;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  max-width: 100%;
}

.top-bar-controls .status-bar strong {
  color: var(--text);
  font-weight: 600;
}

/* Buttons */
.btn {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toolbar-group label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.toolbar-group select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

/* Page layout (game + optional sidebar ads) — 整页自然高度，由浏览器滚动 */
.page-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.page-main {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem);
  min-width: 0;
}

/* 游戏主舞台：占满首屏（顶栏以下），棋盘相对上下分隔线等距居中 */
.game-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  /* 高度 ≈ 视口 − 顶栏，加载时游戏落在屏幕垂直中心 */
  min-height: calc(100svh - var(--top-bar-offset));
  min-height: calc(100dvh - var(--top-bar-offset));
  padding: clamp(1.65rem, 4.67vh, 3rem) 0;
}

@media (min-width: 1024px) {
  .page-layout {
    flex-direction: row;
    align-items: stretch;
  }
}

/* Ad slots — hidden by default; shown only when body.ads-enabled */
.ad-slot {
  display: none;
  position: relative;
  background: #eef0f3;
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.ad-slot[hidden] {
  display: none !important;
}

body.ads-enabled .ad-banner-bottom:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 90px;
  max-height: 120px;
  margin-top: 12px;
}

body.ads-enabled .ad-sidebar:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: flex-start;
  min-width: 160px;
  max-width: 300px;
  min-height: 600px;
  margin-top: 1rem;
  margin-left: 12px;
}

body.ads-debug .ad-slot:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-style: dashed;
}

body.ads-debug .ad-banner-bottom:not([hidden]) {
  width: 100%;
  min-height: 90px;
  max-height: 120px;
  margin-top: 12px;
}

body.ads-debug .ad-sidebar:not([hidden]) {
  min-width: 160px;
  max-width: 300px;
  min-height: 200px;
  margin-top: 1rem;
  margin-left: 12px;
}

@media (min-width: 1024px) {
  body.ads-debug .page-layout {
    flex-direction: row;
  }

  body.ads-debug .ad-sidebar:not([hidden]) {
    min-height: 600px;
  }
}

.ad-label {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.ad-slot-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.ad-slot-inner .adsbygoogle {
  max-width: 100%;
}

.ad-banner-bottom.ad-slot--modal-hidden {
  visibility: hidden;
}

.ad-debug-placeholder {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Main area */
.game-container {
  flex: 0 0 auto;
  width: max-content;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: auto;
}

.game-loading {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Game help — 随整页滚动，无内层滚动条 */
.game-help {
  width: 100%;
  margin: 0;
  padding: 1.75rem 0 2rem;
  border-top: 1px solid var(--border);
}

.game-help-header {
  margin-bottom: 1.25rem;
}

.game-help-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.game-help-intro {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.game-help-body {
  overflow: visible;
}

.game-help-panel.hidden {
  display: none;
}

.help-article {
  animation: help-fade 200ms ease;
}

@keyframes help-fade {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.help-lead {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}

.help-card {
  margin-bottom: 1.25rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.help-card--accent {
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border-color: #bfdbfe;
}

.help-card--figure {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 640px) {
  .help-card--figure {
    grid-template-columns: auto 1fr;
  }
}

.help-figure {
  margin: 0;
  text-align: center;
}

.help-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.help-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.help-card-text {
  min-width: 0;
}

.help-h3 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.help-h4 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.help-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.help-list li {
  margin-bottom: 0.35rem;
}

.help-list li:last-child {
  margin-bottom: 0;
}

.help-list strong {
  color: var(--text);
}

.help-columns {
  display: grid;
  gap: 1rem;
}

@media (min-width: 560px) {
  .help-columns {
    grid-template-columns: 1fr 1fr;
  }
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.help-table th,
.help-table td {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  text-align: left;
}

.help-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text);
}

.help-table td {
  color: var(--text-muted);
}

.help-note {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
}

.help-steps {
  margin: 0;
  padding-left: 1.35rem;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.help-steps li {
  margin-bottom: 0.5rem;
}

.help-steps li:last-child {
  margin-bottom: 0;
}

.help-faq {
  margin: 0;
}

.help-faq dt {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  margin-top: 0.75rem;
}

.help-faq dt:first-child {
  margin-top: 0;
}

.help-faq dd {
  margin: 0.25rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.help-tag-list {
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.help-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1rem;
  background: #e5e7eb;
}

.help-tag.n1 { color: #2563eb; }
.help-tag.n2 { color: #16a34a; }
.help-tag.n3 { color: #dc2626; }
.help-tag.n4 { color: #7c3aed; }
.help-tag.n5 { color: #b45309; }
.help-tag.n6 { color: #0891b2; }
.help-tag.n7 { color: #1f2937; }
.help-tag.n8 { color: #6b7280; }

kbd {
  display: inline-block;
  padding: 0.1em 0.35em;
  font-size: 0.85em;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border);
}

.site-footer {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 4vw, 2rem) 2.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
}

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

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

.site-footer p a {
  color: var(--primary);
  text-decoration: none;
}

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

@media (max-width: 639px) {
  :root {
    --top-bar-offset: 5.75rem;
  }

  .game-stage {
    padding: clamp(1.35rem, 4vh, 2.35rem) 0;
  }

  .top-bar .status-bar {
    flex: 1 1 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--surface);
  padding: 1.5rem 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  max-width: 90vw;
}

.modal h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.modal p {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.modal-actions .btn.hidden {
  display: none;
}

/* ========== Sudoku ========== */
.sudoku-wrap {
  --sudoku-cell-size: calc(var(--cell-size) * 1.5);
  --sudoku-scale: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(1rem * var(--sudoku-scale));
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, var(--sudoku-cell-size));
  border: calc(2px * var(--sudoku-scale)) solid var(--border-strong);
  background: var(--surface);
}

.sudoku-cell {
  width: var(--sudoku-cell-size);
  height: var(--sudoku-cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  font-size: calc(1.25rem * var(--sudoku-scale));
  cursor: pointer;
  user-select: none;
  position: relative;
  background: var(--surface);
}

.sudoku-cell.given {
  font-weight: 700;
  background: #eef2f7;
  color: var(--text);
  cursor: default;
}

.sudoku-cell.hovered:not(.selected) {
  box-shadow: inset 0 0 0 calc(2px * var(--sudoku-scale)) #c7d2e0;
}

.sudoku-cell.same-value {
  background: #dbeafe;
  color: var(--primary);
  font-weight: 600;
}

.sudoku-cell.given.same-value {
  color: var(--primary);
}

.sudoku-cell.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  z-index: 1;
}

.sudoku-cell.error {
  background: var(--error-bg);
  color: var(--error);
  box-shadow: inset 0 0 0 2px var(--error);
}

.sudoku-cell.error.same-value {
  color: var(--error);
}

.sudoku-cell.box-right {
  border-right: calc(2px * var(--sudoku-scale)) solid var(--border-strong);
}

.sudoku-cell.box-bottom {
  border-bottom: calc(2px * var(--sudoku-scale)) solid var(--border-strong);
}

.sudoku-cell .notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  font-size: calc(0.55rem * var(--sudoku-scale));
  color: var(--text-muted);
  padding: calc(2px * var(--sudoku-scale));
  line-height: 1;
}

.sudoku-cell .notes span {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sudoku-controls {
  display: flex;
  flex-wrap: wrap;
  gap: calc(0.5rem * var(--sudoku-scale));
  justify-content: center;
  max-width: calc(400px * var(--sudoku-scale));
  width: 100%;
}

.sudoku-numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: calc(0.35rem * var(--sudoku-scale));
  width: 100%;
}

.sudoku-numpad .btn {
  min-width: calc(36px * var(--sudoku-scale));
  padding: calc(0.5rem * var(--sudoku-scale));
  font-size: calc(1rem * var(--sudoku-scale));
  font-weight: 600;
}

/* ========== Minesweeper ========== */
.game-stage:has(.game-container--mines) {
  align-items: stretch;
}

.game-container--mines {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.mines-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
}

.mines-board {
  display: grid;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  --mine-cell: 28px;
  grid-auto-rows: var(--mine-cell);
  border: 2px solid var(--border-strong);
  background: var(--border);
  gap: 1px;
  touch-action: manipulation;
}

.mine-cell {
  width: var(--mine-cell);
  height: var(--mine-cell);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: max(0.65rem, calc(var(--mine-cell) * 0.42));
  font-weight: 700;
  border: none;
  padding: 0;
  cursor: pointer;
  background: #c4c9d4;
  box-shadow: inset 2px 2px 0 #e8ebf0, inset -2px -2px 0 #9ca3af;
}

.mine-cell:hover:not(:disabled) {
  filter: brightness(1.03);
}

.mine-cell.revealed {
  background: #e5e7eb;
  box-shadow: none;
  cursor: default;
}

.mine-cell.flagged {
  background: #c4c9d4;
  color: var(--error);
  font-size: 1rem;
}

.mine-cell.flagged::after {
  content: "🚩";
  font-size: 0.75rem;
}

.mine-cell.mine-hit {
  background: var(--error-bg);
}

.mine-cell.mine-revealed {
  background: #fecaca;
}

.mine-cell.mine-revealed::after {
  content: "💣";
  font-size: 0.7rem;
}

.mine-cell:disabled {
  cursor: default;
}

.mine-cell.num-1 { color: #2563eb; }
.mine-cell.num-2 { color: #16a34a; }
.mine-cell.num-3 { color: #dc2626; }
.mine-cell.num-4 { color: #7c3aed; }
.mine-cell.num-5 { color: #b45309; }
.mine-cell.num-6 { color: #0891b2; }
.mine-cell.num-7 { color: #1f2937; }
.mine-cell.num-8 { color: #6b7280; }

/* ========== 15 Puzzle / 滑块拼图 ========== */
.puzzle15-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
}

.puzzle15-image-label {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

.puzzle15-layout {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0.25rem;
}

.puzzle15-main {
  flex: 0 0 auto;
  order: 1;
}

.puzzle15-preview {
  flex: 0 0 auto;
  order: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.55rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.puzzle15-preview-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.puzzle15-preview-frame {
  box-sizing: border-box;
  flex-shrink: 0;
  width: var(--puzzle-preview-size, 120px);
  height: var(--puzzle-preview-size, 120px);
  padding: 3px;
  background: var(--border-strong);
  border-radius: 8px;
  line-height: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.puzzle15-preview-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg);
}

.puzzle15-preview-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.puzzle15-board {
  display: inline-grid;
  gap: 3px;
  padding: 3px;
  background: var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  touch-action: manipulation;
}

.puzzle15-tile {
  width: var(--puzzle-tile);
  height: var(--puzzle-tile);
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background-color: #c4c9d4;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition: filter 0.12s ease, transform 0.1s ease;
}

.puzzle15-tile:not(.empty):hover {
  filter: brightness(1.06);
  z-index: 1;
}

.puzzle15-tile:not(.empty):active {
  transform: scale(0.98);
}

.puzzle15-tile:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  z-index: 2;
}

.puzzle15-tile.empty {
  background: #e5e7eb;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.06);
  cursor: default;
  visibility: visible;
}

@media (max-width: 600px) {
  :root {
    --cell-size: 34px;
    --mine-cell: 24px;
    --top-bar-offset: 5.5rem;
  }

  .game-nav-item {
    padding: 0.7rem 0.85rem;
    font-size: 0.875rem;
  }

  .game-nav-item::after {
    left: 0.65rem;
    right: 0.65rem;
  }

  .site-brand {
    padding: 0.7rem clamp(0.65rem, 3vw, 1rem);
    font-size: 0.8125rem;
    gap: 0.35rem;
  }

  .site-brand__logo {
    width: 1.5rem;
    height: 1.5rem;
  }

  .lang-switcher {
    padding: 0 0.65rem 0 0.35rem;
  }

  .lang-select {
    min-width: 6.5rem;
    max-width: 8rem;
    font-size: 0.75rem;
    padding-right: 1.5rem;
  }

  .top-bar-controls {
    padding: 0.45rem 0.65rem 0.5rem;
  }

  .top-bar-controls .status-bar {
    margin-left: 0;
    width: 100%;
  }

  .memory-board {
    --memory-card-size: 64px;
  }

  .g2048-cell {
    width: 64px;
    height: 64px;
    font-size: 1.35rem;
  }
}

/* —— 2048 —— */
.game-container--2048 {
  display: flex;
  justify-content: center;
  width: 100%;
}

.g2048-wrap {
  text-align: center;
}

.g2048-hint {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.g2048-board {
  display: inline-grid;
  grid-template-columns: repeat(var(--g2048-n, 4), 1fr);
  gap: 8px;
  padding: 10px;
  background: #bbada0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  touch-action: none;
}

.g2048-cell {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1.5rem;
  background: rgba(238, 228, 218, 0.35);
  color: var(--text);
  user-select: none;
}

.g2048-cell.tile-empty {
  background: rgba(238, 228, 218, 0.35);
}

.g2048-cell.tile-v1 { background: #eee4da; color: #776e65; }
.g2048-cell.tile-v2 { background: #ede0c8; color: #776e65; }
.g2048-cell.tile-v3 { background: #f2b179; color: #f9f6f2; }
.g2048-cell.tile-v4 { background: #f59563; color: #f9f6f2; }
.g2048-cell.tile-v5 { background: #f67c5f; color: #f9f6f2; }
.g2048-cell.tile-v6 { background: #f65e3b; color: #f9f6f2; }
.g2048-cell.tile-v7 { background: #edcf72; color: #f9f6f2; }
.g2048-cell.tile-v8 { background: #edcc61; color: #f9f6f2; }
.g2048-cell.tile-v9 { background: #edc850; color: #f9f6f2; }
.g2048-cell.tile-v10 { background: #edc53f; color: #f9f6f2; }
.g2048-cell.tile-v11 { background: #edc22e; color: #f9f6f2; font-size: 1.25rem; }
.g2048-cell.tile-v12,
.g2048-cell.tile-v13,
.g2048-cell.tile-v14,
.g2048-cell.tile-v15,
.g2048-cell.tile-v16,
.g2048-cell.tile-v17 {
  background: #3c3a32;
  color: #f9f6f2;
  font-size: 1.1rem;
}

/* —— 记忆翻牌 —— */
.game-container--memory {
  display: flex;
  justify-content: center;
  width: 100%;
}

.memory-loading {
  color: var(--text-muted);
  text-align: center;
}

.memory-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.memory-board {
  --memory-card-size: 76px;
  display: grid;
  grid-template-columns: repeat(var(--memory-cols, 4), var(--memory-card-size));
  gap: 8px;
  padding: 4px;
}

.memory-card {
  width: var(--memory-card-size);
  height: var(--memory-card-size);
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--primary);
  cursor: pointer;
  position: relative;
  perspective: 400px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.memory-card:not(:disabled):hover {
  border-color: var(--primary-hover);
  transform: scale(1.02);
}

.memory-card:disabled:not(.matched) {
  cursor: default;
}

.memory-card.matched {
  border-color: var(--success);
  opacity: 0.85;
  cursor: default;
}

.memory-back,
.memory-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  transition: transform 0.35s ease;
}

.memory-back {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
}

.memory-face {
  transform: rotateY(180deg);
  background: var(--surface);
}

.memory-face--emoji {
  font-size: 2rem;
}

.memory-face--img {
  background-size: cover;
  background-position: center;
}

.memory-card.face-up .memory-back {
  transform: rotateY(180deg);
}

.memory-card.face-up .memory-face {
  transform: rotateY(0);
}

/* —— 24点 —— */
.game-container--twentyfour {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.tf-wrap {
  text-align: center;
}

.tf-daily-badge {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 0.75rem;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
}

.tf-cards {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.tf-card {
  width: 72px;
  height: 96px;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.tf-card-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.tf-card-value {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tf-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tf-expr-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.tf-expr-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.tf-hint-text {
  margin: 0;
  min-height: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.tf-keyboard {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}

.tf-keyboard-hint {
  margin: 0 0 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tf-kb-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.tf-kb-row:last-child {
  margin-bottom: 0;
}

.tf-kb-row-nums {
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.tf-kb-key {
  min-width: 2.75rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
  touch-action: manipulation;
}

.tf-kb-key:hover:not(:disabled) {
  background: #eff6ff;
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
}

.tf-kb-key:active:not(:disabled) {
  transform: scale(0.96);
}

.tf-kb-key:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.tf-kb-key:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tf-kb-num {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  min-height: 3rem;
  padding: 0.35rem 0.5rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.tf-kb-num-label {
  font-size: 1rem;
  line-height: 1.1;
  color: var(--primary);
}

.tf-kb-num-value {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
}

.tf-kb-op {
  min-width: 3rem;
  font-size: 1.15rem;
}

.tf-kb-fn {
  min-width: 4.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.tf-kb-row-actions {
  margin-top: 0.15rem;
}

@media (max-width: 400px) {
  .tf-kb-num {
    min-width: 2.85rem;
    min-height: 2.75rem;
  }

  .tf-kb-key {
    min-width: 2.5rem;
    padding: 0.45rem 0.5rem;
  }
}

/* —— 点灯 —— */
.game-container--lightsout {
  display: flex;
  justify-content: center;
  width: 100%;
}

.lo-wrap {
  text-align: center;
}

.lo-hint {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.lo-board {
  display: inline-grid;
  grid-template-columns: repeat(var(--lo-n, 3), 1fr);
  gap: 6px;
  padding: 8px;
  background: var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.lo-cell {
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  background: #374151;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.lo-cell.on {
  background: #fbbf24;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.6), inset 0 0 8px rgba(255, 255, 255, 0.4);
}

.lo-cell:hover {
  transform: scale(1.04);
}

.lo-cell:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* —— 数织 —— */
.game-container--nonogram {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.ng-wrap {
  max-width: 100%;
}

.ng-title {
  text-align: center;
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.ng-meta {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.875rem;
}

.ng-board-outer {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    'corner col-clues'
    'row-clues grid';
  gap: 4px;
  margin: 0 auto;
}

.ng-corner {
  grid-area: corner;
}

.ng-col-clues {
  grid-area: col-clues;
}

.ng-row-clues {
  grid-area: row-clues;
}

.ng-grid {
  grid-area: grid;
}

.ng-corner {
  width: 8px;
  min-height: 8px;
}

.ng-col-clues {
  display: flex;
  gap: 0;
  align-items: flex-end;
  justify-content: flex-start;
}

.ng-clue-col-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: var(--ng-cell, 30px);
  min-height: calc(var(--ng-cell, 30px) * 0.6);
}

.ng-clue-col {
  display: block;
  font-size: 0.975rem;
  line-height: 1.15;
  color: var(--text);
  font-weight: 600;
  text-align: center;
}

.ng-row-clues {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ng-clue-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-right: 4px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.ng-board-outer .ng-grid {
  display: grid;
  gap: 1px;
  background: var(--border-strong);
  border: 2px solid var(--border-strong);
  width: max-content;
}

.ng-cell {
  width: var(--ng-cell, 30px);
  height: var(--ng-cell, 30px);
  padding: 0;
  border: none;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.12s;
}

.ng-cell:hover {
  background: #f1f5f9;
}

.ng-cell.filled {
  background: #1e293b;
}

.ng-cell.marked {
  background: var(--surface);
  background-image: linear-gradient(
      45deg,
      transparent 42%,
      var(--text-muted) 42%,
      var(--text-muted) 48%,
      transparent 48%
    ),
    linear-gradient(
      -45deg,
      transparent 42%,
      var(--text-muted) 42%,
      var(--text-muted) 48%,
      transparent 48%
    );
}

.ng-hint {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* —— 华容道 —— */
.game-container--huarong {
  display: flex;
  justify-content: center;
  width: 100%;
}

.hr-wrap {
  text-align: center;
  max-width: 360px;
}

.hr-hint {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.hr-board {
  display: grid;
  grid-template-columns: repeat(var(--hr-cols, 4), 1fr);
  grid-template-rows: repeat(var(--hr-rows, 5), minmax(56px, 1fr));
  gap: 4px;
  padding: 8px;
  background: #c4a574;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #8b6914;
  position: relative;
}

.hr-block {
  margin: 0;
  padding: 0;
  border: 2px solid #5c4030;
  border-radius: 6px;
  background: linear-gradient(180deg, #d4a574 0%, #b8864a 100%);
  color: #3d2914;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: filter 0.12s, transform 0.1s;
  z-index: 1;
}

.hr-block-cao {
  background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
  color: #fff;
  border-color: #7f1d1d;
  font-size: 1.15rem;
}

.hr-block:hover {
  filter: brightness(1.06);
  transform: scale(1.01);
}

.hr-empty-cell {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  min-height: 56px;
}

.hr-exit {
  position: absolute;
  bottom: -10px;
  left: 25%;
  width: 50%;
  height: 10px;
  background: #22c55e;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.4);
}

/* —— 聪明格 —— */
.game-container--kenken {
  width: 100%;
  max-width: 630px;
  margin: 0 auto;
}

.kk-wrap {
  text-align: center;
}

.kk-title {
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.kk-meta {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.875rem;
}

.kk-grid {
  display: inline-grid;
  gap: 0;
  border: 2px solid var(--border-strong);
  margin-bottom: 1rem;
}

.kk-cell {
  position: relative;
  padding: 0;
  border: 1px solid #cbd5e1;
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  box-sizing: border-box;
}

.kk-cell.bt {
  border-top-width: 2px;
  border-top-color: var(--border-strong);
}

.kk-cell.bb {
  border-bottom-width: 2px;
  border-bottom-color: var(--border-strong);
}

.kk-cell.bl {
  border-left-width: 2px;
  border-left-color: var(--border-strong);
}

.kk-cell.br {
  border-right-width: 2px;
  border-right-color: var(--border-strong);
}

.kk-cell.selected {
  background: #eff6ff;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.kk-cage-label {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
  pointer-events: none;
}

.kk-val {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.875rem;
  font-weight: 600;
}

.kk-pad {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  max-width: 280px;
  margin: 0 auto;
}

.kk-pad-key {
  min-width: 2.75rem;
  height: 2.5rem;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.kk-pad-key:hover {
  background: #eff6ff;
  border-color: var(--primary);
  color: var(--primary);
}

.kk-hint {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}
