/* ==========================================================================
   Brawl Quiz Cheat Sheet - クロス表スタイル
   言語（列）× 単語（行）で答えを一目で確認
   ========================================================================== */

:root {
  --bqc-primary: #9AB08F;
  --bqc-primary-dark: #728A67;
  --bqc-primary-light: #EEF4EB;
  --bqc-accent: #EEAFA1;
  --bqc-accent-dark: #C97260;
  --bqc-accent-light: #FDF2EF;
  --bqc-info: #92B5BC;
  --bqc-info-dark: #638B93;
  --bqc-info-light: #EBF3F5;
  --bqc-text: #5A473C;
  --bqc-text-muted: #8E7E75;
  --bqc-bg: #FBF6EA;
  --bqc-card-bg: #FFFFFF;
  --bqc-border: rgba(90, 71, 60, 0.14);
  --bqc-radius: 10px;
  --bqc-radius-sm: 6px;

  /* クロス表セルサイズ */
  --cell-w: 86px;
  --cell-h: 34px;
  --row-label-w: 96px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- コンテナ全体 ---- */
.bqc-hud-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

/* ---- トップバー ---- */
.bqc-top-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.bqc-search-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
  align-items: center;
}

.bqc-hud-search {
  width: 100%;
  height: 36px;
  padding: 4px 34px 4px 12px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--bqc-text);
  background: #FFFFFF;
  border: 1.5px solid var(--bqc-primary);
  border-radius: var(--bqc-radius-sm);
  outline: none;
  transition: all 0.15s ease;
}

.bqc-hud-search:focus {
  border-color: var(--bqc-primary-dark);
  box-shadow: 0 0 0 3px rgba(154, 176, 143, 0.25);
}

.bqc-hud-search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--bqc-text-muted);
  cursor: pointer;
  display: none;
}

.bqc-reset-btn {
  background: #FFFFFF;
  border: 1.5px solid var(--bqc-border);
  color: var(--bqc-text-muted);
  height: 36px;
  padding: 0 12px;
  border-radius: var(--bqc-radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.bqc-reset-btn:hover {
  background: var(--bqc-accent-light);
  border-color: var(--bqc-accent-dark);
  color: var(--bqc-accent-dark);
}

.bqc-mini-sync-btn {
  background: #FFFFFF;
  border: 1.5px solid var(--bqc-primary);
  color: var(--bqc-text);
  height: 36px;
  padding: 0 12px;
  border-radius: var(--bqc-radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.bqc-mini-sync-btn:hover {
  background: var(--bqc-primary-light);
  border-color: var(--bqc-primary-dark);
}

/* ---- タブ切り替え ---- */
.bqc-tab-bar {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bqc-tab-btn {
  background: var(--bqc-bg);
  border: 1.5px solid var(--bqc-border);
  color: var(--bqc-text-muted);
  height: 32px;
  padding: 0 14px;
  border-radius: 8px 8px 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.bqc-tab-btn:hover {
  background: #FFFFFF;
  color: var(--bqc-text);
}

.bqc-tab-btn.active {
  background: #FFFFFF;
  border-color: var(--bqc-primary);
  border-bottom-color: #FFFFFF;
  color: var(--bqc-primary-dark);
  font-weight: 900;
}

/* ---- クロス表ラッパー ---- */
.bqc-matrix-wrapper {
  background: #FFFFFF;
  border: 1.5px solid var(--bqc-primary);
  border-radius: 0 var(--bqc-radius) var(--bqc-radius) var(--bqc-radius);
  overflow: auto;
  max-height: calc(100vh - 210px);
  box-shadow: 0 3px 12px rgba(90, 71, 60, 0.07);
  /* スクロールバーをスリムに */
  scrollbar-width: thin;
  scrollbar-color: var(--bqc-primary) transparent;
}

.bqc-matrix-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.bqc-matrix-wrapper::-webkit-scrollbar-thumb {
  background: var(--bqc-primary);
  border-radius: 3px;
}

/* ---- テーブル本体 ---- */
.bqc-matrix-table {
  border-collapse: collapse;
  table-layout: fixed;
  min-width: max-content;
}

/* ---- コーナーセル（左上固定） ---- */
.bqc-corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 30;
  width: var(--row-label-w);
  min-width: var(--row-label-w);
  background: var(--bqc-primary-light);
  border-right: 2px solid var(--bqc-primary);
  border-bottom: 2px solid var(--bqc-primary);
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--bqc-primary-dark);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.bqc-corner:hover {
  background: #dff0da;
}

/* ---- 言語ヘッダー列（上固定） ---- */
.bqc-lang-th {
  position: sticky;
  top: 0;
  z-index: 20;
  width: var(--cell-w);
  min-width: var(--cell-w);
  height: 44px;
  padding: 4px 4px 4px 4px;
  background: var(--bqc-primary-light);
  border-right: 1px solid var(--bqc-border);
  border-bottom: 2px solid var(--bqc-primary);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--bqc-primary-dark);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.bqc-lang-th:hover {
  background: #dff0da;
}

.bqc-lang-th.is-active {
  background: var(--bqc-primary-dark) !important;
  color: #FFFFFF !important;
  box-shadow: 0 2px 8px rgba(114, 138, 103, 0.4);
}

.bqc-lang-th.hidden-col {
  display: none;
}

/* ---- 単語ラベル列（左固定） ---- */
.bqc-word-th {
  position: sticky;
  left: 0;
  z-index: 10;
  width: var(--row-label-w);
  min-width: var(--row-label-w);
  height: var(--cell-h);
  padding: 4px 8px;
  background: var(--bqc-accent-light);
  border-right: 2px solid var(--bqc-primary);
  border-bottom: 1px solid var(--bqc-border);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--bqc-accent-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bqc-word-th:hover {
  background: #fce5df;
}

.bqc-word-th.is-active {
  background: var(--bqc-accent-dark) !important;
  color: #FFFFFF !important;
  box-shadow: 2px 0 8px rgba(201, 114, 96, 0.4);
}

/* ---- 答えセル ---- */
.bqc-cell {
  width: var(--cell-w);
  min-width: var(--cell-w);
  height: var(--cell-h);
  padding: 2px 5px;
  border-right: 1px solid var(--bqc-border);
  border-bottom: 1px solid var(--bqc-border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bqc-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #FFFFFF;
  transition: background 0.08s, box-shadow 0.15s;
  cursor: pointer;
}

.bqc-cell:hover {
  background: var(--bqc-primary-light);
  color: var(--bqc-primary-dark);
}

.bqc-cell.empty {
  color: var(--bqc-border);
}

.bqc-cell.hidden-col {
  display: none;
}

/* 行・列の選択ハイライト */
.bqc-cell.is-col-active {
  background-color: #f0f7ee !important;
}

.bqc-cell.is-row-active {
  background-color: #fdf3f0 !important;
}

/* 行・列両方選択時の中間色 */
.bqc-cell.is-col-active.is-row-active {
  background-color: #f4f6e8 !important;
}

/* 交点セルの発光・強調 */
.bqc-cell.is-intersection {
  background-color: #FFE6D9 !important;
  color: #8C2E1B !important;
  font-weight: 900 !important;
  font-size: 0.9rem !important;
  position: relative;
  z-index: 5;
  box-shadow: inset 0 0 0 2px var(--bqc-accent-dark), 0 0 14px rgba(201, 114, 96, 0.65) !important;
  animation: bqc-glow 1.5s infinite alternate ease-in-out;
}

@keyframes bqc-glow {
  0% {
    box-shadow: inset 0 0 0 2px var(--bqc-accent-dark), 0 0 6px rgba(201, 114, 96, 0.4);
  }
  100% {
    box-shadow: inset 0 0 0 2.5px var(--bqc-accent-dark), 0 0 16px rgba(201, 114, 96, 0.9);
  }
}

/* 行のストライプ */
.bqc-matrix-table tbody tr:nth-child(even) .bqc-cell {
  background: #FDFAF5;
}
.bqc-matrix-table tbody tr:nth-child(even) .bqc-cell:hover {
  background: var(--bqc-primary-light);
}

/* ---- 行・列ハイライト（ホバー） ---- */
.bqc-matrix-table tbody tr:hover .bqc-word-th:not(.is-active) {
  background: #fce5df;
}
.bqc-matrix-table tbody tr:hover .bqc-cell {
  background: var(--bqc-primary-light);
}
.bqc-matrix-table tbody tr:hover .bqc-cell:hover {
  background: #c8dfc2;
  font-weight: 900;
  color: var(--bqc-primary-dark);
}

/* ---- 行非表示（検索フィルタ） ---- */
.bqc-matrix-table tbody tr.hidden-row {
  display: none;
}

/* ---- その他（雑学）パネル ---- */
.bqc-trivia-wrapper {
  display: none;
  background: #FFFFFF;
  border: 1.5px solid var(--bqc-accent);
  border-radius: 0 var(--bqc-radius) var(--bqc-radius) var(--bqc-radius);
  padding: 10px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  box-shadow: 0 3px 12px rgba(90, 71, 60, 0.07);
  scrollbar-width: thin;
  scrollbar-color: var(--bqc-accent) transparent;
}

.bqc-trivia-wrapper.active {
  display: block;
}

.bqc-trivia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 6px;
}

.bqc-trivia-item {
  background: #FFFFFF;
  border: 1.5px solid var(--bqc-border);
  border-radius: 8px;
  padding: 7px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: default;
  transition: border-color 0.1s, background 0.1s;
}

.bqc-trivia-item:hover {
  border-color: var(--bqc-accent);
  background: var(--bqc-accent-light);
}

.bqc-trivia-q {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bqc-text);
  line-height: 1.3;
  flex: 1;
}

.bqc-trivia-a {
  font-size: 1rem;
  font-weight: 900;
  color: var(--bqc-accent-dark);
  background: #FFFFFF;
  padding: 2px 10px;
  border-radius: 5px;
  border: 1px solid rgba(238, 175, 161, 0.45);
  white-space: nowrap;
}

/* ---- トースト ---- */
.bqc-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #2D2825;
  color: #FFFFFF;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
}

.bqc-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---- スマホ対応 ---- */
@media (max-width: 600px) {
  :root {
    --cell-w: 74px;
    --row-label-w: 80px;
  }

  .bqc-top-bar {
    flex-wrap: wrap;
  }
}
