/* ===== 三角形数表 · 数塔寻宝 ===== */
/* 模块前缀: tri- */


/* === Welcome & Level Select === */
.tri-welcome-icon { font-size: var(--text-hero); text-align: center; margin: var(--space-4) 0; }
.tri-welcome-icon img { width: 80px; height: 80px; }

#triLevelGrid {
  max-width: 480px;
  margin: var(--space-4) auto;
  padding: 0 var(--space-4);
}
.tri-level-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
.tri-level-btn {
  background: var(--surface);
  border: 2px solid var(--surface-dim);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-2);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
}
.tri-level-btn:active { transform: scale(0.96); }
.tri-level-btn.locked {
  opacity: 0.5;
  pointer-events: none;
}
.tri-level-btn.locked::after {
  content: '🔒';
  position: absolute;
  top: var(--space-1);
  right: var(--space-2);
  font-size: var(--text-body);
}
.tri-level-btn.completed {
  border-color: var(--correct);
  background: var(--correct-bg);
}
.tri-done-badge {
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  color: var(--correct);
  margin-top: var(--space-2);
}
.tri-question-count {
  font-size: var(--text-caption);
  color: var(--text-muted);
  margin-top: var(--space-2);
}
.tri-review-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--surface);
  border: 2px dashed var(--tri-color, var(--warning));
  border-radius: var(--radius-md);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  color: var(--tri-color, var(--warning));
  cursor: pointer;
}
.tri-review-entry:active { transform: scale(0.97); }
.tri-level-btn .tri-ln {
  font-size: var(--text-title);
  font-weight: var(--weight-bold);
  color: var(--tri-color, var(--warning));
  font-family: var(--font-display);
}
.tri-level-btn .tri-lname {
  font-size: var(--text-caption);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}
.tri-level-btn .tri-stars {
  font-size: var(--text-caption);
  margin-top: var(--space-1);
}

/* 关卡卡片内的迷你三角形预览 */
.tri-mini-triangle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: var(--space-2);
}
.tri-mini-row {
  display: flex;
  gap: 2px;
  justify-content: center;
}
.tri-mini-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 16px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-dim);
  border-radius: 3px;
  font-family: var(--font-body);
  line-height: 1;
}
.tri-mini-hint {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* === Core Navigation === */
.tri-core-slide-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
.tri-core-nav {
  text-align: center;
  margin-top: var(--space-3);
}
.tri-core-counter {
  font-size: var(--text-caption);
  color: var(--text-muted);
  display: block;
  margin-bottom: var(--space-3);
}
.tri-core-nav-btns {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.tri-core-nav-btns .btn-primary {
  min-width: 140px;
}

/* === Game Screen === */
.tri-game-wrap {
  max-width: clamp(480px, 70vw, 680px);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  /* 不用 100dvh — iPad 键盘弹出时 dvh 缩小会触发重排导致输入框失焦 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.tri-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}
.tri-header .tri-level-tag {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  font-family: var(--font-display);
}
.tri-header .tri-progress {
  font-size: var(--text-caption);
  color: var(--text-muted);
}

/* 底部固定区域：大三角形时题目+按钮不被推出屏幕 */
.tri-bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 160;
  background: var(--bg-warm);
  padding-top: var(--space-2);
}

/* Question Banner (shown after tower per 3.9 principle: 先看参考物再提问) */
.tri-question-banner {
  text-align: center;
  font-size: clamp(18px, 3vw, 24px);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--tri-color, var(--warning));
}

/* Expand Hint Banner (引导提示：搭建前的说明) */
.tri-expand-hint-banner {
  text-align: center;
  font-size: var(--text-body);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-2);
  font-weight: var(--weight-bold);
}
/* 读题按钮：嵌在题目 banner 左侧 */
.tri-read-btn {
  background: none;
  border: none;
  font-size: var(--text-heading);
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
  opacity: 0.7;
  transition: opacity var(--duration-fast);
}
.tri-read-btn:active { opacity: 1; transform: scale(1.2); }

.tri-question-banner .tri-findpos-value {
  color: var(--tri-color, var(--warning));
  font-size: clamp(20px, 3.5vw, 28px);
}

/* Tower (the triangle number display) */
.tri-tower {
  flex: 0 0 auto;
  margin-bottom: var(--space-3);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}
/* 桌面端始终显示横向滚动条，提示可滚动 */
@media (hover: hover) {
  .tri-tower::-webkit-scrollbar { height: 6px; }
  .tri-tower::-webkit-scrollbar-track { background: var(--surface-dim); border-radius: 3px; }
  .tri-tower::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
}
.tri-tower-row {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}
.tri-row-num {
  width: clamp(20px, 3vw, 28px);
  font-size: var(--text-caption);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  padding-right: var(--space-1);
}
.tri-brick {
  width: clamp(36px, 5.5vw, 52px);
  height: clamp(36px, 5.5vw, 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: clamp(13px, 2vw, 18px);
  font-weight: var(--weight-bold);
  background: var(--surface);
  border: 1.5px solid var(--surface-dim);
  color: var(--text-primary);
  transition: all var(--duration-normal) var(--ease-out);
  flex-shrink: 0;
}
.tri-brick.boss {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning);
}
.tri-brick.boss-label {
  font-size: var(--text-caption);
  color: var(--text-muted);
  background: none;
  border: none;
  width: auto;
  height: auto;
  padding: 0 var(--space-1);
}
.tri-brick.lit {
  background: var(--warning);
  color: var(--text-on-accent);
  border-color: var(--warning);
  animation: triBrickLit 0.4s var(--ease-bounce);
}
.tri-brick.target {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--info);
  font-size: var(--text-body);
}
.tri-brick.hint-glow {
  animation: triHintGlow 1s ease-in-out infinite;
}
.tri-brick.shake {
  animation: triShake 0.4s ease-out;
}

@keyframes triBrickLit {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes triHintGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(59,130,246,0.3); }
  50% { box-shadow: 0 0 12px rgba(59,130,246,0.6); }
}
@keyframes triShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Question Area */
.tri-question {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-3);
  text-align: center;
}
.tri-question .tri-q-text {
  font-size: clamp(16px, 2.5vw, 22px);
  color: var(--text-primary);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-3);
  line-height: var(--leading-normal);
}
.tri-question .tri-q-hint {
  font-size: var(--text-caption);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* Input area */
.tri-input-row {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.tri-input-row label {
  font-size: var(--text-body);
  color: var(--text-secondary);
}
.tri-input-row input {
  width: clamp(80px, 12vw, 120px);
  padding: clamp(8px, 1.5vw, 14px) var(--space-3);
  border: 2px solid var(--surface-dim);
  border-radius: var(--radius-sm);
  font-size: clamp(18px, 2.8vw, 26px);
  font-weight: var(--weight-bold);
  text-align: center;
  font-family: var(--font-body);
  -webkit-appearance: none;
  outline: none;
  transition: border-color var(--duration-fast);
}
.tri-input-row input:focus {
  border-color: var(--tri-color, var(--warning));
}
.tri-input-row .tri-submit-btn {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: clamp(8px, 1.5vw, 14px) clamp(20px, 3vw, 32px);
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: transform var(--duration-fast);
}
.tri-input-row .tri-submit-btn:active { transform: scale(0.95); }

/* Feedback */
.tri-feedback {
  text-align: center;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  display: none;
}
.tri-feedback.correct {
  display: block;
  background: var(--correct-bg);
  color: var(--correct);
}
.tri-feedback.wrong {
  display: block;
  background: var(--wrong-bg);
  color: var(--wrong);
}

/* Score Bar */
.tri-score-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-5);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-body);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}
.tri-score-bar .tri-sval {
  font-weight: var(--weight-bold);
  font-size: var(--text-heading);
  color: var(--tri-color, var(--warning));
}
.tri-score-bar .tri-cval {
  font-weight: var(--weight-bold);
  font-size: var(--text-heading);
  color: var(--warning);
}

/* Boss Ruler (side panel showing boss values) */
.tri-boss-ruler {
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--text-caption);
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}
.tri-boss-ruler span {
  background: var(--surface);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.tri-boss-ruler span b { color: var(--warning); }

/* Transform lens button */
.tri-lens-btn {
  background: var(--info-bg);
  color: var(--info);
  border: 1.5px solid var(--info);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  cursor: pointer;
  margin-bottom: var(--space-3);
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.tri-lens-btn.active {
  background: var(--info);
  color: var(--text-on-accent);
}

/* Level complete overlay */
.tri-complete-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal);
}
.tri-complete-overlay.show { opacity: 1; pointer-events: auto; }
.tri-complete-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
}
.tri-complete-card h2 {
  font-size: var(--text-title);
  font-family: var(--font-display);
  color: var(--tri-color, var(--warning));
  margin-bottom: var(--space-3);
}
.tri-complete-card .tri-stars-display {
  font-size: var(--text-hero);
  margin-bottom: var(--space-3);
}
.tri-complete-card .tri-score-summary {
  font-size: var(--text-body);
  color: var(--text-secondary);
  margin-bottom: var(--space-5);
}
.tri-complete-card button {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-8);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  cursor: pointer;
  margin: var(--space-2);
}

/* === Core Slides (闯关秘籍) === */
.tri-core-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.tri-core-title {
  color: var(--warning);
  font-family: var(--font-display);
  font-size: var(--text-heading);
  margin-bottom: var(--space-3);
  text-align: center;
}
.tri-core-body {
  font-size: var(--text-body);
  line-height: var(--leading-loose);
}
.tri-core-formula {
  background: var(--warning-bg);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin: var(--space-2) 0;
  font-size: var(--text-heading);
  text-align: center;
}
.tri-core-example {
  text-align: center;
  padding: var(--space-2);
  color: var(--text-secondary);
}
.tri-core-question {
  background: var(--info-bg);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  text-align: center;
  font-size: var(--text-heading);
}
.tri-core-steps {
  background: var(--surface-dim);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
}
/* 步骤编号标题——让每步有清晰的视觉分隔 */
.tri-step-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 2px solid var(--warning);
}
.tri-step-num {
  background: var(--warning);
  color: var(--text-on-accent);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}
.tri-step-label {
  font-weight: var(--weight-bold);
  font-size: var(--text-body);
  color: var(--text-primary);
}
/* 步骤之间的分隔间距 */
.tri-core-step + .tri-core-step {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--text-muted);
}
.tri-core-result {
  text-align: center;
  font-size: var(--text-heading);
  padding: var(--space-2) 0;
}
.tri-core-result-correct { color: var(--correct); }
.tri-core-result-warning { color: var(--warning); }
.tri-core-result-muted {
  text-align: center;
  padding: var(--space-2) 0;
  color: var(--text-secondary);
}
/* 步骤导航栏（上一步 | 1/6 | 下一步） */
.tri-step-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-4) auto 0;
}
.tri-step-nav-btn {
  background: var(--info);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  cursor: pointer;
}
.tri-step-counter {
  font-size: var(--text-caption);
  color: var(--text-secondary);
  font-weight: var(--weight-bold);
  min-width: 3em;
  text-align: center;
}
.tri-core-reveal-btn {
  display: block;
  margin: var(--space-3) auto 0;
  background: var(--info);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-body);
  cursor: pointer;
}

/* === Level Path (线性知识路径) === */
.tri-level-path {
  max-width: clamp(320px, 60vw, 420px);
  margin: var(--space-4) auto;
}
.tri-path-node {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.tri-path-node:active { transform: scale(0.97); }
.tri-path-node.done { border-left: 4px solid var(--correct); }
.tri-path-node.current {
  border-left: 4px solid var(--tri-color, var(--warning));
  box-shadow: var(--shadow-md);
  animation: triPathPulse 2s ease-in-out infinite;
}
.tri-path-node.locked {
  opacity: 0.5;
  pointer-events: none;
  border-left: 4px solid var(--surface-dim);
}
.tri-path-icon { font-size: var(--text-heading); flex-shrink: 0; }
.tri-path-info { flex: 1; }
.tri-path-title {
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}
.tri-path-desc {
  font-size: var(--text-caption);
  color: var(--text-muted);
  margin-top: 2px;
}
.tri-path-line {
  width: 2px;
  height: var(--space-3);
  background: var(--surface-dim);
  margin: 0 auto;
}
.tri-path-line.done { background: var(--correct); }

@keyframes triPathPulse {
  0%, 100% { box-shadow: var(--shadow-md); }
  50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15), var(--shadow-md); }
}

/* === Game inline replacements === */
.tri-table-type-hint {
  text-align: center;
  font-size: var(--text-caption);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.tri-findpos-value {
  color: var(--warning);
  font-size: var(--text-heading);
}
.tri-lens-seq {
  font-size: var(--text-caption);
  color: var(--text-muted);
}

/* === Tower Row Animation === */
.tri-tower-row.tri-row-new {
  animation: triRowSlideIn 0.4s var(--ease-bounce);
}
.tri-tower-row.tri-row-new .tri-brick {
  animation: triBrickPopIn 0.35s var(--ease-bounce) backwards;
}
.tri-tower-row.tri-row-new .tri-brick:nth-child(1) { animation-delay: 0.05s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(2) { animation-delay: 0.1s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(3) { animation-delay: 0.15s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(4) { animation-delay: 0.2s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(5) { animation-delay: 0.25s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(6) { animation-delay: 0.3s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(7) { animation-delay: 0.35s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(8) { animation-delay: 0.4s; }
.tri-tower-row.tri-row-new .tri-brick:nth-child(n+9) { animation-delay: 0.45s; }

@keyframes triRowSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes triBrickPopIn {
  from { opacity: 0; transform: scale(0.3); }
  60% { transform: scale(1.15); }
  to { opacity: 1; transform: scale(1); }
}

/* === Step Guide === */
.tri-step-label {
  font-size: clamp(18px, 3vw, 24px);
  font-family: var(--font-display);
  color: var(--tri-color, var(--warning));
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  text-align: center;
}
.tri-step-done {
  font-size: var(--text-caption);
  color: var(--correct);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--correct-bg);
  border-radius: var(--radius-sm);
  display: inline-block;
}
.tri-question.has-steps .tri-q-text {
  font-size: var(--text-body);
  color: var(--text-secondary);
  font-weight: var(--weight-normal);
  margin-bottom: var(--space-2);
}

/* === Expandable Tower === */
.tri-expand-area {
  text-align: center;
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--bg-cream);
  border-radius: var(--radius-md);
  border: 2px dashed var(--tri-color, var(--warning));
}
.tri-expand-prompt {
  font-size: clamp(18px, 3vw, 24px);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  color: var(--tri-color, var(--warning));
  margin-bottom: var(--space-3);
}
.tri-expand-btn {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  cursor: pointer;
}
.tri-expand-hint {
  font-size: var(--text-caption);
  color: var(--text-muted);
  margin-top: var(--space-2);
  min-height: 20px;
}
.tri-expand-hint.wrong {
  color: var(--wrong);
}

/* === Locator Bar === */
.tri-locator {
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.tri-locator-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-caption);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}
.tri-locator-bar {
  position: relative;
  height: 8px;
  background: var(--surface-dim);
  border-radius: 4px;
  margin-bottom: var(--space-2);
}
.tri-locator-fill {
  height: 100%;
  background: var(--tri-color, var(--warning));
  border-radius: 4px;
  opacity: 0.3;
}
.tri-locator-dot {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  background: var(--tri-color, var(--warning));
  border-radius: 50%;
  border: 2px solid var(--surface);
  transform: translateX(-50%);
  box-shadow: var(--shadow-sm);
}
.tri-locator-tip {
  font-size: var(--text-caption);
  color: var(--tri-color, var(--warning));
  font-weight: var(--weight-bold);
  text-align: center;
}

/* === First-time Tutorial === */
.tri-tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tri-tutorial-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 320px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: triBrickLit 0.4s var(--ease-bounce);
}
.tri-tutorial-card h3 {
  font-size: var(--text-heading);
  font-family: var(--font-display);
  color: var(--tri-color, var(--warning));
  margin-bottom: var(--space-3);
}
.tri-tutorial-card p {
  font-size: var(--text-body);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  line-height: var(--leading-loose);
}
.tri-tutorial-card button {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-8);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  cursor: pointer;
}

/* === 辅助按钮栏（求助+读题+草稿，在答题区域中间） === */
/* 操作按钮必须醒目——孩子注意力有限，太小的按钮等于没有 */
.tri-action-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.tri-action-btn {
  background: var(--surface);
  border: 2px solid var(--module-color);
  border-radius: var(--radius-md);
  padding: var(--space-2) clamp(10px, 3vw, 20px);
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: var(--weight-bold);
  color: var(--module-color);
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.tri-action-btn:active {
  background: var(--module-color);
  color: var(--text-on-accent);
  transform: scale(0.95);
}
.tri-action-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* === 游戏内导航栏 === */
.tri-nav-bar {
  position: relative;
  z-index: 160;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(8px, 2vw, 16px);
  padding: var(--space-2) 0;
  margin-top: var(--space-2);
}

/* 草稿工具栏在 tri 模块中上移，紧贴底部操作区上方（bottom-bar ~180px） */
body[data-module="tri"] #scratchpadBar {
  bottom: 200px;
}

/* === 直觉化复习：阶梯演示 === */
.tri-staircase-demo {
  font-family: monospace;
  font-size: var(--text-heading);
  line-height: 1.6;
  padding: var(--space-3);
  background: var(--surface-dim);
  border-radius: var(--radius-sm);
  margin: var(--space-2) 0;
  text-align: center;
}

/* === 直觉化复习：L型砖块演示 === */
.tri-gnomon-demo {
  font-family: monospace;
  font-size: var(--text-heading);
  line-height: 1.4;
  padding: var(--space-2);
  display: inline-block;
  text-align: left;
}
.tri-gnomon-new { color: var(--tri-color, #F59E0B); font-weight: var(--weight-bold); }
.tri-gnomon-new2 { color: var(--correct); font-weight: var(--weight-bold); }

/* === 解题思路速查卡 === */
.tri-ref-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  border-left: 4px solid var(--tri-color, #F59E0B);
}
/* 转化金句——卡片最醒目的一句话 */
.tri-ref-transform {
  font-size: var(--text-heading);
  font-weight: var(--weight-bold);
  color: var(--tri-color, #F59E0B);
  background: var(--warning-bg);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  text-align: center;
  line-height: 1.5;
}
/* 迷你数塔图 */
.tri-ref-tower {
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-dim);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.tri-ref-tower pre {
  font-family: var(--font-body);
  font-size: var(--text-caption);
  line-height: 1.6;
  margin: 0;
  text-align: center;
  white-space: pre;
  color: var(--text-secondary);
}
.tri-ref-tower pre b {
  color: var(--tri-color, #F59E0B);
}
.tri-ref-tower-note {
  font-size: var(--text-caption);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-1);
}
.tri-ref-tower-note b {
  color: var(--tri-color, #F59E0B);
}
.tri-ref-formula {
  font-size: var(--text-heading);
  color: var(--tri-color, #F59E0B);
  margin-bottom: var(--space-3);
  text-align: center;
}
.tri-ref-steps {
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-dim);
  border-radius: var(--radius-sm);
  line-height: 1.6;
}
.tri-ref-steps p { margin: var(--space-1) 0; }
.tri-ref-steps b { color: var(--text-primary); }
.tri-ref-example {
  padding: var(--space-2) var(--space-3);
  background: var(--correct-bg);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  line-height: 1.6;
}
.tri-ref-example b { color: var(--correct); }
.tri-ref-why {
  font-size: var(--text-caption);
  color: var(--info);
  cursor: pointer;
}

/* 复习秘籍按钮：Secondary 样式，和"继续闯关"同级大小 */
.tri-review-btn {
  background: var(--surface);
  color: var(--module-color);
  border: 2px solid var(--module-color);
  width: 100%;
  margin-top: var(--space-3);
  box-shadow: var(--shadow-sm);
}

/* ===== v2 迷雾探索新增样式 ===== */

/* --- 迷雾格子 --- */
.tri-brick.fog {
  background: var(--surface-dim);
  border-color: transparent;
  color: transparent;
  cursor: default;
}

/* 可点击的迷雾格子：呼吸脉动引导孩子点击 */
.tri-brick.fog-clickable {
  background: #e8e0d8;
  border: 2px dashed var(--module-color);
  cursor: pointer;
  animation: fogPulse 1.8s ease-in-out infinite;
}
@keyframes fogPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; background: #f0e6dc; }
}
.tri-brick.fog-clickable:active {
  transform: scale(0.92);
  animation: none;
}

/* 老大格子在迷雾中金色发光——引导孩子优先攻克老大 */
.tri-brick.fog-boss-glow {
  background: var(--warning-bg);
  border: 2px solid var(--warning);
  animation: triFogBossGlow 1.5s ease-in-out infinite;
  cursor: pointer;
}
@keyframes triFogBossGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(245,158,11,0.3); }
  50% { box-shadow: 0 0 14px rgba(245,158,11,0.6); }
}

/* 目标格子："?"金色脉动——"来揭开我！" */
.tri-brick.fog-target {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border: 2px solid var(--warning);
  color: var(--warning);
  font-size: var(--text-heading);
  font-weight: var(--weight-bold);
  cursor: pointer;
  animation: triFogTargetPulse 2s ease-in-out infinite;
}
@keyframes triFogTargetPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(245,158,11,0.3); }
  50% { box-shadow: 0 0 18px rgba(245,158,11,0.6), 0 0 0 3px rgba(245,158,11,0.2); }
}

/* 占位符格子："·"，已揭开但隐藏数值（防泄露/防数数） */
.tri-brick.fog-placeholder {
  background: var(--surface);
  border-color: var(--surface-dim);
  color: var(--text-muted);
  font-size: var(--text-heading);
}

/* 当前键盘打开的格子高亮 */
.tri-brick.fog-active {
  border-color: var(--tri-color, var(--warning));
  box-shadow: 0 0 0 3px rgba(245,158,11,0.3);
  transform: scale(1.1);
  z-index: var(--z-base);
}

/* --- 连锁揭开动画 --- */
.tri-brick.cascade-reveal {
  animation: triCascadeReveal 0.35s var(--ease-bounce);
}
@keyframes triCascadeReveal {
  0% { transform: rotateY(90deg) scale(0.8); opacity: 0; }
  50% { transform: rotateY(0deg) scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* 老大连锁时的金色强调 */
.tri-brick.cascade-boss {
  background: var(--warning);
  color: var(--text-on-accent);
  border-color: var(--warning);
  animation: triCascadeBoss 0.5s var(--ease-bounce);
}
@keyframes triCascadeBoss {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); box-shadow: 0 0 20px rgba(245,158,11,0.6); }
  100% { transform: scale(1); }
}

/* 目标揭开（宝藏发现！） */
.tri-brick.target-reveal {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: var(--text-on-accent);
  border-color: var(--warning);
  animation: triTargetReveal 0.6s var(--ease-bounce);
  box-shadow: 0 0 16px rgba(245,158,11,0.5);
}
@keyframes triTargetReveal {
  0% { transform: scale(0.5) rotateY(180deg); opacity: 0; }
  50% { transform: scale(1.3) rotateY(0deg); }
  100% { transform: scale(1); opacity: 1; }
}

/* --- 迷你键盘（贴格子弹出） --- */
.tri-keypad {
  position: fixed;
  z-index: var(--z-modal);
  width: 156px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--tri-color, var(--warning));
  padding: var(--space-2);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}
.tri-keypad.show {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.tri-kp-display {
  text-align: center;
  padding: var(--space-1) var(--space-2);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--surface-dim);
}
.tri-kp-prompt {
  display: block;
  font-size: var(--text-caption);
  color: var(--text-muted);
}
.tri-kp-value {
  font-size: var(--text-title);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  font-family: var(--font-display);
}

.tri-kp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-1);
}
.tri-kp-key {
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(36px, 5vw, 44px);
  border-radius: var(--radius-sm);
  background: var(--surface-dim);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--duration-fast);
}
.tri-kp-key:active, .tri-kp-key.pressed {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
}
.tri-kp-ok {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
  font-size: var(--text-heading);
}
.tri-kp-del {
  font-size: var(--text-heading);
  color: var(--text-muted);
}

/* --- 搜索定位 LOCATE 输入栏 --- */
.tri-locate-bar {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-3);
  text-align: center;
}
.tri-locate-prompt {
  font-size: var(--text-heading);
  font-weight: var(--weight-bold);
  color: var(--tri-color, var(--warning));
  margin-bottom: var(--space-3);
  font-family: var(--font-display);
}

/* --- 求助弹窗 --- */
.tri-gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.tri-help-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: triBrickLit 0.3s var(--ease-bounce);
}
.tri-gate-close {
  background: var(--tri-color, var(--warning));
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  cursor: pointer;
}

/* Responsive */
@media (max-width: 380px) {
  .tri-level-grid { grid-template-columns: repeat(2, 1fr); }
  .tri-keypad { width: 140px; }
}
