/* 頭の切り替えの速さを測る（固定ページ trail-making 専用） */

.tm {
  --tm-mono: "SFMono-Regular", Menlo, Consolas, monospace;
  --tm-a: #4b5691;
  --tm-b: #d98423;
  --tm-ok: #2f7a5c;
  width: min(100% - 2.5rem, 760px);
  margin-inline: auto;
}

.tm-note {
  margin: 1.6rem 0 0;
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-tint);
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.85;
}

.tm-note strong { color: var(--ink); }
.tm-note p { margin: 0 0 0.6rem; }
.tm-note p:last-child { margin-bottom: 0; }

.tm-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.2rem, 3vw, 1.9rem);
  margin-top: 1.4rem;
}

.tm-panel h2 {
  font-family: var(--mincho);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  margin: 0 0 0.9rem;
}

.tm-step {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.tm-lead {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.85;
  margin: 1rem 0 0;
}

.tm-how {
  margin: 0;
  padding-left: 1.3rem;
  font-size: 0.95rem;
  line-height: 1.9;
}

.tm-how li { margin-bottom: 0.4rem; }

.tm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.tm-panel button {
  font-family: var(--gothic);
  font-size: 0.95rem;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.tm-panel button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.tm-panel button.ghost {
  background: #fff;
  color: var(--ink-soft);
  border-color: var(--line);
}

.tm-panel button.ghost:hover { color: var(--accent); border-color: var(--accent); }

/* ---- 課題の画面 ---- */
.tm-stage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.tm-instruction {
  margin: 0;
  font-family: var(--mincho);
  font-size: 1.1rem;
  line-height: 1.5;
}

.tm-meters { text-align: right; flex: 0 0 auto; }

.tm-timer {
  margin: 0;
  font-family: var(--tm-mono);
  font-size: 1.9rem;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tm-timer .u { font-size: 0.45em; color: var(--muted); margin-left: 0.15em; }

.tm-miss { margin: 0.2rem 0 0; font-size: 0.78rem; color: var(--muted); }
.tm-miss span { font-family: var(--tm-mono); color: var(--accent-dark); }

.tm-next {
  margin: 0.9rem 0 0.6rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.tm-next strong {
  display: inline-block;
  min-width: 2.4rem;
  margin-left: 0.3rem;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-align: center;
  font-family: var(--tm-mono);
  font-size: 1.05rem;
}

.tm-board-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfbfa;
  overflow: hidden;
}

.tm-board-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
}

.tm-dot { cursor: pointer; }
.tm-dot circle {
  fill: #fff;
  stroke: var(--line);
  stroke-width: 1.5;
  transition: fill 0.12s ease, stroke 0.12s ease;
}
.tm-dot text {
  font-family: var(--tm-mono);
  font-size: 17px;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}
.tm-dot.is-done circle { fill: #eef1f8; stroke: var(--tm-a); }
.tm-dot.is-done text { fill: var(--tm-a); }
.tm-dot.is-next circle { stroke: var(--accent); stroke-width: 2.5; }
.tm-dot.is-miss circle { fill: #fbe6ea; stroke: var(--accent-dark); }

.tm-line { stroke: var(--tm-a); stroke-width: 2; fill: none; }

.tm-countdown {
  font-family: var(--mincho);
  font-size: 64px;
  fill: var(--accent);
  text-anchor: middle;
  dominant-baseline: central;
}

/* ---- 結果 ---- */
.tm-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0.6rem 0 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

@media (max-width: 640px) { .tm-facts { grid-template-columns: 1fr; } }

.tm-facts > div { background: #fff; padding: 0.95rem 1.1rem 1.05rem; }
.tm-facts dt { font-size: 0.74rem; letter-spacing: 0.08em; color: var(--muted); }
.tm-facts dd {
  margin: 0.25rem 0 0;
  font-family: var(--tm-mono);
  font-size: 1.85rem;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tm-facts dd .u { font-size: 0.45em; color: var(--muted); margin-left: 0.15em; }
.tm-facts p { margin: 0.35rem 0 0; font-size: 0.76rem; color: var(--muted); line-height: 1.6; }

.tm-bar { margin-top: 1.4rem; display: flex; flex-direction: column; gap: 0.5rem; }
.tm-bar-row { display: grid; grid-template-columns: 1.5rem 1fr 4.5rem; align-items: center; gap: 0.7rem; }
.tm-bar-row .l { font-family: var(--tm-mono); font-size: 0.85rem; color: var(--muted); }
.tm-bar-row .t { display: block; height: 14px; background: var(--line-soft); border-radius: 7px; overflow: hidden; }
.tm-bar-row .t span { display: block; height: 100%; border-radius: 7px; }
.tm-bar-row:first-child .t span { background: var(--tm-a); }
.tm-bar-row:last-child .t span { background: var(--tm-b); }
.tm-bar-row .v { font-family: var(--tm-mono); font-size: 0.85rem; text-align: right; color: var(--ink-soft); }

.tm-comment {
  margin: 1.3rem 0 0;
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-tint);
  font-size: 0.9rem;
  line-height: 1.85;
  color: var(--ink-soft);
}

.tm-comment strong { color: var(--ink); }

/* ---- 記録 ---- */
.tm-history { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tm-history th,
.tm-history td {
  text-align: right;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.85rem;
}
.tm-history th { color: var(--muted); font-weight: 400; }
.tm-history th:first-child,
.tm-history td:first-child { text-align: left; }
.tm-history td { font-family: var(--tm-mono); color: var(--ink); }

.tm-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-dark);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}

/* ---- 解説 ---- */
.tm-source { font-size: 0.9rem; line-height: 1.95; color: var(--ink-soft); }
.tm-source p { margin: 0 0 0.9rem; }
.tm-source strong { color: var(--ink); }
.tm-fine { font-size: 0.86rem; color: var(--muted); }
