/* ドパドリル タイピング（非公式改造版）。元の style.css の上に重ねて使う。 */

/* 画面の文言を含むサブセットフォント（../fonts/ に生成手順あり） */
@font-face { font-family: "Drill Maru"; src: url("../fonts/drill-maru-bold.woff2") format("woff2"); font-weight: 700; font-display: block; }
@font-face { font-family: "Drill Maru"; src: url("../fonts/drill-maru-black.woff2") format("woff2"); font-weight: 900; font-display: block; }
/* 見出し・数字用: 丸ゴシックの いちばん太い字（しゃかい と同じ。どの太さを指定されても この字で出す） */
@font-face { font-family: "Drill Heavy"; src: url("../fonts/drill-maru-black.woff2") format("woff2"); font-weight: 100 900; font-display: block; }
/* 元の fx.js が canvas に "Dela Gothic One" と名前で書く文字（コンボ・+ドパ）も この字にする（同じ条件の @font-face は あとのものが使われる） */
@font-face { font-family: "Dela Gothic One"; src: url("../fonts/drill-maru-black.woff2") format("woff2"); font-display: block; }
@font-face { font-family: "Dela Gothic One"; src: url("../fonts/drill-maru-black.woff2") format("woff2"); font-weight: 900; font-display: block; }

/* ビートに合わせた光（元の style.css の body.lv9 .card）に使う値。カードにだけ書き、子には伝えない */
@property --kick { syntax: '<number>'; inherits: false; initial-value: 0; }

:root {
  --round: "Drill Maru", "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  --chunky: "Drill Heavy", "Drill Maru", "Zen Maru Gothic", sans-serif;
  /* 指の色（うすい色 = キーの地の色、こい色 = つぎに打つキー） */
  --f-pinky: #ffd6e8; --f-pinky-on: #ff7ab6;
  --f-ring: #fff0b3; --f-ring-on: #ffc400;
  --f-middle: #c9f5e6; --f-middle-on: #2fcf9c;
  --f-index: #d4e3ff; --f-index-on: #5b8cff;
  --f-thumb: #e6dcff; --f-thumb-on: #a77bff;
}

#app { width: min(100vw, 1000px); }
/* 子ども向けの文は ことばの間に空白を入れているので、ことばの途中では改行しない */
#app, .modal { word-break: keep-all; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ タイトル */
#screen-title { gap: 12px; padding-top: calc(12px + env(safe-area-inset-top)); }
#screen-title > * { width: 100%; max-width: 520px; }
.ty-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ty-top .icon-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 4px; text-decoration: none; color: var(--ink); font-size: 26px; line-height: 1; box-shadow: 0 3px 0 var(--ink); }
.ty-gear svg { width: 100%; height: 100%; }
.ty-unofficial { padding: 3px 10px; border: 2px dashed var(--ink); border-radius: 999px; background: #fff; font-size: 12px; }
.ty-logo { margin: 4px 0 0; display: grid; justify-items: center; line-height: 1.05; font-weight: 400; }
.ty-logo-sub { padding: 2px 16px; border: 3px solid var(--ink); border-radius: 999px; background: var(--mint); font-family: var(--round); font-weight: 900; font-size: 17px; box-shadow: 0 4px 0 var(--ink); transform: rotate(-3deg); }
.ty-logo-main { margin-top: 8px; font-family: var(--chunky); font-size: clamp(40px, 12vw, 58px); color: var(--blue); letter-spacing: .04em; white-space: nowrap;
  text-shadow: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink), 0 7px 0 var(--ink); }
.ty-title-stage { height: min(16vh, 140px); }

.ty-levels { display: grid; gap: 10px; }
.ty-level { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 12px; min-height: 62px; padding: 8px 16px; border: 3px solid var(--ink); border-radius: 20px; background: #fff; box-shadow: 0 5px 0 var(--ink); text-align: left; transition: transform .08s; }
.ty-level b { font-family: var(--chunky); font-weight: 400; font-size: 23px; color: var(--c, var(--blue)); white-space: nowrap; }
.ty-level-sub { display: grid; gap: 1px; }
.ty-level small { font-size: 13px; }
.ty-level em { font-style: normal; font-size: 12px; color: #d2452f; }
.ty-level[data-level="kana"] { --c: #1aa37a; }
.ty-level[data-level="short"] { --c: var(--blue); }
.ty-level[data-level="word"] { --c: #8a4fff; }
.ty-level[data-level="phrase"] { --c: #ff5a8a; }
.ty-level[data-level="sentence"] { --c: #d2452f; }
.ty-level[aria-pressed="true"] { background: #fffbe6; }
.ty-level:active, .ty-chips button:active, .ty-switch:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

.ty-panel { padding: 12px 12px 14px; border: 3px solid var(--ink); border-radius: 20px; background: #fff; box-shadow: 0 5px 0 var(--ink); }
.ty-panel h2 { margin: 0 0 8px; font-size: 16px; }
.ty-panel h2 small { font-size: 12px; font-weight: 700; opacity: .65; }
.ty-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ty-chips button { min-height: 40px; padding: 4px 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; font-size: 15px; box-shadow: 0 3px 0 var(--ink); }
.ty-chips button[aria-checked="true"] { background: var(--blue); color: #fff; }
.ty-switches { display: grid; gap: 8px; }
.ty-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 4px 6px 4px 14px; border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; font-size: 15px; box-shadow: 0 3px 0 var(--ink); text-align: left; }
.ty-switch span { flex: none; min-width: 64px; padding: 3px 10px; border-radius: 999px; background: #e9e7f3; color: #6b6890; font-size: 13px; text-align: center; }
.ty-switch[aria-pressed="true"] span { background: var(--mint); color: var(--ink); }
.ty-howto ol { margin: 8px 0 0; padding-left: 1.4em; font-size: 14px; line-height: 1.7; }
.ty-howto ol b { color: #d2452f; }
.ty-note { margin: 8px 0 0; padding: 6px 10px; border-radius: 12px; background: var(--paper); font-size: 13px; line-height: 1.6; }
.ty-home-kbd { pointer-events: none; }
.ty-records p { margin: 0; font-size: 14px; line-height: 1.7; }
.ty-credit { margin: 4px 0 0; font-size: 12px; text-align: center; line-height: 1.6; }
.ty-credit a { color: var(--blue); }
kbd { display: inline-block; min-width: 1.6em; padding: 0 .35em; border: 2px solid var(--ink); border-bottom-width: 3.5px; border-radius: 6px; background: #fff; font: inherit; font-weight: 900; line-height: 1.35; text-align: center; }

/* ------------------------------------------------------------ キーボード（SVG） */
.kbd { display: block; width: 100%; height: auto; overflow: visible; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.kb-key rect { fill: #fff; stroke: var(--ink); stroke-width: .55; }
.kb-key text { fill: var(--ink); font-family: var(--round); font-weight: 900; font-size: 4.1px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.kb-key[data-k=" "] text { font-size: 3.4px; }
.kb-bump { stroke: var(--ink); stroke-width: .7; stroke-linecap: round; pointer-events: none; }
.kb-key.f0 rect, .kb-key.f7 rect { fill: var(--f-pinky); }
.kb-key.f1 rect, .kb-key.f6 rect { fill: var(--f-ring); }
.kb-key.f2 rect, .kb-key.f5 rect { fill: var(--f-middle); }
.kb-key.f3 rect, .kb-key.f4 rect { fill: var(--f-index); }
.kb-key.f8 rect { fill: var(--f-thumb); }
.kb-key { transform-box: fill-box; transform-origin: center; }
/* つぎに打つキー: こい色で光らせて、はずませる */
.kb-key.next rect { stroke-width: 1.3; filter: drop-shadow(0 0 1.6px rgba(255, 255, 255, .9)); }
.kb-key.next.f0 rect, .kb-key.next.f7 rect { fill: var(--f-pinky-on); }
.kb-key.next.f1 rect, .kb-key.next.f6 rect { fill: var(--f-ring-on); }
.kb-key.next.f2 rect, .kb-key.next.f5 rect { fill: var(--f-middle-on); }
.kb-key.next.f3 rect, .kb-key.next.f4 rect { fill: var(--f-index-on); }
.kb-key.next.f8 rect { fill: var(--f-thumb-on); }
.kb-key.next { animation: kb-next .7s ease-in-out infinite; }
@keyframes kb-next { 50% { transform: scale(1.12); } }
.kb-key.hit rect { fill: #fff !important; }
.kb-key.miss rect { fill: #ff5a4f !important; }
.kb-key.miss { animation: kb-miss .35s; }
@keyframes kb-miss { 25% { transform: translateX(-1.2px); } 75% { transform: translateX(1.2px); } }
/* スタート前: F と J（ホームポジションの目じるし）を光らせる */
.kb-key.guide rect { stroke-width: 1.3; }
.kb-key.guide.f3 rect, .kb-key.guide.f4 rect { fill: var(--f-index-on); }
.kb-key.guide { animation: kb-next .9s ease-in-out infinite; }
body.reduced .kb-key.next, body.reduced .kb-key.guide, body.reduced .kb-key.miss { animation: none; }
/* 遊び方の図: ホームポジションのキーだけ こい色 */
.ty-home-kbd .kb-key.home.f0 rect, .ty-home-kbd .kb-key.home.f7 rect { fill: var(--f-pinky-on); }
.ty-home-kbd .kb-key.home.f1 rect, .ty-home-kbd .kb-key.home.f6 rect { fill: var(--f-ring-on); }
.ty-home-kbd .kb-key.home.f2 rect, .ty-home-kbd .kb-key.home.f5 rect { fill: var(--f-middle-on); }
.ty-home-kbd .kb-key.home.f3 rect, .ty-home-kbd .kb-key.home.f4 rect { fill: var(--f-index-on); }

/* 指の色の丸 */
.ty-dot { display: inline-block; width: .9em; height: .9em; margin-right: .35em; border: 2px solid var(--ink); border-radius: 50%; vertical-align: -.1em; background: var(--dot); }
.f0, .f7 { --dot: var(--f-pinky-on); }
.f1, .f6 { --dot: var(--f-ring-on); }
.f2, .f5 { --dot: var(--f-middle-on); }
.f3, .f4 { --dot: var(--f-index-on); }
.f8 { --dot: var(--f-thumb-on); }

/* ------------------------------------------------------------ プレイ */
#screen-play { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.hud { gap: 8px; }
.ty-quit { font-size: 22px; line-height: 1; }
.pips.lots .pip { width: 8px; height: 8px; border-width: 1.5px; }
.ty-stage { flex: 0 0 auto; height: clamp(56px, 11vh, 120px); min-height: 0; }
.ty-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0 10px 8px; padding: 8px 10px 8px; }
.ty-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }

.ty-words { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; padding: 4px 2px; text-align: center; }
.ty-words[hidden] { display: none; }
.ty-words p { margin: 0; max-width: 100%; line-height: 1.3; }
.ty-text { font-family: var(--chunky); font-size: clamp(24px, 7.4vw, 44px); letter-spacing: .02em; }
.ty-kana { font-weight: 900; font-size: clamp(18px, 5.2vw, 30px); letter-spacing: .06em; word-break: break-all; color: var(--ink); }
.ty-roma { font-weight: 900; font-size: clamp(16px, 4.8vw, 28px); letter-spacing: .07em; word-break: break-all; color: #8d88ad; }
.ty-kana .done { color: #b9bbd9; }
.ty-kana .now { padding: 0 .08em; border-radius: .25em; background: #fff3b8; box-shadow: 0 0 0 2px var(--yellow); }
.ty-roma .done { color: var(--blue); }
.ty-roma .next { color: #fff; padding: 0 .1em; border-radius: .2em; background: var(--pink); }
.ty-roma .more { color: #b9bbd9; }
body.no-hint .ty-roma .next:empty { display: none; }
/* 文字の大きさは main.js の fitWords() が カードの幅に合わせて決める（上の値は 計る前の仮の大きさ） */
/* 表示と読みが同じ（ひらがなだけ）のときは、読みの行だけを出す */
.ty-words.solo .ty-text { display: none; }
.ty-words.cleared .ty-kana, .ty-words.cleared .ty-text { color: var(--pink); }
.ty-shake { animation: ty-shake .3s; }
@keyframes ty-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
body.reduced .ty-shake { animation: none; }

.ty-start { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 6px; }
.ty-start[hidden] { display: none; }
.ty-start-btn { display: grid; gap: 2px; justify-items: center; min-width: min(280px, 90%); padding: 10px 20px 12px; border: 3px solid var(--ink); border-radius: 20px; background: var(--yellow); box-shadow: 0 5px 0 var(--ink); }
.ty-start-btn b { font-family: var(--chunky); font-weight: 400; font-size: 32px; }
.ty-start-btn small { font-size: 13px; }
.ty-start-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.ty-start-note { margin: 0; font-size: 14px; }

.ty-kbd-box { flex: none; width: 100%; max-width: 600px; margin: 0 auto; }
.ty-kbd { padding: 0 1px; }
.ty-finger { margin: 4px 0 0; min-height: 22px; font-size: 14px; text-align: center; }
.ty-finger b { display: inline-block; min-width: 1.4em; padding: 0 .3em; border: 2px solid var(--ink); border-radius: 6px; background: #fff; }
body.no-kbd .ty-kbd { display: none; }

/* 背の低い画面（スマホ横・小さいノートPC）: ステージを小さくして、キーボードまで入るように */
@media (max-height: 640px) {
  .ty-stage { height: 44px; }
  .ty-kbd-box { max-width: min(600px, 120vh); }
}
@media (min-width: 760px) {
  .ty-card { padding: 10px 16px 10px; }
}

/* ------------------------------------------------------------ 結果 */
#screen-result .result-card { max-width: 520px; }
.ty-score b { font-size: 84px; }
.ty-score span { font-size: 22px; }
.ty-rank { margin: 6px 0 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 8px; }
.ty-rank-name { padding: 2px 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--yellow); font-family: var(--chunky); font-size: 20px; box-shadow: 0 3px 0 var(--ink); }
.ty-best { padding: 2px 10px; border-radius: 999px; background: var(--pink); color: #fff; font-size: 14px; font-weight: 900; }
.ty-rank small { flex-basis: 100%; font-size: 13px; color: #d2452f; }
.ty-weak { margin: 8px 0 4px; }
.ty-weak-title { margin: 0 0 6px; font-size: 14px; text-align: center; }
.ty-weak-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.ty-weak-key { display: grid; justify-items: center; gap: 2px; }
.ty-weak-key kbd { min-width: 2em; font-size: 22px; background: var(--dot, #fff); }
.ty-weak-key small { font-size: 11px; line-height: 1.3; text-align: center; }
.ty-perfect { margin: 6px 0; text-align: center; font-size: 16px; color: var(--pink); }
.ty-retry { width: 100%; min-width: 0; padding: 0 12px; font-size: clamp(15px, 4.4vw, 20px); white-space: nowrap; background: var(--pink); color: var(--ink); text-shadow: none; }

/* ------------------------------------------------------------ 設定 */
.ty-reset { background: #fff0f4; }
