/* ===================================================
   数独問題集 - メインスタイルシート
   テーマ：和モダン（墨色 × 和紙ベージュ）
=================================================== */

/* ── CSS変数 ────────────────────────────────────── */
:root {
  --ink:        #1a1a2e;
  --ink-soft:   #3d3d5c;
  --paper:      #f7f3ed;
  --paper-dark: #ede8e0;
  --line:       #c8bfb0;
  --line-dark:  #8a7f72;

  --easy:   #4a7c59;
  --medium: #c07a2e;
  --hard:   #8b2e2e;

  --accent:     #2e5f8b;
  --accent-light: #e8f0f8;

  --radius: 4px;
  --shadow: 0 2px 12px rgba(26,26,46,0.08);
  --font-serif: 'Noto Serif JP', 'Shippori Mincho', serif;
}

/* ── リセット & ベース ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-serif);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── ヘッダー ────────────────────────────────────── */
.site-header {
  background: var(--ink);
  color: var(--paper);
  padding: 0 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--paper);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.welcome-msg { font-size: 0.85rem; opacity: 0.8; }

.nav-link {
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(247,243,237,0.3);
  border-radius: var(--radius);
  transition: background 0.2s;
}

.nav-link:hover { background: rgba(247,243,237,0.15); }
.nav-link--login { background: var(--accent); border-color: var(--accent); }

/* ── メインコンテンツ ─────────────────────────────── */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── フッター ────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--line-dark);
}

/* ── ボタン ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.98); }

.btn--primary { background: var(--ink); color: var(--paper); }
.btn--secondary { background: var(--paper-dark); color: var(--ink); border: 1px solid var(--line); }
.btn--ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn--full { width: 100%; justify-content: center; }

/* ── バッジ ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 2px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.badge--easy   { background: #e6f2ea; color: var(--easy); }
.badge--medium { background: #fdf0e0; color: var(--medium); }
.badge--hard   { background: #fde8e8; color: var(--hard); }

/* ====================================================
   トップページ
==================================================== */
.hero {
  text-align: center;
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.5rem;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--line-dark);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
}

/* 難易度カード */
.difficulty-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.difficulty-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.4rem 1.6rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.difficulty-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 20px rgba(26,26,46,0.12);
}

.difficulty-card--easy   { border-left: 4px solid var(--easy); }
.difficulty-card--medium { border-left: 4px solid var(--medium); }
.difficulty-card--hard   { border-left: 4px solid var(--hard); }

.card-icon {
  font-size: 1.4rem;
  min-width: 2rem;
  text-align: center;
  color: var(--line-dark);
}

.card-body { flex: 1; }

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 0.15rem;
}

.card-desc { font-size: 0.85rem; color: var(--ink-soft); }
.card-note { font-size: 0.78rem; color: var(--line-dark); margin-top: 0.1rem; }

.card-arrow { font-size: 1.2rem; color: var(--line-dark); }

/* ====================================================
   問題表示ページ
==================================================== */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 2rem;
}

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 0.8rem; }

/* 横並びに適したサイズ */
/* .problems-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
} */

/* 縦並びに適したサイズ */
.problems-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 480px;   /* 横幅が広すぎるので制限 */
  margin: 0 auto;
}

/* problems-grid側でサイズ制御したのでコメントアウト
@media (max-width: 700px) {
  .problems-grid { grid-template-columns: 1fr; }
} */

.problem-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.problem-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.8rem;
}

.problem-number { font-size: 1rem; font-weight: 700; letter-spacing: 0.08em; }
.problem-id { font-size: 0.78rem; color: var(--line-dark); }

/* ── 数独グリッド ────────────────────────────────── */
.sudoku-grid {
  border-collapse: collapse;
  width: 100%;
  aspect-ratio: 1;
  table-layout: fixed;
}

.sudoku-grid td.cell {
  border: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-serif);
  width: 11.1%;      /* 9列均等 */
  height: 2.8rem;    /* 高さを固定 */
  min-height: 2.8rem;
  cursor: default;
  user-select: none;
}

/* 3×3ブロックの太い境界線 */
.sudoku-grid td.cell--border-right {
  border-right: 2px solid var(--ink) !important;
}
.sudoku-grid td.cell--border-bottom {
  border-bottom: 2px solid var(--ink) !important;
}

/* 外枠 */
.sudoku-grid { border: 2px solid var(--ink) !important; }

.cell--given { background: var(--paper); color: var(--ink); }
.cell--empty { background: white; color: transparent; }

/* 解答グリッド */
.cell--answer-filled {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
}

.print-note {
  margin-top: 1.5rem;
  font-size: 0.83rem;
  color: var(--line-dark);
  text-align: center;
}
.print-note a { color: var(--accent); text-decoration: underline; }

/* ====================================================
   ログインページ
==================================================== */
.page-login {
  background: var(--paper-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-wrapper { width: 100%; padding: 1rem; }

.login-card {
  max-width: 380px;
  margin: 0 auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}

.login-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  margin-bottom: 0.3rem;
}

.login-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--line-dark);
  margin-bottom: 1.8rem;
}

.login-form { display: flex; flex-direction: column; gap: 1.2rem; }

.form-group { display: flex; flex-direction: column; gap: 0.3rem; }

.form-label { font-size: 0.85rem; font-weight: 600; letter-spacing: 0.05em; }

.form-input {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: var(--accent); }

.login-back {
  text-align: center;
  margin-top: 1.2rem;
  font-size: 0.82rem;
  color: var(--line-dark);
}
.login-back a { color: var(--accent); }

/* ── アラート ─────────────────────────────────────── */
.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.alert--error { background: #fde8e8; color: var(--hard); border: 1px solid #f8c0c0; }

/* ====================================================
   マイページ
==================================================== */
.page-heading { margin-bottom: 2rem; }
.page-title { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.1em; }
.page-user { font-size: 0.85rem; color: var(--line-dark); margin-top: 0.2rem; }

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.9rem;
}

.history-table th, .history-table td {
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.history-table th {
  background: var(--paper-dark);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--accent-light); }

.empty-state {
  text-align: center;
  padding: 3rem;
  background: white;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--line-dark);
}
.empty-state .btn { margin-top: 1rem; }

.page-actions { margin-top: 1.5rem; }
