* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation; /*タブレット連打時の拡大防止 */
}
html {
  margin: 0;
  height: 100%;
}
body {
  margin: 0;
  height: 100vh;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
  background: #f2f2f2;
  display: flex;
  justify-content: center;
  align-items: center;
}
.container {
  margin: 0 auto;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
}
.game-header {
  height: 50px;
  flex: 0 0 50px;
  align-items: center;
}
.info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: bold;
  flex-wrap: wrap;
}
.game-main {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
}
:root {
  --wood:#8a5a34;
  --paper:#fff7e6;
  --red:#e8543d;
  --red-dark:#c93f2c;
  --gold:#f2b705;
  --teal:#2f9c95;
  --indigo:#2b3a67;
  --ink:#3a2317;
}
.bg-scene {
  position:absolute;
  inset:0;
  z-index:0;
}
.bg-scene svg {
  width:100%;
  height:100%;
  display:block;
}
.bg-sun {
  animation:sun-pulse 4s ease-in-out infinite;
  transform-origin:1300px 180px;
}
@keyframes sun-pulse {
  0%,100% {
    transform:scale(1);
  }
  50% {
    transform:scale(1.06);
  }
}
.bg-cloud {
  animation:cloud-drift 22s linear infinite;
}
.bg-cloud.c2 {
  animation-duration:28s;
  animation-delay:-6s;
}
@keyframes cloud-drift {
  0% {
    transform:translateX(-40px);
  }
  50% {
    transform:translateX(40px);
  }
  100% {
    transform:translateX(-40px);
  }
}
.bg-bird {
  animation:bird-bob 2.4s ease-in-out infinite;
}
.bg-bird.b2 {
  animation-delay:-1s;
}
.petals {
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  overflow:hidden;
}
.petal {
  position:absolute;
  top:-30px;
  width:14px;
  height:14px;
  background:#ffb7c9;
  border-radius:70% 0 70% 0;
  opacity:.85;
  animation:petal-fall linear infinite;
}
@keyframes petal-fall {
  0% {
    transform:translateY(-20px) translateX(0) rotate(0deg);
  }
  50% {
    transform:translateY(280px) translateX(20px) rotate(180deg);
  }
  100% {
    transform:translateY(580px) translateX(-14px) rotate(360deg);
  }
}
.screen {
  position:absolute;
  inset:0;
  z-index:2;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:22px 28px;
  opacity:0;
  pointer-events:none;
  transform:scale(.98);
  transition:opacity .32s ease, transform .32s ease;
}
.screen.active {
  opacity:1;
  pointer-events:auto;
  transform:scale(1);
}
.kamishibai-frame {
  position:relative;
  background:var(--wood);
  border-radius:22px;
  padding:10px;
  box-shadow:0 10px 24px rgba(0,0,0,.25), inset 0 0 0 3px rgba(0,0,0,.15);
}
.kamishibai-frame::before {
  content:"";
  position:absolute;
  left:14px;
  right:14px;
  top:-14px;
  height:20px;
  background:var(--red-dark);
  border-radius:10px 10px 0 0;
}
.kamishibai-inner {
  background:var(--paper);
  border-radius:16px;
  padding:18px 22px;
  display:flex;
  flex-direction:column;
  align-items:center;
  position:relative;
}
.start-frame {
  width:min(720px,92%);
}
.title {
  margin:4px 0 6px;
  font-size:44px;
  line-height:1.25;
  color:var(--ink);
  text-align:center;
  text-shadow:2px 2px 0 var(--gold);
  letter-spacing:2px;
}
.subtitle {
  margin:0 0 18px;
  font-size:19px;
  color:var(--indigo);
  text-align:center;
}
.emoji-row {
  font-size:34px;
  margin-bottom:10px;
  letter-spacing:6px;
}
.game-main .btn {
  border:none;
  cursor:pointer;
  font-family:inherit;
  font-weight:700;
  border-radius:50px;
  transition:transform .12s ease, box-shadow .12s ease, filter .12s ease;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}
.game-main .btn:active {
  transform:translateY(3px) scale(.97);
}
.big-btn {
  font-size:26px;
  padding:18px 48px;
  color:#fff;
}
.game-main .btn-primary {
  background:linear-gradient(180deg,#ff8a5c,var(--red));
  box-shadow:0 8px 0 var(--red-dark), 0 12px 20px rgba(0,0,0,.25);
}
.game-main .btn-primary:active {
  box-shadow:0 3px 0 var(--red-dark);
}
.game-main .btn-secondary {
  background:linear-gradient(180deg,#4bc4bb,var(--teal));
  box-shadow:0 8px 0 #1f6e68, 0 12px 20px rgba(0,0,0,.2);
}
.game-main .btn-secondary:active {
  box-shadow:0 3px 0 #1f6e68;
}
.quiz-frame {
  width:min(1080px,100%);
  flex-shrink:0;
}
.quiz-frame .kamishibai-inner {
  padding:10px 12px;
}
.panels {
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
  width:100%;
}
.panel {
  position:relative;
  height:220px;
  border-radius:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:34px;
  letter-spacing:2px;
  border:0;
  box-shadow:none;
  animation:panel-slide-in 450ms ease-out both;
}
.panel:nth-child(2) {
  animation-delay:180ms;
}
.panel:nth-child(3) {
  animation-delay:360ms;
}
.panel:nth-child(4) {
  animation-delay:540ms;
}
@keyframes panel-slide-in {
  from {
    opacity:0;
    transform:translateX(24px);
  }
  to {
    opacity:1;
    transform:translateX(0);
  }
}
.panel img {
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  border-radius:14px;
}
.panel-badge {
  position:absolute;
  top:6px;
  left:6px;
  width:26px;
  height:26px;
  border-radius:50%;
  background:#fff;
  color:var(--ink);
  font-size:15px;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 2px 4px rgba(0,0,0,.25);
}
.question-label {
  margin:auto 0 8px;
  font-size:24px;
  color:var(--ink);
  font-weight:700;
  text-align:center;
}
.choices {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  flex-shrink:0;
  width:min(680px,96%);
}
.choice-btn {
  background:#fff;
  border:3px solid var(--indigo);
  color:var(--indigo);
  font-size:20px;
  line-height:1.3;
  font-weight:700;
  padding:9px 10px;
  border-radius:18px;
  box-shadow:0 6px 0 rgba(43,58,103,.35);
}
.choice-btn:active {
  box-shadow:0 2px 0 rgba(43,58,103,.35);
}
.choice-btn.correct {
  background:#dff7e0;
  border-color:#2e9e46;
  color:#1d6e2c;
}
.choice-btn.wrong {
  background:#ffe0dc;
  border-color:var(--red-dark);
  color:var(--red-dark);
}
.choice-btn[disabled] {
  pointer-events:none;
  opacity:.9;
}
.answer-overlay {
  position:absolute;
  inset:0;
  z-index:40;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  background:#281e1447;
}
.answer-overlay[hidden] {
  display:none;
}
.answer-feedback {
  max-width:100%;
  padding:25px 45px;
  border-radius:30px;
  background:#fff;
  color:var(--ink);
  text-align:center;
  overflow-wrap:anywhere;
  box-shadow:0 14px 25px #0004;
}
.answer-feedback span, .answer-feedback strong {
  display:block;
}
.answer-feedback span {
  font-size:60px;
}
.answer-feedback strong {
  font-size:39px;
}
.answer-feedback p {
  font-size:20px;
  font-weight:800;
}
.answer-feedback.good strong {
  color:#2fb768;
}
.answer-feedback.bad strong {
  color:#d9534f;
}
.result-frame {
  width:min(680px,92%);
}
.result-face {
  font-size:64px;
  margin-bottom:4px;
}
.result-score {
  font-size:30px;
  font-weight:700;
  color:var(--ink);
  margin-bottom:6px;
  text-align:center;
}
.result-msg {
  font-size:20px;
  color:var(--indigo);
  margin-bottom:18px;
  text-align:center;
}
.result-buttons {
  display:flex;
  gap:16px;
  flex-wrap:wrap;
  justify-content:center;
}
@media (max-width:700px) {
  .title {
    font-size:32px;
  }
  .panels {
    grid-template-columns:repeat(2,1fr);
  }
  .big-btn {
    font-size:22px;
    padding:14px 34px;
  }
}
.container {
  position: relative;
  isolation: isolate;
  background: #eaf6ff;
}
.game-main {
  min-height: 0;
  background: transparent;
  overflow: visible;
}
.bg-scene {
  top: -50px;
  pointer-events: none;
}
.is-home .bg-scene {
  top: 0;
}
.petals {
  top: -50px;
}
.is-home .petals {
  top: 0;
}
.game-header {
  position: relative;
  z-index: 5;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  padding: 3px 10px;
  gap: 8px;
}
.info {
  width: auto;
}
.info-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 40px;
  padding: 6px 16px;
  font-size: 18px;
  font-weight: bold;
  color: #444;
  box-shadow: 0 2px 0 #e8a000;
}
.info-box .val {
  font-size: 22px;
  color: #ff6f3c;
  min-width: 28px;
  text-align: center;
}
.header-center {
  text-align: center;
}
.header-center h2 {
  margin: 0 0 3px;
  font-size: 20px;
  color: var(--ink);
}
.progress-wrap {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ddd;
}
.progress-dot.done {
  background: #6ecb63;
}
.progress-dot.current {
  background: #f9a825;
  border: 2px solid #c77c00;
}
.header-actions {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 8px;
}
button {
  font-family: inherit;
  cursor: pointer;
}
.quit-btn, .sound-btn {
  border: 3px solid #ddd;
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 16px;
  font-weight: 700;
  background: #fff;
  color: #888;
}
.quit-btn:hover {
  border-color: #e05a5a;
  color: #e05a5a;
}
.sound-btn {
  background: #fff0ad;
  border-color: #f2b321;
  color: #694100;
  box-shadow: 0 3px 0 #d89500;
  min-width: 90px;
}
.sound-btn:hover {
  background: #ffe680;
  border-color: #dc9700;
  color: #5a3500;
}
.sound-btn.sound-off {
  background: #e9edf1;
  border-color: #aeb7c0;
  color: #66717b;
  box-shadow: 0 3px 0 #929ba4;
}
.is-home .game-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  pointer-events: none;
}
.is-home .info, .is-home .header-center, .is-home .quit-btn {
  display: none;
}
.is-home .header-actions {
  grid-column: 3;
  pointer-events: auto;
}
.screen {
  visibility: hidden;
}
.screen.active {
  visibility: visible;
}
#screen-quiz {
  padding: 22px 20px 10px;
  justify-content: flex-start;
}
.choice-btn {
  font-family: inherit;
  cursor: pointer;
}
@keyframes bird-bob {
  50% {
    transform: translateY(-6px);
  }
}
@media (max-width: 700px) {
  .game-header {
    padding: 3px 5px;
    gap: 4px;
    grid-template-columns: 1fr 1.2fr 1fr;
  }
  .header-center h2 {
    font-size: 13px;
  }
  .info-box {
    padding: 5px 7px;
    font-size: 12px;
    gap: 3px;
  }
  .info-box .val {
    font-size: 17px;
    min-width: 12px;
  }
  .header-actions {
    gap: 3px;
  }
  .quit-btn, .sound-btn {
    font-size: 12px;
    padding: 5px;
    min-width: 0;
    white-space: nowrap;
  }
  .screen {
    padding: 18px 10px;
  }
  #screen-quiz {
    padding: 18px 10px 6px;
  }
  .quiz-frame {
    width: 100%;
  }
  .quiz-frame .kamishibai-inner {
    padding: 8px;
  }
  .panels {
    gap: 6px;
  }
  .panel {
    height: 112px;
    font-size: 27px;
    letter-spacing: 0;
  }
  .panel-badge {
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    font-size: 12px;
  }
  .choices {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    width: 100%;
  }
  .choice-btn {
    font-size: clamp(13px, 3.4vw, 18px);
    padding: 9px 3px;
    min-height: 42px;
  }
  .question-label {
    margin: auto 0 8px;
    font-size: 20px;
  }
  .answer-feedback {
    padding:22px 24px;
  }
  .start-frame, .result-frame {
    width: 96%;
  }
  .kamishibai-inner {
    padding: 14px 10px;
  }
  .subtitle {
    font-size: 16px;
  }
  .result-score {
    font-size: 23px;
  }
  .result-msg {
    font-size: 18px;
  }
  .result-buttons {
    gap: 12px;
  }
  .result-buttons .big-btn {
    font-size: 18px;
    padding: 12px 24px;
  }
}
.petal:nth-child(1) {
  left:8%;
  animation-duration:9s;
  animation-delay:0s;
}
.petal:nth-child(2) {
  left:22%;
  animation-duration:12s;
  animation-delay:-3s;
  width:10px;
  height:10px;
}
.petal:nth-child(3) {
  left:38%;
  animation-duration:10s;
  animation-delay:-6s;
}
.petal:nth-child(4) {
  left:55%;
  animation-duration:13s;
  animation-delay:-2s;
  width:11px;
  height:11px;
}
.petal:nth-child(5) {
  left:68%;
  animation-duration:9.5s;
  animation-delay:-8s;
}
.petal:nth-child(6) {
  left:80%;
  animation-duration:11s;
  animation-delay:-4s;
  width:10px;
  height:10px;
}
.petal:nth-child(7) {
  left:92%;
  animation-duration:14s;
  animation-delay:-1s;
}
.container {
  overflow: hidden;
}
.confetti-layer {
  position: absolute;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 15px;
  animation: confetti-fall 1.2s linear both;
}
@keyframes confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  10%, 75% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift), var(--fall), 0) rotate(var(--spin));
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .confetti-layer {
    display: none;
  }
  .panel {
    animation: none;
  }
}
