/* ===== まほうタイプたいけん ===== */

:root {
  --navy-0: #070b1e;
  --navy-1: #0e1433;
  --navy-2: #182052;
  --navy-3: #232e6e;
  --white: #f4f6ff;
  --muted: #aab6e8;
  --gold: #ffd75e;
  --gold-dark: #c89a2a;
  --green: #6ee08a;
  --red: #ff7b8a;
  --cyan: #7fd9ff;
  --pink: #ff9fd6;
}

* { box-sizing: border-box; user-select: none; }
html, body { height: 100%; margin: 0; }

body {
  font-family: 'DotGothic16', 'Hiragino Kaku Gothic ProN', monospace;
  color: var(--white);
  background:
    radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1.6px),
    linear-gradient(180deg, #0a0f26 0%, #070b1e 100%);
  background-size: 26px 26px, 100% 100%;
  overflow: hidden;
}

img, canvas { image-rendering: pixelated; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ===== 固定解像度スケーリング ===== */
.scale-root {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1280px;
  height: 800px;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 14px;
}

/* おとコントロール（全画面で固定表示） */
.audio-dock {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 80;
  display: flex;
  gap: 7px;
  background: rgba(7, 10, 28, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  padding: 5px 8px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}
.dock-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border: 2px solid var(--white);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  color: var(--white);
  font-size: 13px;
  letter-spacing: 1px;
}
.dock-btn .dock-icon { font-size: 14px; }
.dock-btn:hover { background: linear-gradient(180deg, var(--navy-3), var(--navy-2)); }
.dock-btn:active { transform: translateY(1px); }
.dock-btn.off {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.35);
  opacity: 0.62;
  position: relative;
}
.dock-btn.off .dock-icon { opacity: 0.7; }
.dock-btn.off::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  background: var(--red);
  transform: rotate(-12deg);
  border-radius: 2px;
}
/* ゲーム画面: サイドパネルが右上にあり ドックと重なるので 上に余白 */
.game-screen .side { padding-top: 50px; }

/* ===== 共通パネル（RPGウィンドウ） ===== */
.panel {
  background: linear-gradient(180deg, rgba(16, 21, 50, 0.96), rgba(10, 14, 36, 0.96));
  border: 3px solid var(--white);
  border-radius: 12px;
  box-shadow:
    inset 0 0 0 3px var(--navy-2),
    inset 0 0 0 4px rgba(255, 255, 255, 0.18),
    0 6px 0 rgba(0, 0, 0, 0.4);
}

/* =========================================================
   タイトル画面
========================================================= */
.title-screen { background: #1b3f7e; }

.title-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  animation: title-pan 36s ease-in-out infinite alternate;
}
@keyframes title-pan {
  from { transform: scale(1.04) translateX(-12px); }
  to   { transform: scale(1.04) translateX(12px); }
}
.title-sky-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 46% at 50% 12%, rgba(255, 244, 190, 0.32), transparent 70%),
    linear-gradient(180deg, rgba(20, 40, 110, 0.18) 0%, rgba(8, 12, 34, 0.46) 78%, rgba(6, 9, 26, 0.72) 100%);
}
.title-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 180px rgba(4, 7, 22, 0.85);
}

.title-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 38px 60px 22px;
}

.title-badge {
  background: var(--navy-1);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 6px 22px;
  font-size: 17px;
  letter-spacing: 2px;
  color: var(--gold);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.title-logo {
  margin: 18px 0 6px;
  text-align: center;
  line-height: 1.0;
  white-space: nowrap;
  filter: drop-shadow(0 10px 0 rgba(5, 8, 24, 0.55));
  animation: logo-bob 3.2s ease-in-out infinite;
}
@keyframes logo-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.logo-main, .logo-accent {
  display: inline;
  font-weight: 700;
  font-size: 78px;
  letter-spacing: 3px;
  color: #fff;
  text-shadow:
    3px 0 0 #142055, -3px 0 0 #142055, 0 3px 0 #142055, 0 -3px 0 #142055,
    3px 3px 0 #142055, -3px 3px 0 #142055, 3px -3px 0 #142055, -3px -3px 0 #142055,
    0 7px 0 #142055,
    0 11px 0 #0a1130;
}
.logo-accent { color: var(--gold); }

.title-chars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.title-hero, .title-wizard {
  position: absolute;
  bottom: 196px;
  filter: drop-shadow(0 10px 6px rgba(5, 8, 24, 0.5));
}
.title-hero {
  right: 40px;
  animation: char-bob 2.4s ease-in-out infinite;
}
.title-wizard {
  left: 56px;
  animation: char-bob 2.4s ease-in-out 0.5s infinite;
}
@keyframes char-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.title-copy {
  margin: 12px 0 10px;
  font-size: 19px;
  letter-spacing: 1px;
  background: rgba(10, 14, 36, 0.78);
  border-radius: 999px;
  padding: 7px 24px;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  background: rgba(10, 14, 36, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 5px;
}
.mode-tab {
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  letter-spacing: 2px;
  padding: 7px 26px;
  transition: all 0.15s;
}
.mode-tab:hover { color: var(--white); }
.mode-tab.active {
  background: linear-gradient(180deg, #ffe89a, var(--gold));
  border-color: #8a6a10;
  color: #4a3200;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.mode-note {
  margin: 8px 0 10px;
  font-size: 14px;
  color: var(--gold);
  background: rgba(10, 14, 36, 0.7);
  border-radius: 999px;
  padding: 3px 16px;
}

.grade-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.grade-chip {
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 1px;
  padding: 6px 16px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  transition: transform 0.1s;
}
.grade-chip:hover { color: var(--white); transform: translateY(-2px); }
.grade-chip:active { transform: translateY(1px); }
.grade-chip.active {
  background: linear-gradient(180deg, #ffe89a, var(--gold));
  border-color: #8a6a10;
  color: #4a3200;
  font-weight: 700;
}

.difficulty-label {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 2px;
  margin: 2px 0 6px;
}
.difficulty-row {
  display: grid;
  grid-template-columns: repeat(3, 232px);
  gap: 20px;
}
.difficulty-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 16px 12px 13px;
  border-radius: 14px;
  border: 3px solid var(--white);
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.14), 0 7px 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.difficulty-card:hover {
  transform: translateY(-5px);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.2), 0 12px 0 rgba(0, 0, 0, 0.45);
}
.difficulty-card:active { transform: translateY(1px) scale(0.98); }
.difficulty-card[data-difficulty='easy'] { border-color: #8af0a5; }
.difficulty-card[data-difficulty='normal'] { border-color: #84c8ff; }
.difficulty-card[data-difficulty='hard'] { border-color: #ff9fb0; }
.card-stars { font-size: 19px; color: var(--gold); letter-spacing: 3px; }
.difficulty-card strong { font-size: 28px; letter-spacing: 3px; }
.difficulty-card[data-difficulty='easy'] strong { color: #8af0a5; }
.difficulty-card[data-difficulty='normal'] strong { color: #84c8ff; }
.difficulty-card[data-difficulty='hard'] strong { color: #ff9fb0; }
.card-copy { font-size: 15px; color: var(--muted); }
.card-progress {
  margin-top: 4px;
  font-size: 14px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 3px 12px;
}

.title-summary {
  margin-top: 14px;
  font-size: 16px;
  color: var(--white);
  background: rgba(10, 14, 36, 0.78);
  border-radius: 999px;
  padding: 6px 22px;
  letter-spacing: 1px;
}
.title-summary strong { color: var(--gold); }

.title-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
  color: rgba(220, 228, 255, 0.85);
  text-shadow: 0 2px 0 rgba(5, 8, 24, 0.6);
}
.text-button {
  background: none;
  border: none;
  color: rgba(220, 228, 255, 0.7);
  text-decoration: underline;
  font-size: 13px;
}
.text-button:hover { color: var(--red); }
.settings-link { color: var(--gold); text-decoration: none; }
.settings-link:hover { color: #fff; }

/* こまかい せってい モーダル */
.settings-card {
  width: 620px;
  padding: 20px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-header { display: flex; justify-content: space-between; align-items: center; }
.settings-header strong { font-size: 22px; color: var(--gold); letter-spacing: 2px; }
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 12px;
  padding: 12px 16px;
}
.setting-label { display: flex; flex-direction: column; gap: 3px; }
.setting-label strong { font-size: 17px; }
.setting-label span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.seg-toggle {
  display: flex;
  flex: none;
  border: 2px solid var(--navy-3);
  border-radius: 10px;
  overflow: hidden;
}
.seg-toggle button {
  background: var(--navy-0);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 12px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.seg-toggle button + button { border-left: 2px solid var(--navy-3); }
.seg-toggle button.active {
  background: linear-gradient(180deg, #ffe89a, var(--gold));
  color: #4a3200;
  font-weight: 700;
}
.settings-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 2px; }

/* =========================================================
   ゲーム画面
========================================================= */
.game-screen { background: transparent; }

.game-grid {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 14px;
  gap: 10px;
  grid-template-columns: 1fr 296px;
  grid-template-rows: 376px 114px 94px 158px;
  grid-template-areas:
    'scene side'
    'word side'
    'msg msg'
    'keys keys';
}

/* ----- 戦闘シーン ----- */
.scene-frame {
  grid-area: scene;
  overflow: hidden;
  padding: 0;
}
.scene-frame.shake { animation: scene-shake 0.3s linear; }
@keyframes scene-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 3px); }
  40% { transform: translate(6px, -4px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -2px); }
}

.scene {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 9px;
}
.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scene-night { object-fit: fill; }
.scene-tint { position: absolute; inset: 0; pointer-events: none; }
.scene[data-theme='field'] .scene-tint { background: linear-gradient(180deg, rgba(8, 12, 40, 0.08), transparent 36%); }
.scene[data-theme='forest'] .scene-tint {
  background: radial-gradient(ellipse 130% 100% at 50% 110%, transparent 62%, rgba(4, 22, 10, 0.4) 100%);
}
.scene[data-theme='cave'] .scene-tint { background: linear-gradient(180deg, rgba(20, 8, 44, 0.2), transparent 50%); }
.scene[data-theme='night'] .scene-tint { background: transparent; }

.scene-chip {
  position: absolute;
  top: 12px;
  z-index: 5;
  background: rgba(10, 14, 36, 0.88);
  border: 2px solid var(--white);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 16px;
  letter-spacing: 1px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}
.stage-chip { left: 12px; color: var(--gold); }
.subtitle-chip { left: 12px; top: 50px; font-size: 13px; color: var(--muted); padding: 4px 14px; }

.combo-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: rgba(10, 14, 36, 0.88);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 6px 14px;
  color: var(--gold);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.15s;
}
.combo-badge.visible { opacity: 1; transform: scale(1); }
.combo-badge.pop { animation: combo-pop 0.28s ease; }
@keyframes combo-pop {
  0% { transform: scale(1.45) rotate(-4deg); }
  100% { transform: scale(1); }
}
.combo-num { font-size: 30px; line-height: 1; }
.combo-label { font-size: 14px; }

/* キャラクター */
.hero-wrap {
  position: absolute;
  right: 9%;
  bottom: 26px;
  z-index: 3;
}
.hero-sprite {
  position: relative;
  z-index: 2;
  display: block;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.35));
  animation: hero-idle 1.6s ease-in-out infinite;
}
@keyframes hero-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.hero-wrap.attack .hero-sprite { animation: hero-attack 0.52s cubic-bezier(0.22, 0.9, 0.3, 1); }
@keyframes hero-attack {
  0% { transform: translateX(0) rotate(0); }
  34% { transform: translateX(-430px) rotate(-7deg) scale(1.05); }
  52% { transform: translateX(-408px) rotate(-3deg); }
  100% { transform: translateX(0) rotate(0); }
}

.enemy-wrap {
  position: absolute;
  left: 10%;
  bottom: 34px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.enemy-canvas {
  position: relative;
  z-index: 2;
  display: block;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.35));
  animation: enemy-idle 2s ease-in-out infinite;
  transform-origin: 50% 100%;
}
@keyframes enemy-idle {
  0%, 100% { transform: scaleY(1) translateY(0); }
  50% { transform: scaleY(0.94) translateY(3px) scaleX(1.03); }
}
.enemy-wrap.enter .enemy-canvas { animation: enemy-enter 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes enemy-enter {
  0% { transform: translateX(-180px) scale(0.4); opacity: 0; }
  70% { transform: translateX(10px) scale(1.06); opacity: 1; }
  100% { transform: translateX(0) scale(1); }
}
.enemy-wrap.hit .enemy-canvas {
  animation: enemy-hit 0.4s ease;
}
@keyframes enemy-hit {
  0% { filter: drop-shadow(0 6px 4px rgba(0,0,0,0.35)) brightness(4) saturate(0.2); transform: translateX(-26px) rotate(-4deg); }
  40% { filter: drop-shadow(0 6px 4px rgba(0,0,0,0.35)) brightness(2); transform: translateX(-14px); }
  100% { filter: drop-shadow(0 6px 4px rgba(0,0,0,0.35)); transform: translateX(0); }
}
.enemy-wrap.down .enemy-canvas {
  animation: enemy-down 0.62s ease forwards;
}
@keyframes enemy-down {
  0% { transform: scale(1); filter: brightness(3); opacity: 1; }
  45% { transform: scaleY(0.5) scaleX(1.25) translateY(16px); opacity: 0.9; }
  100% { transform: scaleY(0.05) scaleX(1.5) translateY(40px); opacity: 0; }
}
.enemy-wrap.down .enemy-plate { opacity: 0; }

.enemy-plate {
  z-index: 3;
  margin-bottom: 8px;
  text-align: center;
  padding: 0 6px;
  transition: opacity 0.2s;
}
.enemy-name {
  font-size: 17px;
  letter-spacing: 1px;
  text-shadow:
    2px 0 0 #060a1c, -2px 0 0 #060a1c, 0 2px 0 #060a1c, 0 -2px 0 #060a1c,
    2px 2px 0 #060a1c, -2px 2px 0 #060a1c, 2px -2px 0 #060a1c, -2px -2px 0 #060a1c,
    0 3px 4px rgba(0, 0, 0, 0.6);
}
.enemy-hp { display: flex; gap: 5px; justify-content: center; margin-top: 5px; }
.hp-pip {
  width: 22px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(180deg, #8af0a5, #3dbb63);
  border: 1px solid #0c3018;
  transition: transform 0.18s, opacity 0.18s, background 0.18s;
}
.hp-pip.lost {
  background: #2a3358;
  border-color: #141b3a;
  transform: scaleY(0.55);
}

/* ボス */
.enemy-wrap.boss .enemy-name { color: var(--gold); }
.boss-tag {
  display: inline-block;
  background: linear-gradient(180deg, #ff9fb0, #e2485e);
  border: 1px solid #6e0a1e;
  border-radius: 5px;
  color: #fff;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 1px 7px;
  margin-right: 6px;
  vertical-align: 2px;
}
.enemy-wrap.boss .enemy-canvas { animation-duration: 2.8s; }
.scene-flash.danger { background: #ff5d6e; }

.char-shadow {
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 76%;
  height: 18px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.4), transparent 68%);
  z-index: 1;
}
.hero-wrap .char-shadow { bottom: -10px; }

/* エフェクト */
.fx-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.dmg-num {
  position: absolute;
  font-size: 40px;
  color: var(--gold);
  -webkit-text-stroke: 1.5px #5b3a00;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
  animation: dmg-float 0.8s ease-out forwards;
  white-space: nowrap;
}
.dmg-num.special { color: #fff; -webkit-text-stroke: 1.5px #b1003c; font-size: 34px; }
@keyframes dmg-float {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  18% { transform: translateY(-14px) scale(1.25); opacity: 1; }
  100% { transform: translateY(-70px) scale(1); opacity: 0; }
}
.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--gold);
  clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
  animation: spark-fly 0.6s ease-out forwards;
}
@keyframes spark-fly {
  0% { transform: translate(0, 0) scale(1.4) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2) rotate(180deg); opacity: 0; }
}
.scene-flash {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.scene-flash.active { animation: flash 0.26s ease-out; }
@keyframes flash {
  0% { opacity: 0.75; }
  100% { opacity: 0; }
}

/* ステージ開始バナー */
.stage-banner {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(7, 10, 28, 0.55);
  opacity: 0;
  pointer-events: none;
}
.stage-banner.show { animation: banner-show 1.9s ease forwards; }
@keyframes banner-show {
  0% { opacity: 0; }
  12% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.banner-stage {
  font-size: 46px;
  letter-spacing: 6px;
  color: var(--white);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.6);
}
.stage-banner.show .banner-stage { animation: banner-slide 1.9s cubic-bezier(0.2, 1, 0.3, 1); }
@keyframes banner-slide {
  0% { transform: translateX(-60px); }
  18% { transform: translateX(0); }
  100% { transform: translateX(0); }
}
.banner-world {
  font-size: 26px;
  color: var(--gold);
  letter-spacing: 10px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
}

/* ----- サイドパネル ----- */
.side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 14px;
}
.side-section { display: flex; flex-direction: column; gap: 6px; }
.side-heading {
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 2px;
  border-bottom: 2px solid rgba(255, 215, 94, 0.35);
  padding-bottom: 4px;
}
.side-stage-label { font-size: 17px; }
.stage-pips { display: flex; gap: 7px; }
.stage-pip {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 2px solid var(--navy-3);
  background: var(--navy-1);
  display: grid;
  place-items: center;
  font-size: 15px;
  color: transparent;
}
.stage-pip.done {
  background: linear-gradient(180deg, #ffe289, var(--gold));
  border-color: #8a6a10;
  color: #5b3a00;
  animation: pip-pop 0.3s ease;
}
@keyframes pip-pop {
  0% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

.level-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 16px;
}
.level-row strong { font-size: 32px; color: var(--gold); }
.exp-bar {
  height: 14px;
  border-radius: 7px;
  border: 2px solid var(--navy-3);
  background: var(--navy-0);
  overflow: hidden;
}
.exp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #59c8ff, #8af0a5);
  border-radius: 5px;
  transition: width 0.4s cubic-bezier(0.2, 1, 0.3, 1);
}
.exp-text { font-size: 13px; color: var(--muted); text-align: right; }
.mini-stats { display: flex; gap: 8px; margin-top: 2px; }
.mini-stat {
  flex: 1;
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 8px;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
}
.mini-stat strong { font-size: 20px; color: var(--white); }

.side-buttons {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.side-button {
  border: 2px solid var(--white);
  border-radius: 9px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  color: var(--white);
  font-size: 14px;
  padding: 8px 4px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  letter-spacing: 1px;
}
.side-button:hover { background: linear-gradient(180deg, var(--navy-3), var(--navy-2)); }
.side-button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45); }
.side-button.quiet { border-color: rgba(255, 255, 255, 0.4); color: var(--muted); grid-column: 1 / -1; }
.side-button.off { color: var(--muted); border-color: rgba(255, 255, 255, 0.4); }

/* タイトルへ戻る = 赤で目立たせる */
#btnTitle {
  grid-column: 1 / -1;
  border-color: #ff8a98;
  background: linear-gradient(180deg, #e85067, #bd283d);
  color: #fff;
  box-shadow: 0 3px 0 #7a1020;
  letter-spacing: 2px;
}
#btnTitle:hover { background: linear-gradient(180deg, #f4607a, #cf3350); }
#btnTitle:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a1020; }

/* ----- ことばパネル ----- */
.word-panel {
  grid-area: word;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
}
.word-label { font-size: 12px; color: var(--muted); letter-spacing: 2px; margin-bottom: 2px; }
.word-hira-box {
  min-width: 218px;
  text-align: center;
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 10px;
  padding: 7px 18px 9px;
}
.word-yomi {
  font-size: 15px;
  color: var(--cyan);
  letter-spacing: 3px;
  line-height: 1.1;
  margin-bottom: 1px;
}
.word-hira { font-size: 50px; line-height: 1.1; letter-spacing: 6px; }
.word-hira-box.with-yomi .word-hira { font-size: 40px; letter-spacing: 4px; }
.word-hira.pop { animation: word-pop 0.3s ease; }
@keyframes word-pop {
  0% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.romaji-box { flex: 1; }
.romaji-row { display: flex; gap: 9px; margin-top: 2px; }
.romaji-letter {
  width: 52px;
  height: 62px;
  display: grid;
  place-items: center;
  font-size: 36px;
  border-radius: 9px;
  border: 2px solid var(--navy-3);
  background: var(--navy-1);
  color: rgba(170, 182, 232, 0.62);
  transition: transform 0.12s;
}
.romaji-letter.current {
  background: var(--white);
  color: var(--navy-1);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 215, 94, 0.45), 0 0 18px rgba(255, 215, 94, 0.5);
  animation: letter-pulse 0.9s ease-in-out infinite;
}
@keyframes letter-pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.romaji-letter.done {
  background: linear-gradient(180deg, #ffe289, var(--gold));
  color: #5b3a00;
  border-color: #8a6a10;
  animation: letter-done 0.22s ease;
}
@keyframes letter-done {
  0% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.romaji-row.slim .romaji-letter { width: 42px; height: 56px; font-size: 28px; }
.romaji-row.slim { gap: 6px; }
.romaji-letter.space {
  width: 26px;
  background: transparent;
  border-style: dashed;
  position: relative;
}
.romaji-letter.space::after {
  content: '';
  position: absolute;
  bottom: 12px;
  left: 5px;
  right: 5px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.55;
}
.romaji-row.slim .romaji-letter.space { width: 20px; }
.romaji-row.miss { animation: row-miss 0.32s ease; }
@keyframes row-miss {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}
.romaji-letter.miss-flash { background: var(--red); color: #fff; border-color: #b1003c; }

/* ----- キーボード ----- */
.keyboard-panel {
  grid-area: keys;
  padding: 11px 16px;
  display: grid;
  place-items: center;
}
.keyboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.key-row { display: grid; gap: 7px; }
.key {
  height: 27px;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--muted);
  background: linear-gradient(180deg, #2d3a78, #1f2a5e);
  border: 2px solid #0d1334;
  border-radius: 6px;
  box-shadow: 0 3px 0 #0d1334, inset 0 1px 0 rgba(255, 255, 255, 0.22);
  position: relative;
}
.key.home::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.5);
}
/* 機能キー（飾り）。打鍵対象ではない */
.key.func {
  font-size: 11px;
  letter-spacing: 0;
  color: rgba(170, 182, 232, 0.7);
  background: linear-gradient(180deg, #222b52, #18203f);
  border-color: #0b1030;
  box-shadow: 0 3px 0 #0b1030, inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
/* Enter を上下で連結して 1つの大きなキーに見せる */
.key.func.enter-top {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.key.func.enter-bot {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: -9px;          /* 行間ぶん上に詰めて連結 */
  box-shadow: 0 3px 0 #0b1030;
}
.key.current {
  background: linear-gradient(180deg, #ffe89a, var(--gold));
  color: #4a3200;
  border-color: #8a6a10;
  box-shadow: 0 3px 0 #8a6a10, 0 0 16px rgba(255, 215, 94, 0.8);
  animation: key-glow 0.8s ease-in-out infinite;
  font-weight: 700;
}
@keyframes key-glow {
  0%, 100% { box-shadow: 0 3px 0 #8a6a10, 0 0 9px rgba(255, 215, 94, 0.55); }
  50% { box-shadow: 0 3px 0 #8a6a10, 0 0 22px rgba(255, 226, 137, 0.95); }
}
.key.pressed {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0d1334;
  background: linear-gradient(180deg, #3d4d96, #2c3a7c);
  color: var(--white);
}
.key.pressed.good {
  background: linear-gradient(180deg, #9af2b1, #4ec973);
  color: #093a18;
  border-color: #0c3018;
  box-shadow: 0 1px 0 #0c3018;
}
.key.pressed.bad {
  background: linear-gradient(180deg, #ff9fb0, #f06078);
  color: #4a000d;
  border-color: #6e0a1e;
  box-shadow: 0 1px 0 #6e0a1e;
}

/* ----- メッセージウィンドウ ----- */
.message-panel {
  grid-area: msg;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
}
.msg-portrait {
  width: 68px;
  height: 68px;
  flex: none;
  border: 2px solid var(--white);
  border-radius: 10px;
  background: linear-gradient(180deg, #29346e, #161d44);
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}
.msg-portrait img {
  height: 58px;
  margin-top: 8px;
  animation: wizard-talk 2.6s ease-in-out infinite;
}
@keyframes wizard-talk {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.msg-body { flex: 1; min-width: 0; }
.msg-name { font-size: 13px; color: var(--gold); letter-spacing: 1px; margin-bottom: 3px; }
.msg-text { font-size: 20px; letter-spacing: 1px; line-height: 1.3; min-height: 26px; }
.msg-text::after {
  content: '▼';
  font-size: 12px;
  color: var(--gold);
  margin-left: 6px;
  animation: cursor-blink 0.9s steps(2) infinite;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

/* =========================================================
   オーバーレイ（クリア・ずかん）
========================================================= */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 22, 0.72);
  animation: overlay-in 0.25s ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.clear-card {
  width: 560px;
  padding: 26px 34px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: card-in 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes card-in {
  from { transform: scale(0.7) translateY(30px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.clear-ribbon {
  font-size: 40px;
  letter-spacing: 5px;
  color: var(--gold);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
}
.clear-stars { display: flex; gap: 14px; font-size: 52px; }
.clear-stars span { color: #39406e; transition: color 0.2s; }
.clear-stars span.on {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 215, 94, 0.8), 0 4px 0 rgba(0, 0, 0, 0.4);
  animation: star-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) backwards;
}
.clear-stars span.on:nth-child(1) { animation-delay: 0.15s; }
.clear-stars span.on:nth-child(2) { animation-delay: 0.4s; }
.clear-stars span.on:nth-child(3) { animation-delay: 0.65s; }
@keyframes star-pop {
  from { transform: scale(0) rotate(-120deg); }
  to { transform: scale(1) rotate(0); }
}
.clear-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.clear-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 9px;
  padding: 8px 16px;
}
.clear-stat-row strong { color: var(--gold); }

.big-button {
  border: 3px solid #8a6a10;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe89a, var(--gold));
  color: #4a3200;
  font-size: 22px;
  letter-spacing: 2px;
  padding: 12px 34px;
  box-shadow: 0 5px 0 #8a6a10;
  font-weight: 700;
}
.big-button:hover { filter: brightness(1.06); }
.big-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #8a6a10; }
.big-button.secondary {
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  border-color: var(--white);
  color: var(--white);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.5);
}

/* キー操作の案内 */
.key-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  animation: key-hint-pulse 1.6s ease-in-out infinite;
}
@keyframes key-hint-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.key-hint .keycap {
  background: linear-gradient(180deg, #2d3a78, #1f2a5e);
  border: 2px solid #0d1334;
  border-radius: 6px;
  box-shadow: 0 2px 0 #0d1334, inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: var(--white);
  font-size: 14px;
  padding: 4px 12px;
  letter-spacing: 1px;
}
.key-hint .keycap-space { min-width: 120px; text-align: center; }
.key-hint-or { font-size: 12px; }
.key-hint-text { color: var(--gold); }

.allclear-card { width: 620px; }
.allclear-title {
  font-size: 42px;
  white-space: nowrap;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.5);
  animation: logo-bob 2.4s ease-in-out infinite;
}
.allclear-sub { font-size: 20px; text-align: center; line-height: 1.5; }
.allclear-hero { animation: char-bob 1.8s ease-in-out infinite; }
.allclear-buttons { display: flex; gap: 16px; }

/* レベルアップ */
.levelup-toast {
  position: absolute;
  top: 116px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: baseline;
  gap: 12px;
  background: linear-gradient(180deg, rgba(20, 26, 60, 0.97), rgba(12, 16, 40, 0.97));
  border: 3px solid var(--gold);
  border-radius: 14px;
  padding: 12px 30px;
  box-shadow: 0 0 30px rgba(255, 215, 94, 0.55), 0 6px 0 rgba(0, 0, 0, 0.5);
  animation: levelup-in 2.2s ease forwards;
  pointer-events: none;
}
@keyframes levelup-in {
  0% { transform: translateX(-50%) translateY(-30px) scale(0.6); opacity: 0; }
  12% { transform: translateX(-50%) translateY(0) scale(1.08); opacity: 1; }
  20% { transform: translateX(-50%) scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; }
}
.levelup-text { font-size: 26px; color: var(--gold); letter-spacing: 3px; }
.levelup-num { font-size: 34px; color: #fff; }

/* ずかんモーダル */
.modal-card {
  width: 760px;
  max-height: 640px;
  padding: 18px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-tabs { display: flex; gap: 8px; }
.tab-button {
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 9px;
  background: var(--navy-1);
  color: var(--muted);
  font-size: 15px;
  padding: 7px 18px;
}
.tab-button.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--navy-2);
}
.modal-panel { overflow-y: auto; padding-right: 4px; }
.modal-panel::-webkit-scrollbar { width: 8px; }
.modal-panel::-webkit-scrollbar-thumb { background: var(--navy-3); border-radius: 4px; }

.codex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.codex-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 12px;
  padding: 12px 14px;
}
.codex-card.unknown { opacity: 0.6; }
.codex-card.unknown canvas { filter: brightness(0) opacity(0.5); }
.codex-icon-box {
  width: 84px;
  height: 84px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--navy-0);
  border: 2px solid var(--navy-3);
  border-radius: 10px;
}
.codex-info { display: flex; flex-direction: column; gap: 3px; }
.codex-info strong { font-size: 18px; }
.codex-count { font-size: 12px; color: var(--gold); }
.codex-desc { font-size: 13px; color: var(--muted); line-height: 1.45; }

.records-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.record-card {
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 12px;
  padding: 14px 16px;
}
.record-card.wide { grid-column: 1 / -1; }
.record-card h3 { margin: 0 0 10px; font-size: 15px; color: var(--gold); letter-spacing: 2px; }
.record-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.record-list li {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  border-bottom: 1px dashed rgba(170, 182, 232, 0.25);
  padding-bottom: 4px;
}
.record-list strong { color: var(--white); }

/* =========================================================
   ゆびれんしゅうモード
========================================================= */
/* タイトルの入口ボタン */
.flow-entry {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 3px solid var(--cyan);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  color: var(--white);
  padding: 10px 22px;
  box-shadow: inset 0 0 0 3px rgba(127, 217, 255, 0.18), 0 6px 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.flow-entry:hover {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 3px rgba(127, 217, 255, 0.3), 0 9px 0 rgba(0, 0, 0, 0.45);
}
.flow-entry:active { transform: translateY(1px); }
.flow-entry-icon { font-size: 26px; }
.flow-entry-main { font-size: 21px; letter-spacing: 2px; color: var(--cyan); font-weight: 700; }
.flow-entry-copy { font-size: 14px; color: var(--muted); }

/* 画面レイアウト */
/* 不透明背景 + z-index で独立させ、他画面の z-index 要素が透けないようにする */
.flow-screen {
  z-index: 10;
  background:
    radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1.6px),
    linear-gradient(180deg, #0a0f26 0%, #070b1e 100%);
  background-size: 26px 26px, 100% 100%;
}
.flow-grid {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 14px;
  gap: 10px;
  grid-template-rows: 56px 236px 130px 1fr;
}

.flow-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 200px 8px 16px;   /* 右に ドック分の余白 */
}
.flow-title-chip {
  font-size: 18px;
  color: var(--cyan);
  letter-spacing: 2px;
}
.flow-stats { display: flex; gap: 10px; margin-left: auto; }
.flow-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 9px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--muted);
}
.flow-stat strong { font-size: 20px; color: var(--white); min-width: 30px; text-align: right; }
.flow-stat.combo { border-color: var(--gold); }
.flow-stat.combo strong { color: var(--gold); }
.flow-exit { grid-column: auto; width: auto; padding: 8px 14px; }

/* レーン */
.flow-lane-panel { padding: 0; overflow: hidden; }
.flow-lane {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
  background:
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.6px),
    linear-gradient(180deg, #101740, #0a0f2c);
  background-size: 24px 24px, 100% 100%;
}
.flow-goal-zone {
  position: absolute;
  left: 30px;
  bottom: 38px;
  z-index: 2;
}
.flow-goal-zone canvas {
  display: block;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.35));
  animation: hero-idle 1.6s ease-in-out infinite;
}
.flow-goal-zone canvas.bump { animation: flow-hero-bump 0.4s ease; }
@keyframes flow-hero-bump {
  0% { translate: -14px 0; filter: drop-shadow(0 6px 4px rgba(0,0,0,0.35)) brightness(2.4) saturate(0.4); }
  100% { translate: 0 0; }
}
.flow-hero-shadow { bottom: -12px; }
.flow-goal-line {
  position: absolute;
  left: 150px;
  top: 12px;
  bottom: 12px;
  border-left: 3px dashed rgba(255, 123, 138, 0.55);
  z-index: 1;
}
.flow-lane-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(90deg, rgba(255, 93, 110, 0.4), transparent 40%);
  opacity: 0;
  pointer-events: none;
}
.flow-lane-flash.on { animation: flash 0.35s ease-out; }

/* 文字カード */
.flow-card {
  position: absolute;
  left: 0;
  top: 50%;
  width: 64px;
  height: 78px;
  display: grid;
  place-items: center;
  font-size: 42px;
  border-radius: 12px;
  border: 3px solid var(--fcol);
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  color: var(--fcol);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  z-index: 2;
  will-change: transform;
}
.flow-card.front {
  background: var(--white);
  color: var(--navy-1);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 0 22px var(--fcol);
  animation: flow-front-pulse 0.9s ease-in-out infinite;
}
@keyframes flow-front-pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.07; }
}
.flow-card.hit { animation: flow-card-hit 0.32s ease forwards; }
@keyframes flow-card-hit {
  0% { scale: 1.1; opacity: 1; filter: brightness(2.6); }
  100% { scale: 1.7; opacity: 0; filter: brightness(3); }
}
.flow-card.escape { animation: flow-card-escape 0.42s ease forwards; }
@keyframes flow-card-escape {
  0% { opacity: 1; rotate: 0deg; }
  100% { opacity: 0; translate: -60px 0; rotate: -14deg; scale: 0.6; }
}
.flow-card.shake { animation: flow-card-shake 0.3s ease; }
@keyframes flow-card-shake {
  0%, 100% { rotate: 0deg; }
  25% { rotate: -7deg; }
  50% { rotate: 6deg; }
  75% { rotate: -4deg; }
}

/* ガイド */
.flow-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 10px 20px;
  transition: opacity 0.2s;
}
.flow-guide.idle { opacity: 0.35; }
.flow-guide.pop .flow-big-letter { animation: word-pop 0.26s ease; }

.flow-phonics {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: var(--navy-1);
  border: 2px solid var(--navy-3);
  border-radius: 10px;
  padding: 8px 16px;
  min-width: 250px;
  min-height: 44px;
}
.flow-phonics.pop { animation: word-pop 0.26s ease; }
.flow-phonics strong { font-size: 26px; color: var(--gold); }
.flow-phonics .ph-sound { font-size: 20px; color: var(--cyan); }
.flow-phonics .ph-word { font-size: 17px; }
.flow-phonics .ph-word small { font-size: 13px; color: var(--muted); }
.flow-phonics .ph-hint { font-size: 13px; color: var(--muted); }
.flow-phonics-toggle { padding: 8px 12px; }
.flow-phonics-toggle.off { color: var(--muted); border-color: rgba(255, 255, 255, 0.4); }
.flow-big-letter {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  font-size: 58px;
  font-weight: 700;
  border-radius: 16px;
  border: 4px solid var(--fcol, var(--gold));
  background: var(--white);
  color: var(--navy-1);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), 0 0 24px var(--fcol, transparent);
}
.flow-guide-text {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 26px;
}
.flow-joint { color: var(--muted); }
.flow-chip {
  background: var(--navy-1);
  border: 3px solid var(--white);
  border-radius: 999px;
  padding: 8px 22px;
  font-size: 28px;
  letter-spacing: 2px;
}
.flow-chip.finger {
  border-color: var(--fcol, var(--gold));
  color: var(--fcol, var(--gold));
  box-shadow: 0 0 18px color-mix(in srgb, var(--fcol, var(--gold)) 45%, transparent);
}

/* キーボード + ゆび */
.flow-keys {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 12px 18px 10px;
}
.flow-keyboard { width: 100%; }
.flow-keyboard .key { height: 31px; font-size: 16px; }
.flow-key { border-bottom: 4px solid var(--fcol, #0d1334); }
.flow-key.mute { opacity: 0.32; }
.flow-key.fcurrent {
  background: var(--fcol);
  color: #20264e;
  border-color: rgba(0, 0, 0, 0.4);
  font-weight: 700;
  animation: flow-key-glow 0.8s ease-in-out infinite;
}
@keyframes flow-key-glow {
  0%, 100% { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4), 0 0 8px var(--fcol); }
  50% { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4), 0 0 22px var(--fcol); }
}

/* 両手の指（中央に左右で並べる） */
.flow-hands {
  display: flex;
  justify-content: center;
  gap: 70px;
  align-items: flex-start;
  margin-top: 6px;
}
.hand-group {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.finger-stub {
  width: 28px;
  border-radius: 14px 14px 5px 5px;
  background: #39406e;
  border: 2px solid #1a2150;
  border-bottom: none;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.14);
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
}
.finger-stub.active {
  background: var(--fcol);
  border-color: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 14px var(--fcol), inset 0 3px 0 rgba(255, 255, 255, 0.35);
  animation: stub-bounce 0.7s ease-in-out infinite;
}
@keyframes stub-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}
.finger-stub.tap { animation: stub-tap 0.18s ease; }
@keyframes stub-tap {
  0% { transform: translateY(7px); }
  100% { transform: translateY(0); }
}

/* ホームポジション（基本の指の位置）を強調 */
.flow-key.homerow {
  background: linear-gradient(180deg, #34427e, #283566);
  box-shadow: 0 3px 0 #0d1334, inset 0 0 0 2px rgba(255, 255, 255, 0.14);
}
.flow-key.home::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--gold);
}
.flow-homerow-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}
.flow-homerow-note .home-dot { color: var(--gold); }
.flow-homerow-note strong { color: var(--gold); letter-spacing: 1px; }
.flow-homerow-note b {
  color: #4a3200;
  background: var(--gold);
  border-radius: 4px;
  padding: 0 6px;
  margin: 0 1px;
}

/* スタートオーバーレイ */
.flow-start-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 22, 0.74);
}
.flow-start-card {
  width: 560px;
  padding: 30px 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.flow-start-title {
  font-size: 34px;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
}
.flow-start-copy { margin: 0; font-size: 19px; line-height: 1.6; }
.flow-ime-note {
  margin: 0;
  font-size: 15px;
  color: var(--red);
  background: rgba(255, 123, 138, 0.12);
  border: 2px solid rgba(255, 123, 138, 0.4);
  border-radius: 999px;
  padding: 5px 18px;
}
.flow-start-key {
  margin-top: 6px;
  font-size: 27px;
  color: var(--gold);
  letter-spacing: 2px;
  animation: start-key-pulse 1.4s ease-in-out infinite;
}
@keyframes start-key-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.flow-start-sub { font-size: 14px; color: var(--muted); }
.flow-start-best { font-size: 15px; color: var(--gold); min-height: 18px; }

.flow-level-buttons { display: flex; gap: 16px; margin-top: 6px; }
.flow-level-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 240px;
  padding: 14px 16px;
  border: 3px solid var(--white);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.14), 0 6px 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.12s, box-shadow 0.12s;
}
.flow-level-btn:hover { transform: translateY(-4px); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.2), 0 11px 0 rgba(0, 0, 0, 0.45); }
.flow-level-btn:active { transform: translateY(1px); }
.flow-level-btn.easy { border-color: #8af0a5; }
.flow-level-btn.normal { border-color: #84c8ff; }
.flow-level-btn strong { font-size: 24px; letter-spacing: 2px; }
.flow-level-btn.easy strong { color: #8af0a5; }
.flow-level-btn.normal strong { color: #84c8ff; }
.flow-level-btn span { font-size: 13px; color: var(--muted); line-height: 1.4; text-align: center; }
.flow-level-btn em {
  font-style: normal;
  font-size: 12px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 2px 12px;
}
/* やさしいモードの赤線（デッドライン）を やわらかく */
.flow-screen.easy-mode .flow-goal-line { opacity: 0.5; }

/* 紙吹雪 */
.confetti-layer { position: absolute; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(840px) rotate(720deg); opacity: 0; }
}
