/* ============================================================
   キーボード道場 共通CSS
   全レッスンHTMLが <link rel="stylesheet" href="kb.css"> で参照
   ============================================================ */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans", "Yu Gothic", sans-serif;
  background-color: #e8f0fa;
  background-image:
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(0,0,0,0.03) 31px, rgba(0,0,0,0.03) 32px),
    repeating-linear-gradient(90deg, transparent 0, transparent 31px, rgba(0,0,0,0.03) 31px, rgba(0,0,0,0.03) 32px);
  color: #222;
  line-height: 1.7;
  font-size: 17px;
}
ruby rt { font-size: 0.55em; }
.pixel-font { font-family: "DotGothic16", "Helvetica Neue", sans-serif; letter-spacing: 0.04em; }

/* ヘッダー */
header {
  background: #fff; border-bottom: 3px solid #1abc9c;
  padding: 12px 20px; position: sticky; top: 0; z-index: 10;
}
.header-container {
  max-width: 1000px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.logo-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #222; }
.logo-img { height: 40px; }
.logo-text { font-weight: bold; font-size: 1.05rem; display: flex; flex-direction: column; line-height: 1.2; }
.logo-text-sub { font-size: 0.7rem; color: #666; }
.back-to-overview {
  background: #1abc9c; color: #fff; padding: 6px 14px;
  border-radius: 4px; text-decoration: none; font-size: 0.9rem; font-weight: bold; white-space: nowrap;
}

/* レイアウト */
main { max-width: 900px; margin: 24px auto; padding: 0 16px; }
.lesson { display: flex; flex-direction: column; gap: 24px; }
.lesson-header {
  background: #fff; border: 3px solid #222; border-radius: 12px;
  padding: 16px 20px; box-shadow: 4px 4px 0 #222;
}
.lesson-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tag {
  font-family: "DotGothic16", sans-serif; font-size: 0.85rem;
  padding: 3px 10px; border-radius: 4px; border: 2px solid #222; background: #fff;
}
.tag-num { background: #fff36a; }
.tag-lv { background: #b3e0ff; }
.tag-time { background: #fff; }
.tag-mode-standard { background: #d4edda; }
.tag-mode-boss { background: #f8d7da; }
.tag-mode-speed { background: #fff3cd; }
.tag-mode-fall { background: #d1ecf1; }
.lesson-header h1 {
  margin: 0; font-family: "DotGothic16", sans-serif;
  font-size: 1.55rem; line-height: 1.4;
}

/* ミッションカード */
.mission-card {
  border: 3px solid #222; border-radius: 12px; box-shadow: 4px 4px 0 #222;
  overflow: hidden; background: #fff;
}
.mission-banner {
  background: #ffd35a; font-family: "DotGothic16", sans-serif;
  padding: 8px 16px; font-size: 1rem; border-bottom: 3px solid #222;
}
.mission-content { padding: 14px 18px; }
.mission-content p { margin: 0 0 8px; }
.mission-content p:last-child { margin-bottom: 0; }

/* 練習エリア共通 */
.practice-stage {
  background: #fff; border: 3px solid #222; border-radius: 12px;
  box-shadow: 4px 4px 0 #222; padding: 20px 18px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.phase-indicator {
  font-family: "DotGothic16", sans-serif; font-size: 1.05rem;
  text-align: center; background: #b3e0ff; border: 2px solid #222;
  border-radius: 6px; padding: 6px 12px;
}
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-meter {
  flex: 1; height: 18px; background: #eee;
  border: 2px solid #222; border-radius: 9px; overflow: hidden;
}
.progress-meter > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #1abc9c, #3498db);
  transition: width 0.25s ease;
}
.progress-count {
  font-family: "DotGothic16", sans-serif; font-size: 1.1rem;
  min-width: 70px; text-align: right;
}

/* ターゲット表示 */
.target-display {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 8px 0;
}
.target-label {
  font-family: "DotGothic16", sans-serif; font-size: 1.1rem;
  margin: 0; color: #444;
}
.target-key {
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(3rem, 14vw, 6rem);
  min-width: clamp(100px, 26vw, 160px);
  height: clamp(100px, 26vw, 160px);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #fff36a 0%, #ffd35a 100%);
  border: 4px solid #222; border-radius: 18px;
  box-shadow: 6px 6px 0 #222; color: #222; position: relative;
  animation: target-pulse 1.6s ease-in-out infinite;
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
.target-key.is-word {
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  letter-spacing: 0.04em; padding: 12px 24px;
  height: auto; min-height: 80px;
  text-transform: none;
}
.target-key.is-correct { animation: target-correct 0.35s ease-out; background: linear-gradient(180deg, #b9f0c5, #6ddc8a); }
.target-key.is-wrong { animation: target-wrong 0.35s ease-out; background: linear-gradient(180deg, #ffc4c4, #ff8888); }
.target-key.is-finished { animation: none; background: linear-gradient(180deg, #b3e0ff, #74c0fc); }
.target-finger-hint {
  font-family: "DotGothic16", sans-serif; font-size: 0.95rem;
  color: #555; margin: 0; text-align: center;
}
.word-typed-progress {
  font-family: "DotGothic16", sans-serif; font-size: 1.1rem;
  letter-spacing: 0.1em; color: #888; margin-top: 4px;
}
.word-typed-progress .typed { color: #1abc9c; }
.word-typed-progress .next { color: #f39c12; text-decoration: underline; }

@keyframes target-pulse {
  0%, 100% { transform: translate(0, 0); box-shadow: 6px 6px 0 #222; }
  50% { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 #222; }
}
@keyframes target-correct {
  0% { transform: scale(1); }
  40% { transform: scale(1.12) rotate(-3deg); }
  100% { transform: scale(1); }
}
@keyframes target-wrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* バーチャルキーボード */
.virtual-keyboard {
  display: flex; flex-direction: column; gap: 5px;
  align-items: center; padding: 12px 4px;
  background: #f0f4f8; border: 3px solid #222; border-radius: 10px;
  user-select: none;
}
.kb-row { display: flex; gap: 4px; flex-wrap: nowrap; justify-content: center; }
.kb-key {
  font-family: "DotGothic16", sans-serif;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 2px solid #222;
  border-bottom-width: 4px; border-radius: 6px;
  font-size: 0.95rem; color: #333; cursor: pointer;
  transition: transform 0.05s ease, background 0.1s ease;
  padding: 0;
}
.kb-key.kb-wide { width: 60px; font-size: 0.75rem; }
.kb-key.kb-space { width: 200px; font-size: 0.8rem; }
.kb-key.is-target {
  background: linear-gradient(180deg, #fff36a, #ffd35a);
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.4);
}
.kb-key.is-home { background: #fff; position: relative; }
.kb-key.is-home::after { content: none; }
.kb-key.is-pressed { transform: translateY(2px); border-bottom-width: 2px; background: #74c0fc; }
.kb-key.is-pressed-correct { transform: translateY(2px); border-bottom-width: 2px; background: #6ddc8a; }
.kb-key.is-pressed-wrong { transform: translateY(2px); border-bottom-width: 2px; background: #ff8888; }

/* コントロール */
.practice-controls {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; align-items: center;
}
.practice-controls button,
.practice-controls a,
.practice-links a {
  font-family: "DotGothic16", sans-serif; font-size: 1rem;
  padding: 10px 20px; border: 3px solid #222; border-radius: 8px;
  background: #1abc9c; color: #fff; cursor: pointer; text-decoration: none;
  box-shadow: 3px 3px 0 #222;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}
.practice-controls button.primary-start,
.dojo-cta button.primary-start,
.arena-cta button.primary-start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: min(100%, 340px);
  min-height: 60px;
  padding: 14px 24px;
  background: linear-gradient(180deg, #ffcf3f, #f39c12);
  color: #22180a;
  border-color: #4a3520;
  border-radius: 10px;
  box-shadow: 0 7px 0 #4a3520, 0 16px 28px rgba(74,53,32,0.2);
  font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0;
}
.practice-controls button.primary-start:hover,
.dojo-cta button.primary-start:hover,
.arena-cta button.primary-start:hover {
  transform: translateY(2px);
  box-shadow: 0 5px 0 #4a3520, 0 12px 22px rgba(74,53,32,0.18);
}
.practice-controls button.primary-start:active,
.dojo-cta button.primary-start:active,
.arena-cta button.primary-start:active {
  transform: translateY(7px);
  box-shadow: 0 0 0 #4a3520;
}
.primary-start .start-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  color: #1abc9c;
  font-size: 0.92rem;
  line-height: 1;
  flex: 0 0 auto;
}
.practice-controls button:hover,
.practice-controls a:hover,
.practice-links a:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 #222; }
.practice-controls button:active,
.practice-controls a:active,
.practice-links a:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #222; }
.practice-controls button.secondary,
.practice-controls a,
.practice-links a { background: #fff; color: #222; }
.practice-links {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.practice-links a:first-child { background: #fff36a; }
.sound-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: "DotGothic16", sans-serif; cursor: pointer; user-select: none;
}
.sound-toggle input { width: 18px; height: 18px; }

/* 統計 */
.practice-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.stat-box {
  background: #f8f9fa; border: 2px solid #222; border-radius: 8px;
  padding: 8px 6px; text-align: center;
}
.stat-label { font-size: 0.8rem; color: #555; }
.stat-value {
  font-family: "DotGothic16", sans-serif; font-size: 1.4rem; color: #1abc9c;
}
.stat-value.wrong-color { color: #e74c3c; }

/* ボス戦 */
.boss-stage {
  background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
  border: 3px solid #222; border-radius: 12px;
  padding: 18px; box-shadow: 4px 4px 0 #222;
  color: #fff; display: flex; flex-direction: column; gap: 14px;
}
.boss-display { text-align: center; padding: 10px 0; }
.boss-emoji {
  font-size: clamp(4rem, 16vw, 7rem);
  display: inline-block;
  filter: drop-shadow(3px 3px 0 #000);
  transition: transform 0.15s ease;
}
/* PNG画像のボスアバター（has-image時はparent filterを切る → 画像独自のシャドウを使う） */
.boss-emoji.has-image {
  font-size: 0;
  filter: none;
  line-height: 0;
}
.boss-emoji .boss-avatar-img {
  display: block;
  width: clamp(7rem, 22vw, 10rem);
  height: clamp(7rem, 22vw, 10rem);
  object-fit: contain;
  margin: 0 auto;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55));
  user-select: none;
  -webkit-user-drag: none;
}
.boss-emoji.intro .boss-avatar-img {
  width: clamp(6rem, 18vw, 8rem);
  height: clamp(6rem, 18vw, 8rem);
}
.boss-emoji.is-hurt { animation: boss-hurt 0.4s ease-out; }
.boss-emoji.is-defeated { animation: boss-defeated 1.0s ease-out forwards; }
.boss-emoji.has-image.is-defeated { animation: boss-defeated-img 1.0s ease-out forwards; }
.boss-name {
  font-family: "DotGothic16", sans-serif; font-size: 1.2rem;
  margin: 4px 0; color: #fff;
}
.boss-hp-bar {
  background: #1a252f; border: 2px solid #fff;
  border-radius: 6px; height: 22px; overflow: hidden; position: relative;
  max-width: 400px; margin: 8px auto;
}
.boss-hp-bar > span {
  display: block; height: 100%; background: linear-gradient(90deg, #e74c3c, #c0392b);
  transition: width 0.3s ease;
}
.boss-hp-text {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: "DotGothic16", sans-serif; font-size: 0.9rem;
  color: #fff; text-shadow: 1px 1px 2px #000;
}
.boss-attack-banner {
  font-family: "DotGothic16", sans-serif; text-align: center;
  font-size: 1.4rem; color: #e74c3c; height: 30px;
  text-shadow: 2px 2px 0 #000;
  animation: attack-flash 0.5s ease-out;
}
.boss-target {
  background: #fff; color: #222; border: 3px solid #fff36a;
  border-radius: 10px; padding: 14px; text-align: center;
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  letter-spacing: 0.06em; min-height: 70px;
}
.boss-player-hp {
  display: flex; gap: 6px; justify-content: center; align-items: center;
  font-family: "DotGothic16", sans-serif;
}
.boss-player-hp .heart { font-size: 1.6rem; transition: opacity 0.2s ease; }
.boss-player-hp .heart.is-lost { opacity: 0.3; }

@keyframes boss-hurt {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px) rotate(-5deg); }
  40% { transform: translateX(12px) rotate(5deg); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}
@keyframes boss-defeated {
  0% { transform: scale(1) rotate(0); opacity: 1; filter: drop-shadow(3px 3px 0 #000); }
  50% { transform: scale(1.3) rotate(15deg); filter: drop-shadow(0 0 20px #fff36a); }
  100% { transform: scale(0.3) rotate(720deg); opacity: 0; }
}
@keyframes boss-defeated-img {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  50% { transform: scale(1.3) rotate(15deg); }
  100% { transform: scale(0.3) rotate(720deg); opacity: 0; }
}
@keyframes attack-flash {
  0% { opacity: 0; transform: translateY(-10px); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(0); }
}

/* ボス連戦（boss rush） */
.campaign-banner {
  background: rgba(0,0,0,0.4); color: #fff;
  font-family: "DotGothic16", sans-serif;
  text-align: center; padding: 6px 12px;
  border-radius: 6px; border: 2px solid #fff36a;
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.campaign-banner .banner-divider { color: #fff36a; }
.campaign-header { text-align: center; }
.campaign-title {
  font-family: "DotGothic16", sans-serif;
  margin: 0 0 6px; font-size: 1.4rem; color: #fff36a;
  text-shadow: 2px 2px 0 #000;
}
.campaign-sub { color: #fff; margin: 0; }
.campaign-progress {
  font-family: "DotGothic16", sans-serif;
  text-align: center; color: #fff36a; font-size: 1rem;
}
.campaign-roster {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.roster-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.1); color: #fff;
  border: 2px solid #fff36a; border-radius: 8px; padding: 8px;
  font-family: "DotGothic16", sans-serif;
}
.roster-num { font-size: 0.8rem; color: #fff36a; }
.roster-emoji { font-size: 2rem; display: inline-flex; align-items: center; justify-content: center; }
.roster-emoji.has-image { font-size: 0; }
.roster-emoji .boss-avatar-img {
  display: inline-block;
  width: 2.6rem; height: 2.6rem;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}
.roster-name { font-size: 0.9rem; }
.roster-hp { font-size: 0.8rem; color: #ffc4c4; }
.campaign-best {
  background: #fff36a; color: #222; padding: 8px 14px;
  border-radius: 6px; text-align: center;
  font-family: "DotGothic16", sans-serif;
  border: 2px solid #222;
}
.campaign-next { text-align: center; }
.campaign-next .next-label {
  font-family: "DotGothic16", sans-serif; color: #fff36a;
  margin: 0 0 6px;
}
.campaign-next .boss-name {
  margin: 4px 0; font-family: "DotGothic16", sans-serif;
  font-size: 1.4rem; color: #fff;
}
.campaign-next .next-hp { color: #ffc4c4; margin: 0; }
.campaign-defeat { text-align: center; color: #fff; }
.campaign-defeat h2 {
  font-family: "DotGothic16", sans-serif;
  font-size: 1.4rem; margin: 0 0 8px; color: #ff8888;
  text-shadow: 2px 2px 0 #000;
}
.campaign-defeat p { margin: 0; }
.campaign-victory { text-align: center; }
.campaign-victory h2 {
  font-family: "DotGothic16", sans-serif;
  font-size: 1.6rem; margin: 0 0 8px;
}
.campaign-victory .new-record {
  font-family: "DotGothic16", sans-serif;
  color: #e74c3c; font-size: 1.2rem; margin: 8px 0 0;
  animation: target-correct 0.6s ease-out;
}

/* スピードモード（早打ち道場） */
.speed-stage {
  position: relative;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(255, 200, 80, 0.45) 0%, transparent 40%),
    linear-gradient(180deg, #ffe066 0%, #ffb347 65%, #ff8c1a 100%);
  border: 3px solid #222; border-radius: 12px; padding: 14px;
  box-shadow: 4px 4px 0 #222, inset 0 0 30px rgba(255, 255, 255, 0.2);
  display: flex; flex-direction: column; gap: 10px;
  overflow: hidden;
  isolation: isolate;
}
/* 上昇する星・パーティクル */
.speed-stage::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.9) 1.2px, transparent 2.5px),
    radial-gradient(circle, rgba(255,243,106,0.7) 1.5px, transparent 3px),
    radial-gradient(circle, rgba(255,150,50,0.5) 1px, transparent 2px);
  background-size: 90px 200px, 140px 280px, 60px 160px;
  background-position: 0 0, 50px 80px, 30px 40px;
  animation: stars-rise 7s linear infinite;
  pointer-events: none;
  opacity: 0.55;
  z-index: 0;
}
@keyframes stars-rise {
  to { background-position: 0 -200px, 50px -200px, 30px -120px; }
}
.speed-stage > * { position: relative; z-index: 1; }

/* タイマー（プログレスバー付き） */
.timer-display {
  position: relative;
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  text-align: center; color: #222;
  background: #fff; border: 3px solid #222; border-radius: 10px;
  padding: 3px 16px 10px; box-shadow: 3px 3px 0 #222;
  overflow: hidden;
}
.timer-display::after {
  content: "";
  position: absolute; left: 0; bottom: 0;
  height: 5px;
  background: linear-gradient(90deg, #6ddc8a, #fff36a 50%, #e74c3c);
  width: var(--time-pct, 100%);
  transition: width 0.4s linear;
}
.timer-display.is-warning { color: #e74c3c; animation: timer-pulse 0.5s ease infinite; }
@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* お題ボックス（光る・はじける） */
.speed-target {
  position: relative;
  background: #fff; border: 3px solid #222; border-radius: 10px;
  padding: 12px 16px; text-align: center;
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(1.3rem, 3.6vw, 1.9rem);
  letter-spacing: 0.05em; min-height: 60px;
  box-shadow: 0 0 0 3px rgba(255,243,106,0.4), 3px 3px 0 #222;
  overflow: visible;
  transition: transform 0.12s ease;
}
.speed-target.is-active {
  background: linear-gradient(180deg, #fff 0%, #fffdf0 100%);
  animation: target-glow 1.6s ease-in-out infinite;
}
@keyframes target-glow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,243,106,0.5), 3px 3px 0 #222; }
  50%      { box-shadow: 0 0 0 7px rgba(255,243,106,0.8), 0 0 18px rgba(255,200,80,0.6), 3px 3px 0 #222; }
}
.speed-target.is-bump { animation: target-bump 0.18s ease-out; }
@keyframes target-bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.speed-target.is-burst { animation: target-burst 0.4s ease-out; }
@keyframes target-burst {
  0%   { transform: scale(1); background: #fff; }
  40%  { transform: scale(1.08); background: #fff36a; }
  100% { transform: scale(1); background: #fff; }
}

/* 上昇キラキラ（正解時にお題から飛び出す） */
.speed-spark {
  position: absolute;
  width: 10px; height: 10px;
  background: radial-gradient(circle, #fff, #fff36a 60%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  animation: spark-fly 0.6s ease-out forwards;
}
@keyframes spark-fly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--sx,0), var(--sy,0)) scale(0.3); }
}

.speed-stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.speed-stat-box {
  background: #fff; border: 2px solid #222;
  border-radius: 8px; padding: 5px 4px; text-align: center;
}
.speed-stat-label { font-size: 0.75rem; color: #555; }
.speed-stat-value {
  font-family: "DotGothic16", sans-serif;
  font-size: 1.25rem; color: #1abc9c;
  display: inline-block;
  transition: color 0.2s ease;
}
.speed-stat-value.is-bump { animation: stat-bump 0.25s ease-out; }
@keyframes stat-bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); color: #ff8c1a; }
  100% { transform: scale(1); }
}

.record-display {
  background: #fff; border: 3px dashed #f39c12; border-radius: 8px;
  padding: 6px 10px; text-align: center; font-family: "DotGothic16", sans-serif;
}
.record-display .record-label { font-size: 0.78rem; color: #555; }
.record-display .record-value { font-size: 1.15rem; color: #f39c12; }
.record-display.is-new { background: #fff36a; animation: record-celebrate 0.6s ease; }
@keyframes record-celebrate {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* COMBO 表示（早打ち道場・右上） */
.speed-combo {
  position: absolute; top: 10px; right: 14px;
  font-family: "DotGothic16", sans-serif;
  color: #fff; font-size: 0.9rem;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
  z-index: 3;
  pointer-events: none;
  opacity: 0; transition: opacity 0.3s ease;
}
.speed-combo.is-active { opacity: 1; }
.speed-combo .combo-num {
  display: inline-block;
  font-size: 1.6rem; color: #fff36a;
  text-shadow: 2px 2px 0 #000, 0 0 12px rgba(255,243,106,0.7);
  margin: 0 4px;
}
.speed-combo.is-fire .combo-num {
  color: #ff7e00;
  text-shadow: 2px 2px 0 #000, 0 0 14px rgba(255,90,0,0.95), 0 0 22px rgba(255,40,0,0.6);
}
.speed-combo.is-bump { animation: combo-bump 0.28s ease-out; }

/* フォールモード（雨アリーナ） */
.fall-stage {
  background: linear-gradient(180deg, #0c1a3e 0%, #1e3c72 50%, #2a5298 100%);
  border: 3px solid #222; border-radius: 12px;
  padding: 14px; box-shadow: 4px 4px 0 #222;
  color: #fff;
  display: flex; flex-direction: column; gap: 12px;
}
.fall-stats {
  display: flex; justify-content: space-between; align-items: center;
  font-family: "DotGothic16", sans-serif; gap: 10px; flex-wrap: wrap;
}
.fall-stats .lives { display: flex; gap: 4px; }
.fall-stats .lives .heart {
  font-size: 1.4rem; transition: opacity 0.2s ease;
  text-shadow: 0 0 8px rgba(255, 90, 90, 0.6);
}
.fall-stats .lives .heart.is-lost { opacity: 0.25; filter: grayscale(0.8); text-shadow: none; }
.fall-stats .timer.is-warning { color: #ff8a8a; animation: timer-blink 0.6s ease-in-out infinite; }
@keyframes timer-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.fall-arena {
  position: relative; height: 380px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(80, 100, 150, 0.55) 0%, transparent 55%),
    linear-gradient(180deg, #0a1535 0%, #1e3c72 55%, #2a5298 90%, #1a3a78 100%);
  border: 2px solid #fff; border-radius: 8px; overflow: hidden;
  isolation: isolate;
}
/* 流れる雨の線 */
.fall-arena::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(102deg, transparent 0 49.4%, rgba(180, 220, 255, 0.55) 49.4% 50.4%, transparent 50.4% 100%),
    linear-gradient(102deg, transparent 0 49.6%, rgba(180, 220, 255, 0.32) 49.6% 50.2%, transparent 50.2% 100%),
    linear-gradient(102deg, transparent 0 49.6%, rgba(180, 220, 255, 0.22) 49.6% 50.1%, transparent 50.1% 100%);
  background-size: 16px 70px, 24px 90px, 38px 110px;
  background-position: 0 0, 8px 0, 16px 0;
  animation: rain-fall 0.7s linear infinite;
  pointer-events: none;
  opacity: 0.7;
  z-index: 0;
}
@keyframes rain-fall {
  to { background-position: -14px 70px, -22px 90px, -38px 110px; }
}
/* 床（水たまり）— ::after は地面のみ。波線・反射はアニメで */
.fall-arena::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 38px;
  background:
    linear-gradient(0deg, rgba(0, 20, 40, 0.85) 0%, rgba(20, 60, 110, 0.5) 60%, rgba(20, 60, 110, 0.0) 100%);
  border-top: 2px dashed rgba(255, 255, 255, 0.55);
  pointer-events: none;
  z-index: 1;
}
/* 雲（複数置く） */
.fall-arena .cloud {
  position: absolute; top: 8px; height: 22px; width: 140px;
  background: radial-gradient(closest-side at 50% 60%, rgba(220, 230, 245, 0.4), transparent 75%);
  filter: blur(6px);
  pointer-events: none;
  z-index: 1;
  animation: cloud-drift linear infinite;
}
.fall-arena .cloud.cloud-2 { top: 28px; width: 200px; height: 28px; opacity: 0.55; animation-duration: 50s; }
.fall-arena .cloud.cloud-3 { top: 50px; width: 100px; height: 18px; opacity: 0.4; animation-duration: 70s; }
@keyframes cloud-drift {
  from { transform: translateX(-180px); }
  to   { transform: translateX(120%); }
}
/* 稲光フラッシュ */
.fall-arena .lightning-flash {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  z-index: 4;
  animation: lightning 0.32s ease-out forwards;
}
@keyframes lightning {
  0%   { opacity: 0; }
  10%  { opacity: 0.95; }
  20%  { opacity: 0.4; }
  35%  { opacity: 0.85; }
  60%  { opacity: 0.2; }
  100% { opacity: 0; }
}
/* カメラ揺れ */
.fall-arena.is-shaking { animation: arena-shake 0.45s ease-out; }
@keyframes arena-shake {
  0%, 100% { transform: translate(0, 0); }
  15%  { transform: translate(-7px, 3px); }
  30%  { transform: translate(6px, -4px); }
  45%  { transform: translate(-4px, 5px); }
  60%  { transform: translate(5px, -2px); }
  75%  { transform: translate(-3px, 3px); }
  90%  { transform: translate(2px, -1px); }
}

/* 落ちる文字＝雨粒（しずく型） */
.fall-letter {
  position: absolute; top: -50px;
  font-family: "DotGothic16", sans-serif;
  font-size: 1.45rem;
  padding: 14px 16px 11px;
  min-width: 48px;
  text-align: center;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 30, 60, 0.85), 0 0 6px rgba(120, 200, 255, 0.4);
  background:
    radial-gradient(ellipse at 30% 30%, rgba(255, 255, 255, 0.55) 0%, transparent 35%),
    linear-gradient(180deg, rgba(140, 210, 250, 0.95) 0%, rgba(60, 130, 200, 0.95) 100%);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 60% 60% 50% 50% / 55% 55% 75% 75%;
  box-shadow:
    inset 4px 4px 8px rgba(255, 255, 255, 0.3),
    inset -2px -3px 6px rgba(0, 30, 60, 0.4),
    0 6px 14px rgba(0, 0, 0, 0.4);
  z-index: 2;
  animation: letter-sway 2.4s ease-in-out infinite;
  transform-origin: 50% 30%;
}
@keyframes letter-sway {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}
/* 単語モードで横長になる場合はもう少し丸く */
.fall-letter.is-word { border-radius: 50% / 60%; padding: 12px 18px; }

/* 入力進捗表示 */
.fall-letter.is-typed-progress { color: rgba(255, 255, 255, 0.55); }
.fall-letter.is-typed-progress .typed { color: #b6f7c1; text-shadow: 0 0 6px rgba(180, 255, 200, 0.6); }
.fall-letter.is-typed-progress .next  { color: #fff36a; text-shadow: 0 0 8px rgba(255, 243, 106, 0.7); font-weight: bold; }

/* クリア（正解で消える）→ 水しぶきへつなぐ */
.fall-letter.is-cleared { animation: fall-clear 0.45s ease-out forwards; }
@keyframes fall-clear {
  0%   { transform: scale(1) rotate(0); opacity: 1; }
  40%  { transform: scale(1.4) rotate(-8deg); opacity: 0.9; filter: brightness(1.4); }
  100% { transform: scale(0.3) rotate(15deg); opacity: 0; }
}
/* ミス（地面着弾） */
.fall-letter.is-missed { animation: fall-miss 0.5s ease-out forwards; }
@keyframes fall-miss {
  0%   { transform: scale(1) rotate(0); opacity: 1; }
  20%  { transform: scaleY(0.5) scaleX(1.4) rotate(0); opacity: 1; filter: hue-rotate(330deg); }
  100% { transform: scaleY(0.2) scaleX(2) rotate(0); opacity: 0; filter: hue-rotate(330deg); }
}

/* 水しぶき（正解時の放射粒子） */
.fall-splash {
  position: absolute;
  width: 8px; height: 8px;
  background: radial-gradient(circle, #b9e8ff 0%, rgba(120, 200, 250, 0.6) 60%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  animation: splash-fly 0.55s ease-out forwards;
}
@keyframes splash-fly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--sx, 0), var(--sy, 0)) scale(0.4); }
}
/* 着弾時の波紋（地面に広がる） */
.fall-ripple {
  position: absolute;
  bottom: 8px;
  width: 16px; height: 6px;
  border: 2px solid rgba(180, 220, 255, 0.85);
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  animation: ripple-expand 0.7s ease-out forwards;
}
@keyframes ripple-expand {
  0%   { opacity: 1; transform: translateX(-50%) scale(0.3); }
  100% { opacity: 0; transform: translateX(-50%) scale(4); }
}

/* COMBO 表示（アリーナ右上） */
.fall-combo {
  position: absolute; top: 8px; right: 12px;
  font-family: "DotGothic16", sans-serif;
  color: #fff; font-size: 0.95rem;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
  z-index: 5;
  pointer-events: none;
  opacity: 0; transition: opacity 0.3s ease;
}
.fall-combo.is-active { opacity: 1; }
.fall-combo .combo-num {
  display: inline-block;
  font-size: 1.7rem; color: #fff36a;
  text-shadow: 2px 2px 0 #000, 0 0 12px rgba(255, 243, 106, 0.6);
  margin: 0 4px;
}
.fall-combo.is-fire .combo-num {
  color: #ffb84d;
  text-shadow: 2px 2px 0 #000, 0 0 16px rgba(255, 90, 0, 0.9), 0 0 24px rgba(255, 50, 0, 0.6);
}
.fall-combo.is-bump { animation: combo-bump 0.3s ease-out; }
@keyframes combo-bump {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* 完了・ゲームオーバー */
.complete-panel {
  background: linear-gradient(180deg, #fff36a, #ffd35a);
  border: 3px solid #222; border-radius: 12px;
  box-shadow: 4px 4px 0 #222; padding: 22px; text-align: center;
  display: none;
}
.complete-panel.is-shown { display: block; }
.complete-panel.is-fail { background: linear-gradient(180deg, #ffc4c4, #ff8888); }
.complete-title { font-family: "DotGothic16", sans-serif; font-size: 1.5rem; margin: 0 0 12px; }
.complete-stats {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px;
}
.complete-stat {
  background: #fff; border: 2px solid #222; border-radius: 8px;
  padding: 8px 14px; font-family: "DotGothic16", sans-serif;
}
.complete-stat strong { color: #1abc9c; font-size: 1.3rem; }

/* ふりかえり */
.reflection {
  background: #fff; border: 3px dashed #1abc9c;
  border-radius: 12px; padding: 16px 18px;
}
.reflection h2 { font-family: "DotGothic16", sans-serif; font-size: 1.2rem; margin: 0 0 10px; }
.reflection ul { margin: 0; padding-left: 20px; }
.reflection li { margin-bottom: 4px; }

/* レッスンナビ */
.lesson-nav {
  display: flex; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-top: 8px;
}
.lesson-nav a {
  font-family: "DotGothic16", sans-serif; background: #fff;
  border: 2px solid #222; border-radius: 6px;
  padding: 8px 14px; text-decoration: none; color: #222;
}
.lesson-nav a.disabled { opacity: 0.4; pointer-events: none; }

/* タッチヒント */
.touch-hint {
  background: #fff8e1; border: 2px dashed #f39c12;
  border-radius: 8px; padding: 10px 14px; font-size: 0.9rem;
  display: none;
}
.touch-hint.is-shown { display: block; }

/* フォーカス */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 4px solid #fff36a; outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(34,34,34,0.35);
}

/* フッター */
footer {
  background: #222; color: #ddd; text-align: center;
  padding: 20px; font-size: 0.9rem; margin-top: 30px;
}
.footer-content { max-width: 900px; margin: 0 auto; }

/* レスポンシブ */
@media (max-width: 600px) {
  .kb-key { width: 28px; height: 32px; font-size: 0.75rem; }
  .kb-key.kb-wide { width: 44px; font-size: 0.65rem; }
  .kb-key.kb-space { width: 130px; }
  .lesson-header h1 { font-size: 1.3rem; }
  .practice-stats { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 1.1rem; }
  .speed-stats-row { grid-template-columns: repeat(3, 1fr); }
  .speed-stat-value { font-size: 1.2rem; }
  .fall-arena { height: 300px; }
}
@media (max-width: 380px) {
  .kb-key { width: 24px; height: 28px; font-size: 0.65rem; }
  .kb-key.kb-wide { width: 36px; }
  .kb-key.kb-space { width: 100px; }
}
