:root {
  color-scheme: light;
  --ink: #241840;
  --muted: #635878;
  --purple: #6940c7;
  --line: #eae3f4;
  --display: "Outfit", "Avenir Next", "Trebuchet MS", sans-serif;
  --body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #fffafd 0, #fff 360px);
  font-family: var(--body);
  line-height: 1.6;
}

button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
svg { width: 1.15rem; height: 1.15rem; flex: none; }

.skip-link {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 20;
  padding: .65rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgb(105 64 199 / 12%);
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border-radius: .8rem;
  background: linear-gradient(135deg, #7a4dd1, #e26a9d);
  color: white;
  font-family: var(--body);
  font-size: 1.25rem;
}

nav { display: flex; gap: clamp(.8rem, 3vw, 2rem); }
nav a { color: var(--muted); font-weight: 700; text-decoration: none; }
nav a:hover { color: var(--purple); }

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr);
  gap: clamp(1.5rem, 5vw, 4.5rem);
  align-items: center;
  padding: clamp(3rem, 8vw, 6.5rem) 0 clamp(2.5rem, 6vw, 5rem);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0 0 .8rem;
  color: var(--purple);
  font-family: var(--display);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--display); line-height: 1.08; }
h1 {
  max-width: 11ch;
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 5.6rem);
  letter-spacing: -.055em;
}
h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.3rem); letter-spacing: -.04em; }

.hero-lead {
  max-width: 38rem;
  margin: 1.35rem 0 2rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.hero-art {
  min-height: clamp(250px, 34vw, 420px);
  border: 1px solid #eadff5;
  border-radius: 2rem;
  background: url("assets/fuji-sakura.webp") center / cover, url("assets/fuji-sakura.svg") center / cover;
  box-shadow: 0 24px 60px rgb(82 47 133 / 18%);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 3rem;
  padding: .75rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}
.button.primary { background: var(--purple); color: white; box-shadow: 0 12px 28px rgb(105 64 199 / 25%); }
.button.primary:hover { background: #5932ad; }
.button.secondary { border-color: #d9cdf0; background: white; color: var(--purple); }
.button.secondary:hover { border-color: var(--purple); }

.collections, .play-area { padding: clamp(2.5rem, 6vw, 5rem) 0; }
.section-heading { max-width: 720px; }
.section-heading > p:last-child, .play-subtitle { color: var(--muted); }

.genre-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.genre-card {
  min-height: 220px;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  background: white;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 30px rgb(70 45 110 / 6%);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.genre-card:hover, .genre-card[aria-pressed="true"] {
  border-color: #bda5ea;
  box-shadow: 0 18px 38px rgb(105 64 199 / 14%);
  transform: translateY(-4px);
}
.genre-card[aria-pressed="true"] { outline: 3px solid rgb(105 64 199 / 18%); }
.genre-icon {
  display: grid;
  width: 3.1rem;
  height: 3.1rem;
  margin-bottom: 1rem;
  place-items: center;
  border-radius: 1rem;
  background: #f0e8ff;
  color: var(--purple);
}
.genre-icon svg { width: 1.7rem; height: 1.7rem; }
.genre-card strong { display: block; font-family: var(--display); font-size: 1.1rem; line-height: 1.2; }
.genre-card span { display: block; margin-top: .55rem; color: var(--muted); font-size: .9rem; }
.genre-count { color: var(--purple) !important; font-weight: 800; }
.load-status { color: var(--muted); }
.load-status[hidden] { display: none; }

.play-area {
  margin-bottom: clamp(2rem, 6vw, 5rem);
  padding-inline: clamp(1rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: linear-gradient(180deg, #fcfaff, white);
  box-shadow: 0 24px 70px rgb(70 45 110 / 9%);
}

.play-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}
.mode-switch {
  display: flex;
  padding: .3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
}
.mode-switch button {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .65rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.mode-switch button[aria-pressed="true"] { background: var(--purple); color: white; }

.flashcards, .quiz { margin-top: 2rem; }
.card-tools, .quiz-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-tools label { font-weight: 800; }
.card-tools select {
  min-width: min(320px, 100%);
  padding: .7rem .9rem;
  border: 1px solid #d9cdf0;
  border-radius: .8rem;
  background: white;
  color: var(--ink);
}
.text-button {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem .75rem;
  border: 0;
  border-radius: 999px;
  background: #f0e8ff;
  color: var(--purple);
  font-weight: 800;
}

.word-card, .quiz-card {
  margin-top: 1rem;
  padding: clamp(1.4rem, 5vw, 3rem);
  border: 1px solid #eadff5;
  border-radius: 1.7rem;
  background: radial-gradient(circle at 85% 10%, #ffe4ef 0, transparent 30%), linear-gradient(145deg, white, #fbf8ff);
  text-align: center;
}
.card-top, .quiz-top { color: var(--muted); font-weight: 700; }
.card-top { display: flex; justify-content: space-between; gap: 1rem; }
.meaning { margin: 1.5rem 0 .25rem; color: var(--purple); font-family: var(--display); font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; }
.romaji { margin: 0; color: var(--muted); font-size: 1.1rem; }
.kana { margin: .7rem 0 .2rem; font-family: var(--body); font-size: clamp(3.4rem, 11vw, 7rem); letter-spacing: .04em; }
.kanji { min-height: 2.4rem; margin: 0; font-family: var(--body); font-size: clamp(1.6rem, 4vw, 2.5rem); font-weight: 700; }
.word-details {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 2rem 0 0;
}
.word-details dt { color: var(--muted); font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.word-details dd { margin: .2rem 0 0; font-weight: 800; }
.card-navigation {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}
.card-navigation button {
  padding: .8rem 1.2rem;
  border: 1px solid #d9cdf0;
  border-radius: 999px;
  background: white;
  color: var(--purple);
  font-weight: 800;
}

.quiz-top { justify-content: space-between; }
.quiz-label { margin: 1rem 0 .3rem; color: var(--purple); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.quiz-meaning { margin: 0 0 2rem; font-size: clamp(2rem, 5vw, 3.6rem); }
.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.choice {
  min-height: 130px;
  padding: 1rem;
  border: 2px solid #e4d9f4;
  border-radius: 1.2rem;
  background: white;
  color: var(--ink);
}
.choice:hover:not(:disabled) { border-color: #bda5ea; transform: translateY(-2px); }
.choice .choice-kana { display: block; font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; }
.choice .choice-detail { display: block; margin-top: .35rem; color: var(--muted); }
.choice.correct { border-color: #2e9e62; background: #eaf8ef; }
.choice.incorrect { border-color: #d9546d; background: #fff0f3; }
.feedback { min-height: 3.2rem; margin: 1.4rem auto .5rem; font-weight: 800; }
.next-question { margin-top: .5rem; }
.next-question[hidden] { display: none; }

.learning-links {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.learning-links h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
.learning-links p { color: var(--muted); }
.learning-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  color: var(--muted);
  font-size: .92rem;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .genre-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .genre-card { min-height: 190px; }
  .play-heading, .learning-links { align-items: start; grid-template-columns: 1fr; flex-direction: column; }
}

@media (max-width: 620px) {
  .site-header { align-items: flex-start; }
  nav { gap: .75rem; font-size: .92rem; }
  .brand span:last-child { display: none; }
  .genre-grid, .choices { grid-template-columns: 1fr; }
  .genre-card { min-height: auto; }
  .mode-switch { width: 100%; }
  .mode-switch button { flex: 1; justify-content: center; }
  .card-tools select { width: 100%; }
  .word-details { gap: 1rem; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .genre-card, .choice { transition: none; }
}
