/* まなびのタイピング れんしゅう（/manabi/typing/）。色・角丸・影は manabi.css の :root の変数だけを使う（manabi/DESIGN.md）。
   たて・よこ・高さの3色は使わない。正しいは木の色で塗る＋✓、まちがいは墨の × と図解の赤（--fig-red）の枠。色だけに頼らない。 */

.ty { padding-top: 8px; }
/* hidden の部品は、display を持つ部品（ボタン・キーボードの図）でも必ず隠す */
.ty [hidden], .ty-teacher [hidden] { display: none !important; }
.ty-head { margin-bottom: 24px; }
.ty-head > div:first-child { max-width: 46em; }
.ty-head__lead { color: var(--ink-soft); }
.ty-notice { margin-top: 14px; padding: 12px 16px; background: var(--wood-light); border: 2px solid var(--ink); border-radius: var(--radius-s); font-weight: 700; }

/* 初めて開いたときの「おとを だしますか？」 */
.ty-sound-ask { margin-bottom: 24px; padding: 20px 24px; background: var(--panel); border: 2.5px solid var(--ink); border-radius: var(--radius-m); box-shadow: var(--lift); }
.ty-sound-ask__q { font: 900 24px/1.3 var(--font-head); }
.ty-sound-ask__note { color: var(--ink-soft); margin: 6px 0 14px; }
.ty-sound-ask__buttons { display: flex; flex-wrap: wrap; gap: 14px; }

/* 学年と音 */
.ty-menu__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.ty-grades { display: flex; flex-wrap: wrap; gap: 10px; }
.ty-grade {
  min-width: 64px; min-height: 44px; padding: 0 16px; font: 900 18px/1 var(--font-head); color: var(--ink);
  background: var(--panel); border: 2px solid var(--ink); border-radius: var(--radius-pill); cursor: pointer;
  transition: background-color var(--t), transform var(--t);
}
.ty-grade:hover { background: var(--wood-light); }
.ty-grade[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.ty-sound {
  min-height: 44px; padding: 0 18px; font: 900 16px/1 var(--font-head); color: var(--ink); cursor: pointer;
  background: var(--wood-light); border: 2px solid var(--ink); border-radius: var(--radius-pill);
}
.ty-sound[aria-pressed="false"] { background: var(--panel); }
.ty-sound--small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.ty-grade-lead { margin: 14px 0 26px; max-width: 46em; }

.ty-columns { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 32px; align-items: start; }
.ty-panel { background: var(--panel); border: 2.5px solid var(--ink); border-radius: var(--radius-m); box-shadow: var(--lift); padding: 24px; }
.ty-panel__title { font: 900 24px/1.3 var(--font-head); margin-bottom: 10px; }
.ty-panel__lead { color: var(--ink-soft); margin-bottom: 14px; }

/* ステージの一覧 */
.ty-stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ty-stage {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title stars" "sub stars";
  gap: 2px 12px; align-items: center; text-align: left; padding: 12px 16px; cursor: pointer; color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-s); font: inherit;
  transition: background-color var(--t), transform var(--t);
}
.ty-stage:hover { background: var(--wood-light); transform: translateY(-1px); }
.ty-stage__title { grid-area: title; font: 900 18px/1.35 var(--font-head); }
.ty-stage__sub { grid-area: sub; font-size: 13px; color: var(--ink-soft); }
.ty-stars { grid-area: stars; font-size: 18px; letter-spacing: 2px; color: var(--wood-edge); }
.ty-all { margin-top: 20px; }
.ty-all summary { cursor: pointer; font-weight: 700; }
.ty-all__group { font: 900 16px/1.4 var(--font-head); margin: 18px 0 8px; }

/* けんてい */
.ty-best { font-weight: 700; margin-bottom: 14px; }
.ty-best:empty { display: none; }
.ty-ranks { width: 100%; margin-top: 22px; border-collapse: collapse; font-size: 14px; }
.ty-ranks caption { text-align: left; font-weight: 700; margin-bottom: 6px; }
.ty-ranks th, .ty-ranks td { padding: 5px 8px; border-top: 1px dashed var(--grid); text-align: left; }
.ty-ranks th { width: 4.5em; font-family: var(--font-head); }
.ty-ranks__note { display: block; font-size: 12px; color: var(--ink-soft); }

/* つくった たてもの（まち） */
.ty-town { margin-top: 32px; padding: 24px; background: var(--panel); border: 2.5px solid var(--ink); border-radius: var(--radius-m); box-shadow: var(--lift); }
.ty-town__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px; }
.ty-town__item { display: grid; justify-items: center; gap: 2px; text-align: center; padding: 8px 6px 10px; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-s); }
.ty-town__item--empty { border-style: dashed; border-color: var(--wood-edge); }
.ty-town__pic { width: 80px; height: 110px; }
.ty-town__name { font: 700 12px/1.35 var(--font-body); }
.ty-town__stars { font-size: 13px; color: var(--wood-edge); letter-spacing: 1px; }

/* 遊ぶ画面 */
.ty-play { background: var(--panel); border: 2.5px solid var(--ink); border-radius: var(--radius-m); box-shadow: var(--lift); padding: 20px 24px 24px; }
.ty-play__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-bottom: 12px; border-bottom: 2px dashed var(--grid); }
.ty-play__name { font: 900 20px/1.3 var(--font-head); margin-right: auto; }
.ty-play__count, .ty-play__time { font-weight: 700; font-variant-numeric: tabular-nums; }
.ty-combo { font: 900 18px/1 var(--font-head); padding: 6px 12px; border: 2px solid var(--ink); border-radius: var(--radius-pill); background: var(--wood-light); }
.ty-combo:empty { display: none; }
.ty-combo--big { background: var(--wood); font-size: 20px; }
.ty-quit { padding: 6px 14px; font: 700 14px/1 var(--font-body); background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--radius-pill); cursor: pointer; }
.ty-quit:hover { background: var(--wood-light); }

.ty-play__main { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 24px; align-items: center; padding: 18px 0 8px; }
.ty-word { text-align: center; min-height: 240px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; }
.ty-word__display { font: 900 clamp(30px, 4.4vw, 48px)/1.3 var(--font-head); }
.ty-word__display--keys { letter-spacing: .12em; text-transform: lowercase; }
.ty-word__kana { font-size: 20px; color: var(--ink-soft); min-height: 1.5em; }
.ty-done { color: var(--ink); }
.ty-word__kana .ty-done { text-decoration: underline 3px var(--wood-edge); text-underline-offset: 6px; }

/* まちがいの しるし（正しいキーを 押すまで 残す） */
.ty-miss { min-height: 40px; display: flex; align-items: center; gap: 10px; font: 900 20px/1 var(--font-head); }
.ty-miss__x { padding: 6px 12px; border: 2.5px solid var(--fig-red); border-radius: var(--radius-s); color: var(--ink); background: var(--panel); }
.ty-miss__ok { padding: 6px 12px; border: 2.5px solid var(--ink); border-radius: var(--radius-s); background: var(--wood); }
.ty-miss__arrow { color: var(--ink-soft); }

/* ローマ字の駒 */
.ty-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-height: 48px; }
.ty-tile {
  min-width: 34px; height: 46px; padding: 0 4px; display: inline-grid; place-items: center; position: relative;
  font: 700 26px/1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; color: var(--ink);
  background: var(--panel); border: 2px solid var(--grid); border-radius: 6px;
}
.ty-tile--done { background: var(--wood); border-color: var(--wood-edge); }
.ty-tile--done::after { content: "✓"; position: absolute; right: 2px; bottom: 0; font: 700 11px/1 var(--font-body); color: var(--ink); }
.ty-tile--now { border: 3px solid var(--ink); }
.ty-tile--now::before { content: ""; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); border: 6px solid transparent; border-bottom-color: var(--ink); border-top: 0; }
.ty-tile--miss { border-color: var(--fig-red); animation: ty-shake 220ms ease; }
@keyframes ty-shake { 0%, 100% { transform: none; } 30% { transform: rotate(-6deg); } 70% { transform: rotate(6deg); } }

.ty-ime { color: var(--fig-red); font-weight: 700; }
.ty-start-hint { color: var(--ink-soft); font-size: 14px; }

/* 漢字に へんかん */
.ty-henkan { display: grid; justify-items: center; gap: 10px; }
.ty-henkan__line { font: 900 clamp(24px, 3.4vw, 34px)/1.5 var(--font-head); }
.ty-henkan__box { display: inline-block; min-width: 3em; margin: 0 .2em; padding: 0 .3em; border-bottom: 3px dashed var(--ink); }
.ty-henkan__box--select { background: var(--wood-light); border-bottom-style: solid; }
.ty-henkan__box--done { background: var(--wood); border-bottom-style: solid; }
.ty-henkan__rest { color: var(--ink-soft); }
.ty-henkan__help { font-weight: 700; }
.ty-henkan__hint { min-height: 1.5em; font-weight: 700; color: var(--ink); }
.ty-henkan__hint:not(:empty) { padding: 6px 12px; border: 2.5px solid var(--fig-red); border-radius: var(--radius-s); }
.ty-cands { list-style: none; margin: 0; padding: 6px; display: grid; gap: 4px; min-width: 220px; background: var(--panel); border: 2.5px solid var(--ink); border-radius: var(--radius-s); box-shadow: 0 4px 0 var(--ink); }
.ty-cand { display: flex; align-items: center; gap: 12px; padding: 6px 12px; border-radius: 6px; font: 900 24px/1.2 var(--font-head); }
.ty-cand__num { font: 700 14px/1 var(--font-body); color: var(--ink-soft); }
.ty-cand--on { background: var(--ink); color: var(--paper); }
.ty-cand--on .ty-cand__num { color: var(--paper); }

/* たてもの */
.ty-build { width: 170px; height: 234px; background: repeating-linear-gradient(0deg, transparent 0 11px, var(--grid) 11px 12px), var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-s); }
.ty-build__ground { stroke: var(--ink); stroke-width: 3; }
.ty-build__slot { fill: none; stroke: var(--wood-edge); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ty-build__wood { fill: var(--wood); stroke: var(--ink); stroke-width: 1.8; }
.ty-build__wood--b { fill: var(--wood-light); }
.ty-build__window { fill: var(--panel); stroke: var(--ink); stroke-width: 1.5; }
.ty-build__line { stroke: var(--ink); stroke-width: 1.5; fill: none; }
.ty-build__band { fill: var(--wood-dark); }
.ty-build__roof { fill: var(--wood-dark); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.ty-build__pole { stroke: var(--ink); stroke-width: 2.5; }
.ty-build__flag { fill: var(--fig-red); stroke: var(--ink); stroke-width: 1.5; }
.ty-build__block--new { animation: ty-drop 200ms ease-out; }
@keyframes ty-drop { from { transform: translateY(-16px); opacity: .3; } to { transform: none; opacity: 1; } }

/* キーボードの図 */
.ty-finger { text-align: center; font-weight: 700; min-height: 1.6em; margin: 4px 0 10px; }
.ty-keyboard { display: grid; gap: 6px; justify-content: center; }
.ty-kb__row { display: flex; gap: 6px; }
.ty-kb__row--1 { padding-left: 22px; }
.ty-kb__row--2 { padding-left: 34px; }
.ty-kb__row--3 { padding-left: 52px; }
.ty-kb__row--4 { justify-content: center; }
.ty-kb__key {
  width: 42px; height: 42px; display: grid; place-items: center; position: relative; font: 700 15px/1 var(--font-body);
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-s); box-shadow: 0 2px 0 var(--ink);
}
.ty-kb__key--wide { width: 72px; font-size: 13px; }
.ty-kb__key--space { width: 260px; font-size: 13px; }
.ty-kb__key--home { text-decoration: underline 2px var(--ink); text-underline-offset: 4px; }
.ty-kb__key--next { background: var(--wood); transform: translateY(2px); box-shadow: none; border-width: 3px; }
.ty-kb__key--wrong { border-color: var(--fig-red); }
.ty-kb__key--wrong::after { content: "×"; position: absolute; top: -10px; right: -6px; font: 900 16px/1 var(--font-head); color: var(--ink); background: var(--panel); border: 2px solid var(--fig-red); border-radius: var(--radius-pill); width: 20px; height: 20px; display: grid; place-items: center; }
.ty-toggles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; margin-top: 18px; font-size: 14px; }

/* けっか */
.ty-result { background: var(--panel); border: 2.5px solid var(--ink); border-radius: var(--radius-m); box-shadow: var(--lift); padding: 24px; outline: none; }
.ty-result__grid { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 24px; align-items: start; }
.ty-result__rank { font: 900 40px/1.2 var(--font-head); color: var(--ink); margin-bottom: 14px; }
.ty-result__nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.ty-result__nums div { padding: 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-s); }
.ty-result__nums dt { font-size: 13px; color: var(--ink-soft); }
.ty-result__nums dd { margin: 4px 0 0; font: 900 24px/1.2 var(--font-head); font-variant-numeric: tabular-nums; }
.ty-result__next { font-weight: 700; }
.ty-result__compare { margin-top: 6px; }
.ty-result__compare:empty, .ty-result__weak:empty { display: none; }
.ty-result__weak { color: var(--ink-soft); margin-top: 6px; }
.ty-result__buttons { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 20px; }
.ty-btn--sub { background: var(--panel); }

/* 先生用の リンク */
.ty-teacher { padding: 20px; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-m); align-self: start; }
.ty-teacher__title { font: 900 18px/1.4 var(--font-head); margin-bottom: 8px; }
.ty-teacher__form { display: grid; gap: 10px; margin: 12px 0; }
.ty-teacher__form label { display: flex; align-items: center; gap: 8px; }
.ty-teacher__form select {
  min-height: 40px; max-width: 100%; padding: 6px 10px; font: 400 16px/1.5 var(--font-body); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 6px; background: var(--panel);
}
/* 「おうちの方・先生へ」の最後の行が、下のフッターの線にくっつかないように */
.m-body--typing .m-parents { padding-bottom: 72px; }
.ty-teacher__url code { display: block; padding: 8px 10px; background: var(--panel); border: 1.5px dashed var(--ink); border-radius: 6px; font-size: 13px; word-break: break-all; }

@media (max-width: 860px) {
  .ty-columns, .ty-result__grid { grid-template-columns: minmax(0, 1fr); }
  .ty-play__main { grid-template-columns: minmax(0, 1fr); }
  .ty-build { margin-inline: auto; width: 140px; height: 192px; }
  .ty-result__nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ty-kb__key { width: 30px; height: 34px; font-size: 13px; }
  .ty-kb__key--wide { width: 48px; font-size: 11px; }
  .ty-kb__key--space { width: 170px; }
  .ty-kb__row, .ty-keyboard { gap: 4px; }
  .ty-kb__row--1 { padding-left: 14px; }
  .ty-kb__row--2 { padding-left: 22px; }
  .ty-kb__row--3 { padding-left: 34px; }
  .ty-tile { min-width: 26px; height: 38px; font-size: 20px; }
}
@media (max-width: 520px) {
  .ty-play { padding: 16px 12px 20px; }
  .ty-keyboard { max-width: 100%; overflow: hidden; }
  .ty-kb__key { width: 20px; height: 26px; font-size: 10px; border-width: 1.5px; border-radius: 4px; }
  .ty-kb__key--wide { width: 34px; font-size: 9px; }
  .ty-kb__key--space { width: 120px; font-size: 10px; }
  .ty-kb__row, .ty-keyboard { gap: 2px; }
  .ty-kb__row--1 { padding-left: 8px; }
  .ty-kb__row--2 { padding-left: 12px; }
  .ty-kb__row--3 { padding-left: 18px; }
  .ty-kb__key--wrong::after { width: 14px; height: 14px; font-size: 11px; top: -7px; right: -5px; }
  .ty-cands { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ty-tile--miss, .ty-build__block--new { animation: none; }
  .ty-stage, .ty-grade { transition: none; }
}
