.bfhcs2-root {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
}

.bfhcs2-wrapper {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px;
  background: #fafafa;
}

/* ヘッダー＋強化済み特性全体を固定するラッパ */
.bfhcs2-header-area {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fafafa;
}

/* ヘッダー */
.bfhcs2-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 2px;
  border-bottom: none;
}

.bfhcs2-title {
  font-weight: 600;
  font-size: 16px;
}

.bfhcs2-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bfhcs2-total-sp {
  font-weight: 600;
}

.bfhcs2-total-sp-label {
  margin-right: 2px;
}

.bfhcs2-reset-button {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid #c00;
  background: #f9e0e0;
  color: #900;
  cursor: pointer;
}

.bfhcs2-reset-button:hover {
  background: #f5caca;
}

/* 強化済み特性バー */
.bfhcs2-active-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 6px;
  border-bottom: 1px solid #ddd;
  background: #f5f5f5;
}

.bfhcs2-active-label {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.bfhcs2-active-list {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 4px;
  padding-bottom: 2px;
}

/* 強化済み特性のアイテム */
.bfhcs2-active-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 2px;
  border-radius: 4px;
  box-sizing: border-box;
  background: #fff;
}

.bfhcs2-active-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
}

.bfhcs2-active-icon img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.bfhcs2-active-level {
  font-size: 10px;
  line-height: 1;
}

/* コンテンツ全体 */
.bfhcs2-content {
  margin-top: 6px;
}

/* グループセクション */
.bfhcs2-group-section {
  margin-bottom: 4px;
}

.bfhcs2-group-title {
  margin: 0 !important;
  padding: 2px 4px !important;
  font-size: 12px;
  font-weight: 600;
  background: #eee;
  border-radius: 3px;
}

/* グリッドレイアウト */
.bfhcs2-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 4px;
}

/* カード */
.bfhcs2-card {
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fff;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
}

.bfhcs2-card:hover {
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.12);
  background: #fdfdfd;
}

/* 状態別の枠色と太さ */
.bfhcs2-card--off {
  border-color: #ccc;
  border-width: 1px;
}

.bfhcs2-card--lv1,
.bfhcs2-card--lv2,
.bfhcs2-card--lv3,
.bfhcs2-card--on,
.bfhcs2-active-item.bfhcs2-card--lv1,
.bfhcs2-active-item.bfhcs2-card--lv2,
.bfhcs2-active-item.bfhcs2-card--lv3,
.bfhcs2-active-item.bfhcs2-card--on {
  border-width: 2px;
}

.bfhcs2-card--lv1,
.bfhcs2-active-item.bfhcs2-card--lv1 {
  border-color: #007bff;
}

.bfhcs2-card--lv2,
.bfhcs2-active-item.bfhcs2-card--lv2 {
  border-color: #28a745;
}

.bfhcs2-card--lv3,
.bfhcs2-card--on,
.bfhcs2-active-item.bfhcs2-card--lv3,
.bfhcs2-active-item.bfhcs2-card--on {
  border-color: #dc3545;
}

/* アイコン */
.bfhcs2-card-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bfhcs2-card-icon img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* テキスト部分 */
.bfhcs2-card-content {
  flex: 1 1 auto;
  min-width: 0;
}

.bfhcs2-card-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 2px;
  word-break: keep-all;
}

.bfhcs2-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
}

.bfhcs2-card-state {
  font-weight: 600;
}

.bfhcs2-card-sp {
  color: #555;
}

/* レスポンシブ */
@media (max-width: 600px) {
  .bfhcs2-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .bfhcs2-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .bfhcs2-active-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .bfhcs2-active-list {
    width: 100%;
  }
}