* {
  touch-action: manipulation; /*タブレット連打時の拡大防止 */
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100vh;
  font-family: sans-serif;
  background:
    repeating-linear-gradient(135deg, rgba(255, 217, 61, .16) 0 14px, rgba(77, 150, 255, .12) 14px 28px),
    #fff7d8;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 1196px;
  height: 540px;
  margin: 0 auto;
  background: #ffffff;
  border: 4px solid #ffb13d;
  border-radius: 16px;
  box-shadow: 0 10px 0 #d98a1d, 0 18px 34px rgba(80, 48, 0, .18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.game-header {
  height: 56px;
  flex: 0 0 56px;
  padding: 10px 16px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.24) 0 10px, transparent 10px 22px),
    linear-gradient(90deg, #ff6b9d 0%, #ffd93d 52%, #6bcb77 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 4px solid #ef8a1f;
  position: relative;
}

.info {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 10px;
  font-weight: bold;
  flex-wrap: wrap;
}

.info span {
  color: #ffffff;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow:
    0 3px 0 #d45a86,
    2px 0 0 rgba(255,255,255,.18),
    0 0 10px rgba(255,255,255,.42);
}

.sound-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  width: 40px;
  height: 40px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #4D96FF;
  color: #ffffff;
  cursor: pointer;
  font-size: 1.25rem;
  box-shadow: 0 4px 0 #2765c8;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  transition: transform .1s, box-shadow .1s, background .15s;
}

.sound-toggle:hover {
  transform: translateY(-54%);
  box-shadow: 0 6px 0 #2765c8;
}

.sound-toggle:active {
  transform: translateY(-44%);
  box-shadow: 0 2px 0 #2765c8;
}

.sound-toggle.is-off {
  background: #b9b9b9;
  box-shadow: 0 4px 0 #888888;
}

.sound-toggle.sound-off-pop {
  animation:soundTogglePop .5s;
}

@keyframes soundTogglePop {
  0%,100% { transform:translateY(-50%) scale(1); }
  30%     { transform:translateY(-62%) scale(1.16); }
  60%     { transform:translateY(-44%) scale(.96); }
}

.game-main {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #fff9f5;
  overflow: hidden;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange:  #FF6B35;
  --green:   #6BCB77;
  --blue:    #4D96FF;
  --purple:  #C77DFF;
  --red:     #FF4C61;
  --white:   #ffffff;
  --dark:    #2d2d2d;
}

#game-wrapper {
  width: 100%;
  max-width: none;
  height: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 0;
  box-shadow: none;
  font-family: 'Nunito', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
}

canvas#confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

#start-screen {
  background: linear-gradient(145deg, #fce4ff 0%, #d4eeff 55%, #d4ffe4 100%);
  gap: 18px;
  padding: 28px;
}

.floaters {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
  z-index: 0;
}
.floater {
  position: absolute;
  animation: floatUp linear infinite;
  opacity: 0;
}
@keyframes floatUp {
  0%   { transform: translateY(20px) rotate(0deg);  opacity: 0; }
  15%  { opacity: .65; }
  85%  { opacity: .65; }
  100% { transform: translateY(-160px) rotate(25deg); opacity: 0; }
}

.title-card {
  background: var(--white);
  border-radius: 28px;
  padding: 14px 44px;
  box-shadow: 0 8px 0 #c8a0ff;
  text-align: center;
  animation: bobble 2.2s ease-in-out infinite;
  position: relative;
  z-index: 1;
}
@keyframes bobble {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.title-sub { font-size: 1rem; color: var(--purple); font-weight: 900; letter-spacing: 4px; }
.title-main {
  font-family: 'Fredoka One', cursive;
  font-size: 3.4rem; line-height: 1;
  color: var(--orange);
  text-shadow: 0 4px 0 #ffb08a;
  letter-spacing: 2px;
}

.cat-grid {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center; max-width: 820px;
  position: relative;
  z-index: 1;
}
.cat-btn {
  background: var(--white);
  border: none; border-radius: 22px;
  padding: 13px 20px; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  min-width: 112px;
  font-family: inherit;
  transition: transform .12s, box-shadow .12s;
}
.cat-btn .ci { font-size: 2.4rem; }
.cat-btn .cn { font-size: .82rem; font-weight: 900; color: var(--dark); }

.cat-btn[data-cat="animals"]  { background:#e8fff0; box-shadow:0 5px 0 #3da84e; }
.cat-btn[data-cat="food"]     { background:#fff3e6; box-shadow:0 5px 0 #d04a18; }
.cat-btn[data-cat="colors"]   { background:#f3e6ff; box-shadow:0 5px 0 #a050cc; }
.cat-btn[data-cat="numbers"]  { background:#e6f0ff; box-shadow:0 5px 0 #2065c0; }
.cat-btn[data-cat="body"]     { background:#ffe6ee; box-shadow:0 5px 0 #c03055; }
.cat-btn[data-cat="vehicles"] { background:#fffae6; box-shadow:0 5px 0 #b07010; }

.cat-btn:hover  { transform:translateY(-4px); }
.cat-btn:active { transform:translateY(2px); }
.cat-btn[data-cat="animals"]:hover  { box-shadow:0 8px 0 #3da84e; }
.cat-btn[data-cat="food"]:hover     { box-shadow:0 8px 0 #d04a18; }
.cat-btn[data-cat="colors"]:hover   { box-shadow:0 8px 0 #a050cc; }
.cat-btn[data-cat="numbers"]:hover  { box-shadow:0 8px 0 #2065c0; }
.cat-btn[data-cat="body"]:hover     { box-shadow:0 8px 0 #c03055; }
.cat-btn[data-cat="vehicles"]:hover { box-shadow:0 8px 0 #b07010; }

#quiz-screen {
  padding: 14px 28px 16px;
  gap: 12px;
  background:
    linear-gradient(90deg, rgba(255, 107, 157, .13) 0 2px, transparent 2px 28px),
    linear-gradient(0deg, rgba(77, 150, 255, .11) 0 2px, transparent 2px 28px),
    #fff8ec;
}
.qbg-animals,
.qbg-food,
.qbg-colors,
.qbg-numbers,
.qbg-body,
.qbg-vehicles {
  background:
    linear-gradient(90deg, rgba(255, 107, 157, .13) 0 2px, transparent 2px 28px),
    linear-gradient(0deg, rgba(77, 150, 255, .11) 0 2px, transparent 2px 28px),
    linear-gradient(160deg,#fff4d4 0%, #eafff0 48%, #eaf0ff 100%);
}

.qhdr {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
}
.back-btn {
  background: #ffffff; border: 3px solid #9bd7ff;
  border-radius: 50px; padding: 7px 16px;
  font-size: .82rem; font-weight: 900;
  cursor: pointer; font-family: inherit; color: #3877c8;
  box-shadow: 0 4px 0 #72b8e8;
  transition: transform .1s, box-shadow .1s;
  flex-shrink: 0;
}
.back-btn:hover  { transform:translateY(-2px); box-shadow:0 6px 0 #72b8e8; }
.back-btn:active { transform:translateY(2px);  box-shadow:0 2px 0 #72b8e8; }

.prog-wrap { flex:1; display:flex; flex-direction:column; gap:4px; }
.prog-top  { display:flex; justify-content:space-between; align-items:center; }
.prog-lbl  { font-size:.8rem; font-weight:900; color:#8c78b8; }
.prog-bar  {
  height:16px;
  background:#ffffff;
  border:3px solid #f2df9b;
  border-radius:99px;
  overflow:hidden;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.08);
}
.prog-fill {
  height:100%;
  background: linear-gradient(90deg,#6BCB77,#FFD93D,#FF6B35);
  border-radius:99px;
  transition: width .55s cubic-bezier(.34,1.56,.64,1);
}

.score-pill {
  background: #FFE05C; border-radius:50px;
  padding:7px 16px; font-size:.88rem; font-weight:900;
  color:#4a3500; box-shadow:0 4px 0 #d4a000;
  white-space:nowrap; flex-shrink:0;
  border:3px solid #fff0a0;
}

.quiz-body {
  display:flex; gap:18px; width:100%; flex:1; align-items:stretch;
}

.q-panel {
  background:
    linear-gradient(135deg, rgba(255,217,61,.18) 0 12px, transparent 12px 24px),
    #ffffff;
  border:4px solid #9bd7ff;
  border-radius:24px;
  box-shadow: 0 8px 0 #65b6e8;
  flex:1.05;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:12px; padding:18px;
  position:relative; overflow:hidden;
}
.sound-ring {
  position:relative;
  display:flex; align-items:center; justify-content:center;
}
.ring {
  position:absolute;
  border-radius:50%;
  border:3px solid var(--blue);
  opacity:0;
  animation: ringPulse 1.6s ease-out infinite;
}
.ring:nth-child(1){ width:80px;  height:80px;  animation-delay:0s; }
.ring:nth-child(2){ width:110px; height:110px; animation-delay:.4s; }
.ring:nth-child(3){ width:140px; height:140px; animation-delay:.8s; }
@keyframes ringPulse {
  0%   { transform:scale(.6); opacity:.7; }
  100% { transform:scale(1.1); opacity:0; }
}
.ring.paused { animation-play-state: paused; opacity:0; }

.speak-btn {
  width:90px; height:90px; border-radius:50%;
  background: linear-gradient(135deg, #6bcbff, #4d68ff);
  border:5px solid #ffffff; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  font-size:2.55rem;
  box-shadow:0 8px 0 #2d48be, 0 0 0 7px rgba(77,150,255,.2);
  transition:transform .15s, box-shadow .15s;
  position:relative; z-index:1;
  animation: speakerBounce .45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes speakerBounce {
  0%  { transform:scale(0); }
  100%{ transform:scale(1); }
}
.speak-btn:hover  { transform:scale(1.08); box-shadow:0 9px 0 #1a50c0, 0 0 0 6px rgba(77,150,255,.25); }
.speak-btn:active { transform:scale(.95);  box-shadow:0 3px 0 #1a50c0; }
.speak-btn.speaking { background:linear-gradient(135deg,#FF6B9D,#e0406a); box-shadow:0 6px 0 #b02050; }

.q-prompt {
  font-size:1.1rem; font-weight:900; color:#4a3c60; text-align:center;
  margin-top:16px;
}
.q-prompt span { color:var(--blue); }

.sound-off-hint {
  min-height:20px;
  color:#d45a00;
  font-size:.82rem;
  font-weight:900;
  opacity:0;
  transform:translateY(-4px);
  transition:opacity .18s, transform .18s;
}

.sound-off-hint.show {
  opacity:1;
  transform:translateY(0);
}

.speak-btn.sound-off-pop,
.listen-again.sound-off-pop {
  animation:soundOffPop .28s;
}

@keyframes soundOffPop {
  0%,100% { transform:translateX(0); }
  25%     { transform:translateX(-5px); }
  50%     { transform:translateX(5px); }
  75%     { transform:translateX(-3px); }
}

.listen-again {
  background:#fff7cc; border:3px solid #ffd35a;
  border-radius:50px; padding:7px 20px;
  font-size:.82rem; font-weight:900; cursor:pointer;
  font-family:inherit; color:#7b5a00;
  box-shadow:0 4px 0 #d7a832;
  transition:border-color .15s, color .15s, transform .1s;
  margin-top:4px;
}
.listen-again:hover { border-color:#ffb13d; color:#d45a00; transform:scale(1.04); }

.a-panel {
  flex:1.6;
  display:flex; flex-direction:column;
  justify-content:center; gap:14px;
  position:relative;
}

.a-instruction {
  width:100%;
  font-size:1.05rem;
  font-weight:900;
  color:#6d4a86;
  text-align:center;
  text-shadow:0 2px 0 rgba(255,255,255,.75);
}

.ans-grid {
  display:grid; grid-template-columns:1fr 1fr;
  gap:14px;
}

.ans-btn {
  background:var(--white);
  border:3px solid transparent;
  border-radius:22px;
  padding:18px 8px;
  cursor:pointer; font-family:inherit;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:2px;
  box-shadow:0 5px 0 #ddd;
  transition:transform .12s, box-shadow .12s;
  min-height:112px;
}
.ans-btn .a-emoji { font-size:2.75rem; line-height:1; }
.ans-btn .a-hira  { font-size:1.05rem; font-weight:900; color:var(--dark); }

.ans-btn:not(:disabled):hover  { transform:translateY(-4px) scale(1.04); box-shadow:0 9px 0 #ccc; }
.ans-btn:not(:disabled):active { transform:translateY(2px);  box-shadow:0 2px 0 #ccc; }

.ans-btn.correct {
  background:#ffe5e9; border-color:#ff9aad;
  box-shadow:0 5px 0 #e67b90;
  animation:correctBounce .5s cubic-bezier(.34,1.56,.64,1);
}
.ans-btn.correct .a-hira { color:var(--dark); }
.ans-btn.wrong {
  background:#eeeeee; border-color:#cfcfcf;
  box-shadow:0 5px 0 #b8b8b8;
  animation:wrongShake .4s;
}
.ans-btn.wrong .a-hira { color:#555; }
.ans-btn.dim {
  background:#f3f3f3;
  border-color:#dddddd;
  box-shadow:0 5px 0 #cfcfcf;
  opacity:.65;
  cursor:not-allowed;
}

@keyframes correctBounce {
  0%   { transform:scale(.85); }
  60%  { transform:scale(1.1); }
  100% { transform:scale(1); }
}
@keyframes wrongShake {
  0%,100%{ transform:translateX(0); }
  20%    { transform:translateX(-8px); }
  40%    { transform:translateX(8px); }
  60%    { transform:translateX(-5px); }
  80%    { transform:translateX(5px); }
}

.bottom-row {
  display:flex; align-items:center; gap:14px; min-height:40px;
}
.feedback {
  font-size:1rem; font-weight:900;
  color:transparent; transition:color .2s; flex:1;
}
.feedback.ok { color:var(--green); }
.feedback.ng { color:var(--red); }

.next-btn {
  background:var(--orange); color:var(--white);
  border:none; border-radius:50px;
  padding:9px 28px;
  font-family:'Fredoka One',cursive; font-size:1.15rem;
  cursor:pointer; box-shadow:0 5px 0 #c04010;
  opacity:0; pointer-events:none;
  transition:transform .12s, box-shadow .12s;
  white-space:nowrap;
}
.next-btn.show {
  opacity:1; pointer-events:all;
  animation:nextPop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes nextPop {
  0%  { transform:scale(.4) translateY(12px); opacity:0; }
  100%{ transform:scale(1)   translateY(0);   opacity:1; }
}
.next-btn:hover  { transform:translateY(-3px); box-shadow:0 8px 0 #c04010; }
.next-btn:active { transform:translateY(2px);  box-shadow:0 2px 0 #c04010; }

#result-screen {
  background:linear-gradient(140deg,#fef0ff,#fff0f8,#f0fff8);
  gap:14px; padding:28px;
}
.star-row {
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
  max-width:520px;
}
.star {
  font-size:2.8rem;
  animation:starPop .5s cubic-bezier(.34,1.56,.64,1) backwards;
}
.star.on {
  color:#FFD93D;
  text-shadow:0 4px 0 #d4a000;
}
.star.off {
  color:#d8d8d8;
  text-shadow:0 3px 0 #aaaaaa;
}
.star:nth-child(1){ animation-delay:.05s; }
.star:nth-child(2){ animation-delay:.18s; }
.star:nth-child(3){ animation-delay:.31s; }
.star:nth-child(4){ animation-delay:.44s; }
.star:nth-child(5){ animation-delay:.57s; }
@keyframes starPop {
  0%  { transform:scale(0) rotate(-30deg); opacity:0; }
  100%{ transform:scale(1) rotate(0deg);   opacity:1; }
}

.res-title {
  font-family:'Fredoka One',cursive;
  font-size:2.7rem; color:var(--orange);
  text-shadow:0 4px 0 #ffb07a;
  animation:titleIn .5s .1s cubic-bezier(.34,1.56,.64,1) backwards;
}
@keyframes titleIn {
  0%  { transform:translateY(28px); opacity:0; }
  100%{ transform:translateY(0);    opacity:1; }
}

.res-comment { font-size:1.1rem; font-weight:900; color:#555; text-align:center; }

.res-btns { display:flex; gap:14px; flex-wrap:wrap; justify-content:center; }
.r-btn {
  border:none; border-radius:50px;
  padding:12px 28px;
  font-family:'Fredoka One',cursive; font-size:1.1rem;
  cursor:pointer;
  transition:transform .12s, box-shadow .12s;
}
.r-btn:hover  { transform:translateY(-3px); }
.r-btn:active { transform:translateY(2px); }
.r-btn.retry { background:var(--blue);  color:#fff; box-shadow:0 5px 0 #1a58cc; }
.r-btn.home  { background:var(--white); color:var(--dark); box-shadow:0 5px 0 #ddd; }
.r-btn.retry:hover { box-shadow:0 8px 0 #1a58cc; }
.r-btn.home:hover  { box-shadow:0 8px 0 #ddd; }



