﻿/* 既存レイアウト：container / header / game-main */
* {
  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;
  background: linear-gradient(160deg, #87CEEB 0%, #FFF9C4 60%, #FFE082 100%);
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
}
.game-header {
  height: 50px;
  padding: 10px;
  background: transparent;
  flex: 0 0 50px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: relative;
  z-index: 10;
}
.header-title {
  grid-column: 2;
  color: #E65100;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.75);
  white-space: nowrap;
}
.game-header .score-display { grid-column: 1; justify-self: start; }
.game-header .btn-quit { grid-column: 3; justify-self: end; }
.game-header.title-mode > * { visibility: hidden; }
.game-main {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: transparent;
  font-family: 'Hiragino Maru Gothic ProN', 'Rounded Mplus 1c', 'BIZ UDPGothic', sans-serif;
}

.game-main * { margin: 0; padding: 0; }

  .summer-quiz {
    max-width: 1196px;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
  }

  /* ===== CLOUDS ===== */
  .cloud {
    position: absolute;
    background: white;
    border-radius: 50px;
    opacity: 0.85;
  }
  .cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
  }
  .cloud1 { width: 120px; height: 40px; top: 30px; left: 60px; animation: floatCloud 18s linear infinite; }
  .cloud1::before { width: 60px; height: 60px; top: -30px; left: 15px; }
  .cloud1::after  { width: 40px; height: 40px; top: -20px; left: 50px; }
  .cloud2 { width: 90px; height: 30px; top: 60px; right: 120px; animation: floatCloud 24s linear infinite reverse; }
  .cloud2::before { width: 45px; height: 45px; top: -22px; left: 12px; }
  .cloud2::after  { width: 32px; height: 32px; top: -15px; left: 40px; }
  .cloud3 { width: 70px; height: 25px; top: 20px; left: 40%; animation: floatCloud 20s linear infinite 3s; }
  .cloud3::before { width: 36px; height: 36px; top: -18px; left: 10px; }
  .cloud3::after  { width: 26px; height: 26px; top: -12px; left: 32px; }

  @keyframes floatCloud {
    0%   { transform: translateX(-20px); }
    50%  { transform: translateX(20px); }
    100% { transform: translateX(-20px); }
  }

  /* ===== SUN ===== */
  .sun {
    position: absolute;
    top: -20px;
    right: 60px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #FFE500 60%, #FFAA00 100%);
    border-radius: 50%;
    box-shadow: 0 0 0 12px rgba(255,220,0,0.25), 0 0 0 24px rgba(255,200,0,0.12);
    animation: sunPulse 3s ease-in-out infinite;
  }
  @keyframes sunPulse {
    0%, 100% { box-shadow: 0 0 0 12px rgba(255,220,0,0.25), 0 0 0 24px rgba(255,200,0,0.12); }
    50%       { box-shadow: 0 0 0 18px rgba(255,220,0,0.30), 0 0 0 36px rgba(255,200,0,0.15); }
  }

  /* ===== GROUND ===== */
  .ground {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 80px;
    background: linear-gradient(180deg, #66BB6A 0%, #388E3C 100%);
    border-radius: 0 0 16px 16px;
  }

  /* ===== SCREENS ===== */
  .screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s, transform 0.4s;
  }
  .screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
  }

  /* ===== TITLE SCREEN ===== */
  #titleScreen { gap: 24px; }

  .title-text {
    font-size: 64px;
    font-weight: 900;
    color: #FF6F00;
    text-shadow:
      3px 3px 0 #FFF176,
      6px 6px 0 rgba(255,111,0,0.25);
    line-height: 1;
    letter-spacing: 4px;
  }

  .title-emoji {
    font-size: 48px;
    display: flex;
    gap: 12px;
    filter: drop-shadow(0 3px 3px rgba(0,0,0,0.15));
  }

  .title-desc {
    font-size: 22px;
    color: #5D4037;
    background: rgba(255,255,255,0.7);
    padding: 10px 28px;
    border-radius: 40px;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  }

  .btn-start {
    background: linear-gradient(180deg, #FFEE58 0%, #FFC107 100%);
    color: #E65100;
    font-size: 32px;
    font-weight: 900;
    padding: 16px 60px;
    border: none;
    border-radius: 60px;
    cursor: pointer;
    box-shadow: 0 6px 0 #F57F17, 0 10px 20px rgba(0,0,0,0.15);
    transition: transform 0.1s, box-shadow 0.1s;
    letter-spacing: 4px;
  }
  .btn-start:hover { transform: translateY(-3px); box-shadow: 0 9px 0 #F57F17, 0 14px 24px rgba(0,0,0,0.18); }
  .btn-start:active { transform: translateY(3px); box-shadow: 0 3px 0 #F57F17; }

  /* ===== GAME SCREEN ===== */
  #gameScreen { gap: 0; }

  .top-bar {
    position: absolute;
    top: 16px;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 28px;
  }

  .progress-dots {
    display: flex;
    gap: 10px;
  }
  .dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    border: 3px solid rgba(255,255,255,0.8);
    transition: background 0.3s, transform 0.3s;
  }
  .dot.done { background: #FF7043; border-color: #FF7043; transform: scale(1.1); }
  .dot.current { background: white; border-color: #FF7043; animation: dotPulse 1s ease-in-out infinite; }
  @keyframes dotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
  }

  .score-display {
    font-size: 20px;
    font-weight: bold;
    color: #5D4037;
    background: rgba(255,255,255,0.7);
    padding: 6px 18px;
    border-radius: 30px;
  }

  .btn-quit {
    background: rgba(255,255,255,0.8);
    border: 2px solid #EF9A9A;
    color: #C62828;
    font-size: 16px;
    font-weight: bold;
    padding: 6px 18px;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.2s;
  }
  .btn-quit:hover { background: #FFCDD2; }

  .question-wrap {
    margin-top: 24px;
    text-align: center;
    padding: 0 20px;
  }

  .question-label {
    font-size: 14px;
    color: #5D4037;
    font-weight: bold;
    margin-bottom: 4px;
    letter-spacing: 2px;
  }

  .question-text {
    font-size: 26px;
    font-weight: 900;
    color: #1A237E;
    background: rgba(255,255,255,0.82);
    padding: 10px 32px;
    border-radius: 50px;
    display: inline-block;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    letter-spacing: 2px;
  }

  .choices {
    display: flex;
    justify-content: center;
    gap: 36px;
    margin-top: 20px;
    padding: 0 48px;
  }

  .choice-btn {
    width: 280px;
    height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    border: 6px solid transparent;
    border-radius: 32px;
    background: rgba(255,255,255,0.92);
    cursor: pointer;
    box-shadow: 0 8px 0 rgba(0,0,0,0.12), 0 10px 22px rgba(0,0,0,0.10);
    transition: transform 0.12s, box-shadow 0.12s, background 0.2s, border-color 0.2s;
    font-size: 24px;
    font-weight: 900;
    color: #4A148C;
    letter-spacing: 2px;
    overflow: hidden;
  }
  .choice-btn:not(:disabled):hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 13px 0 rgba(0,0,0,0.12), 0 16px 26px rgba(0,0,0,0.12);
  }
  .choice-btn:not(:disabled):active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.12);
  }

  .choice-image-wrap {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
  }

  .choice-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.15));
  }

  .choice-label {
    font-size: 24px;
    font-weight: 900;
    color: #4A148C;
    letter-spacing: 1px;
    text-align: center;
  }

  /* Result flash states */
  .choice-btn.correct {
    background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
    border-color: #43A047;
    animation: bounceCard 0.4s ease;
  }
  .choice-btn.wrong {
    background: linear-gradient(135deg, #FFCDD2, #EF9A9A);
    border-color: #E53935;
    animation: shakeCard 0.4s ease;
  }
  .choice-btn.dim {
    opacity: 0.45;
  }

  @keyframes bounceCard {
    0% { transform: scale(1); }
    40% { transform: scale(1.08) translateY(-8px); }
    70% { transform: scale(0.97) translateY(2px); }
    100% { transform: scale(1) translateY(-5px); }
  }
  @keyframes shakeCard {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px) rotate(-2deg); }
    40% { transform: translateX(8px) rotate(2deg); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
  }

  /* Feedback bubble */
  .feedback {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%) scale(0.5);
    font-size: 36px;
    font-weight: 900;
    padding: 14px 44px;
    border-radius: 60px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    white-space: nowrap;
  }
  .feedback.show { opacity: 1; transform: translateX(-50%) scale(1); }
  .feedback.ok  { background: #FFFDE7; color: #F9A825; border: 4px solid #FFD600; }
  .feedback.ng  { background: #FFF3E0; color: #E65100; border: 4px solid #FF9800; }

  /* ===== RESULT SCREEN ===== */
  #resultScreen { gap: 20px; }

  .result-title {
    font-size: 44px;
    font-weight: 900;
    color: #E91E63;
    text-shadow: 3px 3px 0 #FCE4EC;
    letter-spacing: 4px;
  }

  .result-star-row {
    display: flex;
    gap: 12px;
    font-size: 44px;
  }

  .result-score {
    font-size: 28px;
    font-weight: bold;
    color: #4527A0;
    background: rgba(255,255,255,0.8);
    padding: 12px 40px;
    border-radius: 50px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.10);
  }

  .result-msg {
    font-size: 22px;
    color: #5D4037;
    font-weight: bold;
  }

  .result-btns { display: flex; gap: 20px; }

  .btn-retry {
    background: linear-gradient(180deg, #80DEEA 0%, #26C6DA 100%);
    color: #006064;
    font-size: 26px;
    font-weight: 900;
    padding: 14px 48px;
    border: none;
    border-radius: 60px;
    cursor: pointer;
    box-shadow: 0 5px 0 #00838F, 0 8px 16px rgba(0,0,0,0.12);
    transition: transform 0.1s, box-shadow 0.1s;
    letter-spacing: 3px;
  }
  .btn-retry:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #00838F, 0 12px 20px rgba(0,0,0,0.15); }
  .btn-retry:active { transform: translateY(3px); box-shadow: 0 2px 0 #00838F; }

  /* Confetti */
  .confetti-piece {
    position: absolute;
    width: 10px; height: 14px;
    border-radius: 3px;
    pointer-events: none;
    opacity: 0;
    animation: confettiFall 2s ease-in forwards;
  }
  @keyframes confettiFall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(400px) rotate(720deg); }
  }
