/* =====================================================================================
   Synapse Note: Pure White Theme, Clean UI (Version 8.0) - Enhanced Responsive Design
   ===================================================================================== */

/* -----------------------------------------------------------------
   1. Global Settings, CSS Variables & Font Imports
   -----------------------------------------------------------------
   このセクションでは以下を定義しています：
   - Webフォントのインポート（Inter & Noto Sans JP）
   - CSS変数（カラーパレット、フォント、サイズ設定など）
   - レスポンシブ対応のためのブレークポイント変数
------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  /* ===== カラーパレット ===== */
  --primary-color: #3178d7;
  --primary-hover-color: #245ba1;
  --danger-color: #e23d28;
  --danger-hover-color: #b52f1d;
  --correct-color: #23b26c;
  --background-color: #fff;
  --surface-color: #fff;
  --text-color: #1a202c;
  --muted-text-color: #7b8794;
  --border-color: #e5e7eb;
  
  /* ===== フォント設定 ===== */
  --font-family: 'Inter', 'Noto Sans JP', sans-serif;
  
  /* ===== デザイン要素 ===== */
  --border-radius: 8px;
  --box-shadow: 0 4px 16px rgba(49, 120, 215, 0.05);
  
  /* ===== レスポンシブブレークポイント ===== */
  --breakpoint-xs: 480px;    /* 極小画面（小さいスマホ） */
  --breakpoint-sm: 640px;    /* 小画面（スマホ） */
  --breakpoint-md: 768px;    /* 中画面（タブレット） */
  --breakpoint-lg: 1024px;   /* 大画面（デスクトップ） */
  --breakpoint-xl: 1280px;   /* 特大画面（大型デスクトップ） */
  
  /* ===== レスポンシブ対応のサイズ設定 ===== */
  --container-padding: clamp(1rem, 4vw, 2rem);  /* 流動的なコンテナパディング */
  --font-size-base: clamp(0.875rem, 2.5vw, 1rem);  /* 流動的なベースフォントサイズ */
  --font-size-title: clamp(1.5rem, 4vw, 2.4rem);   /* 流動的なタイトルサイズ */
}

/* -----------------------------------------------------------------
   2. Reset & Body Layout (モバイルファースト アプローチ)
   -----------------------------------------------------------------
   モバイルファーストの設計思想に基づき、小さい画面から大きい画面に
   向けてスタイルを定義していきます。
------------------------------------------------------------------- */

/* ===== リセットCSS ===== */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

html, body { 
  height: 100%; 
}

/* ===== ベースボディスタイル（モバイル優先） ===== */
body {
  font-family: var(--font-family);
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.7;                       /* より読みやすい行間 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* レスポンシブフォントサイズ */
  font-size: var(--font-size-base);
  
  /* タッチデバイス対応 */
  -webkit-tap-highlight-color: rgba(49, 120, 215, 0.2);
  touch-action: manipulation;
}

/* ===== メインコンテンツエリア ===== */
main {
  flex: 1 0 auto;                      /* フレックスレイアウトで適切に拡張 */
  width: 100%;
  padding: clamp(1.5rem, 4vw, 2.5rem) var(--container-padding); /* より安定したパディング */
  padding-bottom: clamp(2.5rem, 6vw, 4rem); /* フッターとの間隔を確保 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  
  /* 大画面では中央寄せを調整 */
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 200px);     /* 最小高さを確保してコンテンツの安定性向上 */
}

/* -----------------------------------------------------------------
   3. Header & Footer (レスポンシブナビゲーション)
   -----------------------------------------------------------------
   ヘッダーとフッターのスタイリング。モバイルではハンバーガーメニュー、
   デスクトップでは横並びナビゲーションを提供します。
------------------------------------------------------------------- */

/* ===== ヘッダー基本スタイル ===== */
header {
  background: var(--surface-color);
  padding: 1rem var(--container-padding);  /* 流動的なパディング */
  box-shadow: 0 2px 6px rgba(49,120,215,0.03);
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  flex-shrink: 0;
}

/* ===== ヘッダーコンテナ ===== */
.header-container {
  max-width: 1400px;                     /* 大画面での最大幅制限 */
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;                     /* モバイルメニューの位置基準 */
}

/* ===== サイトロゴ ===== */
header h1 a {
  color: var(--text-color);
  text-decoration: none;
  font-size: clamp(1.25rem, 3vw, 1.5rem); /* レスポンシブフォントサイズ */
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===== ナビゲーション（デスクトップ） ===== */
header nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.5rem);         /* 流動的なギャップ */
}

header nav a,
header nav span {
  color: var(--muted-text-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.18s;
  
  /* タッチデバイス対応 - 最小タップエリア確保 */
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.5rem 0.25rem;
}

header nav a:hover,
header nav a:focus { 
  color: var(--primary-color); 
  outline: none;
}

header nav span a {
  color: var(--text-color);
  font-weight: 600;
}

/* ===== 管理者リンクスタイル ===== */
header nav a.admin-link {
  background: #dc3545;
  color: white !important;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.85em;
  font-weight: 600;
  transition: background-color 0.2s;
  min-height: auto;                       /* 管理者リンクは特別なサイズ */
}

header nav a.admin-link:hover,
header nav a.admin-link:focus {
  background: #c82333 !important;
  color: white !important;
}

/* ===== フッター ===== */
footer {
  background: var(--surface-color);
  text-align: center;
  padding: clamp(2rem, 5vw, 3rem);       /* より安定したパディング */
  color: var(--muted-text-color);
  font-size: 0.92rem;
  margin-top: auto;
  width: 100%;
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  /* フッターがコンテンツに重ならないよう安全なマージンを追加 */
  margin-top: clamp(3rem, 6vw, 4rem);    /* より安定したマージン */
}

/* -----------------------------------------------------------------
   4. Button Components (全種類のボタンスタイル)
   -----------------------------------------------------------------
   プライマリ、セカンダリ、デンジャーボタンなど、アプリケーション全体で
   使用される統一されたボタンスタイルを定義します。
   モバイルデバイスでの使いやすさも考慮しています。
------------------------------------------------------------------- */

/* ===== ベースボタンスタイル ===== */
.button, .btn, .button-secondary, .button-danger, .btn-primary, .btn-secondary {
  display: inline-block;
  border-radius: var(--border-radius);
  font-size: clamp(0.9rem, 2.5vw, 1rem);  /* レスポンシブフォントサイズ */
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.18s;
  border: 2px solid transparent;
  padding: clamp(10px, 2.5vw, 12px) clamp(18px, 4vw, 22px); /* 流動的なパディング */
  
  /* タッチデバイス対応 */
  min-height: 44px;                      /* Appleのヒューマンインターフェースガイドライン推奨 */
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  
  /* フォーカス状態の改善 */
  outline: none;
}

/* ===== プライマリボタン ===== */
.button, .btn-primary {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.button:hover, .btn-primary:hover,
.button:focus, .btn-primary:focus {
  background-color: var(--primary-hover-color);
  border-color: var(--primary-hover-color);
  box-shadow: 0 0 0 3px rgba(49, 120, 215, 0.2); /* フォーカスリング */
}

/* ===== セカンダリボタン ===== */
.button-secondary, .btn-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.button-secondary:hover, .btn-secondary:hover,
.button-secondary:focus, .btn-secondary:focus {
  background-color: var(--primary-color);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(49, 120, 215, 0.2);
}

/* ===== デンジャーボタン ===== */
.button-danger {
  background-color: var(--danger-color);
  color: #fff;
  border-color: var(--danger-color);
}

.button-danger:hover,
.button-danger:focus {
  background-color: var(--danger-hover-color);
  border-color: var(--danger-hover-color);
  box-shadow: 0 0 0 3px rgba(226, 61, 40, 0.2);
}

/* ===== ボタンアクティブ状態 ===== */
.button:active, .button-secondary:active, .button-danger:active, .btn:active {
  transform: scale(0.98);
}

/* -----------------------------------------------------------------
   5. Welcome Page Hero Section (ランディングページスタイル)
   -----------------------------------------------------------------
   トップページのウェルカムセクション。訪問者に良い第一印象を与えるための
   レスポンシブなヒーローセクションです。
------------------------------------------------------------------- */

.welcome-container {
  text-align: center;
  max-width: min(700px, 90vw);            /* レスポンシブ最大幅 */
  padding: clamp(2rem, 5vw, 3rem) var(--container-padding); /* より安定したパディング */
  margin: clamp(1rem, 4vw, 2rem) auto;    /* センタリング用マージン */
}

.welcome-container h2 {
  font-size: var(--font-size-title);     /* 流動的なタイトルサイズ */
  font-weight: 700;
  margin-bottom: clamp(1rem, 3vw, 1.5rem); /* より安定したマージン */
  line-height: 1.2;                      /* タイトルの行間調整 */
}

.welcome-container p {
  font-size: clamp(1rem, 2.5vw, 1.08rem); /* レスポンシブフォントサイズ */
  color: var(--muted-text-color);
  margin-bottom: clamp(1.2rem, 3.5vw, 1.8rem); /* より安定したマージン */
  line-height: 1.7;                      /* より読みやすい行間 */
}

.welcome-container p a {
  color: var(--primary-color);
  font-weight: 600;
  text-decoration: none;
  transition: text-decoration 0.2s;
}

.welcome-container p a:hover,
.welcome-container p a:focus { 
  text-decoration: underline; 
  outline: none;
}

/* -----------------------------------------------------------------
   6. Authentication Pages (ログイン・新規登録フォーム)
   -----------------------------------------------------------------
   ログイン・新規登録ページの統一されたスタイリング。
   モバイルファーストでフォームの使いやすさを重視しています。
------------------------------------------------------------------- */

/* ===== 認証ページコンテナ ===== */
.auth-container {
  width: 100%;
  max-width: min(420px, 95vw);           /* レスポンシブ最大幅 */
  margin: clamp(2rem, 5vw, 3rem) auto;   /* より安定したマージン */
  background: var(--surface-color);
  padding: clamp(2rem, 5vw, 3rem) clamp(1.5rem, 4vw, 2.5rem); /* より余裕のあるパディング */
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  border: 1px solid rgba(0, 0, 0, 0.05); /* 微細なボーダーで安定感向上 */
}

/* ===== ページタイトル ===== */
.auth-container .page-title {
  text-align: center;
  font-size: clamp(1.4rem, 4vw, 1.7rem); /* レスポンシブタイトル */
  font-weight: 700;
  margin-bottom: clamp(2rem, 5vw, 2.5rem); /* より安定したマージン */
  color: var(--text-color);
  line-height: 1.2;                       /* 読みやすい行間 */
}

/* ===== フォーム基本構造 ===== */
.auth-container form {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.auth-container .form-group { 
  margin-bottom: clamp(1.2rem, 3.5vw, 1.6rem); /* より一貫したスペーシング */
}

/* ===== ラベルスタイル ===== */
.auth-container label {
  display: block;
  font-weight: 600;
  font-size: clamp(0.9rem, 2.5vw, 0.95rem);
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

/* ===== 入力フィールドスタイル ===== */
.auth-container input {
  width: 100%;
  padding: clamp(12px, 3.5vw, 16px) clamp(16px, 4vw, 20px); /* より余裕のあるパディング */
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-family: var(--font-family);
  transition: border-color 0.18s, box-shadow 0.18s;
  background: #fff;
  margin-bottom: 0.5rem;                  /* フィールド間のスペース確保 */
  
  /* タッチデバイス対応 */
  min-height: 44px;
}

.auth-container input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2.5px rgba(49, 120, 215, 0.11);
}

/* ===== ボタンスタイル ===== */
.auth-container button {
  width: 100%;
  margin-top: 0.7rem;
}

/* ===== フッターテキスト ===== */
.auth-container .form-footer-text {
  text-align: center;
  margin-top: clamp(1.5rem, 4vw, 2rem);   /* より安定したマージン */
  font-size: clamp(0.85rem, 2.5vw, 0.92rem);
  line-height: 1.5;                       /* 読みやすさ向上 */
}

.auth-container .form-footer-text a {
  color: var(--primary-color);
  font-weight: 600;
  text-decoration: none;
  transition: text-decoration 0.2s;
}

.auth-container .form-footer-text a:hover,
.auth-container .form-footer-text a:focus { 
  text-decoration: underline; 
  outline: none;
}

/* ===== メッセージボックス ===== */
.error-message {
  background: #fff5f5;                      /* より柔らかい背景色 */
  border: 1px solid #fbb6ce;
  color: #b91c1c;                           /* より読みやすい文字色 */
  padding: clamp(12px, 3vw, 16px) clamp(16px, 4vw, 20px); /* より安定したパディング */
  border-radius: 8px;                       /* より大きな角丸 */
  margin-bottom: clamp(1.2rem, 3vw, 1.8rem); /* より安定したマージン */
  text-align: center;
  font-weight: 500;
  font-size: clamp(0.9rem, 2.5vw, 0.95rem);
  line-height: 1.5;                         /* 読みやすい行間 */
}

.info-message {
  background: #f0f9ff;                      /* より柔らかい背景色 */
  border: 1px solid #93c5fd;
  color: #1e40af;                           /* より読みやすい文字色 */
  padding: clamp(12px, 3vw, 16px) clamp(16px, 4vw, 20px); /* より安定したパディング */
  border-radius: 8px;                       /* より大きな角丸 */
  margin-bottom: clamp(1.2rem, 3vw, 1.8rem); /* より安定したマージン */
  text-align: center;
  font-weight: 500;
  font-size: clamp(0.9rem, 2.5vw, 0.95rem);
  line-height: 1.5;                         /* 読みやすい行間 */
}

/* ===== サブミットボタン特別スタイル ===== */
.auth-container button[type="submit"] {
  display: inline-block;
  border-radius: var(--border-radius);
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.18s;
  border: 2px solid transparent;
  padding: clamp(10px, 2.5vw, 12px) clamp(18px, 4vw, 22px);
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  min-height: 44px;
}

.auth-container button[type="submit"]:hover,
.auth-container button[type="submit"]:focus {
  background-color: var(--primary-hover-color);
  border-color: var(--primary-hover-color);
  box-shadow: 0 0 0 3px rgba(49, 120, 215, 0.2);
  outline: none;
}

.auth-container button[type="submit"]:active {
  transform: scale(0.98);
}

/* -----------------------------------------------------------------
   7. Dashboard Page (アクションカード レスポンシブ対応)
   -----------------------------------------------------------------
   ダッシュボードページのレイアウト。ユーザーが最初に見るメインページで、
   各機能へのアクセスポイントとなるカードを配置します。
------------------------------------------------------------------- */

/* ===== ダッシュボードヘッダー ===== */
.dashboard-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.dashboard-header {
  text-align: center;
  margin-bottom: clamp(2.5rem, 6vw, 3.5rem); /* より安定したマージン */
  padding: clamp(1rem, 3vw, 2rem) 0;       /* 上下パディング調整 */
}

.dashboard-header .page-title {
  font-size: clamp(1.6rem, 5vw, 2.1rem); /* レスポンシブタイトル */
  font-weight: 700;
  margin-bottom: 0.8rem;                  /* タイトル下のマージン調整 */
  line-height: 1.2;                       /* 読みやすい行間 */
}

.dashboard-header .welcome-message {
  font-size: clamp(1rem, 3vw, 1.13rem);
  color: var(--muted-text-color);
  margin-top: 0.8rem;                     /* より安定したマージン */
  line-height: 1.5;                       /* 読みやすさ向上 */
}

/* ===== アクションカードグリッド ===== */
.action-list {
  display: grid;
  /* レスポンシブグリッド - モバイルファースト */
  grid-template-columns: 1fr;                    /* モバイル: 1列 */
  gap: clamp(1.4rem, 4vw, 2rem);                /* より安定したギャップ */
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* タブレット以上でのグリッド調整 */
@media (min-width: 640px) {
  .action-list {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* タブレット以上: 自動調整 */
  }
}

/* ===== アクションカードスタイル ===== */
.action-card {
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: clamp(1.8rem, 5vw, 2.5rem);    /* より余裕のあるパディング */
  display: flex;
  align-items: flex-start;
  gap: clamp(1.2rem, 4vw, 1.6rem);        /* より安定したギャップ */
  text-decoration: none;
  color: inherit;
  transition: transform 0.16s, box-shadow 0.16s;
  border: 1px solid rgba(0, 0, 0, 0.05);   /* 微細なボーダーで安定感向上 */
  
  /* タッチデバイス対応 */
  min-height: 44px;
}

.action-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 10px 24px rgba(49,120,215,0.09);
}

.action-card:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(49, 120, 215, 0.2);
}

/* モバイル画面での縦スタック */
@media (max-width: 480px) {
  .action-card {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
}

/* ===== カードアイコン ===== */
.card-icon {
  flex-shrink: 0;
  background-color: #f3f8fe;
  color: var(--primary-color);
  width: clamp(45px, 8vw, 50px);        /* レスポンシブサイズ */
  height: clamp(45px, 8vw, 50px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon svg { 
  width: clamp(22px, 5vw, 26px); 
  height: clamp(22px, 5vw, 26px); 
}

/* ===== カードコンテンツ ===== */
.card-content h3 {
  font-size: clamp(1.05rem, 3vw, 1.14rem);
  font-weight: 600;
  margin: 0 0 0.8rem 0;                   /* タイトル下のマージン調整 */
  color: var(--text-color);
  line-height: 1.3;
}

.card-content p {
  font-size: clamp(0.9rem, 2.5vw, 0.97rem);
  color: var(--muted-text-color);
  margin: 0;
  line-height: 1.6;                       /* より読みやすい行間 */
}

/* -----------------------------------------------------------------
   8. List Pages (クイズ・履歴一覧ページ レスポンシブ対応)
   -----------------------------------------------------------------
   作成したクイズ一覧、挑戦履歴一覧などのリストページスタイル。
   モバイルでの表示最適化を重視しています。
------------------------------------------------------------------- */

/* ===== リストページヘッダー ===== */
.list-page-header {
  text-align: center;
  margin-bottom: clamp(2.2rem, 5vw, 3rem); /* より安定したマージン */
  padding: clamp(1rem, 3vw, 2rem) var(--container-padding); /* 上下パディング追加 */
}

.list-page-header .page-title {
  font-size: clamp(1.5rem, 4vw, 2rem);    /* レスポンシブタイトル */
  font-weight: 700;
  margin-bottom: 1rem;                     /* タイトル下のマージン調整 */
  line-height: 1.2;                        /* 読みやすい行間 */
}

.list-page-header .page-description {
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  color: var(--muted-text-color);
  margin-bottom: 2.5rem;                   /* より安定したマージン */
  max-width: min(540px, 90vw);            /* レスポンシブ最大幅 */
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* ===== リストコンテナ ===== */
.quiz-list, .history-list {
  display: flex;
  flex-direction: column;
  gap: clamp(0.8rem, 2vw, 1.1rem);
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* ===== リストアイテム（基本レイアウト） ===== */
.quiz-list-item, .history-list-item {
  background: var(--surface-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: clamp(1.4rem, 4vw, 2rem) clamp(1.8rem, 5vw, 2.5rem); /* より余裕のあるパディング */
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(1.2rem, 4vw, 1.8rem);        /* より安定したギャップ */
  transition: transform 0.16s, box-shadow 0.16s;
  border: 1px solid rgba(0, 0, 0, 0.05);   /* 微細なボーダーで安定感向上 */
}

.quiz-list-item:hover, .history-list-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(49,120,215,0.07);
}

.quiz-list-item:focus-within, .history-list-item:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(49, 120, 215, 0.2);
}

/* ===== モバイル表示の調整 ===== */
@media (max-width: 640px) {
  .quiz-list-item, .history-list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}

/* ===== リストアイテム情報セクション ===== */
.quiz-info, .history-info { 
  flex-grow: 1; 
  min-width: 0;                           /* フレックスアイテムの縮小を許可 */
}

.quiz-title, .history-title {
  font-size: clamp(1.05rem, 3vw, 1.19rem);
  font-weight: 600;
  margin-bottom: 0.8rem;                   /* より安定したマージン */
  line-height: 1.3;
  
  /* 長いタイトルの処理 */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.quiz-meta, .history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem clamp(0.8rem, 2vw, 1.15rem);
  font-size: clamp(0.85rem, 2vw, 0.93rem);
  color: var(--muted-text-color);
  align-items: center;
}

/* ===== アクションボタンエリア ===== */
.quiz-actions { 
  display: flex; 
  gap: clamp(0.6rem, 2vw, 0.8rem); 
  flex-shrink: 0; 
  flex-wrap: wrap;                        /* 小画面でのボタン折り返し */
}

@media (max-width: 640px) {
  .quiz-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ===== 履歴スコアセクション ===== */
.history-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
  min-width: clamp(80px, 15vw, 110px);
}

@media (max-width: 640px) {
  .history-score {
    align-items: flex-start;
    text-align: left;
    width: 100%;
  }
}

.history-score span {
  font-size: clamp(0.75rem, 2vw, 0.84rem);
  color: var(--muted-text-color);
  margin-bottom: 0.18rem;
}

.history-score p {
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  font-weight: 700;
  color: var(--primary-color);
  margin: 0;
  line-height: 1;
}

/* -----------------------------------------------------------------
   9. Generic Form Pages (Quiz Creation, etc.)
------------------------------------------------------------------- */
.form-container {
  background: var(--surface-color);
  padding: clamp(2rem, 5vw, 3rem) clamp(2rem, 5vw, 2.8rem); /* より余裕のあるパディング */
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  border: 1px solid rgba(0, 0, 0, 0.05);   /* 微細なボーダーで安定感向上 */
  margin: clamp(1rem, 3vw, 2rem) auto;     /* センタリング用マージン */
  max-width: min(800px, 95vw);             /* 最大幅制限でレスポンシブ対応 */
}
.form-container .form-description {
  text-align: center;
  color: var(--muted-text-color);
  margin-bottom: clamp(2rem, 4vw, 2.5rem); /* より安定したマージン */
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;                        /* 読みやすい行間 */
  padding: 0 1rem;                         /* 左右のパディングで余白確保 */
}
.form-container form {
  display: flex;
  flex-direction: column;
  gap: clamp(1.2rem, 3vw, 1.8rem);        /* より一貫したギャップ */
}
.form-container .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;                             /* より安定したギャップ */
}
.form-container label {
  font-weight: 600;
  font-size: 0.96rem;
  color: var(--text-color);
}
.form-container input[type="text"],
.form-container input[type="number"],
.form-container select,
.form-container textarea {
  width: 100%;
  padding: clamp(12px, 3vw, 16px) clamp(16px, 4vw, 20px); /* より余裕のあるパディング */
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.18s, box-shadow 0.18s;
  min-height: 44px;                        /* タッチフレンドリー */
}
.form-container select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8794' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
  padding-right: 2.5rem;
}
.form-container input:focus,
.form-container select:focus,
.form-container textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2.5px rgba(49,120,215,0.10);
}
.form-container textarea { resize: vertical; min-height: 110px; }
.form-container .form-text {
  font-size: 0.88rem;                      /* 少し大きめのサイズ */
  color: var(--muted-text-color);
  margin-top: 0.4rem;                      /* より安定したマージン */
  line-height: 1.5;                        /* 読みやすい行間 */
  padding-left: 0.25rem;                   /* 左側に微細なパディング */
}
.form-container button[type="submit"].button {
  width: 100%;
  margin-top: 0.7rem;
  padding: 13px 0;
  font-size: 1.08rem;
}
.form-actions { display: flex; gap: 1rem; justify-content: flex-end; }
.form-actions-split { display: flex; justify-content: space-between; align-items: center; }
.form-divider { border: none; border-top: 1px solid var(--border-color); margin: 1rem 0; }


/* -----------------------------------------------------------------
   10. Solve Quiz Page (UI Enhancement)
------------------------------------------------------------------- */
.solve-quiz-container .page-title,
.form-container .page-title {
  text-align: center;
  font-size: 1.65rem;
  margin-bottom: 1.4rem;
  font-weight: 700; /* Added from section 9 */
}
.question-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.question-card {
  background: var(--surface-color);
  border-radius: var(--border-radius);
  padding: 1.8rem;
  box-shadow: var(--box-shadow);
}
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.65rem;
  margin-bottom: 1.1rem;
}
.question-header h4 { font-size: 1.1rem; color: var(--text-color); }
.question-header span { font-size: 1rem; font-weight: 600; color: var(--primary-color); }
.question-text {
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}
.options-group {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.option-label {
  display: block;
  position: relative;
  cursor: pointer;
  transition: all 0.16s;
}
.option-label input[type="radio"] {
  opacity: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: pointer;
}
.option-label span {
  display: block;
  padding: 1rem 1.2rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--surface-color);
  transition: all 0.15s;
}
.option-label:hover span {
  border-color: var(--primary-hover-color);
  background: #f8fafd;
  box-shadow: 0 5px 10px rgba(49,120,215,0.05);
}
.option-label input[type="radio"]:checked + span {
  background-color: #f3f8fe;
  border-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 600;
  box-shadow: 0 0 0 2.5px rgba(49,120,215,0.08);
}
.answer-input-group input[type="text"],
.answer-input-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.answer-input-group input[type="text"]:focus,
.answer-input-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2.5px rgba(49,120,215,0.08);
}
.answer-input-group textarea {
  resize: vertical;
  min-height: 100px;
}

/* -----------------------------------------------------------------
   11. Quiz Result Page & Detailed Section
------------------------------------------------------------------- */
.result-header {
  text-align: center;
  padding: 2rem;
  background-color: var(--surface-color);
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
  box-shadow: var(--box-shadow);
}
.final-score {
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--primary-color);
}
.result-message { font-size: 1.05rem; color: var(--muted-text-color); }
.result-list, .results-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.result-card, .result-item {
  background: var(--surface-color);
  border-radius: var(--border-radius);
  padding: 1.2rem;
  box-shadow: var(--box-shadow);
  border-left: 5px solid;
  overflow: hidden;
}
.result-card.correct, .result-item.correct { border-left-color: var(--correct-color); }
.result-card.incorrect, .result-item.incorrect { border-left-color: var(--danger-color); }

.result-card .question-title, .result-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
}
.result-indicator, .result-mark {
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.93rem;
  color: #fff;
}
.result-card.correct .result-indicator, .result-item.correct .result-mark { background-color: var(--correct-color); }
.result-card.incorrect .result-indicator, .result-item.incorrect .result-mark { background-color: var(--danger-color); }
.user-answer, .answer-box.your-answer {
  background-color: #fafbfc;
  padding: 1rem;
  border-radius: var(--border-radius);
}
.answer-box.correct-answer { background-color: #eafbee; border: 1px solid #b7e1c6; }
.answer-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-text-color);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}
.answer-text { margin: 0; color: var(--text-color); }
.feedback-box {
  padding: 1.1rem;
  background-color: #f8fafd;
  border-top: 1px solid var(--border-color);
}
.feedback-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-text-color);
  margin-bottom: 0.4rem;
}
.feedback-text { margin: 0; }
.result-actions, .result-actions-final {
  margin-top: 2.2rem;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* -----------------------------------------------------------------
   12. Utilities & Image Previews
------------------------------------------------------------------- */
.no-content-message {
  text-align: center;
  padding: 2.2rem;
  background-color: var(--surface-color);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
}
.no-content-message p { margin-bottom: 1.2rem; color: var(--muted-text-color); }

.image-preview-wrapper {
  width: 100%;
  max-width: 360px; /* Consolidated from 350px and 360px */
  margin: 1.2em auto 0 auto;
  text-align: center;
  display: flex;
  justify-content: center;
}
.image-preview {
  display: block;
  max-width: 100%;
  max-height: 240px;
  width: auto !important; /* Added for consistency */
  height: auto !important; /* Added for consistency */
  border-radius: 8px;
  box-shadow: 0 1px 4px #0002;
  object-fit: contain;
  background: #fff;
  margin: 0 auto;
  border: 1px solid #e1e3e8;
  transition: box-shadow 0.15s, border 0.15s;
}
.image-preview[style*="display: block"] {
  animation: fadeInImg 0.32s ease;
}
@keyframes fadeInImg {
  from { opacity: 0; transform: scale(0.97);}
  to   { opacity: 1; transform: scale(1);}
}


/* -----------------------------------------------------------------
   13. Custom File Input for Image Upload
------------------------------------------------------------------- */
.form-group .file-input-wrapper {
  position: relative;
  width: 100%;
}
.form-group input[type="file"] {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}
.form-group .file-input-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  padding: 2.2rem 1.5rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  background-color: #f8fafd;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s, background-color 0.18s;
}
.form-group .file-input-label:hover {
  border-color: var(--primary-color);
  background-color: #f3f8fe;
}
.file-input-label .icon {
  width: 44px;
  height: 44px;
  color: var(--primary-color);
}
.file-input-label .text {
  font-weight: 600;
  color: var(--text-color);
  font-size: 1.08rem;
}
.file-input-label .subtext {
  font-size: 0.9rem;
  color: var(--muted-text-color);
}
.file-name-display {
  text-align: center;
  margin-top: 0.9rem;
  font-size: 0.94rem;
  color: var(--muted-text-color);
  font-weight: 500;
}

/* -----------------------------------------------------------------
   14. Header Logo & Hamburger Menu
------------------------------------------------------------------- */
.site-logo {
  margin: 0;
  padding: 0;
  font-size: 1.5rem;
}
.site-logo a {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--text-color);
  text-decoration: none;
  transition: opacity 0.18s;
}
.site-logo a:hover { opacity: 0.8; }
.site-logo svg { stroke: var(--primary-color); }

.hamburger-menu {
  display: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 1001;
  position: relative;
  width: 28px;
  height: 28px;
}
.hamburger-menu svg {
  width: 100%;
  height: 100%;
  color: var(--text-color);
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 0.3s, transform 0.3s;
}
.hamburger-menu .icon-close {
  opacity: 0;
  transform: rotate(-90deg);
}

/* -----------------------------------------------------------------
   15. Manual Quiz Creation Page
------------------------------------------------------------------- */
#questionsArea { margin-bottom: 2rem; }
.question-editor-card {
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 10px 10px 10px;
  margin-bottom: 15px;
  position: relative;
  box-shadow: 0 2px 8px rgba(49,120,215,0.03);
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}
.question-editor-card label {
  display: block;
  font-weight: 500;
  margin-bottom: 7px;
  color: #294475;
}
.question-editor-card input[type="text"],
.question-editor-card input[type="number"],
.question-editor-card select {
  display: inline-block;
  width: auto;
  min-width: 140px;
  margin-bottom: 7px;
  margin-right: 10px;
  padding: 7px 11px;
  border-radius: 5px;
  border: 1px solid #bfc5d2;
  font-size: 1rem;
  background: #fff;
}
.question-editor-card input[type="number"] { max-width: 72px; }
.options-area {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0.5rem 0;
  width: 100%;
}
.options-area-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.options-area input[type="text"] {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  max-width: 320px;
  margin-right: 4px;
  margin-bottom: 6px;
}
.mc-btn, .remove-option-btn, .add-option-btn, .delete-question-btn {
  font-weight: 500;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
  box-shadow: 0 1px 4px #0001;
  outline: none;
  vertical-align: middle;
  line-height: 1.1;
}
.remove-option-btn, .mc-btn-remove {
  background: #fff1f1;
  color: #d93025;
  font-size: 0.97rem;
  padding: 6px 12px;
  margin-left: 7px;
}
.remove-option-btn:hover, .mc-btn-remove:hover {
  background: #ffe5e5;
  color: #b0261e;
}
.add-option-btn, .mc-btn-add {
  background: #f0f7ff;
  color: #357abd;
  font-size: 0.97rem;
  padding: 6px 12px;
  margin-left: 7px;
}
.add-option-btn:hover, .mc-btn-add:hover {
  background: #e3f1ff;
  color: #245ba1;
}
.delete-question-btn, .mc-btn-delete {
  background: #fff0f1;
  color: #d93025;
  padding: 7px 18px;
  font-weight: bold;
  font-size: 1rem;
  margin-top: 10px;
  display: block;
  width: fit-content;
}
.delete-question-btn:hover, .mc-btn-delete:hover {
  background: #ffe5e5;
  color: #b0261e;
}
#addQuestionBtn {
  margin-bottom: 2rem;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 26px;
  font-size: 1.05rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.18s;
}
#addQuestionBtn:hover {
  background: var(--primary-hover-color);
}
#manualQuizForm button[type="submit"] {
  width: 100%;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 13px 0;
  font-size: 1.11rem;
  font-weight: 700;
  margin-top: 1.1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.18s;
}
#manualQuizForm button[type="submit"]:hover {
  background: var(--primary-hover-color);
}

/* -----------------------------------------------------------------
   16. Profile & Profile Edit Pages
------------------------------------------------------------------- */
.profile-container, .profile-edit-container {
  margin: 2rem auto;
  padding: 0 1rem;
}
.profile-container { max-width: 800px; }
.profile-edit-container { max-width: 600px; }

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2rem;
  background: var(--surface-color);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(49,120,215,0.06);
  margin-bottom: 1.5rem;
}
.profile-info h1 {
  margin: 0 0 0.5rem 0;
  color: var(--text-color);
  font-size: 1.8rem;
  font-weight: 700;
}
.profile-info .handle {
  color: var(--primary-color);
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
}
.profile-info .join-date {
  color: #a0aec0;
  font-size: 0.9rem;
  margin: 0;
}
.profile-content {
  background: var(--surface-color);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(49,120,215,0.06);
  overflow: hidden;
}
.profile-section {
  padding: 2rem;
  border-bottom: 1px solid var(--border-color);
}
.profile-section:last-child { border-bottom: none; }
.profile-section h3 {
  margin: 0 0 1rem 0;
  color: var(--text-color);
  font-size: 1.17rem;
  font-weight: 600;
}
.bio-content p { margin: 0; line-height: 1.6; color: #394452; }
.no-bio { color: #b6bbc8; font-style: italic; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.4rem;
}
.stat-item {
  text-align: center;
  padding: 1.2rem;
  background: #fafbfc;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}
.stat-number {
  display: block;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.4rem;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--muted-text-color);
  font-weight: 500;
}
.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}
.form-header h1 {
  margin: 0;
  color: var(--text-color);
  font-size: 1.65rem;
  font-weight: 700;
}
.profile-form {
  background: var(--surface-color);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(49,120,215,0.05);
}
.profile-form .form-group { margin-bottom: 1.1rem; } /* Simplified from original */
.profile-form label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-color);
  font-weight: 600;
  font-size: 0.94rem;
}
.required { color: #e23d28; }
.profile-form input, .profile-form textarea { /* Simplified from original */
  width: 100%;
  padding: 0.7rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.14s;
  box-sizing: border-box;
}
.profile-form input:focus, .profile-form textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2.5px rgba(49,120,215,0.07);
}
.profile-form input:disabled {
  background-color: #fafbfc;
  color: #b6bbc8;
  cursor: not-allowed;
}
.help-text {
  display: block;
  font-size: 0.78rem;
  color: #a0aec0;
  margin-top: 0.2rem;
}
.char-counter {
  text-align: right;
  font-size: 0.77rem;
  color: #a0aec0;
  margin-top: 0.18rem;
}
.profile-form .form-actions { margin-top: 1.4rem; } /* Simplified from original */

.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.2rem;
  font-weight: 500;
}
.alert-success {
  background-color: #f2fdf7;
  border: 1px solid #b7e1c6;
  color: #23b26c;
}
.alert-error {
  background-color: #fff1f1;
  border: 1px solid #e23d28;
  color: #e23d28;
}

/* =====================================================================================
   17. Comprehensive Responsive Design (モバイルファースト アプローチ)
   =====================================================================================
   
   モバイルファーストの設計思想に基づき、各ブレークポイントで段階的に
   レイアウトとスタイリングを調整していきます。
   
   ブレークポイント:
   - 480px (xs): 極小画面 (小さいスマホ)
   - 640px (sm): 小画面 (スマホ)  
   - 768px (md): 中画面 (タブレット)
   - 1024px (lg): 大画面 (デスクトップ)
   - 1280px (xl): 特大画面 (大型デスクトップ)
   ===================================================================================== */

/* ===== 極小画面対応 (〜480px) ===== */
@media (max-width: 480px) {
  /* 基本レイアウトの調整 */
  body {
    font-size: 14px;                     /* より小さなフォントサイズ */
  }
  
  /* ヘッダーの最適化 */
  header {
    padding: 1rem var(--container-padding); /* より安定したパディング */
  }
  
  .header-container h1 a {
    font-size: 1.25rem;                  /* コンパクトなロゴサイズ */
    gap: 0.5rem;                         /* より安定したギャップ */
  }
  
  /* メインコンテンツの調整 */
  main {
    padding: clamp(1.5rem, 4vw, 2rem) var(--container-padding); /* より安定したパディング */
  }
  
  /* 認証フォームの最適化 */
  .auth-container {
    margin: clamp(1.5rem, 4vw, 2rem) auto; /* より安定したマージン */
    padding: clamp(1.5rem, 4vw, 2rem) clamp(1.2rem, 3vw, 1.5rem);
  }
  
  .auth-container .page-title {
    font-size: 1.4rem;
    margin-bottom: clamp(1.5rem, 4vw, 2rem); /* より安定したマージン */
  }
  
  /* ボタンサイズの調整 */
  .button, .btn, .button-secondary, .button-danger, .btn-primary, .btn-secondary {
    padding: 14px 18px;                  /* タップしやすいサイズ確保 */
    font-size: 0.9rem;
  }
  
  /* アクションカードの調整 */
  .action-card {
    flex-direction: column;
    text-align: center;
    padding: clamp(1.5rem, 4vw, 2rem);   /* より安定したパディング */
  }
  
  /* フォームコンテナの最適化 */
  .form-container {
    padding: clamp(1.5rem, 4vw, 2rem) clamp(1rem, 3vw, 1.5rem);
    margin: clamp(1rem, 3vw, 1.5rem) var(--container-padding);
  }
  
  /* ウェルカムコンテナの調整 */
  .welcome-container {
    padding: clamp(1.5rem, 4vw, 2rem) var(--container-padding);
  }
  
  /* 画像プレビューの調整 */
  .image-preview-wrapper {
    max-width: 95vw;
  }
  
  .image-preview {
    max-width: 95vw;
    max-height: 50vw;
    border-radius: 6px;
  }
}

/* ===== 小画面対応 (481px〜640px) ===== */
@media (min-width: 481px) and (max-width: 640px) {
  /* アクションカードグリッドの調整 */
  .action-list {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }
  
  /* リストアイテムの最適化 */
  .quiz-list-item, .history-list-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .quiz-actions, .history-score {
    width: 100%;
    margin-top: 1rem;
  }
  
  .history-score {
    align-items: flex-start;
    text-align: left;
  }
}

/* ===== 中画面対応 (641px〜768px) タブレット ===== */
@media (min-width: 641px) and (max-width: 768px) {
  /* グリッドレイアウトの調整 */
  .action-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.4rem;
  }
  
  /* フォームレイアウトの改善 */
  .form-actions {
    flex-direction: row;
    justify-content: space-between;
  }
  
  /* プロファイルページの調整 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== 中〜大画面対応 (769px〜1024px) デスクトップ ===== */
@media (min-width: 769px) and (max-width: 1024px) {
  /* ハンバーガーメニューを非表示 */
  .hamburger-menu {
    display: none;
  }
  
  /* ナビゲーションを表示 */
  header nav {
    display: flex;
  }
  
  /* アクションカードの3列表示 */
  .action-list {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
  
  /* リストアイテムの横並び復帰 */
  .quiz-list-item, .history-list-item {
    flex-direction: row;
    align-items: center;
  }
  
  .quiz-actions, .history-score {
    width: auto;
    margin-top: 0;
  }
  
  .history-score {
    align-items: flex-end;
    text-align: right;
  }
}

/* ===== 大画面対応 (1025px〜1280px) 標準デスクトップ ===== */
@media (min-width: 1025px) and (max-width: 1280px) {
  /* コンテナの最大幅制限 */
  .header-container {
    max-width: 1200px;
  }
  
  main {
    max-width: 1200px;
  }
  
  /* より大きなフォントサイズ */
  body {
    font-size: 16px;
  }
  
  /* アクションカードの最適化 */
  .action-list {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    max-width: 1000px;
  }
}

/* ===== 特大画面対応 (1281px〜) 大型デスクトップ ===== */
@media (min-width: 1281px) {
  /* より大きなコンテナ */
  .header-container, main {
    max-width: 1400px;
  }
  
  /* より大きなフォントサイズ */
  .welcome-container h2 {
    font-size: 2.6rem;
  }
  
  .dashboard-header .page-title {
    font-size: 2.3rem;
  }
  
  /* アクションカードの4列表示 */
  .action-list {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    max-width: 1200px;
  }
}

/* ===== モバイル専用スタイル (768px以下) ===== */
@media (max-width: 768px) {
  /* ハンバーガーメニューの表示 */
  .hamburger-menu { 
    display: block; 
  }
  
  /* モバイルナビゲーション */
  .header-container .main-nav {
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(5px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.26s, visibility 0.26s, transform 0.26s;
  }
  
  .header-container .main-nav a {
    font-size: 1.4rem;
    color: var(--text-color);
    padding: 1rem;                        /* 大きなタップエリア */
    border-radius: var(--border-radius);
    transition: background-color 0.2s;
  }
  
  .header-container .main-nav a:hover,
  .header-container .main-nav a:focus {
    background-color: rgba(49, 120, 215, 0.1);
  }
  
  .header-container .main-nav span a {
    font-weight: bold;
    color: var(--primary-color);
  }
  
  /* モバイルメニューオープン状態 */
  header.mobile-menu-open .main-nav {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  
  header.mobile-menu-open .hamburger-menu .icon-hamburger {
    opacity: 0;
    transform: rotate(90deg);
  }
  
  header.mobile-menu-open .hamburger-menu .icon-close {
    opacity: 1;
    transform: rotate(0deg);
    color: var(--text-color);
  }
  
  /* フォームアクションの調整 */
  .form-actions {
    flex-direction: column;
    gap: 1rem;
  }
  
  .form-actions-split {
    flex-direction: column;
    gap: 0.7rem;
    align-items: stretch;
  }
  
  .form-actions-split .button-danger {
    order: 2;
  }
  
  .form-actions-split .main-actions {
    order: 1;
    width: 100%;
  }
  
  /* プロファイルページの調整 */
  .profile-container, .profile-edit-container {
    margin: 1rem auto;
    padding: 0 var(--container-padding);
  }
  
  .profile-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 1.5rem;
  }
  
  .profile-section {
    padding: 1.5rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .form-header {
    flex-direction: column;
    gap: 0.8rem;
    align-items: stretch;
  }
}

/* ===== 超小画面対応 (600px以下) ===== */
@media (max-width: 600px) {
  /* フォームコンテナの最小パディング */
  .form-container {
    padding: 1rem;
  }
  
  /* 質問エディタカードの調整 */
  .question-editor-card {
    padding: 10px 8px;
  }
  
  .options-area input[type="text"] {
    max-width: 100%;
  }
  
  /* ボタンサイズの最適化 */
  .mc-btn, .remove-option-btn, .add-option-btn, .delete-question-btn {
    padding: 8px 10px;
    font-size: 0.9rem;
  }
  
  /* 画像プレビューの最終調整 */
  .image-preview-wrapper {
    max-width: 100%;
    padding: 0;
  }
  
  .image-preview {
    max-width: 100%;
    max-height: 60vw;
    border-radius: 6px;
  }
}

/* ===== タッチデバイス最適化 ===== */
@media (hover: none) and (pointer: coarse) {
  /* タッチフレンドリーなボタンサイズ */
  .button, .btn, .button-secondary, .button-danger, .btn-primary, .btn-secondary {
    min-height: 48px;                     /* Appleのガイドライン推奨 */
    min-width: 48px;
  }
  
  /* タッチフレンドリーなリンク */
  header nav a {
    min-height: 48px;
    padding: 12px 8px;
  }
  
  /* タッチフレンドリーなアクションカード */
  .action-card {
    min-height: 80px;
  }
}

/* ===== 高解像度ディスプレイ対応 ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* シャープなボーダーとシャドウ */
  .auth-container, .form-container, .action-card, .quiz-list-item, .history-list-item {
    box-shadow: 0 2px 8px rgba(49, 120, 215, 0.08);
  }
  
  /* より鮮明なアイコン */
  .card-icon svg, .hamburger-menu svg {
    stroke-width: 1.5;
  }
}

/* ===== プリント用スタイル ===== */
@media print {
  /* 不要な要素を非表示 */
  header, footer, .hamburger-menu, .quiz-actions, .form-actions {
    display: none;
  }
  
  /* プリント用の色調整 */
  body {
    color: #000;
    background: #fff;
  }
  
  .action-card, .quiz-list-item, .history-list-item {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* =====================================================================================
   Enhanced Grading Page Styling (採点ページ専用スタイル)
   ===================================================================================== */

/* ===== Quiz Grading Process Enhancement ===== */
.grading-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* ===== Score Display Enhancement ===== */
.result-container .result-summary {
  background: linear-gradient(135deg, #f8fafd 0%, #e3f1ff 100%);
  border-radius: 12px;
  padding: clamp(2rem, 5vw, 3rem);
  margin-bottom: 2rem;
  box-shadow: 0 6px 20px rgba(49, 120, 215, 0.08);
  border: 1px solid rgba(49, 120, 215, 0.1);
  position: relative;
  overflow: hidden;
}

.result-container .result-summary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--correct-color));
}

.score-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  margin: 1.5rem 0;
  gap: 0.25rem;
  font-family: 'Inter', sans-serif;
}

.score-value {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  color: var(--primary-color);
  line-height: 1;
  text-shadow: 0 2px 4px rgba(49, 120, 215, 0.1);
}

.score-divider {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 600;
  color: var(--muted-text-color);
  margin: 0 0.25rem;
}

.score-max {
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 700;
  color: var(--muted-text-color);
}

.score-label {
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 600;
  color: var(--muted-text-color);
  margin-left: 0.5rem;
}

/* ===== Enhanced Result Messages ===== */
.result-message {
  text-align: center;
  font-size: clamp(1.1rem, 3vw, 1.25rem);
  font-weight: 600;
  line-height: 1.5;
  padding: 1rem 2rem;
  border-radius: 8px;
  margin-top: 1.5rem;
}

/* Dynamic result message colors based on score */
.result-summary.excellent .result-message {
  background: rgba(35, 178, 108, 0.1);
  color: var(--correct-color);
  border: 1px solid rgba(35, 178, 108, 0.2);
}

.result-summary.good .result-message {
  background: rgba(49, 120, 215, 0.1);
  color: var(--primary-color);
  border: 1px solid rgba(49, 120, 215, 0.2);
}

.result-summary.needs-improvement .result-message {
  background: rgba(255, 193, 7, 0.1);
  color: #b8860b;
  border: 1px solid rgba(255, 193, 7, 0.2);
}

/* ===== Enhanced Result Items ===== */
.results-list .result-item {
  margin-bottom: 1.5rem;
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-left-width: 6px;
  position: relative;
}

.results-list .result-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.results-list .result-item.correct {
  border-left-color: var(--correct-color);
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}

.results-list .result-item.incorrect {
  border-left-color: var(--danger-color);
  background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
}

/* ===== Enhanced Result Item Header ===== */
.result-item-header {
  padding: 1.2rem 1.5rem 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  margin-bottom: 0;
}

.question-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-color);
}

.question-points {
  font-size: 0.95rem;
  color: var(--muted-text-color);
  font-weight: 500;
}

.result-mark {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.result-item.correct .result-mark {
  background: var(--correct-color);
  color: white;
}

.result-item.incorrect .result-mark {
  background: var(--danger-color);
  color: white;
}

/* ===== Enhanced Question Text ===== */
.question-text-result {
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.6);
  margin: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* ===== Enhanced Answer Group ===== */
.answer-group {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.answer-box {
  border-radius: 8px;
  padding: 1.2rem;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.answer-box.your-answer {
  background: linear-gradient(135deg, #f8fafd 0%, #f0f7ff 100%);
  border-color: rgba(49, 120, 215, 0.2);
}

.answer-box.correct-answer {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: rgba(35, 178, 108, 0.3);
}

.answer-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.8rem;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  display: inline-block;
}

.answer-box.your-answer .answer-label {
  background: rgba(49, 120, 215, 0.1);
  color: var(--primary-color);
}

.answer-box.correct-answer .answer-label {
  background: rgba(35, 178, 108, 0.1);
  color: var(--correct-color);
}

.answer-text {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text-color);
  margin: 0;
  font-weight: 500;
}

/* ===== Enhanced Feedback Box ===== */
.feedback-box {
  padding: 1.5rem;
  background: linear-gradient(135deg, #fafbfc 0%, #f3f8fe 100%);
  border-top: 2px solid var(--border-color);
  margin-top: 0;
}

.feedback-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feedback-label::before {
  content: '💡';
  font-size: 1.1rem;
}

.feedback-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-color);
  margin: 0;
}

/* ===== Mobile Responsive Grading Enhancements ===== */
@media (max-width: 640px) {
  .result-container .result-summary {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
  }
  
  .score-display {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
  }
  
  .score-value {
    font-size: 2.5rem;
  }
  
  .score-divider, .score-max, .score-label {
    font-size: 1.2rem;
  }
  
  .answer-group {
    padding: 1rem;
    gap: 0.8rem;
  }
  
  .answer-box {
    padding: 1rem;
  }
  
  .result-item-header {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  
  .result-mark {
    align-self: flex-end;
  }
  
  .question-text-result {
    padding: 1rem;
  }
  
  .feedback-box {
    padding: 1rem;
  }
}

/* ===== Quiz Taking Enhancement (solve-quiz page) ===== */
.form-container.quiz-taking {
  max-width: 900px;
}

.form-container.quiz-taking .page-title {
  background: linear-gradient(135deg, var(--primary-color), #4a90e2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 2rem;
}

.question-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.question-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(49, 120, 215, 0.08);
}

.question-header {
  background: linear-gradient(135deg, #f8fafd 0%, #e3f1ff 100%);
  margin: -1.8rem -1.8rem 1.1rem -1.8rem;
  padding: 1rem 1.8rem;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.form-container.quiz-taking .form-actions {
  margin-top: 3rem;
  text-align: center;
}

.form-container.quiz-taking .button {
  padding: 1rem 3rem;
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color) 0%, #4a90e2 100%);
  border: none;
  box-shadow: 0 4px 16px rgba(49, 120, 215, 0.3);
  transition: all 0.3s ease;
}

.form-container.quiz-taking .button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(49, 120, 215, 0.4);
}

.form-container.quiz-taking .button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(49, 120, 215, 0.4);
}

/* ===== Enhanced Submit Button ===== */
.form-container.quiz-taking .button {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  position: relative;
  overflow: hidden;
}

.form-container.quiz-taking .button .btn-icon {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.form-container.quiz-taking .button:hover .btn-icon {
  transform: scale(1.1);
}

.form-container.quiz-taking .button.loading .btn-text {
  opacity: 0.7;
}

.form-container.quiz-taking .button.loading .btn-icon {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
}

/* ===== Grading Loading Enhancement ===== */
.loading-overlay.grading-mode .loading-content {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafd 100%);
  border: 2px solid rgba(49, 120, 215, 0.1);
}

.loading-overlay.grading-mode .loading-spinner {
  border-top-color: var(--correct-color);
  border-right-color: var(--primary-color);
}

.loading-overlay.grading-mode .loading-text {
  background: linear-gradient(135deg, var(--primary-color), var(--correct-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* =====================================================================================
   Loading States & Spinner Components
   ===================================================================================== */

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-overlay.active {
  display: flex;
}

/* ===== Loading Content Container ===== */
.loading-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  max-width: 90%;
  max-width: min(90%, 400px);
}

/* ===== Loading Spinner ===== */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== Loading Text ===== */
.loading-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-color);
  margin: 0;
}

.loading-subtext {
  font-size: 0.9rem;
  color: var(--muted-text-color);
  margin: 0;
  line-height: 1.4;
}

/* ===== Progress Bar (Optional) ===== */
.loading-progress {
  width: 100%;
  max-width: 300px;
  height: 4px;
  background-color: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.loading-progress-bar {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Indeterminate progress animation */
.loading-progress-bar.indeterminate {
  width: 30%;
  animation: indeterminate 2s infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(300%); }
  100% { transform: translateX(300%); }
}

/* ===== Button Loading States ===== */
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  color: white;
}

.btn.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: inherit;
  border-radius: inherit;
}

/* ===== Form Loading States ===== */
.form-container.loading {
  pointer-events: none;
  opacity: 0.7;
}

.form-container.loading .form-actions .btn:not(.loading) {
  opacity: 0.5;
  pointer-events: none;
}

/* ===== Mobile Responsive Loading ===== */
@media (max-width: 640px) {
  .loading-content {
    padding: 1.5rem;
    gap: 1rem;
  }
  
  .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
  }
  
  .loading-text {
    font-size: 1rem;
  }
  
  .loading-subtext {
    font-size: 0.85rem;
  }
}