/* ==========================================================
   同訓異字レーサー — dokun-iji-racer.css   v1.0.0
   すべてのセレクタに .dkr-root を親にしてスコープ化
   倍数レーサー multiple-racer.css をベースに改修
   ========================================================== */

.dkr-root {
  --dkr-good: #2ecc71;
  --dkr-bad:  #e74c3c;
  --dkr-gold: #f5c518;
  --dkr-blue: #2d6cdf;

  position: relative;
  width: 100%;
  /* 電子黒板・タブレットを想定した16:9ビューポート高さ */
  height: min(100vw * 9 / 16, 92vh);
  max-width: 760px;
  margin: 0 auto;
  overflow: hidden;
  background: #0c1326;
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", system-ui, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

.dkr-root *, .dkr-root *::before, .dkr-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Canvas ---------- */
.dkr-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- HUD ---------- */
/* 修正: 出題文を表示するため2段構成に変更 */
.dkr-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0,0,0,.6);
  font-weight: 800;
}
.dkr-hud.hidden { display: none !important; }

.dkr-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dkr-hud-pill {
  background: rgba(16,24,46,.78);
  border-radius: 14px;
  padding: 5px 12px;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 54px;
  border: 1px solid rgba(159,180,224,.35);
  backdrop-filter: blur(3px);
}
.dkr-hud-pill small { font-size: 11px; font-weight: 700; opacity: .8; }
.dkr-hud-pill b     { font-size: 18px; }
.dkr-lives b        { font-size: 16px; }

/* 修正: 出題文（（読み）部分をゴールドで強調） */
.dkr-quest {
  text-align: center;
  font-size: clamp(16px, 4.2vw, 26px);
  line-height: 1.4;
  background: rgba(16,24,46,.72);
  border: 1px solid rgba(159,180,224,.35);
  border-radius: 14px;
  padding: 8px 14px;
  align-self: center;
  max-width: 94%;
}
.dkr-quest .dkr-yomi { color: var(--dkr-gold); }

/* 修正: れんしゅうモードの意味ヒント行 */
.dkr-hint-line {
  align-self: center;
  font-size: clamp(12px, 3vw, 16px);
  color: #ffe9a3;
  background: rgba(16,24,46,.6);
  border-radius: 10px;
  padding: 3px 12px;
}
.dkr-hint-line.hidden { display: none !important; }

/* ---------- コンボ・判定 ---------- */
.dkr-combo {
  position: absolute;
  top: 34%; left: 50%;
  transform: translateX(-50%);
  font-size: 34px; font-weight: 900;
  color: var(--dkr-gold); opacity: 0;
  text-shadow: 0 3px 0 #b8860b, 0 0 18px rgba(245,197,24,.8);
  pointer-events: none;
}
.dkr-judge {
  position: absolute;
  top: 46%; left: 50%;
  transform: translate(-50%, -50%) scale(1);
  font-size: 90px; font-weight: 900;
  opacity: 0; pointer-events: none;
}

/* 修正: 正解ヒント／不正解解説のフィードバックバナー */
.dkr-feedback {
  position: absolute;
  left: 50%; bottom: 22%;
  transform: translateX(-50%);
  max-width: 92%;
  font-size: clamp(14px, 3.6vw, 20px);
  font-weight: 800;
  line-height: 1.5;
  padding: 10px 18px;
  border-radius: 14px;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  z-index: 5;
}
.dkr-feedback.ok { background: rgba(24,110,66,.9); border: 2px solid #2ecc71; }
.dkr-feedback.ng { background: rgba(120,32,28,.92); border: 2px solid #e74c3c; }
.dkr-feedback.hidden { display: none !important; }

/* ---------- れんしゅう用 解説カード ---------- */
/* 修正: 一時停止して解説を確認するカード */
.dkr-pause-card {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(92%, 480px);
  background: rgba(13,20,40,.96);
  border: 3px solid var(--dkr-bad);
  border-radius: 20px;
  padding: 20px;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  text-align: center;
  z-index: 10;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.dkr-pause-card.hidden { display: none !important; }
.dkr-pc-mark {
  font-size: 46px; font-weight: 900; line-height: 1;
  color: var(--dkr-bad);
}
.dkr-pc-sentence {
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 800; line-height: 1.5;
}
.dkr-pc-answers { display: flex; flex-direction: column; gap: 4px; }
.dkr-pc-ans { font-size: 16px; font-weight: 800; }
.dkr-pc-mine    { color: #ff9c93; }
.dkr-pc-correct { color: #7dffb0; font-size: 20px; }
.dkr-pc-explain {
  font-size: 15px; line-height: 1.6; color: #cfe;
  background: rgba(255,255,255,.06);
  border-radius: 12px; padding: 10px 14px;
}

/* ---------- 操作ボタン ---------- */
.dkr-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 14px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  pointer-events: none;
}
.dkr-controls.hidden { display: none !important; }

.dkr-ctrl-btn {
  pointer-events: auto;
  width: 88px; height: 88px;
  border: none; border-radius: 50%;
  background: rgba(45,108,223,.9);
  color: #fff; font-size: 40px; font-weight: 900;
  box-shadow: 0 6px 0 #1a4ba0, 0 8px 16px rgba(0,0,0,.4);
  cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.dkr-ctrl-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #1a4ba0;
}

/* ---------- 画面共通 ---------- */
.dkr-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 24px;
  background: linear-gradient(180deg, #16224a, #0c1326);
  text-align: center;
  overflow-y: auto;
}
.dkr-screen.hidden { display: none !important; }
.dkr-screen:not(.hidden) {
  animation: dkr-screen-in .35s ease-out;
}
@keyframes dkr-screen-in {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- タイポ ---------- */
.dkr-game-title {
  font-size: clamp(32px, 9vw, 60px);
  font-weight: 900; letter-spacing: 2px;
  color: var(--dkr-gold);
  text-shadow: 0 4px 0 #b8860b, 0 0 30px rgba(245,197,24,.5);
  line-height: 1.15;
  animation: dkr-title-bob 3s ease-in-out infinite;
}
.dkr-game-title small {
  display: block; font-size: 15px; letter-spacing: 5px;
  color: #9fb4e0; text-shadow: none; margin-top: 6px;
}
.dkr-title-md { font-size: clamp(26px, 7vw, 42px); }
.dkr-title-lg { font-size: clamp(30px, 8.5vw, 52px); }
@keyframes dkr-title-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.dkr-gold-text { color: var(--dkr-gold); }

.dkr-road-divider {
  width: 160px; height: 8px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, var(--dkr-gold) 0 18px, transparent 18px 30px);
}

.dkr-panel {
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: 18px; padding: 18px;
  width: 100%; max-width: 480px; text-align: center;
}
.dkr-panel h3 {
  font-size: 15px; color: #9fb4e0;
  margin-bottom: 12px; letter-spacing: 1px;
}

.dkr-lead {
  max-width: 420px; color: #cfe;
  font-size: 16px; line-height: 1.7;
}

/* ---------- 読み方グループ選択 ---------- */
.dkr-group-grid {
  display: flex; flex-wrap: wrap;
  gap: 8px; justify-content: center;
}
/* 修正: グループ選択の見出しラベル（同じ訓／じゅく語） */
.dkr-opt-label {
  width: 100%;
  font-size: 13px;
  font-weight: 800;
  color: #9fb4e0;
  letter-spacing: 1px;
  margin-top: 4px;
}
/* 修正: 発展もんだいトグル行 */
.dkr-adv-row span { font-size: 14px; }

.dkr-opt {
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  background: rgba(255,255,255,.08);
  border: 2px solid transparent;
  color: #fff; font-weight: 800; font-size: 17px;
  transition: .12s; min-width: 64px; text-align: center;
  box-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.dkr-opt:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.dkr-opt.sel {
  background: var(--dkr-blue); border-color: #fff;
  box-shadow: 0 3px 0 #1a4ba0, 0 0 12px rgba(45,108,223,.6);
}

/* 修正: 意味ヒントON/OFFトグル */
.dkr-hint-toggle-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 16px; font-weight: 800; color: #cfe;
}
.dkr-toggle {
  border: none; cursor: pointer;
  font-weight: 900; font-size: 16px;
  padding: 8px 26px; border-radius: 999px;
  color: #10182e;
  background: linear-gradient(180deg, #7dffb0, #2ecc71);
  box-shadow: 0 4px 0 #1a7d47;
  font-family: inherit;
  transition: .12s;
}
.dkr-toggle.off {
  color: #fff;
  background: rgba(255,255,255,.14);
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
}

/* ---------- モード選択 ---------- */
.dkr-mode-grid {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center; width: 100%; max-width: 640px;
}
.dkr-mode-card {
  flex: 1; min-width: 150px; max-width: 200px; padding: 20px 14px;
  border-radius: 18px; cursor: pointer;
  background: rgba(255,255,255,.07);
  border: 3px solid rgba(255,255,255,.15);
  transition: .14s;
  box-shadow: 0 6px 0 rgba(0,0,0,.35);
}
.dkr-mode-card:hover { transform: translateY(-3px); border-color: var(--dkr-gold); }
.dkr-mode-card:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.dkr-mc-title { font-size: 22px; font-weight: 900; color: var(--dkr-gold); margin-bottom: 6px; }
.dkr-mc-desc  { font-size: 13px; color: #cfe; line-height: 1.5; }

/* ---------- ボタン ---------- */
.dkr-big-btn {
  pointer-events: auto; border: none; cursor: pointer;
  font-weight: 900; font-size: 22px;
  padding: 14px 38px; border-radius: 999px; color: #10182e;
  background: linear-gradient(180deg, #ffe066, var(--dkr-gold));
  box-shadow: 0 6px 0 #b8860b, 0 10px 20px rgba(0,0,0,.4);
  transition: transform .06s, box-shadow .06s;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}
.dkr-big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8860b; }
.dkr-big-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -80%;
  width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.65), transparent);
  animation: dkr-btn-shine 2.8s ease-in-out infinite;
}
@keyframes dkr-btn-shine {
  0%, 60% { left: -80%; }
  100%    { left: 130%; }
}

/* 修正: 復習ボタン（グリーン系で区別） */
.dkr-btn-review {
  color: #fff;
  background: linear-gradient(180deg, #58d68d, #1e8e50);
  box-shadow: 0 6px 0 #14603a, 0 10px 20px rgba(0,0,0,.4);
}
.dkr-btn-review:active { box-shadow: 0 2px 0 #14603a; }

.dkr-sub-btn {
  pointer-events: auto;
  border: 2px solid rgba(255,255,255,.3);
  background: transparent; color: #fff;
  font-weight: 800; font-size: 16px;
  padding: 10px 24px; border-radius: 999px; cursor: pointer;
  font-family: inherit;
}

.dkr-btn-row {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
}

/* ---------- ステージアナウンス ---------- */
.dkr-stage-no   { font-size: clamp(36px, 11vw, 60px); font-weight: 900; color: #fff; line-height: 1; }
.dkr-stage-quest{ font-size: clamp(24px, 7vw, 38px);  font-weight: 900; color: var(--dkr-gold); }
.dkr-stage-meta { font-size: 16px; color: #9fb4e0; }

/* ---------- 結果 ---------- */
.dkr-result-score {
  font-size: clamp(44px, 13vw, 78px); font-weight: 900;
  color: var(--dkr-gold); line-height: 1;
  text-shadow: 0 4px 0 #b8860b;
  animation: dkr-score-pop .5s cubic-bezier(.2,1.6,.4,1);
}
@keyframes dkr-score-pop {
  from { transform: scale(.3); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.dkr-result-line { font-size: 17px; color: #cfe; }
/* 修正: 称号・苦手読み方の表示 */
.dkr-rank {
  font-size: clamp(20px, 5.5vw, 30px); font-weight: 900;
  color: #7dffb0;
  text-shadow: 0 0 16px rgba(46,204,113,.6);
}
.dkr-weak { font-size: 15px; color: #ffd9a3; font-weight: 800; }
.dkr-best { font-size: 14px; color: #9fb4e0; }

/* ---------- まちがい復習 ---------- */
.dkr-review-screen { justify-content: flex-start; padding-top: 20px; }
.dkr-review-list {
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.dkr-review-card {
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 14px 16px;
  text-align: left;
  display: flex; flex-direction: column; gap: 4px;
}
.dkr-rv-sentence { font-size: 17px; font-weight: 900; line-height: 1.5; }
.dkr-rv-mine     { font-size: 14px; font-weight: 800; color: #ff9c93; }
.dkr-rv-correct  { font-size: 16px; font-weight: 900; color: #7dffb0; }
.dkr-rv-explain  { font-size: 13px; color: #cfe; line-height: 1.6; }
.dkr-review-empty { font-size: 18px; font-weight: 800; color: #7dffb0; }

/* ---------- 先生モード ---------- */
/* 修正: 電子黒板向けの大型表示 */
.dkr-t-badge {
  font-size: 15px; font-weight: 900; letter-spacing: 2px;
  color: #10182e;
  background: linear-gradient(180deg, #ffe066, var(--dkr-gold));
  border-radius: 999px;
  padding: 6px 22px;
}
.dkr-t-sentence {
  font-size: clamp(22px, 6vw, 40px);
  font-weight: 900; line-height: 1.6;
  max-width: 640px;
}
.dkr-t-choices {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
}
.dkr-t-choice {
  font-size: clamp(24px, 6.5vw, 42px);
  font-weight: 900;
  padding: 14px 26px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  border: 3px solid rgba(255,255,255,.22);
  transition: .18s;
}
.dkr-t-choice.correct {
  background: rgba(24,110,66,.9);
  border-color: #2ecc71;
  color: #c9ffdd;
  box-shadow: 0 0 24px rgba(46,204,113,.6);
  transform: scale(1.08);
}
.dkr-t-choice.dim { opacity: .35; }
.dkr-t-explain {
  font-size: clamp(16px, 4.2vw, 24px);
  font-weight: 800; line-height: 1.7;
  color: #ffe9a3;
  background: rgba(16,24,46,.8);
  border: 2px solid rgba(245,197,24,.5);
  border-radius: 16px;
  padding: 12px 22px;
  max-width: 640px;
}
.dkr-t-explain.hidden, .dkr-t-reveal.hidden, .dkr-t-next.hidden { display: none !important; }

/* ---------- 全クリア紙吹雪 ---------- */
.dkr-confetti {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 50;
  animation: dkr-confetti-fall 3s linear forwards;
}
@keyframes dkr-confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: .6; }
}

/* ---------- レスポンシブ ---------- */
@media (max-height: 540px) {
  .dkr-game-title  { font-size: 38px; }
  .dkr-panel       { padding: 12px; }
  .dkr-screen      { gap: 10px; }
  .dkr-mode-card   { padding: 12px; }
  .dkr-ctrl-btn    { width: 70px; height: 70px; font-size: 32px; }
}
