/* ==========================================
   夢授業ゲーム - スタイル（iPad対応）
   ========================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* iOSのタップ時の青ハイライト消す */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;              /* 長押しメニュー禁止 */
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;            /* スクロール禁止（iOSのバウンス防止） */
  overscroll-behavior: none;
  touch-action: manipulation;  /* ダブルタップズーム禁止 */
}

body {
  font-family: 'Comic Sans MS', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  background: linear-gradient(135deg, #FFB6C1, #87CEEB, #FFE4B5);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  position: fixed;
  inset: 0;
}

#game-container {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  max-width: 900px;
  width: 100%;
  max-height: 100vh;
  overflow: hidden;
}

.screen { text-align: center; }
.hidden { display: none !important; }

/* ----- タイトル ----- */
h1 {
  font-size: clamp(28px, 5vw, 48px);
  color: #FF6B6B;
  margin-bottom: 15px;
  text-shadow: 3px 3px 0 #FFE66D, 6px 6px 0 rgba(0,0,0,0.1);
}

#game-info {
  font-size: clamp(16px, 2.4vw, 22px);
  line-height: 1.8;
  margin: 15px 0;
  color: #333;
  background: #FFF9E6;
  padding: 18px;
  border-radius: 15px;
  display: inline-block;
  text-align: left;
}

#instructions {
  font-size: clamp(14px, 2vw, 18px);
  color: #555;
  margin: 15px 0;
  padding: 10px;
  background: #E8F4F8;
  border-radius: 10px;
  display: inline-block;
}

/* ----- ボタン ----- */
button {
  font-size: clamp(20px, 3vw, 28px);
  padding: 15px 40px;
  background: linear-gradient(135deg, #FF6B6B, #FFE66D);
  border: none;
  border-radius: 50px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  transition: transform 0.08s, box-shadow 0.08s;
  margin-top: 15px;
  font-family: inherit;
  touch-action: manipulation;
}
button:hover { transform: scale(1.05); }
button:active { transform: scale(0.94); box-shadow: 0 2px 5px rgba(0,0,0,0.3); }

/* ----- HUD ----- */
#hud {
  display: flex;
  justify-content: space-around;
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: bold;
  padding: 10px;
  background: linear-gradient(90deg, #FFE66D, #FF6B6B);
  border-radius: 10px;
  margin-bottom: 8px;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
  flex-wrap: wrap;
  gap: 8px;
}

/* ----- キャンバス（縦持ち・横持ち両方フィット） ----- */
#canvas-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#game-canvas {
  display: block;
  margin: 0 auto;
  border: 4px solid #333;
  border-radius: 10px;
  background: #87CEEB;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 55vh;
  aspect-ratio: 8 / 5;
}

/* DOMで重ねるスプライト（iPad SafariのCanvasに絵文字が
   描画されない問題を回避するため、プレイヤーは <div> として配置） */
.sprite {
  position: absolute;
  left: 0;
  top: 0;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  /* font-size と translate(x, y) は JS で設定 */
  transform-origin: top left;
  z-index: 2;
  will-change: transform;
}

/* ----- クイズ ----- */
#quiz-area {
  padding: 25px;
  background: #FFF9E6;
  border-radius: 15px;
  margin-top: 15px;
}
#quiz-question {
  font-size: clamp(20px, 3.5vw, 28px);
  margin-bottom: 25px;
  color: #333;
  line-height: 1.5;
}
#quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 500px;
  margin: 0 auto;
}
.quiz-btn {
  font-size: clamp(18px, 2.6vw, 24px);
  padding: 18px;
  background: linear-gradient(135deg, #4ECDC4, #44A8B5);
  margin-top: 0;
}

/* ----- 結果画面 ----- */
#result-title {
  font-size: clamp(40px, 7vw, 60px);
  margin: 30px 0;
}
#result-score {
  font-size: clamp(22px, 3.5vw, 30px);
  color: #FF6B6B;
  margin: 15px 0;
}

/* ============================================================
   📱 タッチ操作（iPad/iPhone専用）
   ============================================================ */
#touch-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 12px 4px 4px 4px;
  margin-top: 10px;
  gap: 10px;
  min-height: 180px;
}

.touch-pad-left,
.touch-pad-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  justify-content: center;
  flex: 1;
  max-width: 50%;
}

.touch-pad-left { justify-content: flex-start; }
.touch-pad-right { justify-content: flex-end; }

.touch-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 30px;
  padding: 0;
  margin: 0;
  background: linear-gradient(135deg, #6C7CFF, #4FA0FF);
  color: white;
  border: 3px solid white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  opacity: 0.92;
  flex-shrink: 0;
}

.touch-btn.action {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  font-size: 22px;
}

.touch-btn.special {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  font-size: 28px;
}

.touch-btn:active {
  transform: scale(0.9);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  opacity: 1;
}

.touch-btn.vertical {
  /* 上下キーは横並びの後ろに改行で配置するので display 制御をモードで切替 */
}

/* タッチ操作を出さない場面（デフォルト：非表示） */
#touch-controls.hidden { display: none !important; }

/* シューティング以外では上下ボタンを隠す（JSが付ける） */
#touch-controls.no-vertical .touch-btn.vertical { display: none; }
/* 必殺技を使わないときは隠す（任意） */
#touch-controls.no-special  .touch-btn.special  { display: none; }

/* ============================================================
   レスポンシブ（iPad縦・iPhone）
   ============================================================ */
@media (max-width: 820px) {
  #game-container {
    padding: 12px;
    border-radius: 14px;
  }
  body { padding: 6px; }
}

@media (max-width: 480px) {
  .touch-btn { width: 60px; height: 60px; font-size: 24px; }
  .touch-btn.action { width: 80px; height: 80px; font-size: 18px; }
  .touch-btn.special { width: 60px; height: 60px; font-size: 22px; }
  #hud { font-size: 14px; padding: 8px; }
}
