:root {
  --bg: #f4f7fc;
  --panel: #ffffff;
  --line: #e6ecf6;
  --text: #1d2942;
  --dim: #6c7a94;
  --accent: #0989E2;
  --accent-soft: #e8f4fa;
  --ok: #12a37a;
  --warn: #e05252;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(31, 54, 96, 0.07);
}

* {
  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: #4c5a75;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

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

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

/* ---------- 数据条 ---------- */
.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;
  letter-spacing: 0.01em;
}

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

.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%, #fbfcff 100%);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.stage__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 30px;
  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__next {
  margin: 0;
  flex: none;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #11719c;
  font-size: 12.5px;
}

.stage__next b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

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

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

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid #e2e9f5;
  border-radius: 12px;
  background: #ffffff;
  color: var(--num, #22304d);
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(31, 54, 96, 0.04);
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  -webkit-tap-highlight-color: transparent;
}

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

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

.cell.is-done {
  background: #f1f6ff;
  border-color: #e2ecfd;
  color: #b7c4da;
  box-shadow: none;
  cursor: default;
}

.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-done):hover {
    border-color: #bfe0ef;
    background: #f2f9fd;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(79, 109, 245, 0.12);
  }
}

/* 形状：方格 / 鹅卵石 / 圆形 / 蜂巢 */
.grid[data-shape="pebble"] .cell {
  border-radius: 38% 62% 56% 44% / 46% 40% 60% 54%;
}

.grid[data-shape="pebble"] .cell:nth-child(3n + 2) {
  border-radius: 60% 40% 42% 58% / 42% 62% 38% 58%;
}

.grid[data-shape="pebble"] .cell:nth-child(3n) {
  border-radius: 45% 55% 62% 38% / 60% 45% 55% 40%;
}

.grid[data-shape="circle"] .cell {
  border-radius: 50%;
}

.grid[data-shape="hex"] {
  --gap: 5px;
}

.grid[data-shape="hex"] .cell {
  border: 0;
  border-radius: 0;
  clip-path: polygon(50% 1%, 94% 26%, 94% 74%, 50% 99%, 6% 74%, 6% 26%);
  background: #ffffff;
  box-shadow: none;
}

.grid[data-shape="hex"] .cell.is-empty {
  background: #eef3fb;
}

.grid[data-shape="hex"] .cell.is-done {
  background: #eef4ff;
}

/* 格子数量越多，字号越小 */
.grid[data-cols="3"] .cell { font-size: clamp(28px, 6vw, 42px); }
.grid[data-cols="4"] .cell { font-size: clamp(24px, 5vw, 36px); }
.grid[data-cols="5"] .cell { font-size: clamp(20px, 4.4vw, 30px); }
.grid[data-cols="6"] .cell { font-size: clamp(18px, 3.8vw, 26px); }
.grid[data-cols="7"] .cell { font-size: clamp(16px, 3.2vw, 22px); }
.grid[data-cols="8"] .cell { font-size: clamp(14px, 2.9vw, 20px); }
.grid[data-cols="9"] .cell { font-size: clamp(13px, 2.6vw, 18px); }

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

.board__bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #36cfc9);
  transition: width 0.25s ease;
}

/* ---------- 遮罩 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  border-radius: 18px;
  background: rgba(248, 250, 255, 0.8);
  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: 330px;
  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: 26px;
  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 26px;
  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, background 0.2s ease;
}

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

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 11px 22px rgba(79, 109, 245, 0.34);
}

.btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 5px 12px rgba(79, 109, 245, 0.26);
}

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

.stage__tip {
  font-size: 12.5px;
  color: #9aa6bc;
  text-align: center;
}

/* ---------- 设置面板 ---------- */
.panel {
  padding: 18px 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;
  margin-bottom: 6px;
}

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

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

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

.setting + .setting {
  border-top: 1px dashed #eef2fa;
}

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

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

.chip {
  padding: 6px 13px;
  border: 1px solid #e4eaf5;
  border-radius: 10px;
  background: #fff;
  color: #59667f;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

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

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

/* ---------- 说明卡片 ---------- */
.notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

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

.card__note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: #97a3b9;
}

.steps,
.list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.7;
  color: #5d6a83;
}

.steps li::marker,
.list li::marker {
  color: #b9c6dd;
}

.steps b,
.list b {
  color: var(--text);
  font-weight: 600;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: #9aa6bc;
  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: #f8fafe;
  font-size: 12px;
}

.record__tag {
  flex: none;
  color: #6a7893;
}

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

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

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

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

/* ---------- 动画 ---------- */
.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 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: 860px) {
  .notes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@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: 7px;
    padding: 10px 10px 20px;
  }

  .notes {
    grid-template-columns: minmax(0, 1fr);
  }

  .setting {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .stage__tip {
    display: none;
  }

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