: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; }


/* v2: iPhoneを含むスマートフォン学習画面の固定レイアウト。
   カードだけが伸縮し、操作ボタンの位置は表裏で変わらない。 */
body.study-active {
  height: 100vh; /* dvh非対応ブラウザ向け */
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body.study-active .app-container {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
body.study-active .app-content {
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}
body.study-active #studyView {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
body.study-active .app-footer {
  display: none;
}
body.study-active .study-header {
  margin-bottom: 6px;
  flex: 0 0 auto;
}
body.study-active .counter-text {
  margin-bottom: 6px;
  flex: 0 0 auto;
}
body.study-active .progress-bar {
  flex: 0 0 auto;
}
body.study-active .card {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  margin-bottom: 10px;
  padding: 14px 16px;
}
body.study-active .card.is-revealed {
  justify-content: flex-start;
}
body.study-active .card-actions,
body.study-active .nav-controls {
  flex: 0 0 auto;
}
body.study-active .card-actions {
  margin-bottom: 8px;
}
body.study-active .btn-action {
  padding: 11px 7px;
}
body.study-active .nav-controls button {
  padding: 11px 8px;
}
body.study-active .word-header {
  flex: 0 0 auto;
}
body.study-active .word-title {
  font-size: clamp(25px, 7vw, 34px);
  overflow-wrap: anywhere;
}
body.study-active .answer-area:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 10px;
  padding-top: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.study-active .image-box {
  aspect-ratio: auto;
  flex: 1 1 0;
  min-height: 65px;
  width: 100%;
  margin-bottom: 8px;
}
body.study-active .image-box img {
  object-fit: contain;
}
body.study-active .meaning-text {
  flex: 0 0 auto;
  font-size: 17px;
  line-height: 1.3;
  margin-bottom: 7px;
  padding-bottom: 7px;
}
body.study-active .example-box {
  flex: 0 0 auto;
  padding: 9px 12px;
}
body.study-active .example-en {
  font-size: 16px; /* 14px → 16px */
  line-height: 1.35;
}
body.study-active .example-ja {
  font-size: 13px; /* 12px → 13px */
  line-height: 1.35;
}
@media (max-height: 650px) {
  body.study-active .app-container { padding-top: 6px; }
  body.study-active .app-header { padding-bottom: 4px; }
  body.study-active .study-header { margin-bottom: 2px; }
  body.study-active .counter-text { margin-bottom: 3px; }
  body.study-active .card { padding: 8px 12px; margin-bottom: 5px; }
  body.study-active .answer-area:not([hidden]) { margin-top: 5px; padding-top: 5px; }
  body.study-active .image-box { margin-bottom: 4px; min-height: 40px; }
  body.study-active .meaning-text { margin-bottom: 4px; padding-bottom: 4px; }
  body.study-active .example-box { padding: 6px 10px; }
  body.study-active .card-actions { margin-bottom: 5px; }
  body.study-active .btn-action,
  body.study-active .nav-controls button { padding-top: 8px; padding-bottom: 8px; }
}
