/* ─── Google Fonts ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;600;700&family=Noto+Sans+JP:wght@400;700;900&display=swap');

/* ─── Reset / Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:    #C8922A;
  --gold-lt: #FFD95A;
  --red:     #C62828;
  --blue:    #1565C0;
  --bg:      #FFFDF5;
  --surface: #FFFFFF;
  --text:    #2C1810;
  --muted:   #7B6B5A;
  --radius:  16px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, #8B0000 0%, #C8922A 60%, #1565C0 100%);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.site-logo {
  font-size: 1.5rem;
  font-weight: 900;
  color: #FFD95A;
  text-decoration: none;
  white-space: nowrap;
  padding: 12px 0;
  text-shadow: 1px 1px 4px rgba(0,0,0,.4);
}

.site-logo .logo-sub {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  color: rgba(255,255,255,.85);
  letter-spacing: .05em;
  font-family: 'Sarabun', sans-serif;
}

.site-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,.85);
  font-size: 0.7rem;
  transition: background .2s, color .2s;
  line-height: 1.3;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,.2);
  color: #FFD95A;
}

.nav-icon { font-size: 1.3rem; }

/* ─── Voice Warning Banner ────────────────────────────────────────────────── */
.voice-warning {
  display: none;
  background: #FFF3CD;
  border-bottom: 2px solid #FFC107;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: #856404;
  align-items: center;
  gap: 8px;
  justify-content: center;
  text-align: center;
}

/* ─── Main ────────────────────────────────────────────────────────────────── */
main { max-width: 1000px; margin: 0 auto; padding: 16px; }

/* ─── Category Tabs ───────────────────────────────────────────────────────── */
.tabs-wrapper {
  position: relative;
  margin-bottom: 20px;
}

.scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.95);
  border: 2px solid #ddd;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  transition: opacity .2s, box-shadow .2s;
}

.scroll-arrow:hover { box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.scroll-arrow-left  { left:  0; }
.scroll-arrow-right { right: 0; }
.scroll-arrow.hidden { opacity: 0; pointer-events: none; }

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 44px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}

.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  scroll-snap-align: start;
}

.cat-tab:hover {
  border-color: var(--tab-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

.cat-tab.active {
  background: var(--tab-color);
  border-color: var(--tab-color);
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.tab-icon  { font-size: 1.4rem; }
.tab-label { font-size: 0.7rem; font-weight: 700; }
.tab-th    { font-size: 0.55rem; opacity: .7; font-family: 'Sarabun', sans-serif; }

/* ─── Quiz Start Button ───────────────────────────────────────────────────── */
.quiz-start-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

#startQuizBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--gold), #e8a830);
  color: white;
  border: none;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(200,146,42,.35);
  transition: transform .15s, box-shadow .15s;
  font-family: 'Noto Sans JP', sans-serif;
}

#startQuizBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(200,146,42,.45);
}

/* ─── Word Grid ───────────────────────────────────────────────────────────── */
#wordGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

/* ─── Word Card ───────────────────────────────────────────────────────────── */
.word-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  animation: fadeUp .4s both;
  position: relative;
  overflow: hidden;
}

.word-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-color);
  border-radius: 2px 2px 0 0;
}

.word-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,.14);
  border-color: var(--card-color);
}

.word-card.speaking {
  border-color: var(--card-color);
  background: color-mix(in srgb, var(--card-color) 10%, white);
  transform: scale(1.03);
}

.card-emoji { font-size: 2.4rem; line-height: 1; }

.card-th {
  font-family: 'Sarabun', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--card-color, #333);
  letter-spacing: .02em;
  text-align: center;
  line-height: 1.3;
}

.card-rom {
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  font-weight: 600;
}

.card-ja {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.card-speaker {
  font-size: 1rem;
  margin-top: 4px;
  opacity: .4;
  transition: opacity .2s;
}

.word-card:hover .card-speaker { opacity: .9; }

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

/* ─── Quiz Section ────────────────────────────────────────────────────────── */
#quizSection {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

.quiz-progress {
  text-align: right;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.quiz-card {
  text-align: center;
  padding: 20px 0;
}

.quiz-emoji { font-size: 4rem; line-height: 1; margin-bottom: 8px; }

.quiz-ja {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 500px;
  margin: 0 auto;
}

.quiz-choice {
  padding: 14px 10px;
  border: 2px solid #DDD;
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: border-color .15s, background .15s, transform .1s;
}

.quiz-choice:hover:not(:disabled) {
  border-color: var(--gold);
  background: #FFF8E7;
  transform: translateY(-2px);
}

.quiz-choice:disabled { cursor: default; }

.qc-th  {
  font-family: 'Sarabun', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.qc-rom {
  font-size: 0.7rem;
  color: #888;
}

.quiz-choice.correct {
  border-color: #4CAF50;
  background: #E8F5E9;
}

.quiz-choice.wrong {
  border-color: #F44336;
  background: #FFEBEE;
}

.quiz-feedback {
  margin-top: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 30px;
  display: none;
}

.quiz-feedback.ok { background: #E8F5E9; color: #2E7D32; }
.quiz-feedback.ng { background: #FFF3CD; color: #856404; }

/* ─── Quiz Result ─────────────────────────────────────────────────────────── */
.quiz-result { text-align: center; padding: 24px 0; }
.result-stars { font-size: 2.5rem; margin-bottom: 8px; }
.quiz-result h2 { font-size: 1.4rem; font-weight: 900; margin-bottom: 8px; }
.result-score { font-size: 2rem; font-weight: 900; color: var(--gold); }
.result-pct   { font-size: 1.1rem; color: var(--muted); margin-bottom: 20px; }

.btn-retry,
.btn-back {
  display: inline-block;
  margin: 6px;
  padding: 12px 28px;
  border-radius: 30px;
  border: none;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}

.btn-retry {
  background: linear-gradient(135deg, var(--gold), #e8a830);
  color: white;
  box-shadow: 0 4px 12px rgba(200,146,42,.3);
}

.btn-back {
  background: #F5F5F5;
  color: var(--text);
}

.btn-retry:hover, .btn-back:hover { transform: translateY(-2px); }

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 40px;
}

.site-footer a { color: var(--gold); text-decoration: none; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* ナビが5項目になったのでモバイルは小さめに */
  .nav-link  { padding: 6px 6px; font-size: 0.6rem; }
  .nav-icon  { font-size: 1.1rem; }
}

@media (max-width: 480px) {
  .site-logo { font-size: 1.1rem; }
  .nav-link  { padding: 5px 5px; font-size: 0.58rem; }
  .nav-icon  { font-size: 1rem; }
  #wordGrid  { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .card-th   { font-size: 1.1rem; }
  .quiz-choices { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
  /* 極小画面：ナビアイコンのみ表示 */
  .nav-link span:not(.nav-icon) { display: none; }
  .nav-link { padding: 8px 8px; }
}
