* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html, body { margin: 0; min-height: 100%; }
html { background: #ffe3ec; }
body {
  font-family: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "BIZ UDPGothic", "Meiryo", sans-serif;
  background: linear-gradient(#fff7d6, #ffe3ec);
  color: #4a3b2a;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.screen { display: none; min-height: 100vh; min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 24px; }
.screen.active { display: flex; }
h1 { font-size: clamp(36px, 9vw, 64px); margin: 0; color: #ff7a59; line-height: 1.2; }
.big-emoji { font-size: clamp(64px, 18vw, 120px); }

.main-btn {
  font: inherit; font-size: clamp(28px, 7vw, 40px); font-weight: bold;
  padding: 16px 48px; border: none; border-radius: 999px;
  background: #ff9f43; color: #fff; box-shadow: 0 6px 0 #d97b1f; cursor: pointer;
}
.main-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #d97b1f; }

#quiz { justify-content: flex-start; }
.top-bar { width: 100%; max-width: 800px; display: flex; justify-content: space-between; font-size: 24px; font-weight: bold; }
.question-box {
  position: relative; width: 100%; max-width: 800px; background: #fff; border-radius: 32px;
  padding: 40px 52px 28px; box-shadow: 0 6px 0 #f3c9a0;
}
#qText { font-size: clamp(26px, 7vw, 56px); font-weight: bold; margin: 0; word-break: keep-all; overflow-wrap: anywhere; }
#qPicture { font-size: clamp(44px, 12vw, 88px); margin-top: 16px; word-break: break-all; }
#qPicture:empty { display: none; }
.speak-btn { position: absolute; top: 8px; right: 8px; font-size: 32px; background: none; border: none; cursor: pointer; }

.choices { width: 100%; max-width: 800px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.choice {
  flex: 1 1 0; min-width: 88px; min-height: clamp(110px, 22vh, 180px);
  font: inherit; font-size: clamp(44px, 12vw, 80px); font-weight: bold;
  border: none; border-radius: 28px; cursor: pointer; color: #fff;
  box-shadow: 0 8px 0 rgba(0,0,0,.18);
}
.choice:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.choice:nth-child(1) { background: #4cb8ff; }
.choice:nth-child(2) { background: #6bd66b; }
.choice:nth-child(3) { background: #b48cff; }
.choice.maru { background: #ff6b6b; }
.choice.batsu { background: #4c8dff; }
.choices.long { flex-direction: column; flex-wrap: nowrap; }
.choices.long .choice { word-break: keep-all; flex: none; width: 100%; min-height: clamp(64px, 11vh, 110px); font-size: clamp(28px, 7vw, 48px); padding: 8px 16px; }
.choice.correct { outline: 8px solid #ffd93d; }
.choice.dim { opacity: .35; }

.feedback {
  position: fixed; inset: 0; background: rgba(255,255,255,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 10;
}
.feedback.hidden { display: none; }
#fbIcon { font-size: min(50vw, 38vh, 320px); font-weight: bold; line-height: 1; animation: pop .4s ease-out; }
#fbText { font-size: min(9vw, 8vh, 60px); font-weight: bold; text-align: center; padding: 0 16px; }
.feedback.ok #fbIcon { color: #ff5a5a; }
.feedback.ng #fbIcon { color: #4c8dff; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

#resultText { font-size: clamp(28px, 7vw, 44px); font-weight: bold; margin: 0; }

/* よこむき の スマホ（たかさが ひくい）では つめて ひょうじ */
@media (max-height: 500px) {
  .screen { gap: 10px; }
  .question-box { padding: 12px 16px; }
  #qText { font-size: 30px; }
  #qPicture { font-size: 40px; margin-top: 4px; }
  .choice { min-height: 90px; font-size: 44px; }
  .choices.long { flex-direction: row; }
  .choices.long .choice { flex: 1 1 0; width: auto; min-height: 90px; font-size: 26px; }
}
/* iPad など おおきい がめん */
@media (min-width: 700px) and (min-height: 700px) {
  #quiz { justify-content: center; }
  .genres { grid-template-columns: repeat(3, 1fr); }
}

/* ジャンル えらび */
.sub { font-size: clamp(24px, 6vw, 36px); font-weight: bold; margin: 0; }
.genres { width: 100%; max-width: 800px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.genre-btn {
  font: inherit; font-weight: bold; font-size: clamp(22px, 5.5vw, 32px); color: #4a3b2a;
  background: #fff; border: none; border-radius: 28px; padding: 16px 8px; cursor: pointer;
  box-shadow: 0 6px 0 #f3c9a0; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.genre-btn .icon { font-size: clamp(44px, 12vw, 72px); line-height: 1.1; }
.genre-btn .count { font-size: 16px; color: #a08a70; }
.genre-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #f3c9a0; }
.genre-btn.all { background: #fff3c4; }
.top-bar { align-items: center; gap: 8px; }
#genreLabel { flex: 1; text-align: center; }
.back-btn { font-size: 28px; background: #fff; border: none; border-radius: 50%; width: 52px; height: 52px; cursor: pointer; box-shadow: 0 3px 0 #f3c9a0; }
.sub-btn { font: inherit; font-size: clamp(20px, 5vw, 28px); font-weight: bold; background: #fff; color: #4a3b2a; border: none; border-radius: 999px; padding: 12px 32px; box-shadow: 0 4px 0 #f3c9a0; cursor: pointer; }
@media (max-height: 500px) {
  .genres { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .genres { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .genre-btn { padding: 8px 4px; font-size: 20px; }
  .genre-btn .icon { font-size: 36px; }
  h1 { font-size: 32px; }
  h1 br { display: none; }
  .sub { font-size: 22px; }
}

/* おうちの かた */
.parent-link { font: inherit; font-size: 15px; background: none; border: none; color: #a08a70; text-decoration: underline; cursor: pointer; padding: 8px; }
#parent { justify-content: flex-start; text-align: left; user-select: text; -webkit-user-select: text; }
.parent { width: 100%; max-width: 800px; background: #fff; border-radius: 24px; padding: 20px; box-shadow: 0 6px 0 #f3c9a0; font-size: 16px; }
.parent h2 { margin: 0 0 8px; color: #ff7a59; }
.parent h3 { margin: 20px 0 8px; font-size: 18px; }
.parent table { width: 100%; border-collapse: collapse; }
.parent td { padding: 4px 6px; white-space: nowrap; }
.parent td:nth-child(3) { width: 100%; }
.bar { height: 12px; background: #f1e6da; border-radius: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: #6bd66b; }
.miss { padding-left: 20px; margin: 0; }
.miss li { margin-bottom: 8px; line-height: 1.5; }
.note { font-size: 14px; color: #8a755c; }
#reportText { width: 100%; height: 160px; font-size: 13px; border: 1px solid #e6d5c3; border-radius: 12px; padding: 8px; font-family: inherit; }
.parent-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.main-btn.small { font-size: 20px; padding: 12px 24px; }
.parent-actions .sub-btn { font-size: 18px; padding: 10px 20px; }
.sub-btn.danger { color: #d64545; }
