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

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: #1a1a3a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0c0;
  --accent: #6c5ce7;
  --gold: #FFD700;
  --purple: #9B59B6;
  --blue: #3498DB;
  --gray: #95A5A6;
  --card-width: 300px;
  --card-height: 520px;
}

body {
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== ヘッダー ===== */
.app-header {
  text-align: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--bg-secondary), transparent);
  position: relative;
}

.app-header h1 {
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--gold), #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.app-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ===== ナビゲーション ===== */
.nav-bar {
  display: flex;
  justify-content: center;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  max-width: 160px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
  font-family: inherit;
}

.nav-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.nav-btn:hover { color: var(--text-primary); }

/* ===== 画面切替 ===== */
.screen { display: none; padding: 20px; max-width: 800px; margin: 0 auto; }
.screen.active { display: block; }

/* ===== ガチャ画面 ===== */
.gacha-screen { text-align: center; }

.pack-container {
  margin: 30px auto;
  width: 220px;
  height: 300px;
  perspective: 800px;
  cursor: pointer;
}

.pack {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a3a, #2a2a5a, #1a1a3a);
  border: 3px solid var(--gold);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}

.pack:hover {
  transform: translateY(-5px) rotateY(5deg);
  box-shadow: 0 10px 40px rgba(108, 92, 231, 0.4);
}

.pack::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 40%, rgba(255,215,0,0.1) 50%, transparent 60%);
  animation: packShine 3s infinite;
}

@keyframes packShine {
  0% { transform: translateX(-100%) rotate(45deg); }
  100% { transform: translateX(100%) rotate(45deg); }
}

.pack-icon { font-size: 4rem; margin-bottom: 10px; position: relative; z-index: 1; }
.pack-title { font-size: 1.1rem; font-weight: bold; color: var(--gold); position: relative; z-index: 1; }
.pack-subtitle { font-size: 0.75rem; color: var(--text-secondary); margin-top: 5px; position: relative; z-index: 1; }

.gacha-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 20px 0;
}

.gacha-btn {
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.gacha-btn-single {
  background: linear-gradient(135deg, var(--accent), #5a4bd6);
  color: white;
}

.gacha-btn-ten {
  background: linear-gradient(135deg, var(--gold), #e6a800);
  color: #1a1a3a;
}

.gacha-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.gacha-btn:active { transform: translateY(0); }

.stats-bar {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
}

.stat-item { text-align: center; }
.stat-value { font-size: 1.4rem; font-weight: bold; color: var(--gold); }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== ガチャ演出画面 ===== */
.gacha-reveal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.gacha-reveal-overlay.active { display: flex; }

.gacha-reveal-overlay .reveal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-height: 100vh;
  padding: 20px;
}

.reveal-card-container {
  position: relative;
  width: var(--card-width);
  max-width: 90vw;
}

.reveal-counter {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 16px;
  text-align: center;
  font-weight: bold;
  letter-spacing: 2px;
  padding-top: 10px;
}

.reveal-tap-hint {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 20px;
  animation: pulse 1.5s infinite;
}

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

/* SSR演出 */
.ssr-effect {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 999;
}

/* 回転する光線 */
.ssr-effect .rays {
  position: absolute;
  top: 50%; left: 50%;
  width: 200vmax;
  height: 200vmax;
  transform: translate(-50%, -50%);
  background: conic-gradient(from 0deg,
    transparent, rgba(255,215,0,0.25), transparent,
    rgba(255,165,0,0.2), transparent,
    rgba(255,215,0,0.25), transparent,
    rgba(255,165,0,0.2), transparent);
  animation: rotateRays 3s linear infinite;
}

@keyframes rotateRays { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* 中央からの放射フラッシュ */
.ssr-effect .radial-burst {
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,215,0,0.6), rgba(255,165,0,0.3), transparent);
  transform: translate(-50%, -50%);
  animation: radialBurst 1.2s ease-out forwards;
}

@keyframes radialBurst {
  0% { width: 0; height: 0; opacity: 1; }
  50% { width: 150vmax; height: 150vmax; opacity: 0.5; }
  100% { width: 200vmax; height: 200vmax; opacity: 0; }
}

/* 画面フラッシュ */
.ssr-effect .screen-flash {
  position: absolute;
  inset: 0;
  background: white;
  animation: screenFlash 0.8s ease-out forwards;
}

@keyframes screenFlash {
  0% { opacity: 0.9; }
  30% { opacity: 0.4; }
  100% { opacity: 0; }
}

/* 落ちてくる金の雨 */
.ssr-effect .gold-rain {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  overflow: hidden;
}

.gold-rain-drop {
  position: absolute;
  top: -10px;
  width: 3px;
  height: 12px;
  background: linear-gradient(to bottom, transparent, var(--gold));
  border-radius: 2px;
  animation: goldRainFall linear infinite;
}

@keyframes goldRainFall {
  0% { transform: translateY(-10px); opacity: 0.8; }
  100% { transform: translateY(110vh); opacity: 0; }
}

.ssr-effect .particles { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.ssr-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--gold), 0 0 12px rgba(255,165,0,0.5);
  animation: floatParticle 2s ease-in-out infinite;
}

@keyframes floatParticle {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: translateY(-20vh) scale(1); opacity: 0; }
}

/* 星型パーティクル */
.ssr-star {
  position: absolute;
  font-size: 1.2rem;
  animation: starFloat 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(255,215,0,0.8));
}

@keyframes starFloat {
  0% { transform: translateY(100vh) rotate(0deg) scale(0); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(-20vh) rotate(360deg) scale(1.2); opacity: 0; }
}

/* 画面端のゴールドグロウ */
.ssr-effect .edge-glow {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 80px rgba(255,215,0,0.3), inset 0 0 160px rgba(255,165,0,0.15);
  animation: edgeGlowPulse 1.5s ease-in-out infinite alternate;
}

@keyframes edgeGlowPulse {
  0% { box-shadow: inset 0 0 60px rgba(255,215,0,0.2), inset 0 0 120px rgba(255,165,0,0.1); }
  100% { box-shadow: inset 0 0 100px rgba(255,215,0,0.4), inset 0 0 200px rgba(255,165,0,0.2); }
}

/* SSRカード出現アニメーション（より派手） */
.card-appear-ssr {
  animation: cardAppearSSR 1.0s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardAppearSSR {
  0% { transform: scale(0) rotateY(360deg); opacity: 0; filter: brightness(3); }
  30% { transform: scale(1.3) rotateY(90deg); opacity: 1; filter: brightness(2); }
  60% { transform: scale(1.15) rotateY(0deg); filter: brightness(1.5); }
  80% { transform: scale(0.95); filter: brightness(1.2); }
  100% { transform: scale(1) rotateY(0deg); opacity: 1; filter: brightness(1); }
}

/* SR演出 */
.sr-effect {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 999;
  background: radial-gradient(circle at center, rgba(155, 89, 182, 0.2), transparent 70%);
  animation: srGlow 1.5s ease-in-out infinite alternate;
}

@keyframes srGlow {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* ===== MTG風カードデザイン ===== */
.card {
  width: var(--card-width);
  max-width: 90vw;
  height: var(--card-height);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s;
  flex-shrink: 0;
}

.card:hover { transform: translateY(-4px); }

/* レアリティ別外枠 */
.card-border {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 4px;
  z-index: 1;
}

.card[data-rarity="SSR"] .card-border {
  background: linear-gradient(135deg, #FFD700, #FFA500, #FFD700, #fff, #FFD700);
  background-size: 300% 300%;
  animation: shimmer 3s ease infinite;
}

.card[data-rarity="SR"] .card-border {
  background: linear-gradient(135deg, #9B59B6, #8E44AD, #C39BD3, #9B59B6);
  background-size: 300% 300%;
  animation: shimmer 4s ease infinite;
}

.card[data-rarity="R"] .card-border {
  background: linear-gradient(135deg, #3498DB, #2980B9, #5DADE2, #3498DB);
}

.card[data-rarity="N"] .card-border {
  background: linear-gradient(135deg, #95A5A6, #7F8C8D, #BDC3C7, #95A5A6);
}

@keyframes shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.card-inner {
  position: absolute;
  inset: 4px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1c1c3a 0%, #15152a 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
}

/* カード名 */
.card-name {
  padding: 10px 12px 6px;
  font-size: 0.85rem;
  font-weight: bold;
  line-height: 1.3;
  min-height: 46px;
  display: flex;
  align-items: center;
}

.card[data-rarity="SSR"] .card-name { color: var(--gold); }
.card[data-rarity="SR"] .card-name { color: var(--purple); }
.card[data-rarity="R"] .card-name { color: var(--blue); }
.card[data-rarity="N"] .card-name { color: var(--gray); }

/* イラストエリア */
.card-image {
  margin: 0 10px;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card[data-rarity="SSR"] .card-image { background: linear-gradient(135deg, #1a0a00, #2a1500, #1a0a00); border: 1px solid rgba(255,215,0,0.3); }
.card[data-rarity="SR"] .card-image { background: linear-gradient(135deg, #0d0015, #1a002a, #0d0015); border: 1px solid rgba(155,89,182,0.3); }
.card[data-rarity="R"] .card-image { background: linear-gradient(135deg, #000a15, #00152a, #000a15); border: 1px solid rgba(52,152,219,0.3); }
.card[data-rarity="N"] .card-image { background: linear-gradient(135deg, #0d0d0d, #1a1a1a, #0d0d0d); border: 1px solid rgba(149,165,166,0.3); }

.card-image-icon { font-size: 5rem; }

.card-image-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ホログラフィックエフェクト（SSR/SR） */
.card[data-rarity="SSR"] .card-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,215,0,0.1), transparent, rgba(255,165,0,0.1), transparent);
  background-size: 200% 200%;
  animation: holoShift 3s ease infinite;
}

.card[data-rarity="SR"] .card-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(155,89,182,0.1), transparent);
  background-size: 200% 200%;
  animation: holoShift 4s ease infinite;
}

@keyframes holoShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* カードタイプバー */
.card-type-bar {
  padding: 4px 12px;
  font-size: 0.65rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-rarity-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.7rem;
}

.card[data-rarity="SSR"] .card-rarity-badge { background: rgba(255,215,0,0.2); color: var(--gold); }
.card[data-rarity="SR"] .card-rarity-badge { background: rgba(155,89,182,0.2); color: var(--purple); }
.card[data-rarity="R"] .card-rarity-badge { background: rgba(52,152,219,0.2); color: var(--blue); }
.card[data-rarity="N"] .card-rarity-badge { background: rgba(149,165,166,0.2); color: var(--gray); }

/* 説明文エリア */
.card-description {
  flex: 1;
  margin: 0 10px;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  font-size: 0.65rem;
  line-height: 1.5;
  color: var(--text-secondary);
  overflow-y: auto;
}

.card-flavor {
  margin-top: 6px;
  font-style: italic;
  color: rgba(255,255,255,0.4);
  font-size: 0.6rem;
}

/* 引用元 */
.card-source {
  padding: 3px 12px;
  font-size: 0.55rem;
}

.card-source a {
  color: var(--accent);
  text-decoration: none;
  opacity: 0.7;
}

.card-source a:hover { opacity: 1; text-decoration: underline; }

/* ステータスバー */
.card-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  padding: 0;
  background: rgba(255,255,255,0.05);
}

.card-stat {
  text-align: center;
  padding: 5px 2px;
  background: rgba(0,0,0,0.3);
}

.card-stat-label {
  font-size: 0.5rem;
  color: var(--text-secondary);
  display: block;
}

.card-stat-value {
  font-size: 0.6rem;
  font-weight: bold;
  display: block;
  margin-top: 1px;
}

/* ===== コレクション画面 ===== */
.collection-screen { padding-bottom: 80px; }

.collection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.collection-title { font-size: 1.2rem; }

.completion-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

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

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.filter-btn:hover { border-color: var(--accent); }

/* ===== 詳細フィルター ===== */
.advanced-filters {
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.filter-row:last-of-type {
  margin-bottom: 0;
}

.filter-select {
  flex: 1;
  min-width: 0;
  padding: 8px 28px 8px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23a0a0c0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
}

.filter-select:hover {
  border-color: var(--accent);
}

.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.25);
}

.filter-select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 6px;
}

.filter-reset-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-family: inherit;
  padding: 4px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-reset-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.15);
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

/* ミニカード（コレクション用） */
.mini-card {
  aspect-ratio: 5/7;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s;
}

.mini-card:hover { transform: scale(1.05); }

.mini-card.locked {
  filter: brightness(0.2);
  cursor: default;
}

.mini-card.locked::after {
  content: "?";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: rgba(255,255,255,0.2);
}

.mini-card-border {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  padding: 3px;
}

.mini-card[data-rarity="SSR"] .mini-card-border { background: linear-gradient(135deg, #FFD700, #FFA500, #FFD700); }
.mini-card[data-rarity="SR"] .mini-card-border { background: linear-gradient(135deg, #9B59B6, #8E44AD, #9B59B6); }
.mini-card[data-rarity="R"] .mini-card-border { background: linear-gradient(135deg, #3498DB, #2980B9, #3498DB); }
.mini-card[data-rarity="N"] .mini-card-border { background: linear-gradient(135deg, #95A5A6, #7F8C8D, #95A5A6); }

.mini-card-inner {
  position: absolute;
  inset: 3px;
  border-radius: 7px;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

.mini-card-icon { font-size: 1.8rem; margin-bottom: 6px; }

.mini-card-image {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 6px;
}

.mini-card-name {
  font-size: 0.6rem;
  line-height: 1.3;
  color: var(--text-secondary);
}

.mini-card-count {
  position: absolute;
  bottom: 6px; right: 8px;
  font-size: 0.55rem;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.5);
  padding: 1px 5px;
  border-radius: 3px;
}

.mini-card[data-rarity="SSR"] .mini-card-name { color: var(--gold); }
.mini-card[data-rarity="SR"] .mini-card-name { color: var(--purple); }
.mini-card[data-rarity="R"] .mini-card-name { color: var(--blue); }

/* ===== スタミナ表示 ===== */
.stamina-display {
  margin: 0 auto 12px;
  max-width: 320px;
  text-align: center;
}
.stamina-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}
.stamina-icon { font-size: 1.2rem; }
.stamina-label { font-size: 0.85rem; color: var(--text-secondary); }
.stamina-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  transition: transform 0.3s;
}
.stamina-value.pulse {
  animation: staminaPulse 0.4s ease;
}
@keyframes staminaPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); color: #fff; }
  100% { transform: scale(1); }
}
.stamina-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.stamina-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* 回数不足パネル */
.stamina-empty {
  margin-top: 16px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}
.stamina-empty-title {
  font-size: 0.95rem;
  color: #e74c3c;
  margin-bottom: 14px;
}
.stamina-recovery-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 300px;
  margin: 0 auto;
}
.recovery-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.recovery-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--accent);
}
.recovery-btn:active { transform: scale(0.97); }
.recovery-amount {
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 700;
}
.recovery-btn-sm {
  padding: 8px 12px;
  font-size: 0.75rem;
}
.stamina-reset-hint {
  margin-top: 10px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ===== クイズ画面 ===== */
.quiz-screen { padding-bottom: 80px; }
.quiz-title {
  margin-bottom: 16px;
  font-size: 1.15rem;
}

/* モード切替ボタン */
.quiz-mode-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.quiz-mode-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}
.quiz-mode-btn:hover:not(.active) {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* スコアバー */
.quiz-stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.quiz-stats-bar b { color: var(--text-primary); }
.quiz-streak { color: #e67e22; }

/* 報酬進捗バー */
.quiz-reward-bar {
  margin-bottom: 18px;
}
.quiz-reward-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.quiz-reward-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.quiz-reward-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* 問題エリア */
.quiz-question-area {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  min-height: 200px;
}
.quiz-question-number {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 12px;
}
.quiz-question-text {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 20px;
  white-space: pre-line;
}

/* 選択肢ボタン */
.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  line-height: 1.4;
}
.quiz-choice-btn:hover {
  border-color: var(--accent);
  background: rgba(255,255,255,0.05);
}
.quiz-choice-btn:active { transform: scale(0.98); }
.quiz-choice-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.quiz-choice-btn.correct {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.15);
  pointer-events: none;
}
.quiz-choice-btn.correct .quiz-choice-label {
  background: #2ecc71;
  color: #fff;
}
.quiz-choice-btn.wrong {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.15);
  pointer-events: none;
}
.quiz-choice-btn.wrong .quiz-choice-label {
  background: #e74c3c;
  color: #fff;
}
.quiz-choice-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* スタートプロンプト */
.quiz-start-prompt {
  text-align: center;
  padding: 40px 0;
  color: var(--text-secondary);
}
.quiz-start-btn {
  margin-top: 16px;
  padding: 12px 40px;
  border-radius: 25px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #9b59b6);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-start-btn:hover { transform: scale(1.05); }
.quiz-start-btn:active { transform: scale(0.97); }

/* 結果エリア */
.quiz-result-area {
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.quiz-result-area.result-correct {
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.3);
}
.quiz-result-area.result-wrong {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
}
.quiz-result-icon {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.quiz-result-icon.correct-icon { color: #2ecc71; }
.quiz-result-icon.wrong-icon { color: #e74c3c; }
.quiz-result-explanation {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 8px;
}
.quiz-result-card-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  text-decoration: underline;
}

/* 次の問題ボタン */
.quiz-next-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #9b59b6);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
}
.quiz-next-btn:hover { opacity: 0.9; }
.quiz-next-btn:active { transform: scale(0.98); }

/* クイズフッター (シェア/広告) */
.quiz-footer {
  margin-top: 24px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}
.quiz-footer-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-align: center;
}
.quiz-footer-btns {
  display: flex;
  gap: 8px;
}
.quiz-footer-btns .recovery-btn-sm {
  flex: 1;
}

/* ===== トースト通知 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--gold);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 3000;
  white-space: nowrap;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ===== 広告オーバーレイ ===== */
.ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 40px 30px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  border: 1px solid rgba(255,255,255,0.1);
}
.ad-label {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}
.ad-timer {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.ad-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.ad-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 3px;
}
.ad-hint {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ===== ガチャボタン disabled ===== */
.gacha-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.5);
}

/* ===== カード詳細モーダル ===== */
.card-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.card-modal-overlay.active { display: flex; }

.card-modal-close {
  position: fixed;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 2001;
}

/* カード出現アニメーション */
.card-appear {
  animation: cardAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardAppear {
  0% { transform: scale(0.3) rotateY(180deg); opacity: 0; }
  60% { transform: scale(1.1) rotateY(0deg); opacity: 1; }
  100% { transform: scale(1) rotateY(0deg); opacity: 1; }
}

/* パック開封アニメーション */
.pack-opening {
  animation: packOpen 0.8s ease-out forwards;
}

@keyframes packOpen {
  0% { transform: scale(1); }
  30% { transform: scale(1.1) rotateZ(-3deg); }
  50% { transform: scale(1.15) rotateZ(3deg); }
  70% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(2); }
}

/* ===== レスポンシブ ===== */
@media (max-width: 480px) {
  :root {
    --card-width: 260px;
    --card-height: 460px;
  }

  .app-header h1 { font-size: 1.2rem; }
  .gacha-buttons { flex-direction: column; align-items: center; }
  .gacha-btn { width: 200px; }
  .collection-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .stats-bar { flex-wrap: wrap; }
  .filter-row { flex-direction: column; }
  .quiz-mode-bar { flex-wrap: wrap; }
  .quiz-mode-btn { flex: none; width: calc(33% - 6px); }
  .quiz-footer-btns { flex-direction: column; }
  .quiz-choice-btn { font-size: 0.8rem; padding: 12px 14px; }
}

@media (min-width: 768px) {
  :root {
    --card-width: 340px;
    --card-height: 560px;
  }
}

/* ===== ガチャ結果オーバーレイ ===== */
.gacha-result-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 3000;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.gacha-result-overlay.active { display: flex; justify-content: center; align-items: flex-start; }

.gacha-result-content {
  width: 100%;
  max-width: 600px;
  padding: 24px 16px 40px;
  margin: 20px auto;
}

.gacha-result-header {
  text-align: center;
  margin-bottom: 20px;
}
.gacha-result-title {
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--gold), #fff, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

/* ガチャ結果 ミニカード一覧 */
.gacha-result-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.result-mini-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
}
.result-mini-card:hover {
  transform: translateY(-2px);
}
.result-mini-card[data-rarity="SSR"] { border-color: var(--gold); }
.result-mini-card[data-rarity="SR"] { border-color: var(--purple); }
.result-mini-card[data-rarity="R"] { border-color: var(--blue); }
.result-mini-card[data-rarity="N"] { border-color: rgba(255,255,255,0.1); }

.result-mini-card .rmc-icon { font-size: 1.4rem; display: block; margin-bottom: 2px; }

.result-mini-card .rmc-image {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  margin: 0 auto 2px;
}
.result-mini-card .rmc-rarity {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.result-mini-card[data-rarity="SSR"] .rmc-rarity { color: var(--gold); }
.result-mini-card[data-rarity="SR"] .rmc-rarity { color: var(--purple); }
.result-mini-card[data-rarity="R"] .rmc-rarity { color: var(--blue); }
.result-mini-card[data-rarity="N"] .rmc-rarity { color: var(--gray); }
.result-mini-card .rmc-name {
  font-size: 0.6rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* NEW バッジ */
.result-mini-card .rmc-new {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  line-height: 1.3;
}

/* カード詳細ページリンク */
.result-mini-card .rmc-page-link {
  display: block;
  margin-top: 4px;
  font-size: 0.55rem;
  color: var(--accent);
  text-decoration: none;
}
.result-mini-card .rmc-page-link:hover { text-decoration: underline; }

/* ガチャ結果サマリー */
.gacha-result-summary {
  text-align: center;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.result-rarity-count {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(0,0,0,0.3);
}
.result-rarity-count.rarity-SSR { color: var(--gold); border: 1px solid var(--gold); }
.result-rarity-count.rarity-SR { color: var(--purple); border: 1px solid var(--purple); }
.result-rarity-count.rarity-R { color: var(--blue); border: 1px solid var(--blue); }
.result-rarity-count.rarity-N { color: var(--gray); border: 1px solid var(--gray); }

/* ガチャ結果アクションボタン */
.gacha-result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gacha-result-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.gacha-result-btn:hover { opacity: 0.85; }
.btn-share-result {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
}
.btn-repull {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
}
.btn-to-collection {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.15) !important;
}
.btn-close-result {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.1) !important;
}

/* モーダル内カード詳細リンク */
.modal-card-page-link {
  display: block;
  text-align: center;
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 10px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.1);
  transition: border-color 0.2s;
}
.modal-card-page-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

@media (max-width: 480px) {
  .gacha-result-cards { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .result-mini-card { padding: 8px 2px; }
  .result-mini-card .rmc-icon { font-size: 1.1rem; }
  .gacha-result-title { font-size: 1.1rem; }
}

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

/* スクロールバー */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* フォーカスアウトライン */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
