/* ============================
   海・川・湖の生き物クイズ
   Deep Ocean Theme CSS
   ============================ */

/* フォント */
@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;500;700;800&display=swap');

/* CSS変数 */
:root {
  --ocean-deep:    #03045E;
  --ocean-dark:    #0077B6;
  --ocean-mid:     #00B4D8;
  --ocean-light:   #90E0EF;
  --ocean-pale:    #CAF0F8;
  --coral:         #FF6B6B;
  --sand:          #FFD166;
  --seaweed:       #06D6A0;
  --white:         #FFFFFF;
  --text-primary:  #FFFFFF;
  --text-shadow:   rgba(0,0,0,0.3);
  --card-bg:       rgba(255,255,255,0.10);
  --card-border:   rgba(255,255,255,0.20);
  --radius-lg:     20px;
  --radius-md:     14px;
  --radius-sm:     10px;
  --shadow-card:   0 8px 32px rgba(0,0,0,0.3);
  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
  background: var(--ocean-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ===== 水泡背景 ===== */
.bubbles-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(180deg, #03045E 0%, #0077B6 50%, #00B4D8 100%);
  overflow: hidden;
}

.bubble {
  position: absolute;
  bottom: -60px;
  border-radius: 50%;
  background: rgba(144, 224, 239, 0.15);
  border: 1px solid rgba(144, 224, 239, 0.3);
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0%   { transform: translateY(0) scale(1); opacity: 0.6; }
  100% { transform: translateY(-110vh) scale(0.8); opacity: 0; }
}

/* ===== 画面管理 ===== */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ===== スクロールバー非表示 ===== */
.screen::-webkit-scrollbar { display: none; }
.screen { scrollbar-width: none; }

/* ================================================
   ホーム画面
   ================================================ */
.home-container {
  min-height: 100%;
  padding: calc(var(--safe-top) + 32px) 20px calc(var(--safe-bottom) + 40px);
  max-width: 480px;
  margin: 0 auto;
}

.home-header {
  text-align: center;
  margin-bottom: 36px;
}

.app-icon {
  font-size: 72px;
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(0,180,216,0.6));
  animation: bobFloat 3s ease-in-out infinite;
}

@keyframes bobFloat {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

.app-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.3;
  text-shadow: 0 2px 8px var(--text-shadow);
  margin-bottom: 6px;
}

.app-subtitle {
  font-size: 14px;
  color: var(--ocean-pale);
  opacity: 0.85;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  color: var(--ocean-pale);
  margin-bottom: 18px;
  letter-spacing: 0.05em;
}

/* ===== 難易度カード ===== */
.difficulty-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.difficulty-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  width: 100%;
  color: var(--white);
}
.difficulty-card:active { transform: scale(0.97); }

.difficulty-card.beginner     { border-color: rgba(6,214,160,0.5);  background: rgba(6,214,160,0.12); }
.difficulty-card.intermediate { border-color: rgba(0,180,216,0.5);  background: rgba(0,180,216,0.12); }
.difficulty-card.advanced     { border-color: rgba(255,107,107,0.5); background: rgba(255,107,107,0.12); }
.difficulty-card.expert       { border-color: rgba(155,89,182,0.5);  background: rgba(155,89,182,0.12); }
.difficulty-card.mixed        { border-color: rgba(255,209,102,0.5); background: rgba(255,209,102,0.12); }

.card-icon {
  font-size: 40px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.card-content { flex: 1; }

.card-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 2px;
}

.card-subtitle {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 6px;
}

.card-info {
  display: flex;
  gap: 10px;
}

.card-count, .card-point {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  font-weight: 700;
}

.card-max {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-top: 4px;
}

.card-arrow {
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  flex-shrink: 0;
}

/* ===== ハイスコアセクション ===== */
.highscore-section {
  margin-top: 28px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.highscore-title {
  font-size: 13px;
  color: var(--ocean-pale);
  font-weight: 700;
  margin-bottom: 10px;
  text-align: center;
}

.highscore-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.highscore-item {
  text-align: center;
  padding: 8px 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
}

.highscore-icon { font-size: 18px; }
.highscore-label { font-size: 10px; color: rgba(255,255,255,0.6); margin: 2px 0; }
.highscore-value { font-size: 14px; font-weight: 800; color: var(--sand); }

/* ================================================
   クイズ画面
   ================================================ */
.quiz-container {
  min-height: 100%;
  padding: calc(var(--safe-top) + 0px) 0 calc(var(--safe-bottom) + 20px);
  max-width: 480px;
  margin: 0 auto;
}

/* クイズヘッダー */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(3,4,94,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: var(--white);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-back:active { background: rgba(255,255,255,0.25); }

.quiz-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quiz-progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ocean-mid), var(--seaweed));
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

.quiz-progress-text {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  text-align: right;
}

.quiz-score-badge {
  background: var(--sand);
  color: var(--ocean-deep);
  font-size: 13px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
  flex-shrink: 0;
  min-width: 52px;
  text-align: center;
  transition: transform 0.2s ease;
}

.quiz-score-badge.bump {
  animation: scoreBump 0.3s ease;
}

@keyframes scoreBump {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.25); }
}

/* 難易度バッジ */
.quiz-difficulty-badge {
  margin: 10px 16px 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.quiz-difficulty-badge.beginner     { background: rgba(6,214,160,0.25);  border: 1px solid rgba(6,214,160,0.5);  }
.quiz-difficulty-badge.intermediate { background: rgba(0,180,216,0.25);  border: 1px solid rgba(0,180,216,0.5);  }
.quiz-difficulty-badge.advanced     { background: rgba(255,107,107,0.25); border: 1px solid rgba(255,107,107,0.5); }
.quiz-difficulty-badge.expert       { background: rgba(155,89,182,0.25);  border: 1px solid rgba(155,89,182,0.5);  }
.quiz-difficulty-badge.mixed        { background: rgba(255,209,102,0.25); border: 1px solid rgba(255,209,102,0.5); }

/* クイズメインエリア */
.quiz-main {
  padding: 0 16px 20px;
}

/* ===== 生き物画像コンテナ ===== */
.creature-image-container {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(135deg, #023E8A, #0077B6);
  position: relative;
  margin-bottom: 6px;
  box-shadow: var(--shadow-card);
}

.creature-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: opacity 0.4s ease;
}

.img-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #023E8A, #0077B6);
  z-index: 2;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--ocean-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.img-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #023E8A, #0077B6);
  z-index: 2;
}
.img-error span { font-size: 72px; line-height: 1; }
.img-error p {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-top: 8px;
}

/* 著作権クレジット */
.photo-credit {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  text-align: right;
  margin-bottom: 14px;
  padding-right: 2px;
}

/* 問題文ラップ */
.question-wrap {
  position: relative;
  margin-bottom: 18px;
}

.question-point-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255,209,102,0.25);
  color: var(--sand);
  border: 1px solid rgba(255,209,102,0.5);
  margin-bottom: 8px;
}

.question-text {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ===== 選択肢グリッド ===== */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.choice-btn {
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.10);
  color: var(--white);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 58px;
  text-align: center;
  line-height: 1.3;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.choice-btn:not(:disabled):active { transform: scale(0.95); }

.choice-label {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.7;
  flex-shrink: 0;
}

.choice-btn.correct {
  background: rgba(6,214,160,0.35);
  border-color: var(--seaweed);
  color: var(--white);
  animation: correctPulse 0.4s ease;
}

.choice-btn.wrong {
  background: rgba(255,107,107,0.3);
  border-color: var(--coral);
  color: rgba(255,255,255,0.6);
}

.choice-btn.dimmed {
  opacity: 0.4;
}

@keyframes correctPulse {
  0%,100% { transform: scale(1); }
  40%      { transform: scale(1.04); }
}

/* ===== 生き物情報 ===== */
.species-info {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeSlideUp 0.35s ease;
}

.species-jp {
  font-size: 18px;
  font-weight: 800;
}
.species-en {
  font-size: 13px;
  color: var(--ocean-pale);
}
.species-latin {
  font-size: 11px;
  font-style: italic;
  color: rgba(255,255,255,0.5);
}

/* ===== 解説ボックス ===== */
.explanation-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 16px;
  animation: fadeSlideUp 0.35s ease;
}

.explanation-icon { font-size: 22px; flex-shrink: 0; }
.explanation-text { font-size: 14px; line-height: 1.6; color: rgba(255,255,255,0.9); }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 次へボタン ===== */
.btn-next {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, var(--ocean-dark), var(--ocean-mid));
  color: var(--white);
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,119,182,0.5);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
  animation: fadeSlideUp 0.3s ease;
}
.btn-next:active { transform: scale(0.97); box-shadow: 0 2px 10px rgba(0,119,182,0.4); }

/* ================================================
   結果画面
   ================================================ */
.result-container {
  min-height: 100%;
  padding: calc(var(--safe-top) + 40px) 24px calc(var(--safe-bottom) + 40px);
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.result-rank-icon {
  font-size: 88px;
  filter: drop-shadow(0 4px 20px rgba(255,209,102,0.5));
  animation: rankBounce 0.6s ease;
}
@keyframes rankBounce {
  0%   { transform: scale(0) rotate(-20deg); }
  60%  { transform: scale(1.15) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.result-rank-label {
  font-size: 26px;
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  text-align: center;
}

.result-score-box {
  background: rgba(255,255,255,0.10);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-lg);
  padding: 24px 40px;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  width: 100%;
  max-width: 320px;
}

.result-score-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.result-score-number {
  font-size: 72px;
  font-weight: 800;
  color: var(--sand);
  line-height: 1;
  text-shadow: 0 2px 12px rgba(255,209,102,0.4);
}
.result-score-unit {
  font-size: 28px;
  font-weight: 800;
  color: var(--sand);
}
.result-accuracy {
  font-size: 16px;
  color: rgba(255,255,255,0.75);
  font-weight: 700;
}

/* 統計グリッド */
.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.stat-item {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
}
.stat-icon  { font-size: 22px; display: block; margin-bottom: 4px; }
.stat-label { font-size: 10px; color: rgba(255,255,255,0.6); }
.stat-value { font-size: 18px; font-weight: 800; color: var(--sand); display: block; margin-top: 2px; }

/* 問題見直し */
.result-review {
  width: 100%;
}
.review-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ocean-pale);
  margin-bottom: 10px;
  text-align: center;
}
.review-list { display: flex; flex-direction: column; gap: 8px; }
.review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  font-size: 13px;
}
.review-item.correct-item { border-left: 3px solid var(--seaweed); }
.review-item.wrong-item   { border-left: 3px solid var(--coral); }
.review-result-icon { font-size: 16px; flex-shrink: 0; }
.review-q-text { flex: 1; line-height: 1.4; color: rgba(255,255,255,0.85); }
.review-answer { font-size: 11px; color: rgba(255,255,255,0.55); flex-shrink: 0; }

/* ボタン */
.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn-retry {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  color: var(--white);
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255,107,107,0.4);
  transition: transform 0.12s ease;
}
.btn-retry:active { transform: scale(0.97); }

.btn-home-result {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  color: var(--white);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.btn-home-result:active { transform: scale(0.97); }

/* ================================================
   ユーティリティ
   ================================================ */
.hidden { display: none !important; }

/* タップ時のハイライト無効化 */
button { -webkit-tap-highlight-color: transparent; }

/* ===== レスポンシブ（大画面） ===== */
@media (min-width: 480px) {
  .home-container,
  .quiz-container,
  .result-container {
    max-width: 480px;
  }
}
