/* --------------------------------------------------
   ロビー画面
-------------------------------------------------- */
#lobby {
  position: relative;
  z-index: 10;
  background: rgba(10, 20, 14, 0.22);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  padding: 1.6rem;
  border-radius: 20px;
  border: 1.5px solid rgba(212, 175, 55, 0.45);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.2);
  text-align: center;
  width: 92%;
  max-width: 420px;
}

#lobby button {
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#lobby button:not(.btn-secondary) {
  background: linear-gradient(180deg, rgba(230, 200, 117, 0.55) 0%, rgba(184, 134, 11, 0.55) 100%);
}

#lobby .btn-secondary {
  background: linear-gradient(180deg, rgba(58, 66, 59, 0.35) 0%, rgba(32, 38, 33, 0.35) 100%) !important;
}

#lobby .btn-deck-edit {
  background: linear-gradient(180deg, rgba(42, 157, 143, 0.5) 0%, rgba(27, 99, 82, 0.5) 100%) !important;
}

#lobby input[type="text"] {
  background: rgba(11, 16, 12, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#lobby h1 {
  margin-bottom: 0.8rem;
  color: var(--gold-primary);
  font-size: 1.7rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9), 0 0 12px var(--gold-glow);
  letter-spacing: 2px;
}

/* 📢 ロビー枠外左上のお知らせボタン */
.btn-news-trigger {
  position: absolute;
  top: -38px;
  left: 0;
  width: auto !important;
  padding: 5px 12px !important;
  font-size: 0.72rem !important;
  background: rgba(13, 20, 14, 0.9) !important;
  border: 1px solid var(--gold-primary) !important;
  color: var(--gold-light) !important;
  border-radius: 14px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.8) !important;
  backdrop-filter: blur(4px);
  z-index: 15;
}

/* 📢 NEW! 赤文字バッジスタイル */
.news-badge-new {
  color: #ff3344;
  font-weight: 900;
  font-size: 0.65rem;
  margin-left: 4px;
  text-shadow: 0 0 6px rgba(255, 51, 68, 0.6);
  display: inline-block;
}

/* 【CSSでの手動ON/OFF切り替え用】 has-new クラスが付いていない場合は非表示 */
.btn-news-trigger:not(.has-new) .news-badge-new {
  display: none !important;
}

/* 📢 お知らせモーダル構造 */
.news-modal-content {
  background: linear-gradient(160deg, #18221b 0%, #0c140f 100%);
  border: 1.5px solid var(--gold-primary);
  border-radius: 16px;
  padding: 1rem;
  width: 90%;
  max-width: 380px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 36px rgba(0,0,0,0.9);
}

.news-modal-header h2 {
  font-size: 1.05rem;
  color: var(--gold-primary);
  text-align: center;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
  padding-bottom: 6px;
}

.news-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 55vh;
  padding-right: 4px;
}

.news-item {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
}

.news-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.news-item-title {
  font-size: 0.82rem;
  font-weight: bold;
  color: var(--gold-light);
}

.news-item-date {
  font-size: 0.68rem;
  color: #94a3b8;
}

.news-item-msg {
  font-size: 0.75rem;
  color: #d1d5db;
  line-height: 1.4;
  white-space: pre-wrap;
}

.lobby-section { margin: 0.9rem 0; }

.avatar-select-title {
  font-size: 0.82rem;
  color: var(--gold-light);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.avatar-list {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
  min-height: 48px;
}

/* 🃏 スリーブ選択UI (コンパクト表示) */
.sleeve-list {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 2px;
  margin-bottom: 2px;
  max-width: 100%;
}

.sleeve-option {
  width: 22px;
  height: 32px;
  border-radius: 3px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  cursor: pointer;
  object-fit: cover;
  flex-shrink: 0;
  transition: transform 0.2s ease, border-color 0.2s ease;
  background: #000;
}

.sleeve-option.selected {
  border-color: #ffd700;
  box-shadow: 0 0 8px var(--gold-primary);
  transform: scale(1.08);
}

.avatar-option {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(212, 175, 55, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  background: #0b100c;
  object-fit: cover;
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.avatar-option.selected {
  border-color: var(--gold-primary);
  box-shadow: 0 0 12px var(--gold-primary), 0 0 4px #fff;
  transform: scale(1.12);
}

.biome-select {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--gold-primary);
  background: #0d140e;
  color: var(--gold-light);
  font-size: 0.85rem;
  margin-top: 4px;
  outline: none;
}

.btn-deck-edit {
  background: linear-gradient(180deg, #2a9d8f 0%, #1b6352 100%) !important;
  border: 1px solid #48cae4 !important;
  color: #fff !important;
}

#copy-id-container { margin-top: 8px; display: none; }
.copy-btn {
  background: #0d140e;
  border: 1px solid var(--gold-primary);
  color: var(--gold-light);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  word-break: break-all;
}

/* 🛠️ デッキ構築モーダル */
.deck-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 950;
  padding: 8px;
}
.deck-modal-content {
  background: linear-gradient(160deg, #1a261e 0%, #0c140e 60%, #050806 100%);
  border: 1.5px solid var(--gold-primary);
  border-radius: 18px;
  padding: 0;
  width: 100%;
  max-width: 520px;
  height: 90vh;
  height: 90dvh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.95), 0 0 20px rgba(212, 175, 55, 0.25);
  overflow: hidden;
}

/* 1. 固定トップヘッダー */
.deck-modal-header {
  padding: 10px 12px 6px 12px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  flex-shrink: 0;
}
.deck-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.deck-header h2 {
  font-size: 1.05rem;
  color: var(--gold-primary);
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}
.deck-counter {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--gold-light);
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

/* 積層型マナカーブ */
.deck-mana-curve-container {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  padding: 6px 8px 4px 8px;
  margin-bottom: 6px;
}
.mana-curve-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  font-weight: bold;
  margin-bottom: 4px;
}
.mana-curve-chart {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  height: 48px;
  gap: 3px;
  padding-top: 2px;
  width: 100%;
}
.mana-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.mana-count {
  font-size: 0.6rem;
  font-weight: 900;
  color: var(--gold-light);
  line-height: 1;
  margin-bottom: 2px;
  min-height: 10px;
}
.mana-bar-track {
  width: 100%;
  max-width: 20px;
  margin: 0 auto;
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px 3px 0 0;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-bottom: none;
}
.mana-seg {
  width: 100%;
  transition: height 0.25s ease;
}
.mana-seg.seg-red { background: #f87171; }
.mana-seg.seg-blue { background: #60a5fa; }
.mana-seg.seg-green { background: #4ade80; }
.mana-label {
  font-size: 0.62rem;
  font-weight: bold;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1;
}
.deck-tabs-nav {
  display: flex;
  flex-direction: row;
  gap: 4px;
  margin-top: 4px;
  width: 100%;
}
.deck-tab-btn {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  padding: 6px 2px;
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: #94a3b8;
  border-radius: 6px 6px 0 0;
  box-shadow: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.deck-tab-btn.active {
  background: linear-gradient(180deg, #d4af37 0%, #8a6d0b 100%);
  color: #0d120e;
  border-color: #ffe89c;
  font-weight: bold;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

/* 2. 中央可変エリア */
.deck-modal-body {
  flex: 1;
  overflow: hidden;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.deck-tab-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.deck-tab-content.hidden {
  display: none !important;
}

/* カスタマイズタブ */
.deck-customize-group {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 10px;
  padding: 10px;
}

/* デッキコードタブ */
.deck-code-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.deck-code-desc {
  font-size: 0.78rem;
  color: #cbd5e1;
  margin: 10px 0 16px 0;
  line-height: 1.4;
}
.deck-code-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 3. 固定ボトムフッター */
.deck-modal-footer {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(212, 175, 55, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
}

.stat-item {
  color: var(--text-gold);
}
.stat-item.elem-red { color: #f87171; }
.stat-item.elem-blue { color: #60a5fa; }
.stat-item.elem-green { color: #4ade80; }

.deck-section-title {
  font-size: 0.72rem;
  color: var(--gold-light);
  font-weight: bold;
  margin: 4px 0 2px 0;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.deck-filter-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 2px 0 6px 0;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 6px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-item {
  font-size: 0.68rem;
  color: var(--gold-light);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}
.filter-item input[type="checkbox"] {
  accent-color: var(--gold-primary);
  width: 13px;
  height: 13px;
  cursor: pointer;
}
.deck-grid {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  height: 104px;
  min-height: 104px;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  border: 1px dashed rgba(212, 175, 55, 0.35);
  align-items: center;
  flex-shrink: 0;
}
.pool-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px 6px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 150px;
  align-content: start;
  justify-items: center;
  padding: 8px 4px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  -webkit-overflow-scrolling: touch;
} 

.deck-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.deck-header h2 {
  font-size: 1.1rem;
  color: var(--gold-primary);
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

.deck-counter {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--gold-light);
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

/* デッキ統計情報バー */
.deck-stats-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 8px;
  padding: 4px 6px;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: bold;
}

.stat-item {
  color: var(--text-gold);
}

.stat-item.elem-red { color: #f87171; }
.stat-item.elem-blue { color: #60a5fa; }
.stat-item.elem-green { color: #4ade80; }

.deck-section-title {
  font-size: 0.72rem;
  color: var(--gold-light);
  font-weight: bold;
  margin: 4px 0 2px 0;
  letter-spacing: 0.5px;
}

.deck-grid {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  height: 110px;
  min-height: 110px;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  border: 1px dashed rgba(212, 175, 55, 0.35);
  align-items: center;
  flex-shrink: 0;
}

/* 💎 下部カードリスト（プール）の縦幅拡張とスマホ表示の最適化 */
.pool-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px 6px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 220px;
  align-content: start;
  justify-items: center;
  padding: 8px 4px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  -webkit-overflow-scrolling: touch;
}

.deck-grid .card,
.pool-grid .card {
  position: relative;
  transform: scale(0.96) !important;
  margin: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.deck-grid .card:hover,
.pool-grid .card:hover,
.deck-grid .card:active,
.pool-grid .card:active {
  transform: scale(1.05) !important;
  z-index: 20;
}

/* 💎 カードプール内のEXカード区切り破線スタイル */
.deck-pool-divider {
  grid-column: 1 / -1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0 4px 0;
  position: relative;
  text-align: center;
}

.deck-pool-divider::before,
.deck-pool-divider::after {
  content: '';
  flex: 1;
  border-bottom: 2px dashed rgba(245, 158, 11, 0.6);
}

.deck-pool-divider span {
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: 900;
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
  letter-spacing: 1px;
  white-space: nowrap;
}

/* 📱 スマホ端末向けレスポンシブ最適化 */
@media (max-width: 480px) {
  .deck-modal-content {
    padding: 0;
    height: 98dvh;
    max-height: 98dvh;
  }
  .deck-modal-header {
    padding: 6px 8px 4px 8px;
  }
  .deck-mana-curve-container {
    padding: 4px 6px 2px 6px;
    margin-bottom: 4px;
  }
  .mana-curve-header {
    font-size: 0.62rem;
    margin-bottom: 2px;
  }
  .mana-curve-chart {
    height: 40px;
    gap: 2px;
  }
  .mana-count {
    font-size: 0.55rem;
    min-height: 8px;
  }
  .mana-label {
    font-size: 0.55rem;
  }
  .deck-tab-btn {
    padding: 5px 1px;
    font-size: 0.62rem;
  }
  .pool-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px 4px;
    padding: 6px 2px;
    min-height: 260px;
    flex: 1;
  }
  .deck-grid {
    height: 88px;
    min-height: 88px;
    padding: 2px 4px;
  }
  .biome-select {
    padding: 5px;
    font-size: 0.78rem;
    margin-top: 2px;
  }
  .deck-pool-divider {
    margin: 6px 0 2px 0;
  }
  .deck-pool-divider span {
    font-size: 0.68rem;
    padding: 0 4px;
  }
}

/* カード上の枚数所持バッジ (0~3) */
.card-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, #f59e0b 0%, #b45309 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  z-index: 30;
  pointer-events: none;
}

.card-count-badge.count-0 {
  background: radial-gradient(circle, #4b5563 0%, #1f2937 100%);
  border-color: #9ca3af;
  opacity: 0.6;
}

.card-count-badge.count-3 {
  background: radial-gradient(circle, #ef4444 0%, #991b1b 100%);
  border-color: #fca5a5;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.deck-code-section {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.deck-footer-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
