:root {
  --bg1: #fff6e9;
  --bg2: #e7f5ff;
  --ink: #4a3b5c;
  --ink-soft: #8a7a9c;
  --card: #ffffff;
  --shadow: 0 6px 0 rgba(74, 59, 92, 0.12);
  --radius: 28px;
  --accent: #ff6b81;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }

body {
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, #fff0f6 45%, var(--bg2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  background: none;
}

/* ふわふわ背景 */
.bg-deco span {
  position: fixed;
  font-size: 48px;
  opacity: 0.35;
  pointer-events: none;
  animation: float 8s ease-in-out infinite;
  z-index: 0;
}
.bg-deco span:nth-child(1) { top: 12%; left: 4%; }
.bg-deco span:nth-child(2) { top: 30%; right: 6%; font-size: 32px; animation-delay: -2s; }
.bg-deco span:nth-child(3) { bottom: 18%; left: 8%; font-size: 64px; animation-delay: -4s; }
.bg-deco span:nth-child(4) { bottom: 8%; right: 10%; animation-delay: -1s; }
.bg-deco span:nth-child(5) { top: 60%; left: 45%; font-size: 28px; animation-delay: -5s; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

header, nav, .settings, main, .voice-warn { position: relative; z-index: 1; }

/* ヘッダー */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  max-width: 960px;
  margin: 0 auto;
  gap: 12px;
}
.logo { display: flex; align-items: center; gap: 8px; text-align: left; }
.logo-icon { font-size: 40px; animation: spin 12s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo-text {
  font-size: clamp(20px, 5vw, 30px);
  background: linear-gradient(90deg, #ff6b81, #ffa94d, #40c057, #4dabf7, #9775fa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stars {
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 20px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.stars.pop { animation: pop .5s; }

/* ことばえらび */
.langs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 8px 16px;
  max-width: 960px;
  margin: 0 auto;
}
.lang-btn {
  background: #fff;
  border-radius: 20px;
  padding: 10px 4px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 4px solid transparent;
  transition: transform .15s;
}
.lang-btn .flag { font-size: 34px; line-height: 1.1; }
.lang-btn .lname { font-size: clamp(12px, 3vw, 16px); }
.lang-btn.active {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, white);
  transform: translateY(-3px) scale(1.04);
}
.lang-btn:active { transform: scale(0.95); }

.settings {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px 0;
  flex-wrap: wrap;
}
.pill {
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px;
  box-shadow: 0 3px 0 rgba(74, 59, 92, 0.12);
  color: var(--ink-soft);
}
.pill:active { transform: scale(0.95); }

.voice-warn {
  max-width: 600px;
  margin: 12px auto 0;
  background: #fff3bf;
  border-radius: 16px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  margin-left: 16px;
  margin-right: 16px;
}
@media (min-width: 632px) { .voice-warn { margin-left: auto; margin-right: auto; } }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

h2.screen-title {
  text-align: center;
  font-size: clamp(24px, 6vw, 34px);
  margin: 8px 0 16px;
}

/* ホーム：カテゴリー */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.cat-card {
  background: var(--c);
  border-radius: var(--radius);
  padding: 18px 8px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.12);
  transition: transform .15s;
  animation: popIn .4s backwards;
}
.cat-card .ic {
  font-size: 56px;
  background: rgba(255,255,255,0.85);
  width: 88px; height: 88px;
  border-radius: 50%;
  display: grid; place-items: center;
  text-shadow: none;
}
.cat-card .ct { font-size: 22px; }
.cat-card:hover { transform: translateY(-4px) rotate(-1deg); }
.cat-card:active { transform: scale(0.94); }

.quiz-card {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 16px;
  background: linear-gradient(90deg, #ffa94d, #ff6b81);
  padding: 18px;
}
.quiz-card .ic { width: 72px; height: 72px; font-size: 44px; }
.quiz-card .ct { font-size: 26px; }

/* ことばカード一覧 */
.back {
  background: #fff;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.back:active { transform: scale(0.95); }

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.word-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 4px solid color-mix(in srgb, var(--c) 45%, white);
  transition: transform .15s;
  animation: popIn .35s backwards;
  min-height: 170px;
  justify-content: center;
}
.word-card:active { transform: scale(0.94); }
.word-card .w { font-size: 20px; text-align: center; line-height: 1.3; }
.word-card .rd { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

.pic { font-size: 64px; line-height: 1; display: grid; place-items: center; }
.swatch {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 4px solid #e9e3f0;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,0.1);
}
.num {
  font-size: 56px;
  color: #fff;
  background: #40c057;
  width: 76px; height: 76px;
  border-radius: 24px;
  display: grid; place-items: center;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,0.12);
}

/* かずの ぶん ならべる え */
.pic.multi {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  font-size: 34px;
  max-width: 130px;
  min-height: 64px;
  align-content: center;
}
.pic.multi.n1 { font-size: 64px; }
.pic.multi.n2 { font-size: 46px; }
.big-card .pic.multi { font-size: 64px; max-width: 280px; }
.big-card .pic.multi.n1 { font-size: 120px; }
.big-card .pic.multi.n2 { font-size: 88px; }
.choice .pic.multi { font-size: 30px; max-width: 100px; }
.choice .pic.multi.n1 { font-size: 64px; }

.alt-title { margin-top: 6px; font-size: 15px; color: var(--ink-soft); }
.memo {
  margin-top: 6px;
  background: #fff9db;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  max-width: 520px;
  text-align: left;
}

/* 大きいカード */
.big-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.big-card {
  flex: 1;
  background: #fff;
  border-radius: 36px;
  box-shadow: 0 10px 0 rgba(74, 59, 92, 0.12);
  border: 6px solid color-mix(in srgb, var(--c) 55%, white);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.big-card .pic { font-size: 120px; cursor: pointer; }
.big-card .swatch { width: 120px; height: 120px; cursor: pointer; }
.big-card .num { width: 130px; height: 130px; font-size: 96px; border-radius: 36px; cursor: pointer; }
.big-card .bounce { animation: bounce .6s; }

.main-speak {
  background: var(--lc);
  color: #fff;
  border-radius: 28px;
  padding: 14px 28px;
  font-size: clamp(26px, 7vw, 40px);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--lc) 70%, black);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  text-align: center;
  line-height: 1.25;
}
.main-speak .spk { font-size: 0.8em; }
.main-speak:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--lc) 70%, black); }
.main-speak.speaking { animation: pulse 1s infinite; }
.big-rd { color: var(--ink-soft); font-size: 18px; font-weight: 500; min-height: 1.2em; }

.lang-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}
.mini-speak {
  border-radius: 20px;
  padding: 10px 8px;
  background: color-mix(in srgb, var(--lc) 15%, white);
  border: 3px solid var(--lc);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.mini-speak .top-line { font-size: 13px; color: var(--ink-soft); }
.mini-speak .mt { font-size: 18px; line-height: 1.3; text-align: center; overflow-wrap: anywhere; }
.mini-speak .mr { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.mini-speak:active { transform: scale(0.95); }
.mini-speak.speaking { animation: pulse 1s infinite; }

.all-btn {
  background: linear-gradient(90deg, #ff6b81, #ffa94d, #4dabf7, #9775fa);
  color: #fff;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 20px;
  box-shadow: var(--shadow);
  margin-top: 6px;
}
.all-btn:active { transform: scale(0.95); }

.arrow {
  background: #fff;
  width: 56px; height: 56px;
  border-radius: 50%;
  font-size: 28px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.arrow:active { transform: scale(0.9); }
.arrow:disabled { opacity: 0.3; }

.dots { display: flex; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.dots span { width: 12px; height: 12px; border-radius: 50%; background: #e3d9ee; }
.dots span.on { background: var(--c); transform: scale(1.3); }

@media (max-width: 520px) {
  .big-wrap { gap: 6px; }
  .arrow { width: 44px; height: 44px; font-size: 22px; }
  .big-card { padding: 18px 10px; }
  .big-card .pic { font-size: 96px; }
}

/* クイズ */
.quiz-box {
  background: #fff;
  border-radius: 36px;
  box-shadow: 0 10px 0 rgba(74, 59, 92, 0.12);
  padding: 24px 16px;
  text-align: center;
}
.quiz-q { font-size: clamp(20px, 5vw, 26px); margin-bottom: 12px; }
.listen-btn {
  background: var(--lc);
  color: #fff;
  font-size: 64px;
  width: 128px; height: 128px;
  border-radius: 50%;
  box-shadow: 0 8px 0 color-mix(in srgb, var(--lc) 70%, black);
  margin-bottom: 20px;
}
.listen-btn:active { transform: translateY(4px); box-shadow: 0 4px 0 color-mix(in srgb, var(--lc) 70%, black); }
.listen-btn.speaking { animation: pulse 1s infinite; }
.choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.choice {
  background: #f8f4fc;
  border-radius: 28px;
  padding: 16px 4px;
  border: 4px solid #ebe2f5;
  display: grid;
  place-items: center;
  min-height: 130px;
  transition: transform .15s;
}
.choice .pic { font-size: 72px; }
.choice:active { transform: scale(0.94); }
.choice.correct { background: #d3f9d8; border-color: #40c057; animation: bounce .6s; }
.choice.wrong { background: #ffe3e3; border-color: #ff8787; animation: shake .5s; }
.quiz-msg { font-size: 26px; min-height: 40px; margin-top: 16px; }
.quiz-answer { font-size: 18px; color: var(--ink-soft); min-height: 26px; }
.next-btn {
  margin-top: 12px;
  background: #40c057;
  color: #fff;
  border-radius: 999px;
  padding: 14px 32px;
  font-size: 24px;
  box-shadow: 0 6px 0 #2f9e44;
}
.next-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #2f9e44; }

/* 紙ふぶき */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti span {
  position: absolute;
  top: -40px;
  font-size: 28px;
  animation: fall 1.6s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.6; }
}

@keyframes popIn { from { transform: scale(0.6); opacity: 0; } }
@keyframes pop { 50% { transform: scale(1.3); } }
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.18) rotate(-4deg); }
  60% { transform: scale(0.95) rotate(3deg); }
}
@keyframes pulse {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  50% { filter: brightness(1.12); transform: scale(1.04); }
}
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
