:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-sub: #475569;
  --border-color: #e2e8f0;
  --accent-gold: #ca8a04;
  --accent-green: #16a34a;
  --radius: 16px;
  --max-width: 520px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.app-container {
  width: 100%;
  max-width: var(--max-width);
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px;
}

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

.sub-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: 1px;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 800;
}

.app-header h1 span {
  color: var(--primary-color);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  padding: 12px 20px;
  font-size: 15px;
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-main);
  padding: 12px 20px;
  font-size: 15px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  padding: 8px 12px;
  font-size: 14px;
}

.app-content {
  flex: 1;
  margin-top: 16px;
}

.hero-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.hero-banner h2 {
  font-size: 18px;
  color: #1e3a8a;
  margin-bottom: 6px;
}

.hero-banner p {
  font-size: 13px;
  color: #1e40af;
  line-height: 1.5;
}

.home-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.home-actions button {
  flex: 1;
}

.badge {
  background: #ef4444;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  margin-left: 4px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.section-title h2 {
  font-size: 16px;
}

.section-title span {
  font-size: 12px;
  color: var(--text-sub);
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.set-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.set-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.set-card .set-num {
  font-weight: 800;
  font-size: 16px;
  color: var(--primary-color);
}

.set-card .set-count {
  font-size: 12px;
  color: var(--text-sub);
}

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

.set-badge {
  background: #dbeafe;
  color: #1e40af;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
}

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  width: 0%;
  transition: width 0.3s ease;
}

.counter-text {
  text-align: right;
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 12px;
}

/* カードデザイン（中央配置・余白調整） */
.card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  margin-bottom: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card:hover {
  border-color: var(--primary-color);
}

.word-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.word-title {
  font-size: 34px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  flex: 1;
  text-align: center;
}

.btn-sound {
  background: #eff6ff;
  color: var(--primary-color);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  white-space: nowrap;
}

.answer-area {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #f1f5f9;
  animation: fadeIn 0.3s ease;
  width: 100%;
}

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

.image-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f1f5f9;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-sub);
  font-size: 13px;
  gap: 8px;
}

.placeholder-icon {
  font-size: 32px;
}

.meaning-text {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-color);
  text-align: left;
}

.example-box {
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 10px;
  border-left: 4px solid var(--primary-color);
  text-align: left;
}

.example-tag {
  font-size: 10px;
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.example-en {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 4px;
  font-weight: 500;
}

.example-ja {
  font-size: 12px;
  color: var(--text-sub);
}

.card-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-action {
  flex: 1;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
}

.btn-fav {
  background: #fef08a;
  color: #713f12;
  border: 1px solid #fde047;
}

.btn-fav:hover {
  background: #fde047;
}

.btn-known {
  background: #bbf7d0;
  color: #14532d;
  border: 1px solid #86efac;
}

.btn-known:hover {
  background: #86efac;
}

.nav-controls {
  display: flex;
  gap: 10px;
}

.nav-controls button {
  flex: 1;
}

.app-footer {
  text-align: center;
  padding: 16px 0;
  font-size: 12px;
  color: var(--text-sub);
  margin-top: auto;
}
/* SET 2～5 remain locked during the 20-word pilot */
.set-disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.5); }
.set-disabled:hover { transform: none; }
[hidden] { display:none !important; }

/* 英文例文: 学習対象の語形だけ黒色の太字で表示する */
.example-en strong.target-word {
  color: #000000;
  font-weight: 800;
}


/* MOBILE ONE-SCREEN STUDY FIX (2026-11-27)
   学習画面に限り、縦の余白を調整して回答表示後も4ボタンを残す。
   画像は必ず全体表示(object-fit: contain)。データ・操作は変更しない。 */
@media (max-width: 600px) {
  body.study-mode {
    height: 100vh; /* 古いブラウザのフォールバック */
    height: 100dvh; /* iPhone Safariのアドレスバー変化にも追従 */
    min-height: 0;
    overflow: hidden;
  }
  body.study-mode .app-container {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    overflow: hidden;
  }
  body.study-mode .app-header {
    flex-shrink: 0;
    padding-bottom: 6px;
  }
  body.study-mode .app-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin-top: 6px;
  }
  body.study-mode #studyView:not([hidden]) {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
  }
  body.study-mode .study-header {
    flex-shrink: 0;
    margin-bottom: 6px;
  }
  body.study-mode .progress-bar {
    flex-shrink: 0;
    margin-bottom: 3px;
  }
  body.study-mode .counter-text {
    flex-shrink: 0;
    margin-bottom: 6px;
  }
  body.study-mode #flashCard {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 10px 12px;
    margin-bottom: 8px;
    justify-content: flex-start;
    border-radius: 14px;
  }
  /* 単語だけの1ページ目でも、ボタン位置がイメージ表示ページとそろうように
     カードを同じ縦領域まで広げ、単語は中央付近に配置する。 */
  body.study-mode #flashCard:not(.is-revealed) {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 16px;
    justify-content: center;
  }
  body.study-mode #flashCard .word-header {
    flex: 0 0 auto;
    min-height: 44px;
  }
  body.study-mode #flashCard .word-title {
    font-size: 34px;
  }
  body.study-mode #flashCard .answer-area:not([hidden]) {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    margin-top: 8px;
    padding-top: 8px;
    overflow: hidden;
  }
  body.study-mode .image-box {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    aspect-ratio: auto;
    margin: 0;
    border-radius: 9px;
    background: transparent;
  }
  body.study-mode .image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  body.study-mode .meaning-text {
    flex: 0 0 auto;
    font-size: 18px;
    margin: 0;
    padding-bottom: 4px;
    line-height: 1.25;
  }
  body.study-mode .example-box {
    flex: 0 0 auto;
    padding: 7px 9px;
    border-radius: 8px;
  }
  body.study-mode .example-tag {
    margin-bottom: 2px;
  }
  body.study-mode .example-en {
    font-size: 13px;
    line-height: 1.3;
    margin-bottom: 2px;
  }
  body.study-mode .example-ja {
    font-size: 11.5px;
    line-height: 1.3;
  }
  body.study-mode .card-actions {
    flex: 0 0 auto;
    gap: 10px;
    margin-bottom: 8px;
  }
  body.study-mode .btn-action {
    min-height: 56px;
    padding: 12px 8px;
    font-size: 16px;
  }
  body.study-mode .nav-controls {
    flex: 0 0 auto;
    gap: 10px;
  }
  body.study-mode .nav-controls button {
    min-height: 56px;
    padding: 12px 8px;
    font-size: 16px;
  }
  body.study-mode .app-footer {
    display: none;
  }
}

/* 小さい画面でも、操作ボタンを見失わないようさらに余白を圧縮する */
@media (max-width: 600px) and (max-height: 700px) {
  body.study-mode .app-header h1 { font-size: 17px; }
  body.study-mode .sub-title { font-size: 10px; }
  body.study-mode .study-header { margin-bottom: 3px; }
  body.study-mode .counter-text { margin-bottom: 3px; }
  body.study-mode #flashCard { padding: 6px 10px; margin-bottom: 4px; }
  body.study-mode #flashCard:not(.is-revealed) { padding: 16px 12px; }
  body.study-mode #flashCard .word-header { min-height: 38px; }
  body.study-mode #flashCard .word-title { font-size: 29px; }
  body.study-mode #flashCard .answer-area:not([hidden]) { margin-top: 5px; padding-top: 5px; gap: 4px; }
  body.study-mode .meaning-text { font-size: 16px; }
  body.study-mode .example-box { padding: 5px 7px; }
  body.study-mode .example-en { font-size: 12px; }
  body.study-mode .example-ja { font-size: 11px; }
  body.study-mode .card-actions { gap: 8px; margin-bottom: 5px; }
  body.study-mode .nav-controls { gap: 8px; }
  body.study-mode .btn-action,
  body.study-mode .nav-controls button { min-height: 50px; padding: 10px 6px; font-size: 15px; }
}

/* タップ直後のカード高さのアニメーションで画像が一瞬潰れないようにする */
@media (max-width: 600px) {
  body.study-mode #flashCard {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
}
