/* ================================================================
   style.css – MAKE10 全スタイル
   構成:
   01. CSS カスタムプロパティ（カラーパレット）
   02. リセット & ベース
   03. 背景アニメーション（光球）
   04. レイアウト（header / main / footer）
   05. 画面切り替え（.screen / .active）
   06. ガラスカード
   07. ヘッダー
   08. フッター
   09. トップ画面
   10. ボタン共通・バリアント
   11. ゲーム画面：ヘッダー行
   12. ゲーム画面：タイムゲージ
   13. ゲーム画面：問題カード
   14. ゲーム画面：選択肢タイル
   15. フィードバック演出
   16. リザルト画面
   17. ハイスコア表示
   18. アニメーション一覧
   19. レスポンシブ
   ================================================================ */


/* ──────────────────────────────────────────────────────────────
   01. CSS カスタムプロパティ
   ゲーム全体の色・影・ガラス効果を一元管理する CSS 変数
────────────────────────────────────────────────────────────── */
:root {
  --bg:           #f5f0e6;
  --card:         #ffffff;
  --choice-fill:  #fdf8ee;
  --primary:      #4d80d1;
  --accent:       #9a6bc7;
  --gauge-full:   #6bb884;
  --gauge-warn:   #cc7566;
  --gauge-bg:     #dbd9cc;
  --text:         #383843;
  --muted:        #858588;
  --glass:        rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.35);
  --shadow:       rgba(56, 56, 67, 0.08);
}


/* ──────────────────────────────────────────────────────────────
   02. リセット & ベース
────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

html, body {
  touch-action: manipulation;           /* ダブルタップズームを抑止する */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  overflow-x: hidden;
}


/* ──────────────────────────────────────────────────────────────
   03. 背景アニメーション（光球）
   画面全体に固定した装飾用の光球。ゲーム UI より後ろに配置する。
────────────────────────────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-orbs .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orbFloat 12s ease-in-out infinite alternate;
}

/* 左上：青紫の大きい光球 */
.bg-orbs .orb:nth-child(1) {
  width: 320px; height: 320px;
  background: var(--primary);
  top: -80px; left: -60px;
  animation-duration: 14s;
}

/* 右下：紫の中くらいの光球 */
.bg-orbs .orb:nth-child(2) {
  width: 260px; height: 260px;
  background: var(--accent);
  bottom: -40px; right: -40px;
  animation-duration: 10s;
  animation-delay: -4s;
}

/* 中央：緑の小さい光球 */
.bg-orbs .orb:nth-child(3) {
  width: 200px; height: 200px;
  background: var(--gauge-full);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 16s;
  animation-delay: -8s;
}


/* ──────────────────────────────────────────────────────────────
   04. レイアウト（header / main / footer）
────────────────────────────────────────────────────────────── */
#main-content {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 0 4px;
}

/* ゲーム本体ラッパー：縦幅の上限を設けてコンテンツが広がりすぎないようにする */
.game-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  height: calc(100dvh - 52px - 34px); /* 全画面高さ − ヘッダー − フッター */
  max-height: 720px;
  padding: 12px 20px 12px;
  display: flex;
  flex-direction: column;
}


/* ──────────────────────────────────────────────────────────────
   05. 画面切り替え
   非アクティブな画面は display:none で完全非表示にする。
────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
}

/* ゲーム画面はアイテムを上揃えにする（タイムゲージを上部に固定するため） */
#screen-game {
  justify-content: flex-start;
}


/* ──────────────────────────────────────────────────────────────
   06. ガラスカード
   backdrop-filter で背景をぼかし、半透明の境界線でガラス質感を演出する。
────────────────────────────────────────────────────────────── */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 8px 32px var(--shadow);
  padding: 28px 24px;
  width: 100%;
}


/* ──────────────────────────────────────────────────────────────
   07. ヘッダー
   全画面で常時表示されるゲームタイトルバー。
────────────────────────────────────────────────────────────── */
.site-header {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 10px 20px 6px;
  flex-shrink: 0;
}

.site-title {
  font-size: clamp(1.1rem, 5vw, 1.4rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--text);
  line-height: 1;
}

/* [FIX] "10" の部分をグラデーションカラーで強調する（旧: .title-num → 修正: .title-accent） */
.site-title .title-accent {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* [FIX] ヘッダーのサブタイトル（30-SECOND CHALLENGE）のスタイル */
.site-tagline {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.12em;
  margin-top: 2px;
}


/* ──────────────────────────────────────────────────────────────
   08. フッター
   全画面で常時表示されるコピーライト・外部リンクエリア。
────────────────────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 2;
  width: 100%;
  text-align: center;
  padding: 4px 12px 10px;
  flex-shrink: 0;
}

.footer-copy {
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.8;
}

.footer-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s;
}

.footer-link:hover,
.footer-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  outline: none;
}


/* ──────────────────────────────────────────────────────────────
   09. トップ画面
────────────────────────────────────────────────────────────── */

/* ゲームルール見出し */
/* [FIX] HTML で使用されているが CSS に未定義だったため追加 */
.rule-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* ゲームルールの説明文 */
.title-rule {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  margin-bottom: 28px;
}

.title-rule strong {
  color: var(--text);
}


/* ──────────────────────────────────────────────────────────────
   10. ボタン共通・バリアント
────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 16px 36px;
  text-decoration: none;
}

.btn:active  { transform: scale(0.95); }

.btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* グラデーション背景のメインボタン */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 6px 24px rgba(77, 128, 209, 0.3);
}

.btn-primary:active { box-shadow: 0 2px 12px rgba(77, 128, 209, 0.2); }

/* App Store ダウンロードボタン（現在はコメントアウト中） */
.btn-appstore {
  background: #000;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.btn-appstore svg {
  width: 22px; height: 22px; fill: #fff;
}

/* ガラス素材のセカンダリボタン */
.btn-secondary {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 16px;
  padding: 14px 28px;
}

/* ゲーム画面左上の小さいホームボタン */
.btn-home {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.12s ease;
  padding: 0;
  flex-shrink: 0;
}

.btn-home:active { transform: scale(0.9); }

.btn-home:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}


/* ──────────────────────────────────────────────────────────────
   11. ゲーム画面：ヘッダー行
────────────────────────────────────────────────────────────── */
.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 10px;
}

.score-display {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

/* スコア数字だけ大きく目立たせる */
.score-display span {
  font-size: 22px;
  color: var(--text);
}

/* コンボがないときも高さを確保してレイアウトがずれないようにする */
.combo-display {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-height: 20px;
  transition: transform 0.2s ease;
}

/* JS で .pop を付け外しすることでアニメーションを毎回再トリガーする */
.combo-display.pop {
  animation: comboPop 0.3s ease;
}


/* ──────────────────────────────────────────────────────────────
   12. ゲーム画面：タイムゲージ
────────────────────────────────────────────────────────────── */
.gauge-wrapper {
  width: 100%;
  height: 12px;
  background: var(--gauge-bg);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
}

.gauge-bar {
  height: 100%;
  border-radius: 6px;
  background: var(--gauge-full);
  transition: width 0.08s linear, background-color 0.4s ease;
  will-change: width;
}


/* ──────────────────────────────────────────────────────────────
   13. ゲーム画面：問題カード
────────────────────────────────────────────────────────────── */
.question-area {
  width: 100%;
  text-align: center;
  margin-bottom: 16px;
  position: relative;
}

.question-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 32px var(--shadow);
  position: relative;
}

/* 「MAKE 10!」ラベル */
.question-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 1px;
}

/* 問題の数字（大きく中央に表示） */
.question-number {
  font-size: 80px;
  font-weight: 900;
  line-height: 1;
  color: var(--primary);
  transition: transform 0.2s ease;
}

/* JS が付け外しするクラス。リフロー強制で毎回アニメーションをリセットする */
.question-number.animate-in {
  animation: numberIn 0.25s ease;
}

/* 「? + X = 10」ヒント行 */
.question-hint {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  font-weight: 700;
}

.question-hint span {
  color: var(--accent);
  font-size: 15px;
}

/* カードの右上に「NEXT」ラベルを絶対配置する */
.next-label {
  position: absolute;
  top: 12px; right: 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.7;
}

/* 次の問題の数字をやや薄く表示してプレビュー感を出す */
.next-number {
  position: absolute;
  top: 24px; right: 16px;
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  opacity: 0.5;
}


/* ──────────────────────────────────────────────────────────────
   14. ゲーム画面：選択肢タイル
────────────────────────────────────────────────────────────── */
.tiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  margin-bottom: 8px;
}

.tile {
  aspect-ratio: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--choice-fill);
  border: 2px solid var(--glass-border);
  border-radius: 18px;
  font-size: 42px;
  font-weight: 900;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  position: relative;
  overflow: hidden;
}

.tile:active { transform: scale(0.93); }

.tile:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* 正解タップ時：緑色の背景＋拡大アニメーション */
.tile.correct {
  background: rgba(107, 184, 132, 0.2);
  border-color: var(--gauge-full);
  animation: tileCorrect 0.35s ease;
}

/* 誤答タップ時：赤色の背景＋横揺れアニメーション */
.tile.wrong {
  background: rgba(204, 117, 102, 0.15);
  border-color: var(--gauge-warn);
  animation: tileWrong 0.35s ease;
}

/* 問題切り替え時のタイル出現アニメーション */
.tile.appear {
  animation: tileAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}


/* ──────────────────────────────────────────────────────────────
   15. フィードバック演出
────────────────────────────────────────────────────────────── */

/* 正解・不正解時に問題エリア中央に絵文字を表示してフェードアウトさせる */
.feedback {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  pointer-events: none;
  animation: feedbackPop 0.5s ease forwards;
  z-index: 10;
}

/* コンボ達成時に画面上をランダムな絵文字が舞い上がって消える演出 */
.combo-emoji {
  position: fixed;
  font-size: 36px;
  pointer-events: none;
  z-index: 20;
  animation: emojiRise 1.2s ease forwards;
}


/* ──────────────────────────────────────────────────────────────
   16. リザルト画面
────────────────────────────────────────────────────────────── */
.result-score-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

/* スコア数字：グラデーション＋バウンスで登場 */
.result-score {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
  animation: scoreReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-message {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 6px;
}

.result-combo {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 28px;
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}


/* ──────────────────────────────────────────────────────────────
   17. ハイスコア表示
────────────────────────────────────────────────────────────── */

/* タイトル画面のハイスコア。スコアがない場合は空（min-height で高さを確保） */
.title-hi {
  font-size: 15px;
  font-weight: 900;
  color: var(--accent);
  min-height: 22px;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

/* リザルト画面のハイスコア */
.result-hi {
  font-size: 15px;
  font-weight: 900;
  color: var(--muted);
  min-height: 22px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

/* 新記録時：緑色で拡大アニメーション付き */
.result-hi.new-record {
  color: var(--gauge-full);
  font-size: 18px;
  animation: scoreReveal 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}


/* ──────────────────────────────────────────────────────────────
   18. アニメーション一覧
────────────────────────────────────────────────────────────── */

/* 背景光球の浮遊 */
@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -40px) scale(1.15); }
}

/* 画面切り替え時のフェードイン */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 問題数字の切り替えアニメーション */
@keyframes numberIn {
  from { transform: scale(0.5) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

/* コンボ表示のバウンス */
@keyframes comboPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* 正解タイルの拡大 */
@keyframes tileCorrect {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* 誤答タイルの横揺れ */
@keyframes tileWrong {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

/* タイル出現アニメーション */
@keyframes tileAppear {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* 正解・不正解フィードバック絵文字のポップ＆フェードアウト */
@keyframes feedbackPop {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* コンボ達成絵文字の舞い上がり */
@keyframes emojiRise {
  0%   { transform: translateY(0) scale(0.5) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-160px) scale(1.2) rotate(20deg); opacity: 0; }
}

/* リザルトのスコア登場アニメーション */
@keyframes scoreReveal {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}


/* ──────────────────────────────────────────────────────────────
   19. レスポンシブ
────────────────────────────────────────────────────────────── */

/* 画面高さ 640px 以下（古いスマートフォン）向けに各要素を縮小する */
@media (max-height: 640px) {
  .question-number { font-size: 56px; }
  .tile            { font-size: 34px; }
  .question-card   { padding: 14px; }
  .glass-card      { padding: 20px 18px; }
}

/* 幅が広い端末ではタイルを少し横長にして余白を活かす */
@media (min-width: 500px) {
  .tile { aspect-ratio: 1.6; }
}
