* {
  box-sizing: border-box;
}

:root {
  --bg: #f7f4ff;
  --card: #ffffff;
  --text: #1f2433;
  --muted: #6b7280;
  --primary: #7c4dff;
  --primary-dark: #5b2fe0;
  --secondary: #f0eaff;
  --accent: #ffcb57;
  --green: #1fa87a;
  --red: #e05252;
  --shadow: 0 18px 45px rgba(70, 42, 120, 0.14);
  --radius: 24px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 77, 255, 0.16), transparent 32rem),
    radial-gradient(circle at top right, rgba(255, 203, 87, 0.22), transparent 25rem),
    var(--bg);
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.hero {
  background: linear-gradient(135deg, #ffffff 0%, #f0eaff 52%, #fff7dd 100%);
  border-radius: 32px;
  padding: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "行 食 大";
  position: absolute;
  right: 22px;
  bottom: -18px;
  font-size: 82px;
  font-weight: 900;
  color: rgba(124, 77, 255, 0.10);
  letter-spacing: 0.05em;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 74px);
  line-height: 0.95;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
}

.hero-text {
  max-width: 830px;
  margin: 20px 0 0;
  color: #4a5162;
  line-height: 1.7;
  position: relative;
  z-index: 1;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  position: relative;
  z-index: 1;
}

.score-card {
  min-width: 118px;
  background: var(--card);
  border-radius: 22px;
  padding: 16px 14px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(70, 42, 120, 0.1);
}

.score-card span {
  display: block;
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
}

.score-card small {
  color: var(--muted);
}

button {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 15px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  font-family: inherit;
}

button:hover {
  transform: translateY(-1px);
}

.primary {
  color: white;
  background: var(--primary);
  box-shadow: 0 10px 20px rgba(124, 77, 255, 0.25);
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  color: var(--primary);
  background: var(--secondary);
}

.small {
  padding: 9px 14px;
  font-size: 13px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 4px;
  margin: 12px 0;
  backdrop-filter: blur(10px);
}

.tab {
  white-space: nowrap;
  background: rgba(255,255,255,.86);
  color: var(--muted);
  border: 1px solid rgba(124,77,255,.13);
}

.tab.active {
  background: var(--primary);
  color: white;
}

.lesson-card {
  background: rgba(255,255,255,.96);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(70, 42, 120, 0.08);
  padding: 24px;
  margin: 18px 0;
  border: 1px solid rgba(124,77,255,.08);
}

.section-title {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-title h2,
.lesson-card h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 36px);
}

.section-title p,
.lesson-card p {
  color: var(--muted);
  line-height: 1.65;
  margin: 8px 0 0;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #fff7dd;
  color: #8a5c00;
  font-weight: 900;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
}

.word-card {
  background: #fdfcff;
  border: 1px solid #e5dcff;
  border-radius: 18px;
  padding: 15px;
  text-align: left;
  min-height: 142px;
  display: grid;
  align-content: center;
  gap: 4px;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.word-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124,77,255,.45);
  box-shadow: 0 10px 24px rgba(70,42,120,.09);
}

.jp {
  font-size: 29px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--text);
}

.dictionary {
  color: #8a77b2;
  font-weight: 800;
  font-size: 14px;
}

.romaji {
  color: var(--primary);
  font-weight: 900;
  font-size: 16px;
}

.meaning {
  color: var(--muted);
  font-weight: 700;
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
}

.pattern-card {
  background: #fdfcff;
  border: 1px solid #e5dcff;
  border-radius: 18px;
  padding: 15px;
  text-align: left;
}

.pattern-label {
  display: inline-block;
  color: #8a5c00;
  background: #fff7dd;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 10px;
}

.sentence-list {
  display: grid;
  gap: 12px;
}

.sentence-card {
  background: #fdfcff;
  border: 1px solid #e5dcff;
  border-radius: 18px;
  padding: 16px;
  text-align: left;
}

.sentence-card .jp {
  font-size: 25px;
  margin-bottom: 6px;
}

.practice-panel {
  background: linear-gradient(180deg, #fdfcff, #ffffff);
  border: 1px solid #e5dcff;
  border-radius: 28px;
  padding: 26px;
  text-align: center;
}

.practice-word {
  font-size: clamp(48px, 13vw, 96px);
  font-weight: 900;
  line-height: 1.1;
}

.practice-romaji {
  color: var(--primary);
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 900;
  margin-top: 10px;
}

.practice-meaning {
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
  margin-top: 6px;
}

.practice-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.quiz-box {
  background: linear-gradient(180deg, #fdfcff, #ffffff);
  border: 1px solid #e5dcff;
  border-radius: 24px;
  padding: 18px;
}

.quiz-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
  flex-wrap: wrap;
}

.question-word {
  font-size: clamp(44px, 15vw, 108px);
  font-weight: 900;
  text-align: center;
  padding: 26px 0;
  word-break: keep-all;
}

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

.answer {
  background: var(--secondary);
  color: var(--text);
  border-radius: 18px;
  padding: 16px;
  font-size: 17px;
}

.answer.correct {
  background: rgba(31,168,122,.16);
  color: var(--green);
}

.answer.wrong {
  background: rgba(224,82,82,.15);
  color: var(--red);
}

.feedback {
  min-height: 28px;
  font-weight: 900;
}

.feedback.ok {
  color: var(--green);
}

.feedback.bad {
  color: var(--red);
}

.quiz-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
}

.completion {
  background: linear-gradient(135deg, #7c4dff, #ad8fff);
  color: #fff;
}

.completion p {
  color: rgba(255,255,255,.92);
}

.next-step {
  font-weight: 800;
}

footer {
  text-align: center;
  color: var(--muted);
  padding: 24px 0 12px;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
  }

  .hero,
  .lesson-card {
    border-radius: 22px;
    padding: 18px;
  }

  .hero-top {
    align-items: stretch;
  }

  .score-card {
    min-width: 94px;
    padding: 12px 10px;
  }

  .word-grid,
  .pattern-grid {
    grid-template-columns: 1fr;
  }

  .answers {
    grid-template-columns: 1fr;
  }

  .tabs {
    padding-left: 0;
    padding-right: 0;
  }

  .jp {
    font-size: 26px;
  }
}
