:root {
  /* gacha テイスト */
  --panel:        #fbfbff;
  --panel-edge:   #e4e8f4;
  --panel-inner:  #f3f6fd;

  --ink:       #2a2e52;
  --ink-soft:  #5a608a;
  --ink-muted: #8a90b0;
  --ink-sub:   #c5b38f;
  --ink-value: #2b7fd0;

  --sky:       #b8dcff;
  --sky-deep:  #6ba6e8;
  --sky-btn:   #3b7fe6;
  --sky-btn-d: #2a64c4;

  --gold-1: #f4d27a;
  --gold-2: #d4a04a;
  --gold-3: #8a5a1c;

  /* 属性カラー */
  --el-none:    #bdbdc9;
  --el-fire:    #e8623a;
  --el-water:   #4fa9e6;
  --el-earth:   #b88b4a;
  --el-wind:    #6dbd82;
  --el-holy:    #e8c96a;
  --el-ghost:   #a68bd8;
  --el-poison:  #8ac64c;
  --el-dark:    #555577;
  --el-undead:  #6a5a4a;

  --f-display: "Cinzel", "Noto Serif JP", serif;
  --f-body:    "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  --f-num:     "Barlow", "Noto Sans JP", sans-serif;

  --sh-panel: 0 18px 50px -12px rgba(12, 14, 40, 0.55),
              0 4px 14px rgba(12, 14, 40, 0.25);
  --sh-soft:  0 2px 6px rgba(60, 80, 130, 0.15);

  /* マトリクス寸法 */
  --rowhead-w: 148px;   /* 左固定列（耐性名）の幅 */
  --col-w:     118px;   /* 各ボス列の幅 */
  --dungeon-h: 30px;    /* 上段（ダンジョン名行）の高さ */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  min-height: 100vh;
  touch-action: manipulation;
  overscroll-behavior: none;   /* ページ全体のバウンスを抑止 */
  font-family: var(--f-body);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(120,140,230,0.35), transparent 60%),
    radial-gradient(ellipse at 85% 90%, rgba(180,120,220,0.3), transparent 60%),
    linear-gradient(160deg, #14163a 0%, #2a2d5f 45%, #3c2f6a 100%);
  background-attachment: fixed;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.7), transparent 50%),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.5), transparent 50%),
    radial-gradient(1px 1px at 55% 30%, rgba(255,255,255,0.8), transparent 50%),
    radial-gradient(1.5px 1.5px at 75% 80%, rgba(255,255,255,0.6), transparent 50%),
    radial-gradient(1px 1px at 90% 25%, rgba(255,255,255,0.7), transparent 50%),
    radial-gradient(1px 1px at 40% 90%, rgba(255,255,255,0.55), transparent 50%),
    radial-gradient(1px 1px at 15% 75%, rgba(255,255,255,0.6), transparent 50%),
    radial-gradient(2px 2px at 65% 15%, rgba(255,240,200,0.6), transparent 50%);
  opacity: 0.9;
  z-index: 0;
}

.wrap {
  position: relative; z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 0) 12px env(safe-area-inset-bottom, 14px);
}

/* ヘッダー */
header.site {
  padding: 14px 4px 6px;
  text-align: center;
}
header.site h1 {
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 22px;
  margin: 0 0 3px;
  background: linear-gradient(180deg, #fff0c9 0%, var(--gold-1) 45%, var(--gold-2) 70%, var(--gold-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 14px rgba(244,210,122,0.18);
}
header.site .sub {
  font-size: 11px;
  color: #e3dcc2;
  letter-spacing: 0.22em;
}
header.site .ornament {
  width: 180px; max-width: 60%;
  height: 10px;
  margin: 5px auto 0;
  background:
    linear-gradient(90deg, transparent, var(--gold-2) 50%, transparent) center/100% 1px no-repeat,
    radial-gradient(circle at center, var(--gold-1) 0 3px, transparent 4px);
}
header.site .list-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffe088;
  text-decoration: none;
  padding: 5px 16px;
  border: 1px solid rgba(255,224,136,0.5);
  border-radius: 999px;
  background: rgba(255,224,136,0.08);
  transition: background .15s, border-color .15s, color .15s;
}
header.site .list-link:hover {
  background: rgba(255,224,136,0.18);
  border-color: rgba(255,224,136,0.9);
  color: #fff;
}

/* ツールバー（凡例 + ダンジョンへジャンプ） */
.toolbar {
  margin: 6px 0 8px;
}
.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.92);
  font-size: 11px;
  letter-spacing: 0.05em;
}
.legend .lg-title { font-weight: 700; }
.legend .lg-arrow { color: rgba(255,255,255,0.6); }
.legend .lg {
  width: 18px; height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.08);
  display: inline-block;
}
.legend .lg.sw3 { background: #b7f0cd; }
.legend .lg.sw2 { background: #d8f6e3; }
.legend .lg.sm  { background: #fdf1c7; }
.legend .lg.sr2 { background: #ffd9c2; }
.legend .lg.sr3 { background: #ffc9c9; }
.legend .hint {
  flex-basis: 100%;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

/* フィルタ行（難易度 / ダンジョン） */
.nav-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.nav-label {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.9);
  width: 58px;
  text-align: right;
  white-space: nowrap;
}
.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.chip-row::-webkit-scrollbar { height: 5px; }
.chip-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; }
.dchip {
  flex: 0 0 auto;
  border: 1px solid var(--sky-deep);
  background: rgba(255,255,255,0.92);
  color: var(--sky-btn);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--sh-soft);
  transition: background 0.15s, color 0.15s, transform 0.1s, opacity 0.15s;
}
.dchip:active { transform: scale(0.96); }
.dchip.on {
  background: linear-gradient(180deg, var(--sky-btn), var(--sky-btn-d));
  color: #fff;
  border-color: var(--sky-btn-d);
}
/* 「すべて」チップ（金アクセント） */
.dchip.all { border-color: var(--gold-2); color: var(--gold-3); }
.dchip.all.on {
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  color: #5a3a06;
  border-color: var(--gold-3);
}
/* 現在の難易度に該当ボスがいないダンジョン */
.dchip.empty { opacity: 0.4; }

/* ===== マトリクス本体 ===== */
.matrix-scroll {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 238px);   /* dvh 非対応の古いWebView用フォールバック */
  max-height: calc(100dvh - 238px);
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  box-shadow: var(--sh-panel);
  overscroll-behavior-x: none;     /* 左右のバウンスは抑止 */
  overscroll-behavior-y: contain;  /* 上下のバウンスは残す（ページへは伝播させない） */
  touch-action: pan-x pan-y;
}
.matrix-scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.matrix-scroll::-webkit-scrollbar-thumb {
  background: #c2cce0; border-radius: 5px; border: 2px solid var(--panel);
}
.matrix-scroll::-webkit-scrollbar-corner { background: var(--panel); }

.empty-msg {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.9;
}

table.matrix {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  table-layout: fixed;
}
.matrix th, .matrix td {
  border-right: 1px solid #e7ebf6;
  border-bottom: 1px solid #eef1f9;
}

/* 左上コーナー（縦横ともに固定） */
.matrix .corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 40;
  width: var(--rowhead-w);
  min-width: var(--rowhead-w);
  max-width: var(--rowhead-w);
  background: linear-gradient(180deg, #eaf1fc, #dde7f7);
  border-right: 1px solid #c9d6ec;
  border-bottom: 1px solid #c9d6ec;
  text-align: center;
  font-family: var(--f-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--sky-btn);
  letter-spacing: 0.04em;
  padding: 4px;
}
.matrix .corner .corner-a { color: var(--ink-value); }
.matrix .corner .corner-slash { color: var(--ink-muted); margin: 0 1px; }
.matrix .corner .corner-b { color: var(--sky-btn); }

/* 上段：ダンジョン名（上部固定） */
.matrix .dungeon-th {
  position: sticky;
  top: 0;
  z-index: 35;
  height: var(--dungeon-h);
  padding: 4px 8px;
  background: linear-gradient(180deg, #eef4fd, #e1ebfa);
  border-bottom: 1px solid #c9d6ec;
  color: var(--sky-btn-d);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-align: center;
}
.matrix .dungeon-th:not(:first-of-type) { border-left: 2px solid #cfdcf0; }

/* 下段：ボスのカード（上部固定・ダンジョン行の下） */
.matrix .boss-th {
  position: sticky;
  top: var(--dungeon-h);
  z-index: 30;
  width: var(--col-w);
  min-width: var(--col-w);
  max-width: var(--col-w);
  padding: 0;
  background: #f7f9fe;
  vertical-align: top;
  border-bottom: 1.5px solid #cfd9ee;
}
.col-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  padding: 6px 5px 7px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--f-body);
  color: var(--ink);
  text-align: center;
}
.col-thumb {
  width: 64px; height: 64px;
  border-radius: 11px;
  overflow: hidden;
  background: #eef2fa;
  border: 2px solid var(--sky-deep);
  position: relative;
  flex-shrink: 0;
  box-shadow: var(--sh-soft);
}
.col-thumb img {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 110%; height: 110%;
  object-fit: cover;
}
.col-name {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.col-line {
  display: flex; flex-wrap: wrap; gap: 2px;
  justify-content: center; align-items: center;
}
.col-floor {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.4;
  padding: 0 2px;
}
.mini-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 999px;
  line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}
.mini-tag.diff { background: #fff; border-color: var(--gold-2); color: var(--gold-3); }
.mini-tag.diff.elite { border-color: var(--sky-deep); color: var(--sky-btn); }
.mini-tag.diff.brave { border-color: #e06666; color: #b82b2b; }
.mini-tag.race { background: #fff; border-color: #c9d3e9; color: var(--ink-soft); }
.mini-tag.elem-none   { background: #f1f1f5; color: #4f4f60; border-color: #d0d0dc; }
.mini-tag.elem-fire   { background: #fde4d9; color: #a8381a; border-color: #f4b49a; }
.mini-tag.elem-water  { background: #dff0fd; color: #1e5a94; border-color: #a9d2f4; }
.mini-tag.elem-earth  { background: #f3e6d1; color: #6a4722; border-color: #d9b87e; }
.mini-tag.elem-wind   { background: #dff1e3; color: #2a6a3c; border-color: #a8d9b3; }
.mini-tag.elem-holy   { background: #fbefc8; color: #7a5a10; border-color: #e8c96a; }
.mini-tag.elem-ghost  { background: #eadff4; color: #5b3a86; border-color: #c9b4e1; }
.mini-tag.elem-poison { background: #ebf5d7; color: #3c6118; border-color: #bcd98a; }
.mini-tag.elem-dark   { background: #d8d9e5; color: #34355a; border-color: #9ea1c2; }
.mini-tag.elem-undead { background: #dbd3ca; color: #4e4134; border-color: #a8998a; }
.col-hp {
  font-family: var(--f-num);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-value);
  background: #eaf2fd;
  border: 1px solid #cfe0f6;
  border-radius: 6px;
  padding: 0 5px;
  letter-spacing: 0.02em;
}

/* 左固定列：耐性名 */
.matrix .rowhead {
  position: sticky;
  left: 0;
  z-index: 20;
  width: var(--rowhead-w);
  min-width: var(--rowhead-w);
  max-width: var(--rowhead-w);
  background: var(--panel-inner);
  border-right: 1px solid #c9d6ec;
  text-align: left;
  padding: 5px 8px;
  vertical-align: middle;
}
.matrix .rowhead .rh-text {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.25;
  word-break: break-word;
}
.matrix .rowhead.elem {
  text-align: center;
  padding: 4px;
}
.matrix .rowhead .prefix {
  display: inline-block;
  min-width: 30px;
  padding: 2px 9px;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.12);
}
.prefix.elem-none   { background: linear-gradient(180deg, #c8c8d4, #98989f); }
.prefix.elem-fire   { background: linear-gradient(180deg, #f58556, var(--el-fire)); }
.prefix.elem-water  { background: linear-gradient(180deg, #7abdee, var(--el-water)); }
.prefix.elem-earth  { background: linear-gradient(180deg, #cfa56a, var(--el-earth)); }
.prefix.elem-wind   { background: linear-gradient(180deg, #93d1a4, var(--el-wind)); }
.prefix.elem-holy   { background: linear-gradient(180deg, #f2db8e, var(--el-holy)); color: #5a4500; }
.prefix.elem-ghost  { background: linear-gradient(180deg, #bfa6df, var(--el-ghost)); }
.prefix.elem-poison { background: linear-gradient(180deg, #a4d56f, var(--el-poison)); }
.prefix.elem-dark   { background: linear-gradient(180deg, #7a7a93, var(--el-dark)); }
.prefix.elem-undead { background: linear-gradient(180deg, #8e7f6e, var(--el-undead)); }

/* グループ見出し行（左固定列としてのみ機能。縦スクロールでは流れる） */
.matrix .group-row .group-head {
  background: linear-gradient(180deg, #e7eefb, #dbe6f8);
  color: var(--sky-btn-d);
  font-family: var(--f-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 4px;
  z-index: 22;
  border-right: 1px solid #c9d6ec;
}
.matrix .group-row .group-fill {
  background: linear-gradient(180deg, #eef3fc, #e6edf9);
  height: 22px;
}

/* 値セル */
.matrix .cell {
  width: var(--col-w);
  min-width: var(--col-w);
  max-width: var(--col-w);
  text-align: center;
  font-family: var(--f-num);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  padding: 7px 4px;
  letter-spacing: 0.02em;
  background: #fff;
}
.matrix .cell.txt {
  font-family: var(--f-body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
  word-break: break-word;
}

/* ヒートマップ（数値の上に色を重ねる） */
.matrix .cell.heat-w3 { background: #b7f0cd; color: #14502e; }
.matrix .cell.heat-w2 { background: #d8f6e3; color: #1d5b38; }
.matrix .cell.heat-m  { background: #fdf1c7; color: #6a5410; }
.matrix .cell.heat-r2 { background: #ffd9c2; color: #8a3d12; }
.matrix .cell.heat-r3 { background: #ffc9c9; color: #8a1f1f; }

/* 列ハイライト（ボス名タップで縦に強調） */
.matrix .cell.col-hl { box-shadow: inset 2px 0 0 var(--sky-btn), inset -2px 0 0 var(--sky-btn); }
.matrix .boss-th.col-hl .col-card { background: rgba(59,127,230,0.1); }
.matrix .boss-th.col-hl { outline: 2px solid var(--sky-btn); outline-offset: -2px; }

/* フッター */
footer.note {
  margin-top: 14px;
  padding: 12px 10px 26px;
  text-align: center;
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: 0.04em;
}
footer.note a {
  color: #ffe088;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted rgba(255,224,136,0.55);
}
footer.note a:hover { color: #fff; border-bottom-color: #fff; }
footer.note .copyright {
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.3px;
  line-height: 1.7;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(255,255,255,0.15);
}

/* フッターのキノコ（タップでトップへ戻る）。footer.note a の下線を打ち消すため border-bottom:0 */
footer.note .footer-mushroom {
  display: inline-block;
  margin-top: 10px;
  line-height: 0;
  transform-origin: 50% 100%;
  animation: mushroomBob 3.2s ease-in-out infinite;
  border-bottom: 0;
}
footer.note .footer-mushroom svg { display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
footer.note .footer-mushroom:hover { animation-play-state: paused; }
@keyframes mushroomBob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-3px) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { footer.note .footer-mushroom { animation: none; } }

/* スマホ最適化 */
@media (max-width: 600px) {
  :root {
    --rowhead-w: 116px;
    --col-w: 104px;
  }
  .wrap { padding-left: 8px; padding-right: 8px; }
  header.site { padding: 12px 4px 4px; }
  header.site .ornament { display: none; }
  .matrix-scroll {
    max-height: calc(100vh - 226px);   /* dvh 非対応の古いWebView用フォールバック */
    max-height: calc(100dvh - 226px);
  }
  .nav-label { width: 52px; font-size: 10px; letter-spacing: 0; }
  .col-thumb { width: 58px; height: 58px; }
  .matrix .cell { font-size: 13px; padding: 6px 3px; }
  .col-name { font-size: 10.5px; }
  .matrix .rowhead .rh-text { font-size: 11px; }
}
@media (max-width: 380px) {
  :root { --col-w: 96px; }
}
