/* ===============================
   基本設定（全要素に適用）
   =============================== */

/* paddingやborderを含めてサイズ計算する設定
   レイアウト崩れ防止の超重要設定 */
* {
  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: #87CEEB;

  display: flex;          /* 中央配置 */
  justify-content: center;
  align-items: center;
}

/* ===============================
   外枠（ゲーム全体）
   高さ540px固定レイアウト
   =============================== */

.container {
  margin: 0 auto;         /* 中央寄せ */
  background: #ffffff;
  border: 2px solid #333;

  width: 100%;
  max-width: 1196px;
  height: 540px;          /* ゲーム総高さ固定 */

  display: flex;          /* 縦レイアウトを作るための土台 */
  flex-direction: column; /* 子要素を縦に並べる */
}


/* ===============================
   ヘッダー（高さ固定）
   =============================== */

.game-header {
  height: 50px;           /* 見た目の高さ */
  padding: 10px;
  background: #ffffff;

  /* flex: grow shrink basis
     grow:広がらない
     shrink:縮まない
     basis:50px固定 */
  flex: 0 0 50px;

  display: flex;
  align-items: center;    /* 縦中央 */
}


/* ===============================
   情報表示エリア
   =============================== */

.info {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-weight: bold;
  flex-wrap: wrap;               /* 画面が狭い時は折り返す */
  width: 100%;
}


/* ===============================
   メインゲームエリア
   残り高さすべて使う
   =============================== */

.game-main {
  position: relative;     /* absolute配置の基準になる */
  background: #ffffff;

  flex: 1;                /* ★残りの高さを全部使う（超重要） */

  overflow: hidden;       /* はみ出し防止 */

  display: grid;
  place-items: center;    /* 中央配置のショート記法 */
}

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

/* ===== メインコンテナ ===== */
  #app {
    max-width: 1196px;
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(180deg, #4FC3F7 0%, #81D4FA 35%, #B3E5FC 70%, #E1F5FE 100%);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,80,160,0.25);
  }

  /* ===== 背景の雲装飾 ===== */
  .bg-cloud {
    position: absolute;
    background: rgba(255,255,255,0.55);
    border-radius: 50px;
    pointer-events: none;
  }
  .bg-cloud::before, .bg-cloud::after {
    content: '';
    position: absolute;
    background: rgba(255,255,255,0.55);
    border-radius: 50%;
  }
  .bc1 { width:160px; height:50px; top:18px; left:-20px; }
  .bc1::before { width:70px; height:70px; top:-35px; left:20px; }
  .bc1::after  { width:55px; height:55px; top:-28px; left:65px; }
  .bc2 { width:120px; height:38px; top:60px; right:30px; }
  .bc2::before { width:52px; height:52px; top:-28px; left:15px; }
  .bc2::after  { width:40px; height:40px; top:-22px; left:52px; }
  .bc3 { width:90px; height:30px; bottom:80px; left:60px; opacity:0.4; }
  .bc3::before { width:38px; height:38px; top:-22px; left:10px; }
  .bc3::after  { width:30px; height:30px; top:-16px; left:38px; }

  /* 太陽 */
  .sun {
    position: absolute;
    top: 10px; right: 80px;
    width: 72px; height: 72px;
    background: radial-gradient(circle, #FFE066 60%, #FFD700 100%);
    border-radius: 50%;
    box-shadow: 0 0 0 12px rgba(255,220,0,0.18), 0 0 0 24px rgba(255,220,0,0.08);
    animation: sunPulse 3s ease-in-out infinite;
  }
  @keyframes sunPulse {
    0%,100% { box-shadow: 0 0 0 12px rgba(255,220,0,0.18), 0 0 0 24px rgba(255,220,0,0.08); }
    50%      { box-shadow: 0 0 0 18px rgba(255,220,0,0.22), 0 0 0 34px rgba(255,220,0,0.10); }
  }

  /* 地面 */
  .ground {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(180deg, #81C784 0%, #66BB6A 100%);
    border-radius: 0 0 24px 24px;
  }
  .ground::before {
    content: '';
    position: absolute;
    top: -18px; left: 0; right: 0;
    height: 30px;
    background: #A5D6A7;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  }

  /* ===== 画面共通 ===== */
  .screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease;
  }
  .screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  /* ===== タイトル画面 ===== */
  #titleScreen {
    gap: 24px;
  }
  .title-badge {
    background: rgba(255,255,255,0.92);
    border-radius: 32px;
    padding: 18px 48px 22px;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0,100,200,0.15);
    border: 3px solid rgba(255,255,255,0.8);
  }
  .title-main {
    font-size: 64px;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #1565C0, #0288D1, #00ACC1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
  }
  .title-desc {
    background: rgba(255,255,255,0.82);
    border-radius: 16px;
    padding: 12px 32px;
    font-size: 18px;
    color: #2E7D32;
    font-weight: 700;
    letter-spacing: 1px;
  }
  .btn-start {
    font-family: inherit;
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, #FF7043, #FF5252);
    border: none;
    border-radius: 50px;
    padding: 16px 60px;
    cursor: pointer;
    box-shadow: 0 6px 0 #C62828, 0 8px 20px rgba(255,80,0,0.35);
    letter-spacing: 3px;
    transition: transform 0.1s, box-shadow 0.1s;
    animation: bounce 1.8s ease-in-out infinite;
  }
  .btn-start:hover { transform: translateY(-3px); box-shadow: 0 9px 0 #C62828, 0 12px 24px rgba(255,80,0,0.35); }
  .btn-start:active { transform: translateY(3px); box-shadow: 0 3px 0 #C62828; }
  @keyframes bounce {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
  }

  /* ===== クイズ画面 ===== */
  #quizScreen {
    padding: 0 24px 70px;
    gap: 0;
    justify-content: flex-start;
  }

  /* ヘッダーバー */
  .quiz-header {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px 12px 6px;
  }
  .progress-wrap {
    grid-column: 2;
    display: flex;
    align-items: center;
  }
  .progress-dots {
    display: flex;
    gap: 6px;
  }

  .btn-quit {
    grid-column: 3;
    justify-self: end;
  }
  .dot {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    border: 2px solid rgba(255,255,255,0.7);
    transition: background 0.3s;
  }
  .dot.correct{ background: #69F0AE; border-color: #00C853; }
  .dot.wrong  { background: #FF5252; border-color: #D50000; }

  .btn-quit {
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: #D84315;
    border: 2px solid #fff;
    border-radius: 20px;
    padding: 6px 18px;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: 0 3px 0 #8D2B0C, 0 4px 10px rgba(80,20,0,0.25);
    transition: background 0.2s, transform 0.1s, box-shadow 0.1s;
  }
  .btn-quit:hover { background: #BF360C; transform: translateY(-1px); }
  .btn-quit:active { transform: translateY(2px); box-shadow: 0 1px 0 #8D2B0C; }

  /* 問題エリア */
  .quiz-body {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
    flex: 1;
    padding: 4px 0 0;
  }

  /* 写真 */
  .photo-wrap {
    flex: 0 0 340px;
    height: 320px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0,60,120,0.25);
    border: 4px solid rgba(255,255,255,0.85);
    background: #B3E5FC;
    position: relative;
  }
  .photo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .photo-label {
    position: absolute;
    bottom: 10px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.52);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border-radius: 10px;
    padding: 3px 12px;
    white-space: nowrap;
  }

  /* 右側：問い＋選択肢 */
  .quiz-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
  }
  .question-box {
    background: rgba(255,255,255,0.88);
    border-radius: 20px;
    padding: 14px 24px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,80,160,0.12);
    width: 100%;
  }
  .question-num {
    font-size: 14px;
    color: #0288D1;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 4px;
  }
  .question-text {
    font-size: 26px;
    font-weight: 900;
    color: #1A237E;
    line-height: 1.35;
    letter-spacing: 1px;
  }
  .choices {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
  }
  .btn-choice {
    font-family: inherit;
    font-size: 22px;
    font-weight: 900;
    color: #5D4037;
    background: linear-gradient(135deg, #FFF8D6, #FFE082);
    border: 3px solid #FFB300;
    border-radius: 50px;
    padding: 16px 24px;
    cursor: pointer;
    letter-spacing: 2px;
    box-shadow: 0 5px 0 #E09B00, 0 7px 16px rgba(120,75,0,0.2);
    transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
    text-align: center;
    position: relative;
    overflow: hidden;
  }
  .btn-choice:hover:not(:disabled) {
    transform: translateY(-3px);
    background: linear-gradient(135deg, #FFFDE7, #FFD54F);
    box-shadow: 0 8px 0 #E09B00, 0 11px 20px rgba(120,75,0,0.24);
  }
  .btn-choice:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #E09B00; }
  .btn-choice:disabled { cursor: default; }
  .btn-choice.correct-ans {
    background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
    border-color: #66BB6A;
    color: #1B5E20;
    animation: correctShake 0.4s ease;
  }
  .btn-choice.wrong-ans {
    background: linear-gradient(135deg, #FFCDD2, #EF9A9A);
    border-color: #E57373;
    color: #B71C1C;
  }
  @keyframes correctShake {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.06); }
    60%  { transform: scale(0.97); }
    100% { transform: scale(1); }
  }

  /* フィードバックオーバーレイ */
  #feedback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
  }
  #feedback.show { opacity: 1; pointer-events: auto; }
  .feedback-bubble {
    background: rgba(255,255,255,0.95);
    border-radius: 28px;
    width: min(90%, 720px);
    box-sizing: border-box;
    padding: 26px 56px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    border: 4px solid #fff;
    animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
  }
  @keyframes popIn {
    0%   { transform: scale(0.4); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
  }
  .feedback-emoji { font-size: 56px; line-height: 1; }
  .feedback-text  { font-size: 36px; font-weight: 900; margin-top: 6px; letter-spacing: 2px; }
  .feedback-text.ok   { color: #2E7D32; }
  .feedback-text.ng   { color: #C62828; }
  .feedback-hint {
    font-size: 17px;
    line-height: 1.8;
    color: #555;
    margin-top: 10px;
    font-weight: 700;
  }
  .btn-next {
    font-family: inherit;
    font-size: 22px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, #42A5F5, #1E88E5);
    border: none;
    border-radius: 50px;
    padding: 14px 48px;
    cursor: pointer;
    margin-top: 18px;
    box-shadow: 0 5px 0 #1565C0, 0 7px 18px rgba(30,136,229,0.35);
    letter-spacing: 2px;
    transition: transform 0.1s, box-shadow 0.1s;
  }
  .btn-next:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #1565C0, 0 10px 22px rgba(30,136,229,0.35); }
  .btn-next:active { transform: translateY(3px); box-shadow: 0 2px 0 #1565C0; }

  /* 花吹雪エフェクト */
  .confetti-piece {
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 2px;
    pointer-events: none;
    animation: confettiFall linear forwards;
    z-index: 20;
  }
  @keyframes confettiFall {
    0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(560px) rotate(720deg); opacity: 0; }
  }

  /* ===== リザルト画面 ===== */
  #resultScreen { gap: 20px; }
  .result-card {
    background: rgba(255,255,255,0.93);
    border-radius: 28px;
    padding: 24px 52px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,80,160,0.18);
    border: 3px solid rgba(255,255,255,0.8);
  }
  .result-title {
    font-size: 38px;
    font-weight: 900;
    color: #1565C0;
    letter-spacing: 3px;
    margin-bottom: 10px;
  }
  .result-score {
    font-size: 72px;
    font-weight: 900;
    letter-spacing: 2px;
    line-height: 1;
  }
  .result-score .score-num { color: #FF6F00; }
  .result-score .score-total { font-size: 36px; color: #888; }
  .result-msg {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    margin-top: 8px;
    letter-spacing: 1px;
  }
  .result-stars { font-size: 36px; margin-top: 4px; letter-spacing: 4px; }
  .result-btns { display: flex; gap: 20px; }
  .btn-retry {
    font-family: inherit;
    font-size: 22px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, #FF7043, #FF5252);
    border: none;
    border-radius: 50px;
    padding: 14px 40px;
    cursor: pointer;
    box-shadow: 0 5px 0 #C62828;
    letter-spacing: 2px;
    transition: transform 0.1s, box-shadow 0.1s;
  }
  .btn-retry:hover { transform: translateY(-2px); }
  .btn-retry:active { transform: translateY(3px); box-shadow: 0 2px 0 #C62828; }
  .btn-home {
    font-family: inherit;
    font-size: 22px;
    font-weight: 900;
    color: #1A237E;
    background: rgba(255,255,255,0.9);
    border: 3px solid #90CAF9;
    border-radius: 50px;
    padding: 14px 40px;
    cursor: pointer;
    box-shadow: 0 5px 0 #90CAF9;
    letter-spacing: 2px;
    transition: transform 0.1s, box-shadow 0.1s;
  }
  .btn-home:hover { transform: translateY(-2px); background: #E3F2FD; }
  .btn-home:active { transform: translateY(3px); box-shadow: 0 2px 0 #90CAF9; }
