/* 点数計算ドリル — style.css の配色・角丸・影に揃える (緑卓 + 黄アクセント) */

.drill-body {
  position: static;
  overflow-y: auto;
  min-height: 100vh;
  background: linear-gradient(160deg, #0b3d2a 0%, #0d5c3a 60%, #0b3d2a 100%);
  color: #fff;
  font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  padding-bottom: 32px;
}

/* ─── ヘッダー ─── */
.drill-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  position: sticky; top: 0; z-index: 10;
}
.drill-back {
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  color: #fff; text-decoration: none; font-size: 22px;
  border-radius: 10px;
}
.drill-back:hover, .drill-back:focus-visible { background: rgba(255, 255, 255, 0.12); }
.drill-title { font-size: 16px; font-weight: 700; margin: 0; flex: 1; }
.drill-score { font-size: 12px; color: #ffeb3b; white-space: nowrap; }

/* ─── メニュー ─── */
.drill-menu, .drill-quiz { max-width: 620px; margin: 0 auto; padding: 12px; }
.drill-section { margin-bottom: 22px; }
.drill-h2 {
  font-size: 13px; color: #aee5c8; margin: 0 0 8px;
  border-left: 3px solid #ffeb3b; padding-left: 8px;
}
.drill-note { font-size: 11px; color: #9ec; margin: 6px 2px 0; }

.drill-choices { display: flex; gap: 8px; }
.drill-opt {
  flex: 1; min-height: 48px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent; border-radius: 12px;
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.drill-opt--on { background: rgba(255, 235, 59, 0.16); border-color: #ffeb3b; color: #ffeb3b; }
.drill-opt:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.drill-modes { display: flex; flex-direction: column; gap: 10px; }
.drill-mode {
  display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 64px; padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 14px;
  color: #fff; cursor: pointer;
}
.drill-mode:hover, .drill-mode:focus-visible {
  background: rgba(255, 235, 59, 0.14); border-color: #ffeb3b;
}
.drill-mode__icon { font-size: 26px; flex-shrink: 0; }
.drill-mode__body { display: flex; flex-direction: column; gap: 3px; }
.drill-mode__body b { font-size: 15px; }
.drill-mode__body small { font-size: 11px; color: #bde; line-height: 1.5; }

.drill-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px;
}
.drill-stat {
  background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 10px;
  text-align: center;
}
.drill-stat__label { font-size: 10px; color: #9ec; display: block; }
.drill-stat__value { font-size: 18px; font-weight: 700; color: #ffeb3b; }
.drill-reset {
  margin-top: 10px; min-height: 44px; padding: 0 14px;
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px; color: #bde; font-size: 12px; cursor: pointer;
}

/* ─── 出題 ─── */
.drill-q-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #9ec; margin-bottom: 10px;
}
.drill-q-streak { color: #ffeb3b; font-weight: 700; }
.drill-q-body {
  background: rgba(0, 0, 0, 0.28); border-radius: 14px; padding: 14px; margin-bottom: 14px;
}
/* 手牌は必ず1行。 枚数 (14〜17枚) に応じて牌が自動で縮む。
   折り返すと「どこまでが1つの手か」が読めなくなるため wrap は使わない */
.drill-hand {
  display: flex; flex-wrap: nowrap; gap: 4px;
  justify-content: center; align-items: flex-end;
  /* 親の padding の外まで使って牌を少しでも大きく見せる (14〜15枚を1行に収める都合で
     牌が小さくなりがちなため)。 はみ出さないよう width で相殺する */
  margin: 0 -10px 16px; width: calc(100% + 20px);   /* 下の余白は「鳴」「雀頭」ラベルの分 */
}
.drill-hand:empty { display: none; }
/* 面子のまとまり。 隙間で区切ると どの面子に何符ついたかを追いやすい */
.drill-hand__grp { display: flex; gap: 1px; flex: 0 1 auto; min-width: 0; }
/* width が基準サイズ、 flex-shrink で画面に収まるまで縮む。
   ※ flex-basis を 0 にすると幅が潰れて牌が消えるので width 指定のままにすること */
.drill-hand__grp img {
  flex: 0 1 auto;
  width: 30px; min-width: 0; height: auto;
  aspect-ratio: 3 / 4;     /* 牌画像 (69×92) の比率。 縮んでも潰れない */
  border-radius: 3px;
}
/* 鳴いた面子は明刻 (暗刻の半分の符) になるため、見た目で区別できないと符が計算できない */
.drill-hand__grp { position: relative; }
.drill-hand__grp--open img { outline: 2px solid #ffb74d; outline-offset: -1px; }
/* 面子の種別ラベル (ポン/明槓/暗槓/チー/雀頭)。 暗槓32符と明槓16符は倍違うので明示する */
.drill-hand__grp[data-label]:not([data-label=""])::after {
  content: attr(data-label); position: absolute; left: 50%; bottom: -13px;
  transform: translateX(-50%);
  font-size: 9px; line-height: 1; white-space: nowrap; color: #9ec;
}
.drill-hand__grp--open::after { color: #ffb74d; }
/* あがり牌 (シャンポン待ちのロンだと この刻子が明刻になる) */
.drill-hand .drill-hand__win { outline: 2px solid #ff5722; outline-offset: 1px; border-radius: 3px; }

.drill-legend { font-size: 10px; color: #9ec; text-align: center; margin: 0 0 8px; line-height: 1.9; }
.drill-legend[hidden] { display: none; }
.drill-lg { display: inline-block; padding: 0 3px; border-radius: 3px; font-size: 9px; }
.drill-lg--win { outline: 2px solid #ff5722; color: #ff8a65; }
.drill-lg--open { outline: 1px solid #ffb74d; color: #ffb74d; }
.drill-lg--pair { outline: 1px solid #9ec; color: #9ec; }
.drill-note-inline { color: #ffcc80; }
.drill-cond { font-size: 14px; line-height: 1.7; margin: 0 0 8px; text-align: center; }
.drill-cond b { color: #ffeb3b; }
.drill-ask { font-size: 15px; font-weight: 700; margin: 0; text-align: center; color: #aee5c8; }

.drill-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drill-ans {
  min-height: 56px; padding: 8px 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.16); border-radius: 12px;
  color: #fff; font-size: 17px; font-weight: 700; cursor: pointer;
  line-height: 1.35;
}
.drill-ans:hover:not(:disabled), .drill-ans:focus-visible {
  background: rgba(255, 235, 59, 0.16); border-color: #ffeb3b;
}
.drill-ans:disabled { opacity: 0.5; cursor: default; }
.drill-ans--right { background: rgba(76, 175, 80, 0.35); border-color: #4caf50; opacity: 1; }
.drill-ans--wrong { background: rgba(244, 67, 54, 0.3); border-color: #f44336; opacity: 1; }
.drill-ans small { display: block; font-size: 11px; font-weight: 400; color: #cde; }

.drill-q-foot { margin-top: 16px; text-align: center; }
.drill-quit {
  min-height: 44px; padding: 0 18px;
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px; color: #bde; font-size: 13px; cursor: pointer;
}

/* ─── 解説 ─── */
.drill-explain-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.drill-explain-overlay[hidden] { display: none; }
.drill-explain-modal {
  width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(160deg, #14503a, #0d3d2c);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 16px;
  padding: 18px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.drill-verdict { font-size: 20px; margin: 0 0 12px; text-align: center; }
.drill-verdict--ok { color: #7ee08a; }
.drill-verdict--ng { color: #ff8a80; }
.drill-explain-body { font-size: 13px; line-height: 1.75; }
.drill-explain-body b { color: #ffeb3b; }
.drill-fu-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.drill-fu-table td { padding: 3px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.drill-fu-table td:last-child { text-align: right; color: #ffeb3b; white-space: nowrap; }
.drill-fu-table tr:last-child td { border-bottom: none; font-weight: 700; }
.drill-formula {
  background: rgba(0, 0, 0, 0.3); border-radius: 8px; padding: 8px 10px; margin: 8px 0;
  font-size: 12px; color: #cde;
}
.drill-next {
  width: 100%; min-height: 52px; margin-top: 14px;
  background: #ffeb3b; border: none; border-radius: 12px;
  color: #123; font-size: 16px; font-weight: 700; cursor: pointer;
}

@media (min-width: 640px) {
  .drill-title { font-size: 18px; }
  .drill-hand { gap: 8px; }
  .drill-hand__grp img { width: 38px; }
  .drill-answers { grid-template-columns: repeat(4, 1fr); }
}
