/* ═══════════════════════════════════════════
   東洋医学クエスト ─ スタイル
   ═══════════════════════════════════════════ */

:root {
  --bg: #0f0e17;
  --bg-card: #1a1932;
  --bg-card-hover: #242244;
  --text: #fffffe;
  --text-sub: #a7a9be;
  --accent: #ff8906;
  --success: #2cb67d;
  --danger: #e53170;
  --info: #3498db;
  --font-main: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ─── ステータスバー ─── */
.status-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: rgba(15, 14, 23, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.status-left {
  display: flex; align-items: center; gap: 10px;
}

.level-badge {
  background: linear-gradient(135deg, var(--accent), #e53170);
  color: white;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 20px;
}

.player-title {
  font-size: 14px;
  color: var(--text-sub);
}

.status-right {
  display: flex; align-items: center; gap: 10px;
}

.streak-badge {
  font-size: 14px;
  font-weight: 600;
}

.exp-bar-container {
  width: 80px; height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.exp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #e53170);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ─── 戻るボタン ─── */
.back-btn {
  position: fixed; top: 64px; left: 12px;
  background: rgba(255,255,255,0.08);
  border: none; color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

.back-btn.visible {
  opacity: 1; pointer-events: auto;
}

.back-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* ─── メインコンテンツ ─── */
.main-content {
  padding-top: 56px;
  min-height: 100vh;
}

.view {
  display: none;
  padding: 20px 16px 40px;
  max-width: 600px;
  margin: 0 auto;
}

.view.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ─── ホーム画面 ─── */
.home-view {
  text-align: center;
  padding-top: 24px;
}

.home-title {
  margin-bottom: 28px;
}

.home-icon {
  font-size: 64px;
  animation: float 3s ease-in-out infinite;
  margin-bottom: 8px;
}

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

.home-title h1 {
  font-size: 28px;
  background: linear-gradient(90deg, var(--accent), #e53170, var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.home-title p {
  color: var(--text-sub);
  font-size: 14px;
}

.home-stats {
  margin-bottom: 32px;
}

.home-stat-row {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.home-stat {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 70px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

/* ─── メニューボタン ─── */
.home-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text);
  padding: 16px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.menu-btn:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.menu-btn:active {
  transform: translateY(0);
}

.menu-btn.primary {
  background: linear-gradient(135deg, var(--accent), #e67e22);
  border: none;
}

.menu-btn.primary:hover {
  background: linear-gradient(135deg, #e67e22, var(--accent));
}

.menu-icon {
  font-size: 28px;
  min-width: 36px;
  text-align: center;
}

.menu-text {
  font-size: 16px;
  font-weight: 600;
}

.menu-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-left: auto;
}

.menu-btn.primary .menu-sub {
  color: rgba(255,255,255,0.7);
}

/* ─── ワールドマップ ─── */
.section-title {
  font-size: 22px;
  margin-bottom: 20px;
  padding-top: 12px;
}

.world-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.world-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.world-card:hover {
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.world-card-icon {
  font-size: 32px;
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.world-card-info {
  flex: 1; min-width: 0;
}

.world-card-info h3 {
  font-size: 16px;
  margin-bottom: 2px;
}

.world-card-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.world-card-stats {
  display: flex; gap: 12px;
  font-size: 11px;
  color: var(--text-sub);
}

.world-card-arrow {
  font-size: 20px;
  color: var(--text-sub);
}

/* ─── クイズ画面 ─── */
.quiz-view {
  padding-top: 8px;
}

.quiz-header {
  margin-bottom: 20px;
}

.quiz-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 2px;
  transition: width 0.5s ease;
}

.quiz-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-sub);
}

.quiz-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.quiz-card.slide-in {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

.quiz-category {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  margin-bottom: 16px;
}

.quiz-question {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ─── 選択肢 ─── */
.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}

.choice-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.1);
  border-color: var(--accent);
  transform: translateX(4px);
}

.choice-btn:active:not(:disabled) {
  transform: translateX(2px);
}

.choice-btn:disabled {
  cursor: default;
}

.choice-btn.correct {
  background: rgba(44, 182, 125, 0.2);
  border-color: var(--success);
  color: var(--success);
  animation: correctPulse 0.5s ease;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.choice-btn.wrong {
  background: rgba(229, 49, 112, 0.2);
  border-color: var(--danger);
  color: var(--danger);
  animation: wrongShake 0.4s ease;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ─── 解説 ─── */
.quiz-explanation {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.quiz-explanation.hidden {
  display: none;
}

.explanation-result {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.explanation-result.correct { color: var(--success); }
.explanation-result.wrong { color: var(--danger); }

.streak-bonus {
  font-size: 14px;
  background: linear-gradient(90deg, #ff8906, #e53170);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: streakPulse 0.5s ease;
}

@keyframes streakPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.explanation-text {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.7;
}

/* ─── 次へボタン ─── */
.next-btn {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #e67e22);
  border: none;
  color: white;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255, 137, 6, 0.3);
}

.next-btn.hidden {
  display: none;
}

/* ─── 結果画面 ─── */
.result-view {
  text-align: center;
  padding-top: 16px;
}

.result-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
}

.result-rank {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 8px;
}

.result-card h2 {
  font-size: 28px;
  margin-bottom: 4px;
}

.result-accuracy {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.result-comment {
  color: var(--text-sub);
  font-size: 14px;
  margin-bottom: 16px;
}

.result-streak {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.result-breakdown {
  text-align: left;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.result-breakdown h3 {
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 12px;
}

.result-world-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.result-wrong-list {
  text-align: left;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.result-wrong-list h3 {
  font-size: 14px;
  color: var(--danger);
  margin-bottom: 12px;
}

.result-wrong-item {
  background: rgba(229, 49, 112, 0.08);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.wrong-q { font-weight: 600; margin-bottom: 6px; }
.wrong-your { color: var(--danger); }
.wrong-correct { color: var(--success); }

.result-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-actions .menu-btn {
  justify-content: center;
}

/* ─── 弱点克服 ─── */
.weak-summary {
  text-align: center;
  margin-bottom: 24px;
}

.weak-summary p {
  margin-bottom: 14px;
  color: var(--text-sub);
}

.weak-summary .menu-btn {
  justify-content: center;
  max-width: 300px;
  margin: 0 auto;
}

.weak-world {
  margin-bottom: 20px;
}

.weak-world h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.weak-item {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-sub);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-sub);
  margin-bottom: 20px;
}

.empty-state .menu-btn {
  justify-content: center;
  max-width: 240px;
  margin: 0 auto;
}

/* ─── 成績表 ─── */
.stats-overview {
  margin-bottom: 24px;
}

.stats-level-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}

.stats-level {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), #e53170);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stats-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.stats-next {
  font-size: 12px;
  color: var(--text-sub);
}

.stats-numbers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-box-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.stat-box-label {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 4px;
}

.stats-section-title {
  font-size: 16px;
  color: var(--text-sub);
  margin-bottom: 14px;
}

.stats-worlds {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stat-world-row {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
}

.stat-world-header {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 8px;
}

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

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.stats-reset {
  text-align: center;
  margin-top: 32px;
}

.reset-btn {
  background: none;
  border: 1px solid rgba(229, 49, 112, 0.3);
  color: var(--danger);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-btn:hover {
  background: rgba(229, 49, 112, 0.1);
}

/* ─── オーバーレイ ─── */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.level-up-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
  max-width: 320px;
  animation: popIn 0.4s ease;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.level-up-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.level-up-card h2 {
  font-size: 28px;
  background: linear-gradient(90deg, var(--accent), #e53170);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.level-up-level {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 4px;
}

.level-up-title {
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 20px;
}

.continue-btn {
  background: linear-gradient(135deg, var(--accent), #e67e22);
  border: none;
  color: white;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.continue-btn:hover {
  transform: translateY(-2px);
}

/* ─── 紙吹雪 ─── */
.confetti-container {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  pointer-events: none;
  z-index: 300;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -10px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ─── パーティクル背景 ─── */
.particles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  bottom: -10px;
  width: 3px; height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  animation: particleRise linear infinite;
}

@keyframes particleRise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(-100vh) translateX(40px); opacity: 0; }
}

/* ─── レスポンシブ ─── */
@media (max-width: 400px) {
  .home-stat-row {
    gap: 8px;
  }
  .home-stat {
    padding: 10px 12px;
    min-width: 60px;
  }
  .stat-value { font-size: 18px; }
  .quiz-question { font-size: 16px; }
  .choice-btn { font-size: 14px; padding: 12px 14px; }
  .result-rank { font-size: 56px; }
  .result-accuracy { font-size: 36px; }
}

/* ─── PWA全画面対応 ─── */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
  }
  .status-bar {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }
}
