:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --line: #eae5da;
  --text: #2a2620;
  --dim: #8a8272;
  --accent: #0989E2;
  --accent-soft: #e8f4fa;
  --ok: #16a37a;
  --warn: #e05252;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(84, 66, 35, 0.08);
}

* {
  box-sizing: border-box;
}

.game-card {
  color: var(--text);
  background: transparent;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 外层容器透明：去掉外壳给 rounded-2xl 加的边框 */
.ot_workspace__inner .game-card {
  border: 0;
  box-shadow: none;
}

.page {
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px 56px;
  display: grid;
  gap: 18px;
}

/* ---------- 顶部 ---------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 18px;
}

.topbar__title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.topbar__desc {
  margin: 0;
  max-width: 560px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--dim);
}

.tool {
  flex: none;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  color: #6d6454;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.tool:hover {
  border-color: #bfe0ef;
  color: var(--accent);
}

.tool[aria-pressed="false"] {
  color: #b3ab99;
}

/* ---------- 数据条 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  display: grid;
  gap: 6px;
}

.stat__label {
  font-size: 12px;
  color: var(--dim);
}

.stat__value {
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.stat__value--level {
  color: var(--accent);
}

.stat__value--time.is-low {
  color: var(--warn);
}

.stat__value--time.is-bonus {
  animation: bonus-flash 0.5s ease;
}

.stat__value--best {
  color: var(--ok);
}

.stat__unit {
  margin-left: 2px;
  font-size: 12px;
  font-style: normal;
  font-weight: 500;
  opacity: 0.7;
}

/* ---------- 游戏区 ---------- */
.stage {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #fffdf9 100%);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.stage__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 32px;
  padding: 0 2px;
}

.stage__hint {
  margin: 0;
  font-size: 13px;
  color: var(--dim);
  transition: color 0.2s;
}

.stage__hint.is-warn {
  color: var(--warn);
}

.stage__target {
  margin: 0;
  flex: none;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #11719c;
  font-size: 13px;
}

.stage__target b {
  font-size: 18px;
  font-weight: 650;
}

.board {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.grid {
  --gap: 10px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: var(--gap);
  aspect-ratio: 1;
  padding: 16px 16px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbf9f4;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid #eee7d9;
  border-radius: 14px;
  background: #ffffff;
  color: #3d382e;
  font-family: "Kaiti SC", "KaiTi", "STKaiti", "FangSong", serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(84, 66, 35, 0.05);
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  -webkit-tap-highlight-color: transparent;
}

.cell__char {
  display: block;
  line-height: 1;
}

.cell.is-empty {
  background: #f5f1e8;
  border-color: #efe9dc;
  box-shadow: none;
  cursor: default;
}

.cell.is-right {
  background: #e9f8f1;
  border-color: #c6ecd9;
  color: var(--ok);
  box-shadow: none;
}

.cell.is-wrong {
  border-color: #f2b3b3;
  background: #fff2f2;
  color: var(--warn);
  animation: cell-shake 0.36s ease;
}

@media (hover: hover) {
  .cell:not(.is-empty):not(.is-right):hover {
    border-color: #bfe0ef;
    background: #f2f9fd;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(217, 119, 6, 0.14);
  }
}

/* 格子越多，字号越小 */
.grid[data-cols="2"] .cell { font-size: clamp(34px, 8vw, 56px); }
.grid[data-cols="4"] .cell { font-size: clamp(24px, 5vw, 36px); }
.grid[data-cols="5"] .cell { font-size: clamp(20px, 4.2vw, 30px); }
.grid[data-cols="6"] .cell { font-size: clamp(18px, 3.6vw, 25px); }
.grid[data-cols="7"] .cell { font-size: clamp(16px, 3vw, 21px); }
.grid[data-cols="8"] .cell { font-size: clamp(14px, 2.6vw, 18px); }
.grid[data-cols="12"] .cell { font-size: clamp(14px, 2.6vw, 18px); }

/* 12x12 大格子收窄间距，避免挤占文字空间 */
.grid[data-cols="12"] {
  --gap: 4px;
}

/* 12x12：棋盘容器动态放宽，网格完整显示、不出现滚动条；
   视口较窄时棋盘跟随内容区宽度，单格再按比例缩小 */
.board:has(.grid[data-cols="12"]) { max-width: 780px; }

.board__bar {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 9px;
  height: 4px;
  border-radius: 999px;
  background: #efe9db;
  overflow: hidden;
}

.board__bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a37a, #57c99b);
  transition: width 0.2s linear, background 0.3s;
}

.board__bar i.is-low {
  background: linear-gradient(90deg, #e05252, #f28c6b);
}

/* ---------- 遮罩 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  border-radius: 18px;
  background: rgba(252, 250, 245, 0.82);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.overlay.is-show {
  opacity: 1;
  visibility: visible;
}

.overlay__panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 340px;
  text-align: center;
  animation: panel-in 0.28s ease;
}

.overlay__badge {
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #11719c;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.overlay__badge.is-best {
  background: #e7f8f1;
  color: #0b8a66;
}

.overlay__title {
  margin: 0;
  font-size: 25px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.overlay__desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--dim);
}

.overlay__panel .btn {
  margin-top: 6px;
}

/* ---------- 按钮 ---------- */
.btn {
  padding: 11px 24px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, opacity 0.2s;
}

.btn--primary {
  color: #fff;
  background: linear-gradient(135deg, #1d9ac9, #11719c);
  box-shadow: 0 8px 18px rgba(217, 119, 6, 0.28);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 11px 22px rgba(217, 119, 6, 0.34);
}

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

.btn--ghost {
  border-color: var(--line);
  background: var(--panel);
  color: #6d6454;
}

.btn--ghost:hover:not(:disabled) {
  border-color: #bfe0ef;
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.stage__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.stage__tip {
  font-size: 12.5px;
  color: #a89f8c;
}

/* ---------- 设置面板 ---------- */
.panel {
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.panel__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel__note {
  font-size: 12px;
  color: #a89f8c;
}

.setting {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.setting__label {
  font-size: 13px;
  color: var(--dim);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 13px;
  border: 1px solid #e7e1d4;
  border-radius: 10px;
  background: #fff;
  color: #6b6353;
  font-family: inherit;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.chip:hover {
  border-color: #bfe0ef;
  color: var(--accent);
}

.chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 5px 12px rgba(217, 119, 6, 0.24);
}

/* ---------- 底部介绍 ---------- */
.intro-footer {
  margin-top: 4px;
}

.intro-footer__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.intro-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(50, 70, 100, 0.08);
  padding: 24px 26px;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 18px;
  align-items: center;
}

.intro-card__icon {
  grid-row: 1 / span 2;
  font-size: 30px;
}

.intro-card__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #2c3e50;
}

.intro-card__text {
  align-self: start;
  margin: 0;
  font-size: 13px;
  line-height: 1.9;
  color: #5a6a7e;
}

.intro-card__text strong,
.intro-card__text b {
  color: #0989E2;
  font-weight: 600;
}

/* 最近记录卡片：标题行带清空按钮，列表占据文本行 */
.intro-card__head {
  grid-column: 2;
  align-self: center;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.intro-card--history .intro-card__title {
  margin-bottom: 0;
}

.intro-card--history .records {
  grid-column: 2;
  align-self: start;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: #a89f8c;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.18s;
}

.link-btn:hover {
  color: var(--accent);
}

.records {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.record {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #faf8f3;
  font-size: 12px;
}

.record__tag {
  flex: none;
  color: #756c5a;
}

.record__time {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.record__meta {
  flex: none;
  color: #aaa18d;
}

.record--empty {
  justify-content: center;
  padding: 16px 10px;
  color: #aaa18d;
  background: #fcfaf6;
}

.foot {
  text-align: center;
  font-size: 12px;
  color: #aaa18d;
}

/* ---------- 动画 ---------- */
.cell.is-in {
  animation: cell-in 0.3s ease backwards;
}

@keyframes cell-in {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes cell-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@keyframes bonus-flash {
  0% { color: var(--ok); transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 620px) {
  .page {
    padding: 22px 14px 40px;
    gap: 14px;
  }

  .topbar {
    align-items: center;
  }

  .topbar__title {
    font-size: 22px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    padding: 10px 14px;
  }

  .stat__value {
    font-size: 18px;
  }

  .stage {
    padding: 12px;
  }

  .grid {
    --gap: 8px;
    padding: 10px 10px 20px;
  }

  .stage__tip {
    display: none;
  }

  .overlay__title {
    font-size: 21px;
  }
}
