/* ============================================================
   漢字撃破 (Kanji Gekiha) - スタイルシート
   シンプルでわかりやすい和モダン・アーケード学習UI
   ============================================================ */

:root {
  --bg-color: #f6f5f0;
  --card-bg: #ffffff;
  --text-main: #1e242b;
  --text-sub: #5a6472;
  --text-muted: #8c96a4;
  --accent-red: #c93a2c;
  --accent-red-hover: #b02a1e;
  --accent-navy: #1f3044;
  --accent-gold: #c88a2e;
  --accent-green: #2a7e58;
  --border-color: #e2dfd5;
  --border-dark: #cbd5e1;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-kanji: "Hiragino Mincho ProN", "Yu Mincho", "BIZ UDPMincho", "Noto Serif JP", serif;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  user-select: none;
  overflow-x: hidden;
}

/* アプリ全体のコンテナ */
#app {
  width: 100%;
  max-width: 760px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  position: relative;
}

/* ヘッダー */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 8px 4px 16px 4px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 16px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-icon-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background-color: var(--accent-red);
  color: #fff;
  font-family: var(--font-kanji);
  font-size: 1.35rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-navy);
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-sub);
  display: block;
  font-weight: normal;
}

.header-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex: 0 0 100%;
}

.app-header.game-playing .header-actions {
  display: none;
}

.header-actions > .icon-btn {
  flex: 1 1 0;
}

.main-tabs { display: flex; gap: 5px; flex: 1 1 100%; order: 3; }
.main-tab { flex: 1; border: 1px solid var(--border-dark); border-radius: var(--radius-sm); background: #fff; padding: 8px 4px; font-family: inherit; font-weight: 700; color: var(--text-sub); cursor: pointer; }
.main-tab.active { background: var(--accent-navy); border-color: var(--accent-navy); color: #fff; }
.tab-screen { align-items: center; padding: 30px 0; }
.tab-panel { width: min(100%, 680px); padding: 24px; border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--card-bg); box-shadow: var(--shadow-sm); }
.tab-title { margin: 0 0 18px; color: var(--accent-navy); font-family: var(--font-kanji); font-size: 1.35rem; }
.account-score-summary { margin-top: 22px; }

/* ユーザー情報バッジ (ヘッダー) */
.header-user-area {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.user-info-badge {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.user-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-navy);
  white-space: nowrap;
}

.user-stats-line {
  font-size: 0.72rem;
  color: var(--text-sub);
  display: flex;
  gap: 6px;
}

.user-stats-line b {
  color: var(--accent-red);
}

.logout-btn {
  color: #8c96a4;
}

.logout-btn:hover {
  color: var(--accent-red);
  border-color: #fca5a5;
  background: #fef2f2;
}

.icon-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-width: 0;
  min-height: 46px;
  padding: 8px 10px;
  font-size: 0.9rem;
  color: var(--text-sub);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  text-align: center;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: #f0eee6;
  color: var(--text-main);
  border-color: var(--border-dark);
}

/* 画面切り替え共通 */
.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  flex: 1;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   タイトル画面
   ============================================================ */
.title-hero {
  text-align: center;
  padding: 24px 12px 16px;
}

.hero-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-red);
  letter-spacing: 0.15em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.hero-title {
  font-family: var(--font-kanji);
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-navy);
  margin-bottom: 8px;
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-sub);
  max-width: 480px;
  margin: 0 auto 20px;
}

/* コース選択グリッド */
.section-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.course-card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.course-card:hover {
  border-color: var(--accent-navy);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.course-card.selected {
  border-color: var(--accent-red);
  background: #fffdfc;
  box-shadow: var(--shadow-md);
}

.course-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.course-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f0ede4;
  color: var(--text-sub);
}

.course-card.selected .course-badge {
  background: var(--accent-red);
  color: #fff;
}

.course-icon {
  font-size: 1.4rem;
}

.course-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-navy);
  margin-bottom: 4px;
}

.course-desc {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 8px;
  flex: 1;
}

.course-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* ゲーム開始ボタン */
.start-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.primary-btn {
  background-color: var(--accent-red);
  color: #ffffff;
  border: none;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 14px 48px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.15s ease;
  width: 100%;
  max-width: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-btn:hover {
  background-color: var(--accent-red-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.primary-btn:active {
  transform: translateY(0);
}

.start-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   ゲーム画面 (漢字でGO風メイン)
   ============================================================ */
.game-hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  background: var(--card-bg);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.hud-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 42px;
}

.hud-item-center {
  align-items: center;
  text-align: center;
}

.hud-item-right {
  align-items: flex-end;
  text-align: right;
}

.hud-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.hud-value {
  display: flex;
  align-items: center;
  height: 24px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-navy);
}

.lives-container {
  display: flex;
  align-items: center;
  height: 24px;
  gap: 4px;
  font-size: 1.15rem;
  line-height: 1;
}

.life-heart {
  color: var(--accent-red);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.life-heart.lost {
  opacity: 0.25;
  filter: grayscale(1);
  transform: scale(0.85);
}

/* タイムゲージ */
.timer-wrapper {
  margin-bottom: 14px;
}

.timer-track {
  width: 100%;
  height: 10px;
  background: #e6e3da;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent-green);
  transition: width 0.1s linear, background-color 0.3s ease;
  border-radius: 999px;
}

.timer-fill.warning {
  background: #d97706; /* オレンジ */
}

.timer-fill.danger {
  background: var(--accent-red);
  animation: pulseTimer 0.6s infinite alternate;
}

@keyframes pulseTimer {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

/* 漢字出題カード */
.stage-card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.stage-card.shake {
  animation: cardShake 0.4s ease;
  border-color: var(--accent-red);
}

@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.stage-badge {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
  background: #f1eee6;
  padding: 3px 10px;
  border-radius: 999px;
}

.combo-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent-gold);
  background: #fff8e8;
  border: 1px solid #fed7aa;
  padding: 3px 10px;
  border-radius: 999px;
  display: none;
}

.combo-badge.show {
  display: block;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ふりがな表示 */
.ruby-reading {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-red);
  height: 28px;
  line-height: 28px;
  margin-bottom: 4px;
  visibility: hidden;
  letter-spacing: 0.1em;
}

.ruby-reading.revealed {
  visibility: visible;
  animation: fadeIn 0.15s ease;
}

.hint-dot {
  display: inline-block;
  font-size: 1.1rem;
  color: #8c96a4;
  margin: 0 4px;
  line-height: 1;
}

.hint-char {
  display: inline-block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-red);
  margin: 0 4px;
  line-height: 1;
}

/* 巨大漢字表示 */
.kanji-display {
  font-family: var(--font-kanji);
  font-size: 4.8rem;
  font-weight: 800;
  color: var(--accent-navy);
  letter-spacing: 0.12em;
  margin: 6px 0 10px 0;
  line-height: 1.1;
  word-break: keep-all;
}

.kanji-display.long-text {
  font-size: 3.2rem;
  letter-spacing: 0.05em;
}

/* 正解・撃破カットイン */
.gekiha-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  z-index: 3;
}

.gekiha-overlay.active {
  opacity: 1;
  animation: slashScene 0.78s ease-out both;
}

.slash-kanji {
  position: absolute;
  left: 50%;
  top: 50%;
  font-family: var(--font-kanji);
  font-size: clamp(5rem, 22vw, 9rem);
  font-weight: 900;
  line-height: 1;
  color: #18243a;
  text-shadow: 0 5px 0 rgba(255,255,255,.75), 0 12px 24px rgba(0,0,0,.24);
  opacity: 0;
  white-space: nowrap;
}

.slash-kanji-left { clip-path: inset(0 50% 0 0); }
.slash-kanji-right { clip-path: inset(0 0 0 50%); }

.gekiha-overlay.active .slash-kanji-left {
  animation: splitLeft .78s cubic-bezier(.18,.75,.2,1) both;
}

.gekiha-overlay.active .slash-kanji-right {
  animation: splitRight .78s cubic-bezier(.18,.75,.2,1) both;
}

.slash-blade {
  position: absolute;
  width: 150%;
  height: 8px;
  left: -25%;
  top: 50%;
  border-radius: 99px;
  transform: rotate(-24deg) scaleX(0);
  transform-origin: center;
  background: linear-gradient(90deg, transparent, #fff 18%, #c9f5ff 48%, #fff 62%, transparent);
  filter: drop-shadow(0 0 8px #49c8ff) drop-shadow(0 0 18px #fff);
  opacity: 0;
}

.gekiha-overlay.active .slash-blade {
  animation: bladeSweep .42s cubic-bezier(.3,0,.2,1) .08s both;
}

.slash-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.88), rgba(113,220,255,.32) 24%, transparent 67%);
  opacity: 0;
}

.gekiha-overlay.active .slash-flash {
  animation: slashFlash .38s ease-out .16s both;
}

@keyframes splitLeft {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% - 38px), calc(-50% + 12px)) rotate(-9deg); }
}

@keyframes splitRight {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + 38px), calc(-50% - 12px)) rotate(9deg); }
}

@keyframes bladeSweep {
  0% { opacity: 0; transform: rotate(-24deg) scaleX(0); }
  18% { opacity: 1; }
  65% { opacity: 1; transform: rotate(-24deg) scaleX(1); }
  100% { opacity: 0; transform: rotate(-24deg) scaleX(1.1); }
}

@keyframes slashFlash {
  0% { opacity: 0; }
  24% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes slashScene {
  0%, 100% { background: transparent; }
  20% { background: rgba(45, 160, 205, .16); }
}

@media (prefers-reduced-motion: reduce) {
  .gekiha-overlay.active, .gekiha-overlay.active * { animation-duration: .01ms !important; }
}

/* 意味・例文の即時ヒント（練習モード時や正解時に表示） */
.quick-meaning {
  font-size: 0.85rem;
  color: var(--text-sub);
  max-width: 90%;
  min-height: 20px;
  margin-top: 4px;
}

/* 入力エリア */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.input-box-wrapper {
  position: relative;
  width: 100%;
}

.typing-input {
  width: 100%;
  height: 60px;
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.1em;
  color: var(--accent-navy);
  background: #ffffff;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  caret-color: var(--accent-red);
}

.typing-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
  transition: opacity 0.1s ease;
}

.typing-input:focus::placeholder {
  opacity: 0;
  color: transparent;
}

.typing-input:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 3px rgba(201, 58, 44, 0.12);
}

.typing-input.error {
  border-color: var(--accent-red);
  background-color: #fff5f5;
}

.input-box-wrapper.shake {
  animation: inputShake 0.35s ease;
}

.near-miss-feedback {
  min-height: 0;
  margin: -6px 0 -4px;
  color: var(--accent-red);
  font-family: var(--font-kanji);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  opacity: 0;
  transform: translateY(-4px) scale(0.9);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.near-miss-feedback.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.input-guide {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.romaji-buffer {
  font-family: monospace;
  font-weight: 600;
  color: var(--accent-red);
  font-size: 0.9rem;
}

/* ゲーム操作ボタンバー */
.game-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.secondary-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-dark);
  color: var(--text-sub);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.secondary-btn:hover {
  background: #f0eee6;
  color: var(--text-main);
}

/* 使用済み・ブラックアウト状態 */
.secondary-btn:disabled,
.secondary-btn.blackout {
  background: #23272d !important;
  color: #6e7681 !important;
  border-color: #1b1f23 !important;
  cursor: not-allowed !important;
  opacity: 0.85;
  box-shadow: none !important;
  transform: none !important;
  text-decoration: line-through;
}

/* ============================================================
   リザルト画面
   ============================================================ */
.result-header {
  text-align: center;
  padding: 16px 0 20px;
}

.result-badge {
  display: inline-block;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  background: #e4dfd3;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.result-badge.clear {
  background: #e8f5e9;
  color: #1b5e20;
}

.result-badge.over {
  background: #fbe9e7;
  color: #b71c1c;
}

.result-title {
  font-family: var(--font-kanji);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-navy);
  margin-bottom: 4px;
}

.result-rank-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
}

.rank-circle {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent-red);
  color: #fff;
  font-family: var(--font-kanji);
  font-size: 2.4rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.rank-details {
  text-align: left;
}

.rank-score {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-navy);
  line-height: 1.1;
}

.rank-stats {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-top: 4px;
}

/* 復習単語帳リスト */
.review-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.review-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-navy);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.review-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fdfdfc;
}

.review-item.wrong {
  border-left: 4px solid var(--accent-red);
  background: #fffafa;
}

.review-item.correct {
  border-left: 4px solid var(--accent-green);
}

.review-item-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.review-kanji {
  font-family: var(--font-kanji);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-navy);
}

.review-reading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-red);
}

.review-status {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.review-status.correct {
  background: #e8f5e9;
  color: var(--accent-green);
}

.review-status.wrong {
  background: #ffebee;
  color: var(--accent-red);
}

.review-meaning {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.review-example {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* リザルトボタングループ */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

/* モーダル共通 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.15s ease;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-navy);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  font-size: 0.88rem;
  color: var(--text-sub);
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-body h4 {
  color: var(--accent-navy);
  margin: 12px 0 4px;
  font-size: 0.95rem;
}

.modal-body ul {
  padding-left: 20px;
  margin-bottom: 8px;
}

.app-dialog-content {
  max-width: 420px;
}

.app-dialog-message {
  margin: 0 0 18px;
  color: var(--text-sub);
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-line;
}

.app-dialog-input-field {
  margin-bottom: 18px;
}

.app-dialog-input-field[hidden] {
  display: none;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.app-dialog-actions .primary-btn,
.app-dialog-actions .secondary-btn {
  min-width: 104px;
  padding: 9px 14px;
}

.app-dialog-actions .primary-btn.danger {
  background: #c92c2c;
}

.app-dialog-actions .primary-btn.danger:hover:not(:disabled) {
  background: #a92323;
}

.account-details-body {
  margin-bottom: 0;
}

.account-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-color);
}

.account-detail-row:last-child {
  border-bottom: 0;
}

.account-detail-row strong {
  color: var(--accent-navy);
  font-size: 1.05rem;
}

.delete-account-btn {
  width: 100%;
  margin-top: 20px;
  padding: 10px 14px;
  border: 1px solid #dc2626;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #b91c1c;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.delete-account-btn:hover:not(:disabled),
.delete-account-btn:focus-visible:not(:disabled) {
  background: #fef2f2;
  outline: none;
}

.delete-account-btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.ranking-modal-content {
  max-width: 560px;
}

.ranking-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.ranking-tab {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.ranking-tab.active {
  border-color: var(--accent-navy);
  background: var(--accent-navy);
  color: #fff;
}

.ranking-heading,
.ranking-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 88px;
  align-items: center;
  gap: 8px;
}

.ranking-heading {
  padding: 0 10px 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.ranking-heading span:last-child,
.ranking-value {
  text-align: right;
}

.ranking-list {
  max-height: min(55vh, 420px);
  overflow-y: auto;
  border-top: 1px solid var(--border-color);
}

.ranking-row {
  min-height: 52px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
}

.ranking-row.current-user {
  background: #fff8e8;
}

.ranking-position {
  color: var(--accent-navy);
  font-weight: 800;
}

.ranking-row:nth-child(1) .ranking-position { color: #b7791f; }
.ranking-row:nth-child(2) .ranking-position { color: #64748b; }
.ranking-row:nth-child(3) .ranking-position { color: #a16207; }

.ranking-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-value {
  color: var(--accent-red);
  font-weight: 800;
}

.ranking-status {
  padding: 24px 10px;
  color: var(--text-muted);
  font-size: 0.86rem;
  text-align: center;
}

/* ============================================================
   ログイン / アカウント画面
   ============================================================ */
.auth-card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  max-width: 420px;
  width: 100%;
  margin: 24px auto;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.auth-header {
  margin-bottom: 20px;
}

.auth-icon-wrap {
  margin-bottom: 10px;
}

.auth-logo-img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.auth-title {
  font-family: var(--font-kanji);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--accent-navy);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.auth-tabs {
  display: flex;
  background: #e8e5db;
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  gap: 4px;
}

.auth-tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-sub);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab-btn.active {
  background: var(--card-bg);
  color: var(--accent-navy);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-size: 1rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.auth-input:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 2px rgba(201, 58, 44, 0.12);
}

.locked-label {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e8e5db;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

.locked-input-wrap {
  position: relative;
}

.locked-account-field .auth-input {
  padding-right: 42px;
  border-color: #d7d2c5;
  background: #f2f0e9;
  color: var(--text-sub);
  cursor: not-allowed;
}

.locked-account-field .auth-input:focus {
  border-color: #d7d2c5;
  box-shadow: none;
}

.locked-input-icon {
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.65;
  pointer-events: none;
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap .auth-input {
  padding-right: 64px;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: none;
  border-radius: 5px;
  padding: 5px 8px;
  background: transparent;
  color: var(--accent-navy);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.password-toggle-btn:hover,
.password-toggle-btn:focus-visible {
  background: #f1eee5;
  outline: none;
}

.auth-field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.auth-error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-weight: 600;
}

.auth-error-msg.success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.auth-submit-btn {
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  padding: 12px;
  font-size: 1.05rem;
}

.rank-account-points {
  font-size: 0.85rem;
  color: var(--accent-red);
  font-weight: 700;
  margin-top: 4px;
}

/* レスポンシブ調整 */
@media (max-width: 600px) {
  #app {
    padding: 10px;
  }

  .app-header {
    gap: 10px;
  }

  .header-user-area {
    order: 2;
    width: 100%;
    margin-left: 0;
  }

  .user-info-badge {
    width: 100%;
    justify-content: flex-start;
  }

  .header-actions {
    order: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .icon-btn {
    min-height: 44px;
  }
  
  .hero-title {
    font-size: 2.2rem;
  }
  
  .kanji-display {
    font-size: 3.6rem;
  }
  
  .kanji-display.long-text {
    font-size: 2.6rem;
  }

  .stage-card {
    padding: 20px 12px;
    min-height: 200px;
  }

  .typing-input {
    height: 52px;
    font-size: 1.5rem;
  }

  .course-grid {
    grid-template-columns: 1fr;
  }
}
