/* ============ えいたんごクエスト ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg1: #7ec8ff;
  --bg2: #d8f3ff;
  --card: #ffffff;
  --ink: #35404f;
  --accent: #ff8a3d;
  --accent2: #ffb03d;
  --good: #35c46f;
  --bad: #ff6b81;
  --lock: #b9c4d0;
  --shadow: 0 6px 0 rgba(53, 64, 79, .12);
}

html, body { height: 100%; }
body {
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDGothic", "Yu Gothic", "Meiryo", sans-serif;
  background: linear-gradient(180deg, var(--bg1), var(--bg2) 60%, #fff6e3);
  color: var(--ink);
  overflow: hidden;
  user-select: none;
}

.screen {
  display: none;
  position: fixed; inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: block; }

/* ---------- ホーム ---------- */
.home-wrap {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px 20px;
  text-align: center;
}
.mascot { font-size: 84px; filter: drop-shadow(0 8px 6px rgba(0,0,0,.15)); }
.bounce { animation: bounce 2.4s ease-in-out infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-14px) rotate(3deg); }
}
.app-title {
  font-size: 44px; line-height: 1.15; letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 4px 0 rgba(53,64,79,.25), 0 0 18px rgba(255,255,255,.5);
  -webkit-text-stroke: 2px #4a90d9;
}
.app-sub { font-size: 15px; color: #4a6a8a; font-weight: bold; }
.home-stats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.stat-chip {
  background: #fff; border-radius: 999px; padding: 8px 16px;
  font-weight: bold; font-size: 16px; box-shadow: var(--shadow);
}
.xp-bar {
  width: min(320px, 80vw); height: 14px; border-radius: 999px;
  background: rgba(255,255,255,.7); overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.08);
}
.xp-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ffd34d, #ff8a3d); transition: width .6s; }

.big-btn {
  width: min(340px, 86vw);
  border: none; border-radius: 22px;
  padding: 18px 20px; font-size: 21px; font-weight: bold;
  font-family: inherit; color: #fff; cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,.18);
  transition: transform .08s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn-adventure { background: linear-gradient(180deg, #ffa94d, #ff7b2e); }
.btn-dex { background: linear-gradient(180deg, #63c8ff, #3e97e8); }
.small-btn {
  border: none; background: rgba(255,255,255,.85); border-radius: 999px;
  padding: 8px 18px; font-size: 14px; font-weight: bold; font-family: inherit;
  color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
}

/* ---------- トップバー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,.88); backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.topbar-title { font-weight: bold; font-size: 17px; flex: 1; text-align: center; }
.topbar-stars { font-weight: bold; font-size: 15px; }
.back-btn, .quit-btn {
  border: none; background: #eef3f8; border-radius: 12px;
  padding: 8px 14px; font-size: 14px; font-weight: bold; font-family: inherit;
  color: var(--ink); cursor: pointer;
}

/* ---------- マップ ---------- */
.map-list {
  max-width: 560px; margin: 0 auto; padding: 18px 16px 60px;
  display: flex; flex-direction: column; gap: 12px;
}
.stage-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 20px; padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer; border: 3px solid transparent;
  transition: transform .08s;
}
.stage-card:active { transform: scale(.98); }
.stage-card.cleared { border-color: #ffd34d; }
.stage-card.locked { background: #e9edf2; cursor: default; opacity: .75; }
.stage-num {
  flex-shrink: 0;
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #63c8ff, #3e97e8);
  color: #fff; font-weight: bold; font-size: 19px;
  box-shadow: 0 3px 0 rgba(0,0,0,.15);
}
.stage-card.locked .stage-num { background: var(--lock); }
.stage-card.cleared .stage-num { background: linear-gradient(180deg, #ffd34d, #ff9a2e); }
.stage-info { flex: 1; min-width: 0; }
.stage-name { font-weight: bold; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-meta { font-size: 12px; color: #8a97a5; margin-top: 3px; }
.stage-stars { font-size: 17px; letter-spacing: 1px; flex-shrink: 0; }
.stage-stars .off { opacity: .22; }

/* ---------- クイズ ---------- */
#screen-quiz { display: none; flex-direction: column; }
#screen-quiz.active { display: flex; }
.quiz-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
}
.progress-track {
  flex: 1; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,.75); overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.08);
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #6fe08d, #35c46f);
  transition: width .4s;
}
.combo-badge { min-width: 64px; text-align: center; font-weight: bold; font-size: 15px; color: #ff7b2e; }

.quiz-body {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 6px 16px 30px;
  max-width: 560px; margin: 0 auto; width: 100%;
}
.q-type-label {
  background: #fff; border-radius: 999px; padding: 6px 18px;
  font-weight: bold; font-size: 14px; color: #4a6a8a; box-shadow: var(--shadow);
}
.q-image {
  width: min(340px, 82vw); border-radius: 18px;
  box-shadow: 0 8px 20px rgba(0,0,0,.15);
  background: #fff;
}
.q-word {
  font-size: 40px; font-weight: bold; color: var(--ink);
  display: flex; align-items: center; gap: 12px; text-align: center;
  flex-wrap: wrap; justify-content: center;
}
.q-mean {
  font-size: 30px; font-weight: bold; text-align: center;
  background: #fff; padding: 18px 26px; border-radius: 18px; box-shadow: var(--shadow);
}
.speak-btn {
  border: none; background: linear-gradient(180deg, #63c8ff, #3e97e8);
  color: #fff; border-radius: 50%; width: 52px; height: 52px;
  font-size: 24px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.15);
  transition: transform .08s;
}
.speak-btn:active { transform: scale(.92); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.choices.word-choices { grid-template-columns: 1fr; max-width: 380px; }
.choice-btn {
  border: none; border-radius: 18px; padding: 16px 12px;
  background: var(--card); font-family: inherit;
  font-size: 20px; font-weight: bold; color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .08s;
}
.choice-btn:active { transform: translateY(3px); }
.choice-btn.correct { background: var(--good); color: #fff; animation: pop .35s; }
.choice-btn.wrong { background: var(--bad); color: #fff; animation: shake .4s; }
.choice-btn:disabled { cursor: default; }
.choice-img { padding: 8px; }
.choice-img img { width: 100%; border-radius: 12px; display: block; pointer-events: none; }
.choice-img.correct { outline: 5px solid var(--good); background: var(--good); }
.choice-img.wrong { outline: 5px solid var(--bad); background: var(--bad); }

@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}

/* スペルならべ */
.spell-slots { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; min-height: 56px; }
.spell-slot {
  width: 44px; height: 52px; border-radius: 12px;
  background: rgba(255,255,255,.7);
  border: 3px dashed #b9cbdc;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: bold;
}
.spell-slot.filled { background: #fff; border: 3px solid #63c8ff; }
.spell-tiles { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.spell-tile {
  width: 50px; height: 56px; border: none; border-radius: 14px;
  background: linear-gradient(180deg, #ffd34d, #ffb03d);
  font-size: 26px; font-weight: bold; font-family: inherit; color: #6b4a12;
  box-shadow: 0 4px 0 rgba(0,0,0,.16); cursor: pointer;
  transition: transform .08s;
}
.spell-tile:active { transform: translateY(3px); }
.spell-tile.used { visibility: hidden; }
.spell-del {
  border: none; border-radius: 14px; padding: 10px 22px;
  background: #eef3f8; font-family: inherit; font-weight: bold; font-size: 15px;
  color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
}

/* フィードバック */
.feedback-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: rgba(53,64,79,.35);
  padding: 20px;
}
.feedback-overlay.show { display: flex; }
.feedback-card {
  background: #fff; border-radius: 24px; padding: 22px 26px;
  max-width: 380px; width: 100%;
  text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.25);
  animation: popin .3s;
}
@keyframes popin { from { transform: scale(.7); opacity: 0; } }
.fb-mark { font-size: 46px; }
.fb-title { font-size: 26px; font-weight: bold; margin: 4px 0 10px; }
.fb-title.good { color: var(--good); }
.fb-title.bad { color: var(--bad); }
.fb-img { width: 200px; border-radius: 14px; margin-bottom: 8px; }
.fb-word { font-size: 26px; font-weight: bold; }
.fb-mean { font-size: 17px; color: #5a6b7d; margin-top: 2px; }
.fb-next {
  margin-top: 14px; border: none; border-radius: 16px;
  background: linear-gradient(180deg, #ffa94d, #ff7b2e); color: #fff;
  padding: 13px 40px; font-size: 18px; font-weight: bold; font-family: inherit;
  cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.18);
}

/* ---------- けっか ---------- */
.result-wrap {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 30px 20px; text-align: center;
}
.result-stars { font-size: 58px; letter-spacing: 6px; }
.result-stars .off { opacity: .2; }
.result-title { font-size: 32px; font-weight: bold; color: #ff7b2e; }
.result-score { font-size: 19px; font-weight: bold; }
.result-xp {
  background: #fff; border-radius: 999px; padding: 8px 22px;
  font-weight: bold; box-shadow: var(--shadow);
}
.star-anim { display: inline-block; animation: starpop .5s backwards; }
.star-anim:nth-child(2) { animation-delay: .25s; }
.star-anim:nth-child(3) { animation-delay: .5s; }
@keyframes starpop { from { transform: scale(0) rotate(-120deg); } 70% { transform: scale(1.4); } }

/* ---------- ずかん ---------- */
.dex-list { max-width: 720px; margin: 0 auto; padding: 16px 14px 60px; }
.dex-cat { font-size: 15px; font-weight: bold; color: #4a6a8a; margin: 18px 4px 8px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; }
.dex-card {
  background: var(--card); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; text-align: center;
  transition: transform .08s;
}
.dex-card:active { transform: scale(.95); }
.dex-card img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.dex-card .dex-word {
  font-size: 11px; font-weight: bold; padding: 4px 4px 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-card.unknown { background: #dfe6ee; box-shadow: none; }
.dex-card.unknown .dex-q {
  aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #aeb9c6;
}

/* カード詳細 */
.modal-bg {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(30,40,55,.5); padding: 18px;
}
.modal-bg.show { display: flex; }
.card-detail {
  background: #fff; border-radius: 24px; padding: 20px;
  max-width: 400px; width: 100%; max-height: 88vh; overflow-y: auto;
  text-align: center; animation: popin .25s;
}
.card-detail img { width: 100%; border-radius: 16px; }
.cd-word { font-size: 30px; font-weight: bold; margin-top: 10px; }
.cd-ipa { color: #8a97a5; font-size: 14px; }
.cd-mean { font-size: 19px; font-weight: bold; color: #ff7b2e; margin: 6px 0; }
.cd-ex { background: #f2f7fc; border-radius: 14px; padding: 12px; font-size: 15px; margin-top: 8px; }
.cd-exja { color: #5a6b7d; font-size: 13px; margin-top: 4px; }

/* confetti */
#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  width: 100vw; height: 100vh;
}

@media (min-width: 600px) {
  .app-title { font-size: 54px; }
  .choices { max-width: 520px; }
}
