/* ============================
   Darts Games - 共通スタイル
   ============================ */

:root {
  --theme-color: #378ADD;
  --theme-color-rgb: 55, 138, 221;
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #242424;
  --surface3: #2e2e2e;
  --text: #ffffff;
  --text-muted: #888888;
  --text-dim: #555555;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --correct: #22c55e;
  --correct-rgb: 34, 197, 94;
  --wrong: #ef4444;
  --wrong-rgb: 239, 68, 68;
  --warning: #f59e0b;
  --warning-rgb: 245, 158, 11;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  line-height: 1.5;
}

/* === ヘッダー === */
.game-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  border-bottom: 1px solid var(--surface2);
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}

.game-header h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

/* === ボタン === */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  font-family: inherit;
  text-decoration: none;
  gap: 8px;
  width: 100%;
}

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

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn-primary {
  background: var(--theme-color);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-correct {
  background: var(--correct);
  color: white;
}

.btn-wrong {
  background: var(--wrong);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--theme-color);
  border: 2px solid var(--theme-color);
}

.btn-sm {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 15px;
}

.btn-lg {
  min-height: 64px;
  font-size: 22px;
}

/* === カード === */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.card-elevated {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

/* === 入力 === */
.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 2px solid var(--surface3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--theme-color);
}

/* === プログレスバー === */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--theme-color);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* === バッジ === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-theme {
  background: rgba(var(--theme-color-rgb), 0.15);
  color: var(--theme-color);
}

.badge-correct {
  background: rgba(var(--correct-rgb), 0.15);
  color: var(--correct);
}

.badge-wrong {
  background: rgba(var(--wrong-rgb), 0.15);
  color: var(--wrong);
}

/* === タイマーバー === */
.timer-bar {
  width: 100%;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: var(--theme-color);
  border-radius: 4px;
  transition: width 0.1s linear;
}

.timer-bar-fill.danger {
  background: var(--wrong);
  animation: pulse-danger 0.5s ease-in-out infinite;
}

/* === フラッシュ === */
.flash-correct {
  animation: flash-green 0.4s ease;
}

.flash-wrong {
  animation: flash-red 0.4s ease;
}

/* === ボトムシート === */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

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

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 201;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-sheet.active {
  transform: translateX(-50%) translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  margin: 0 auto 20px;
}

/* === テンキー === */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
}

.numpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, background 0.1s;
}

.numpad-btn:active {
  transform: scale(0.95);
  background: var(--surface3);
}

.numpad-btn.action {
  background: var(--theme-color);
  color: white;
}

.numpad-btn.delete {
  background: var(--surface3);
  font-size: 18px;
}

/* === 紙吹雪 === */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confetti-fall 2.5s ease-in forwards;
}

/* === スコア表示 === */
.score-display {
  font-size: 48px;
  font-weight: 800;
  text-align: center;
  line-height: 1;
}

.score-label {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

/* === ストリーク === */
.streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 20px;
  font-weight: 700;
  color: var(--warning);
}

/* === 難易度セレクタ === */
.difficulty-selector {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius);
}

.difficulty-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.difficulty-btn.active {
  background: var(--theme-color);
  color: white;
}

/* === リザルト画面 === */
.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px 20px;
  min-height: 80dvh;
  text-align: center;
}

.result-score {
  font-size: 72px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--theme-color), #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.result-stat {
  text-align: center;
}

.result-stat-value {
  font-size: 28px;
  font-weight: 700;
}

.result-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* === ページコンテンツ === */
.page-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* === 汎用ユーティリティ === */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; }
.text-2xl { font-size: 28px; }
.text-3xl { font-size: 36px; }
.font-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.w-full { width: 100%; }

/* === アニメーション === */
@keyframes flash-green {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(var(--correct-rgb), 0.3); }
}

@keyframes flash-red {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(var(--wrong-rgb), 0.3); }
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

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

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.animate-slide-up { animation: slide-up 0.3s ease; }
.animate-fade-in { animation: fade-in 0.3s ease; }
.animate-bounce-in { animation: bounce-in 0.5s ease; }
.animate-shake { animation: shake 0.4s ease; }

/* === アクセシビリティ === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* === カード3Dフリップ === */
.flip-card {
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* === SVGボード === */
.dart-board-container {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  aspect-ratio: 1;
}

.dart-board-container svg {
  width: 100%;
  height: 100%;
}

/* === 4択カラーボタン === */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-btn {
  min-height: 64px;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: white;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.1s;
  word-break: break-all;
}

.choice-btn:active {
  transform: scale(0.97);
}

.choice-btn:nth-child(1) { background: #e74c3c; }
.choice-btn:nth-child(2) { background: #3498db; }
.choice-btn:nth-child(3) { background: #f39c12; }
.choice-btn:nth-child(4) { background: #27ae60; }

.choice-btn.correct-answer {
  animation: flash-green 0.5s ease;
  outline: 3px solid var(--correct);
}

.choice-btn.wrong-answer {
  opacity: 0.4;
}

/* === 縦並び選択肢 === */
.choice-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-stack .choice-btn {
  width: 100%;
}

/* === 円形タイマー === */
.circle-timer {
  width: 48px;
  height: 48px;
  position: relative;
}

.circle-timer svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.circle-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

/* === ゲームカード（トップ用） === */
.game-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.1s, background 0.15s;
  border: 1px solid var(--surface2);
}

.game-card:active {
  transform: scale(0.98);
  background: var(--surface2);
}

.game-card-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

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

.game-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.game-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
}

.game-card-arrow {
  color: var(--text-dim);
  font-size: 20px;
  flex-shrink: 0;
}

/* === パスワード画面 === */
.password-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  gap: 24px;
}

.password-logo {
  max-width: 120px;
  max-height: 120px;
}

.password-input-group {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.password-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.password-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface2);
  transition: background 0.2s;
}

.password-dot.filled {
  background: var(--theme-color);
}

/* === トリビアカード === */
.trivia-card {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  border-left: 3px solid var(--theme-color);
}

.trivia-card::before {
  content: "💡 ";
}

/* === スワイプ対応ボタン === */
.swipe-buttons {
  display: flex;
  gap: 12px;
}

.swipe-buttons .btn {
  flex: 1;
}
