/* ============================================
   ページ全体レイアウト
   （イベント履歴一覧 index.blade / スコアボーダー event.blade 共通）

   ※ index.blade.php 側は要素にクラス名が付いていないため、
     ここでは "main > div > div ..." という入れ子構造でスタイルを
     当てています。幸い両ページとも
       main > div > div            … コンテンツカード
       main > div > div > div      … セクション（表・使用率エリアなど）
     という同じ構造なので、共通ルールで両ページをまとめて整えられます。
============================================ */
main {
  display: flex;
  justify-content: center;
  padding: 28px 16px 64px;
}

main > div {
  width: 777px;
  max-width: 100%;
}

/* コンテンツカード本体：背景を他ページと合わせて var(--c-surface) に */
.container,
main > div > div {
  width: 777px;
  max-width: 100%;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* 「一覧に戻る」行：カード背景を持たせず、テキスト部分だけをリンクにする */
.link {
  width: 777px;
  max-width: 100%;
  display: block;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0 0 16px;
}

.link a {
  display: inline-block;
  font-size: 14px;
  font-weight: bold;
  color: var(--c-primary-text);
  text-decoration: none;
}

.link a:hover {
  color: var(--c-primary-dk);
  text-decoration: underline;
}

/* セクション（index: カテゴリごとの表ブロック／event: score-border・usage-rate） */
main > div > div > div {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

main > div > div > div:not(:first-child) {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1.5px dashed var(--c-border);
}

/* セクション内の見出しラッパー
   index: カテゴリ名のみのdiv（例：エーリアスフロンティア）
   event: 上位／下位グループの見出しラッパーdiv（.usage-rate > div） */
main > div > div > div > div {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--c-border);
}

main > div > div > div > div:last-child {
  margin-bottom: 0;
}

/* 上記のうち、中身がテキストだけのdiv＝index側のカテゴリ見出しにのみ文字装飾 */
main > div > div > div > div:not(:has(*)) {
  font-size: 17px;
  font-weight: bold;
  color: var(--c-heading);
  letter-spacing: 0.03em;
}

/* ============================================
   テーブル共通スタイル（index / event 両方のtableに適用）
============================================ */
main table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 14.5px;
}

main thead td {
  background: var(--c-bg-soft);
  color: var(--c-heading);
  font-weight: bold;
  border: 1px solid var(--c-border);
  padding: 9px 7px;
  text-align: center;
  white-space: nowrap;
}

main tbody td {
  border: 1px solid var(--c-border-lt);
  padding: 8px 7px;
  text-align: center;
  color: var(--c-text);
}

main thead td:first-child,
main tbody td:first-child {
  text-align: left;
  white-space: nowrap;
}

main tbody td:first-child {
  font-weight: bold;
  color: var(--c-heading);
}

main tbody tr:nth-child(even) {
  background: var(--c-bg-soft);
}

main tbody tr:hover {
  background: var(--c-primary-lt);
}

main table a {
  color: var(--c-primary-text);
  text-decoration: none;
}

main table a:hover {
  text-decoration: underline;
}

/* スコアボーダー表の「順位」列だけは中央寄せ・幅を絞る */
.score-border td:first-child,
.score-border th:first-child {
  width: 56px;
  text-align: center;
}

/* ============================================
   使用率エリア（.usage-rate）
============================================ */
.usage-rate > div > p:first-child {
  font-size: 16px;
  font-weight: bold;
  color: var(--c-heading);
  margin: 0 0 10px;
}

/* main配下のpタグ全般（未指定のものへのフォールバック） */
main p {
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--c-text);
  margin: 0 0 8px;
}

/* 「９キャラ全員／３キャラが同じ属性の人」等の説明文 */
.text-p {
  font-size: 14.5px;
  font-weight: bold;
  color: var(--c-heading);
  margin: 0 0 6px;
}

/* 上位30人／下位30人の集計テキスト */
.top30,
.bottom30 {
  font-size: 14px;
  line-height: 1.8;
  color: var(--c-text);
  margin: 0 0 10px;
}

.usage-rate ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.usage-rate {
  --c-top: #4fc3d9;
  --c-top-dim: #cdeef5;
  --c-bottom: #e8785a;
  --c-bottom-dim: #fbdbd0;
}

.ur-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--c-heading);
  margin: 0 0 10px;
}

.ur-legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--c-text);
  margin-bottom: 18px;
}

.lg-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.lg-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}

.lg-dot.lg-top { background: var(--c-top); }
.lg-dot.lg-bottom { background: var(--c-bottom); }

span.ur-name {
  border-radius: var(--r-sm);
}

.ur-group {
  margin-top: 24px;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.ur-group:first-of-type {
  margin-top: 0;
}

.ur-group-title {
  font-size: 14.5px;
  font-weight: bold;
  color: var(--c-heading);
  background: var(--c-bg-soft);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  margin-bottom: 8px;
}

.ur-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 上位／下位ラベル（各グラフの見出し）
   .ur-row と同じグリッド列幅にすることで、
   ラベルの表示範囲がバー(.ur-bar-area)の横幅と完全に一致し、
   はみ出さないようにしている */
.ur-header-row {
  display: grid;
  grid-template-columns: 84px 1fr 46px;
  column-gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.ur-header-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ur-label {
  font-size: 12px;
  font-weight: bold;
  color: var(--c-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ur-label-top {
  text-align: left;
}

.ur-label-bottom {
  text-align: right;
}

.ur-row {
  display: grid;
  grid-template-columns: 84px 1fr 46px;
  column-gap: 8px;
  align-items: center;
}

.ur-name {
  font-size: 13.5px;
  font-weight: bold;
  color: var(--c-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ur-bar-area {
  position: relative;
  height: 24px;
  display: flex;
  background: var(--c-bg-soft);
  border-radius: var(--r-sm);
}

/* 中央の基準線 */
.ur-bar-area::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 3px;
  background: var(--c-border);
  z-index: 2;
}

.ur-half {
  position: relative;
  height: 100%;
  width: 50%;
  max-width: 50%;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.ur-half-left,
.ur-half-right {
  background: var(--c-bg-soft);
}

.ur-half-left {
  justify-content: flex-end;
}

.ur-half-right {
  justify-content: flex-start;
}

.ur-half-left span { right: 100%; margin-right: 4px; }
.ur-half-right span { left: 100%; margin-left: 4px; }

.ur-fill {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  transition: width var(--t-base);
  font-size: 11.5px;
  font-weight: bold;
  white-space: nowrap;
}

.ur-fill-top .inside {
  color: #fff;
  text-align: left;
  padding-left: 6px;
}

/* ===== top側(左) ===== */
.ur-fill-top {
  justify-content: flex-end;
  background: var(--c-top);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.ur-fill-top span.inside {
  padding-right: 6px;
  color: #04303a; /* バー上の濃い文字色 */
}

.ur-fill-top span.outside {
  position: absolute;
  right: 100%;
  padding-right: 4px;
  color: var(--c-heading);
}

/* ===== bottom側(右) ===== */
.ur-fill-bottom {
  justify-content: flex-start; /* insideの時、文字を左詰め(中央軸側)に */
  background: var(--c-bottom);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.ur-fill-bottom span.inside {
  padding-left: 6px;
  color: #4a1c10;
}

.ur-fill-bottom span.outside {
  position: absolute;
  left: 100%;
  padding-left: 4px;
  color: var(--c-heading);
}


.ur-diff {
  text-align: right;
  font-size: 12.5px;
  font-weight: bold;
}

.ur-diff.is-pos { color: #2e9e5b; }
.ur-diff.is-neg { color: #d9502f; }
.ur-diff.is-zero { color: var(--c-text-lt, #999); }

/* ============================================
   ★ 属性カラー（--c-attr を使用）※ここは変更していません
============================================ */
.element-1 {
  background-color: var(--c-attr1-lt);
  border: 1.5px solid var(--c-attr1);
}

.element-2 {
  background-color: var(--c-attr2-lt);
  border: 1.5px solid var(--c-attr2);
}

.element-3 {
  background-color: var(--c-attr3-lt);
  border: 1.5px solid var(--c-attr3);
}

.element-4 {
  background-color: var(--c-attr4-lt);
  border: 1.5px solid var(--c-attr4);
}

.element-5 {
  background-color: var(--c-attr5-lt);
  border: 1.5px solid var(--c-attr5);
}

/* ============================================
   タブレット（769px ～ 1024px）
============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  main { padding: 20px 12px 60px; }
}

/* ============================================
   スマホ（～768px）
============================================ */
@media (max-width: 768px) {
  main {
    padding: 16px 10px 60px;
  }

  main > div > div {
    padding: 16px;
  }

  main > div > div > div:not(:first-child) {
    margin-top: 24px;
    padding-top: 18px;
  }

  main table {
    font-size: 13px;
    min-width: 420px;
  }

  main thead td,
  main tbody td {
    padding: 7px 5px;
  }

  main p {
    font-size: 13.5px;
  }

  .text-p {
    font-size: 13.5px;
  }

  .top30,
  .bottom30 {
    font-size: 13px;
  }

  .ur-row {
    grid-template-columns: 64px 1fr 40px;
  }

  .ur-header-row {
    grid-template-columns: 64px 1fr 40px;
  }

  .ur-label {
    font-size: 11px;
  }

  .ur-name {
    font-size: 12.5px;
  }

  .ur-fill {
    font-size: 10.5px;
  }
}

/* ============================================
   小型スマホ（～360px）
============================================ */
@media (max-width: 360px) {
  main table {
    font-size: 12px;
    min-width: 380px;
  }

  main p,
  .text-p,
  .top30,
  .bottom30 {
    font-size: 12.5px;
  }

  main > div > div > div > div:not(:has(*)) {
    font-size: 15.5px;
  }

  .ur-label {
    font-size: 10px;
  }
}

/* ============================================
   印刷対応
============================================ */
@media print {
  main > div > div > div {
    overflow-x: visible;
  }
}