/* 倍数カードコレクター - 完全スコープ化CSS（グローバル衝突完全回避） */

/* ルートラッパー + リセット（グローバル指定を完全排除） */
.mcc,
.mcc * {
  box-sizing: border-box;
}

.mcc {
  /* CSS変数をスコープ内に限定 */
  --primary: #3b82f6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  
  /* サイド幅を可変に */
  --side: clamp(160px, 18vw, 240px);
  
  /* bodyの代わりにルートのスタイル */
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  margin: 0;
}

.mcc .mcc-game-container {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
  overflow: visible;
  width: 100%;
  max-width: clamp(960px, 92vw, 1280px);
  display: flex;
  flex-direction: column;
}

.mcc .mcc-header {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: white;
  padding: 16px;
  text-align: center;
}

.mcc .mcc-header h1 {
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  font-weight: 800;
  margin: 0;
}

.mcc .mcc-main-content {
  flex: 1;
  min-height: 0;
}

/* 可変サイド幅の3カラムレイアウト */
.mcc .mcc-layout-3col {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--side);
  gap: 20px;
  padding: 20px;
  background: var(--background);
  border-top: 1px solid var(--border);
}

.mcc .mcc-center {
  min-height: 600px;
}

.mcc .mcc-sidebar .mcc-panel {
  position: sticky;
  top: 20px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: visible; /* sticky動作を阻害しない */
}

/* 左ステータスカード */
.mcc .mcc-sidebar.mcc-left .mcc-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

.mcc .mcc-sidebar.mcc-left .mcc-info-card .mcc-label {
  font-size: .85rem;
  color: var(--text-light);
  margin-bottom: 4px;
}

.mcc .mcc-sidebar.mcc-left .mcc-info-card .mcc-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

/* 右ボタン束=最長テキスト基準で揃える（完全スコープ化） */
.mcc .mcc-controls.mcc-vertical {
  display: inline-flex;
  flex-direction: column;
  gap: 12px;
  width: max-content;    /* 最長ボタン幅=親幅 */
  align-items: stretch;
  margin: 0;
}

.mcc .mcc-sidebar.mcc-right .mcc-controls.mcc-vertical {
  align-self: center;    /* パネル内で中央配置 */
}

.mcc .mcc-controls.mcc-vertical .mcc-btn {
  width: 100%;           /* 親（最長ボタン）幅に合わせる */
  white-space: nowrap;   /* 折り返し防止 */
}

/* スマホでは横幅いっぱいに */
@media (max-width: 720px) {
  .mcc .mcc-sidebar.mcc-right .mcc-controls.mcc-vertical {
    width: 100%;
    align-self: stretch;
  }
  .mcc .mcc-controls.mcc-vertical .mcc-btn {
    white-space: normal;
  }
}

.mcc .mcc-target-display {
  background: linear-gradient(135deg, var(--warning), #f97316);
  color: white;
  padding: 16px 12px;
  text-align: center;
  font-size: clamp(1.2rem, 2.5vw, 1.4rem);
  font-weight: 900;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 8px;
  word-break: keep-all;
  line-height: 1.2;
}

.mcc .mcc-target-display::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  animation: mcc-targetGlow 3s ease-in-out infinite;
}

@keyframes mcc-targetGlow {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(180deg); }
}

.mcc .mcc-arena {
  flex: 1;
  position: relative;
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
  border-radius: 16px;
  box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.06);
  min-height: 520px;
  overflow: auto;
}

/* ボタンスタイル（.btnではなく.mcc-btnで衝突回避） */
.mcc .mcc-btn {
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  text-align: center;
  min-height: 44px;
}

.mcc .mcc-btn-primary {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: white;
  box-shadow: var(--shadow);
}

.mcc .mcc-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.mcc .mcc-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
}

.mcc .mcc-btn-secondary:hover {
  background: var(--background);
}

.mcc .mcc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.mcc .mcc-game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  z-index: 1000;
}

.mcc .mcc-game-over h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.mcc .mcc-game-over p {
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

/* 浮動テキスト */
.mcc .mcc-float {
  position: absolute;
  font-weight: 900;
  font-size: 2rem;
  z-index: 100;
  pointer-events: none;
  animation: mcc-floatUp 2.5s ease-out forwards;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.mcc .mcc-float.mcc-good {
  color: var(--success);
  text-shadow: 0 2px 4px rgba(16, 185, 129, 0.3), 2px 2px 8px rgba(0, 0, 0, 0.2);
}

.mcc .mcc-float.mcc-bad {
  color: var(--danger);
  text-shadow: 0 2px 4px rgba(239, 68, 68, 0.3), 2px 2px 8px rgba(0, 0, 0, 0.2);
}

.mcc .mcc-float.mcc-clear {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 900;
  color: #ff6b35;
  text-shadow: 0 4px 8px rgba(255, 107, 53, 0.4), 2px 2px 12px rgba(0, 0, 0, 0.3);
  animation: mcc-clearAnimation 4s ease-out forwards;
  z-index: 1000;
}

@keyframes mcc-floatUp {
  0% { transform: translateY(0px) scale(1); opacity: 1; }
  25% { transform: translateY(-20px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-120px) scale(1.3); opacity: 0; }
}

@keyframes mcc-clearAnimation {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  85% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

.mcc .mcc-score.mcc-glow {
  animation: mcc-scoreGlow 0.5s ease-in-out;
}

@keyframes mcc-scoreGlow {
  from { text-shadow: 0 6px 12px rgba(255, 215, 0, 0.4); }
  to { text-shadow: 0 6px 20px rgba(255, 215, 0, 0.8); }
}

/* ライフ低下時のハートビート効果 */
@keyframes mcc-heartBeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* === ライフ表示（右カラム） === */
.mcc .mcc-lives {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  user-select: none;
}

.mcc .mcc-lives .heart {
  font-size: 24px;           /* ハートの大きさ */
  line-height: 1;
  transition: opacity .15s;
}

.mcc .mcc-lives .dead {
  opacity: .25;              /* 失ったライフは薄く表示 */
  filter: grayscale(1);
}

/* カードグリッド（完全スコープ化） */
.mcc .mcc-cards-grid {
  position: relative;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  align-content: start;
  justify-items: stretch;
}

@media (max-width: 1100px) {
  .mcc .mcc-cards-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 860px) {
  .mcc .mcc-cards-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  .mcc .mcc-cards-grid { grid-template-columns: repeat(2, 1fr); }
}

.mcc .mcc-card {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 3px solid var(--border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 900;
  font-size: clamp(24px, 5vw, 40px);
  color: var(--text);
  user-select: none;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  position: relative;
  overflow: hidden;
}

.mcc .mcc-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 60px at -20% -20%, rgba(34, 197, 94, .08), transparent 60%),
              radial-gradient(120px 60px at 120% 120%, rgba(34, 197, 94, .06), transparent 60%);
  opacity: .9;
  pointer-events: none;
}

/* カラーバンド */
.mcc .mcc-card.mcc-band-0  { background: linear-gradient(135deg, #fff, #e0f2fe); border-color: #bae6fd; }
.mcc .mcc-card.mcc-band-1  { background: linear-gradient(135deg, #fff, #d1fae5); border-color: #a7f3d0; }
.mcc .mcc-card.mcc-band-2  { background: linear-gradient(135deg, #fff, #fef3c7); border-color: #fde68a; }
.mcc .mcc-card.mcc-band-3  { background: linear-gradient(135deg, #fff, #fee2e2); border-color: #fecaca; }
.mcc .mcc-card.mcc-band-4  { background: linear-gradient(135deg, #fff, #ede9fe); border-color: #ddd6fe; }
.mcc .mcc-card.mcc-band-5  { background: linear-gradient(135deg, #fff, #cffafe); border-color: #a5f3fc; }
.mcc .mcc-card.mcc-band-6  { background: linear-gradient(135deg, #fff, #dcfce7); border-color: #bbf7d0; }
.mcc .mcc-card.mcc-band-7  { background: linear-gradient(135deg, #fff, #fae8ff); border-color: #f5d0fe; }
.mcc .mcc-card.mcc-band-8  { background: linear-gradient(135deg, #fff, #ffe4e6); border-color: #fecdd3; }
.mcc .mcc-card.mcc-band-9  { background: linear-gradient(135deg, #fff, #e9d5ff); border-color: #d8b4fe; }
.mcc .mcc-card.mcc-band-10 { background: linear-gradient(135deg, #fff, #fef9c3); border-color: #fef08a; }
.mcc .mcc-card.mcc-band-11 { background: linear-gradient(135deg, #fff, #f1f5f9); border-color: #e2e8f0; }
.mcc .mcc-card.mcc-band-12 { background: linear-gradient(135deg, #fff, #e2f2ff); border-color: #bfdbfe; }
.mcc .mcc-card.mcc-band-13 { background: linear-gradient(135deg, #fff, #ffecc7); border-color: #fed7aa; }
.mcc .mcc-card.mcc-band-14 { background: linear-gradient(135deg, #fff, #e7ffe7); border-color: #bbf7d0; }

.mcc .mcc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .22);
}

.mcc .mcc-card.mcc-flash {
  animation: mcc-cardFlash .75s cubic-bezier(.25, .46, .45, .94) forwards;
  z-index: 20;
}

@keyframes mcc-cardFlash {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(234, 179, 8, 0); background: linear-gradient(135deg, #fef9c3, #fff); }
  30% { transform: scale(1.08); box-shadow: 0 0 36px 10px rgba(234, 179, 8, .7); background: linear-gradient(135deg, #fef3c7, #fde68a); }
  60% { transform: scale(1.02); box-shadow: 0 0 50px 16px rgba(234, 179, 8, .45); }
  100% { transform: scale(1); opacity: .25; filter: grayscale(1); }
}

.mcc .mcc-card.mcc-miss {
  animation: mcc-cardMiss .35s ease forwards;
}

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

.mcc .mcc-card.mcc-cleared {
  visibility: hidden;
  pointer-events: none;
}

/* レスポンシブ調整 */
@media (max-width: 1024px) {
  .mcc .mcc-layout-3col {
    grid-template-columns: var(--side) 1fr;
  }
  .mcc .mcc-sidebar.mcc-right {
    order: 3;
    grid-column: 1 / -1;
  }
  .mcc .mcc-sidebar.mcc-right .mcc-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .mcc .mcc-layout-3col {
    grid-template-columns: 1fr;
  }
  .mcc .mcc-sidebar.mcc-left { order: 2; }
  .mcc .mcc-center { order: 1; }
  .mcc .mcc-sidebar.mcc-right { order: 3; }
}

/* 優先度強化（テーマCSSに負けない） */
.entry-content .mcc .mcc-layout-3col {
  grid-template-columns: var(--side) minmax(0, 1fr) var(--side);
}

.entry-content .mcc .mcc-controls.mcc-vertical {
  display: inline-flex;
  width: max-content;
  align-self: center;
}