/* ================================================
   ひなたのうみ — 楽曲ソートツール専用スタイル
   ================================================ */
@import '../css/variables.css';
@import '../css/common.css';

/* ── カード背景色（グループ×種別） ──────────────────────────── */
.card-bg-keyaki-single   { background: linear-gradient(135deg, #e8e0ff, #c8b8ff); }
.card-bg-keyaki-other    { background: linear-gradient(135deg, #f0e8ff, #ddd0ff); }
.card-bg-hinata-single   { background: linear-gradient(135deg, #dff0ff, #b8d8f5); }
.card-bg-hinata-coupling { background: linear-gradient(135deg, #fff0f7, #ffd6ea); }
.card-bg-hinata-album    { background: linear-gradient(135deg, #f0fff4, #b8f0cc); }
.card-bg-unit            { background: linear-gradient(135deg, #fff8e8, #ffd6a0); }

/* ── スタートページ ────────────────────────────────────────── */
.sort-hero {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 72px 24px 80px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(186,230,255,.55) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(255,214,234,.45) 0%, transparent 70%),
    linear-gradient(175deg, #f0f9ff 0%, #fdfbff 60%, #fff9f0 100%);
}
.sort-hero-content { max-width: 600px; width: 100%; }

/* グループ名バッジ */
.sort-group-badge {
  display: inline-block;
  padding: 5px 20px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--c-sky-400), #5ba8d4);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(58,181,224,.35);
}

.sort-hero-title {
  font-size: clamp(26px, 5vw, 44px);
  font-weight: 700;
  color: var(--c-ink-800);
  margin-bottom: 10px;
  letter-spacing: -.01em;
}
.sort-hero-sub {
  font-size: 16px;
  color: var(--c-ink-500);
  line-height: 1.7;
  margin-bottom: 44px;
}
.sort-hero-sub strong { color: var(--c-sky-500); font-size: 1.1em; }

/* 遊び方ステップ */
.sort-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 20px;
}
.sort-step {
  background: rgba(255,255,255,.85);
  border: 1px solid var(--c-sky-100);
  border-radius: var(--r-xl);
  padding: 20px 18px;
  flex: 1;
  max-width: 168px;
  box-shadow: 0 2px 12px rgba(58,181,224,.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform .2s, box-shadow .2s;
}
.sort-step:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(58,181,224,.18);
}
.sort-step-icon  { font-size: 32px; line-height: 1; }
.sort-step-label { font-size: 10px; font-weight: 700; color: var(--c-sky-400); letter-spacing: .12em; }
.sort-step-text  { font-size: 12px; color: var(--c-ink-600); line-height: 1.7; }
.sort-step-body  { display: flex; flex-direction: column; gap: 4px; }

.sort-step-arrow {
  font-size: 22px;
  color: var(--c-sky-200);
  padding: 0 6px;
  flex-shrink: 0;
  font-weight: 300;
}

/* サブヒント */
.sort-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--c-ink-400);
  margin-bottom: 36px;
  flex-wrap: wrap;
}
.sort-hint-sep { color: var(--c-ink-200); }

/* 前回データがある場合 */
.sort-resume-card {
  background: linear-gradient(135deg, var(--c-sky-50), #e8f7fd);
  border: 1.5px solid var(--c-sky-200);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  text-align: center;
}
.sort-resume-title { font-size: 14px; font-weight: 700; color: var(--c-sky-600); margin-bottom: 8px; }
.sort-resume-info  { font-size: 13px; color: var(--c-ink-500); margin-bottom: 14px; }
.sort-resume-btns  { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── 対戦画面 ────────────────────────────────────────────── */

/* 進捗エリア */
.progress-wrap {
  padding: 12px 24px 10px;
  border-bottom: 1px solid var(--c-ink-100);
  position: sticky;
  top: var(--h-header);
  z-index: 50;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  transition: background .3s;
}
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.progress-current {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-ink-700);
}
.progress-count { font-size: 11px; color: var(--c-ink-400); }

.progress-bar-track {
  height: 6px;
  background: var(--c-ink-100);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-sky-300), var(--c-sky-500));
  border-radius: var(--r-full);
  transition: width .5s ease;
}
.progress-wrap.is-lb .progress-bar-fill {
  background: linear-gradient(90deg, #ffad3b, #e65100);
}

@media (max-width: 640px) {
  .progress-wrap {
    padding: 12px 16px 10px;
  }
  .progress-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

/* LBバッジ */
.lb-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff3e0;
  border: 1px solid #ffad3b;
  color: #e65100;
  border-radius: var(--r-full);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
}

/* 対戦メイン */
.battle-main {
  min-height: calc(100vh - var(--h-header) - 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 24px;
}
.battle-question {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-ink-600);
  margin-bottom: 28px;
  text-align: center;
}

/* 対戦カード行 */
.battle-row {
  display: flex;
  align-items: stretch; /* カードを同じ高さに揃える */
  gap: 20px;
  width: 100%;
  max-width: 720px;
  justify-content: center;
}
.battle-vs {
  font-size: 20px;
  font-weight: 700;
  color: var(--c-ink-300);
  flex-shrink: 0;
  align-self: center; /* VS は縦中央に固定 */
}

/* 対戦カード */
.battle-card {
  border-radius: var(--r-xl);
  padding: 28px 20px;
  border: 2px solid rgba(255,255,255,.6);
  cursor: pointer;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  text-align: center;
  flex: 1;
  max-width: 300px;
  min-width: 140px;
  height: 240px;   /* 全カード固定高さ（最長タイトル2行分を含む） */
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--s-sm);
  /* 内容を縦中央に揃える */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.battle-card:hover {
  border-color: var(--c-sky-400);
  transform: translateY(-6px);
  box-shadow: var(--s-md);
}
.is-lb .battle-card { border-color: rgba(255,173,59,.3); }
.is-lb .battle-card:hover { border-color: #ffad3b; transform: translateY(-6px); box-shadow: var(--s-md); }

.battle-card.selected {
  animation: cardSelected .35s ease; /* forwards削除：fill-modeを使わない */
  pointer-events: none;
}
.battle-card.rejected {
  animation: cardRejected .35s ease; /* forwards削除：fill-modeを使わない */
  pointer-events: none;
}
/* アニメーション終了後の終了状態をクラスで保持（fill-modeの代替） */
.battle-card.selected-end {
  opacity: 0;
  transform: scale(.7);
  pointer-events: none;
}
.battle-card.rejected-end {
  opacity: 0;
  transform: scale(.3);
  pointer-events: none;
}
@keyframes cardSelected {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); box-shadow: 0 0 28px rgba(58,181,224,.6); }
  100% { transform: scale(.7); opacity: 0; }
}
@keyframes cardRejected {
  0%   { opacity: 1; }
  100% { transform: scale(.3); opacity: 0; }
}

.battle-card-emoji  { font-size: 56px; display: block; margin: 0 auto 14px; line-height: 1; flex-shrink: 0; }
.battle-card-info   { display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; }
.battle-card-title  { font-size: 15px; font-weight: 700; color: var(--c-ink-800); margin-bottom: 6px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; width: 100%; }
.battle-card-release{ font-size: 11px; color: var(--c-ink-500); line-height: 1.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.battle-card-type   { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: var(--r-full); font-size: 10px; font-weight: 600; }
.type-single   { background: var(--c-sky-50); color: var(--c-sky-600); }
.type-coupling { background: #fff0f7; color: #c2185b; }
.type-album    { background: #f0fff4; color: #2e7d32; }
.type-unit     { background: #fff8e8; color: #e65100; }

/* 下部ボタン */
.battle-sub-btns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
  width: 100%;
  max-width: 720px;
  align-items: center;
}

#btn-draw {
  grid-column: 1 / -1;
  justify-self: center;
  appearance: none;
  border: 0;
  border-radius: var(--r-full);
  padding: 12px 18px;
  background: linear-gradient(135deg, #fff5d9, #ffe7a3);
  color: #8a5a00;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 10px 24px rgba(255, 193, 7, .16);
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

#btn-draw:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(255, 193, 7, .2);
  filter: brightness(1.02);
}

#btn-draw:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
  box-shadow: none;
}

#btn-undo,
.battle-sub-btns a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  min-width: 188px;
  width: auto;
  padding: 12px 20px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
  box-shadow: 0 12px 26px rgba(15, 23, 42, .10);
  transition: border-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease, background .2s ease, filter .2s ease;
}

#btn-undo {
  background: linear-gradient(135deg, #e8f5ff, #cfeeff);
  border-color: #9cd7f7;
  color: #0b5c82;
}

.battle-sub-btns a {
  background: linear-gradient(135deg, #fff1f0, #ffe0dd);
  border-color: #f6b8b1;
  color: #a53c32;
}

#btn-undo:not(:disabled):hover,
.battle-sub-btns a:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(15, 23, 42, .14);
}

#btn-undo:disabled {
  cursor: not-allowed;
  opacity: 1;
  box-shadow: 0 12px 26px rgba(15, 23, 42, .10);
}



@media (max-width: 640px) {
  /* ボタン行：横並びで中央揃え */
  .battle-sub-btns {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
  }
  /* 3ボタン共通：テキスト幅・高さを統一 */
  #btn-draw,
  #btn-undo,
  .battle-sub-btns a {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 11px;
    box-shadow: none;
    justify-self: auto;
    grid-column: auto;
  }
  /* 引き分けを真ん中に */
  #btn-undo         { order: 1; }
  #btn-draw         { order: 2; }
  .battle-sub-btns a { order: 3; }
}

/* ── 結果画面 ────────────────────────────────────────────── */
.result-wrap { max-width: 760px; margin: 0 auto; padding: 40px 24px; }
.result-header { text-align: center; margin-bottom: 40px; }
.result-header-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.result-header-title { font-size: 26px; font-weight: 700; color: var(--c-ink-800); margin-bottom: 8px; }
.result-header-sub   { font-size: 13px; color: var(--c-ink-400); }

/* TOP3 カード */
.top3-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 28px;
  width: 100%;
}
.top3-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 192px;
  border-radius: 24px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(255,255,255,.92);
  text-align: left;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .10);
  backdrop-filter: blur(10px);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.top3-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,.72), transparent 38%),
    linear-gradient(180deg, rgba(255,255,255,.26), rgba(255,255,255,.08));
  opacity: .9;
  pointer-events: none;
}
.top3-card > * {
  position: relative;
  z-index: 1;
}
.top3-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 22px 52px rgba(15, 23, 42, .14);
  border-color: rgba(255,255,255,1);
}
.top3-card.rank-1 {
  min-height: 192px;
  box-shadow: 0 28px 64px rgba(15, 23, 42, .18);
  border-color: rgba(255,255,255,1);
}
.top3-card.rank-1:hover {
  transform: translateY(-6px);
}
.top3-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.top3-medal {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, .12));
}
.top3-rank-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.84);
  color: var(--c-ink-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.78);
}
.top3-rank {
  font-size: 10px;
  font-weight: 800;
  color: rgba(15, 23, 42, .56);
  letter-spacing: .24em;
  margin-bottom: 8px;
}
.top3-card-main {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  flex: 1;
  gap: 12px;
  min-height: 0;
}
.top3-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  min-width: 54px;
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 10px 20px rgba(15, 23, 42, .12));
}
.top3-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.top3-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--c-ink-900);
  line-height: 1.22;
  letter-spacing: .01em;
  min-height: calc(1.22em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.top3-release {
  font-size: 10px;
  color: rgba(15, 23, 42, .62);
  line-height: 1.35;
  min-height: calc(1.35em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.top3-score {
  display: inline-flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.72);
}
.top3-score-label {
  font-size: 9px;
  font-weight: 800;
  color: rgba(15, 23, 42, .52);
  letter-spacing: .24em;
}
.top3-points {
  font-size: 17px;
  font-weight: 800;
  color: var(--c-ink-900);
  white-space: nowrap;
}
.top3-card.rank-1 .top3-emoji { font-size: 34px; }
.top3-card.rank-1 .top3-title { font-size: 17px; }
.top3-card.rank-1 .top3-points { font-size: 17px; }

/* ランキングリスト（4位〜） */
.rank-list { margin-bottom: 32px; }
.rank-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-ink-100);
  margin-bottom: 6px;
  background: var(--c-white);
  transition: box-shadow .15s;
}
.rank-item:hover { box-shadow: var(--s-sm); }
.rank-item-num   { font-size: 16px; font-weight: 700; color: var(--c-ink-400); text-align: center; }
.rank-item-emoji { font-size: 22px; text-align: center; width: 36px; line-height: 1; overflow: hidden; white-space: nowrap; flex-shrink: 0; }
.rank-item-info  { min-width: 0; overflow: hidden; }
.rank-item-title { font-size: 13px; font-weight: 700; color: var(--c-ink-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-item-sub   { font-size: 11px; color: var(--c-ink-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-item-pts   { font-size: 12px; font-weight: 700; color: var(--c-sky-500); white-space: nowrap; }
.rank-item.rank-top10 { border-color: var(--c-sky-200); }
.rank-item-lower { align-items: start; }
.rank-item-title-lower {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.45;
  display: block;
}

/* 11位〜30位 */
.lower-section { margin-top: 24px; }
.lower-toggle { cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--c-ink-600); background: none; border: none; padding: 0; margin-bottom: 16px; }
.lower-toggle .arrow { transition: transform .2s; font-size: 12px; }
.lower-toggle.open .arrow { transform: rotate(180deg); }
.lower-items { display: none; }
.lower-items.show { display: block; }
.lower-group-title { font-size: 11px; font-weight: 700; color: var(--c-ink-400); letter-spacing: .1em; margin: 16px 0 8px; padding-left: 4px; }

/* 統計 */
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 28px; }
.stat-box     { background: var(--c-ink-50); border-radius: var(--r-md); padding: 14px 12px; text-align: center; }
.stat-box-num { font-size: 22px; font-weight: 700; color: var(--c-sky-500); }
.stat-box-lbl { font-size: 11px; color: var(--c-ink-400); margin-top: 2px; }

/* アクションボタン */
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 40px; }

/* ── ランキングページ ──────────────────────────────────────── */
.ranking-wrap { max-width: 760px; margin: 0 auto; padding: 40px 24px; }
.ranking-header { text-align: center; margin-bottom: 32px; }
.ranking-header-title { font-size: 26px; font-weight: 700; color: var(--c-ink-800); margin-bottom: 8px; }
.ranking-meta  { font-size: 13px; color: var(--c-ink-400); }

.ranking-top3  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }

.ranking-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-ink-100);
  margin-bottom: 6px;
  background: var(--c-white);
}
.ranking-bar-wrap { grid-column: 1/-1; padding: 0 4px 4px; }
.ranking-bar-track { height: 6px; background: var(--c-ink-100); border-radius: var(--r-full); overflow: hidden; }
.ranking-bar-fill  { height: 100%; border-radius: var(--r-full); width: 0; transition: width .8s ease; }

.ranking-bar-fill.keyaki-single   { background: linear-gradient(90deg, #c8b8ff, #a080ff); }
.ranking-bar-fill.keyaki-other    { background: linear-gradient(90deg, #ddd0ff, #b898ff); }
.ranking-bar-fill.hinata-single   { background: linear-gradient(90deg, var(--c-sky-300), var(--c-sky-500)); }
.ranking-bar-fill.hinata-coupling { background: linear-gradient(90deg, #ffd6ea, #ff7eb3); }
.ranking-bar-fill.hinata-album    { background: linear-gradient(90deg, #b8f0cc, #34c97a); }
.ranking-bar-fill.unit            { background: linear-gradient(90deg, #ffd6a0, #ffad3b); }

/* ランキングアイテム背景色 */
.rank-item.item-keyaki-single   { background: #f3f0ff; border-color: #c8b8ff; }
.rank-item.item-keyaki-other    { background: #f7f4ff; border-color: #ddd0ff; }
.rank-item.item-hinata-single   { background: #eef8ff; border-color: #b8dff8; }
.rank-item.item-hinata-coupling { background: #fff0f7; border-color: #ffd6ea; }
.rank-item.item-hinata-album    { background: #f0fff6; border-color: #b8f0cc; }
.rank-item.item-unit            { background: #fff8ee; border-color: #ffd6a0; }
.ranking-item.item-keyaki-single   { background: #f3f0ff; border-color: #c8b8ff; }
.ranking-item.item-keyaki-other    { background: #f7f4ff; border-color: #ddd0ff; }
.ranking-item.item-hinata-single   { background: #eef8ff; border-color: #b8dff8; }
.ranking-item.item-hinata-coupling { background: #fff0f7; border-color: #ffd6ea; }
.ranking-item.item-hinata-album    { background: #f0fff6; border-color: #b8f0cc; }
.ranking-item.item-unit            { background: #fff8ee; border-color: #ffd6a0; }

/* ── 折りたたみセクション ── */
.rank-expand-section { margin-top: 12px; }
.rank-expand-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: var(--c-ink-50);
  border: 1.5px solid var(--c-ink-100);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-ink-600);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.rank-expand-btn:hover {
  background: var(--c-sky-50);
  border-color: var(--c-sky-300);
  color: var(--c-sky-600);
}
.rank-expand-section.open .rank-expand-btn {
  background: var(--c-sky-50);
  border-color: var(--c-sky-300);
  color: var(--c-sky-600);
}
.rank-expand-arrow {
  font-size: 11px;
  color: var(--c-ink-300);
  transition: transform var(--t-fast);
}
.rank-expand-section.open .rank-expand-arrow { transform: rotate(180deg); }

.rank-expand-body {
  display: none;
  border: none;
  border-radius: 0;
  overflow: visible;
  padding-top: 10px;
}
.rank-expand-section.open .rank-expand-body { display: block; }
.rank-expand-body .rank-item {
  margin-bottom: 8px;
  border-radius: var(--r-md);
}
.rank-expand-body .rank-item:last-child { margin-bottom: 0; }

/* フィルタタブ */
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-tab  { padding: 6px 14px; border-radius: var(--r-full); border: 1.5px solid var(--c-ink-200); background: var(--c-white); font-size: 12px; font-weight: 600; color: var(--c-ink-500); cursor: pointer; transition: all .15s; }
.filter-tab:hover { border-color: var(--c-sky-400); color: var(--c-sky-500); }
.filter-tab.active { background: var(--c-sky-500); border-color: var(--c-sky-500); color: #fff; }

.count-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.count-tab  { padding: 6px 14px; border-radius: var(--r-full); border: 1.5px solid var(--c-ink-200); background: var(--c-white); font-size: 12px; font-weight: 600; color: var(--c-ink-500); cursor: pointer; transition: all .15s; }
.count-tab.active { background: var(--c-ink-600); border-color: var(--c-ink-600); color: #fff; }

/* ランキング空状態 */
.ranking-empty { text-align: center; padding: 60px 24px; color: var(--c-ink-400); }
.ranking-empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── レスポンシブ ──────────────────────────────────────────── */
@media (max-width: 600px) {
  /* カード行：縦積みレイアウト（横幅を最大活用し、高さを固定しやすくする） */
  .battle-row {
    flex-direction: column;
    align-items: stretch;
    max-width: 420px;
    gap: 0;
  }
  .battle-vs {
    align-self: center;
    font-size: 14px;
    padding: 4px 0;
  }
  /* カード：横幅フルで高さを固定 */
  .battle-card {
    max-width: 100%;
    min-width: 0;
    width: 100%;
    height: 130px !important; /* デスクトップの240pxに確実に優先 */
    overflow: hidden;         /* 内容が溢れてもカードサイズを変えない */
    padding: 14px 16px;
    flex-direction: row;      /* 絵文字と情報を横並びに */
    gap: 14px;
    text-align: left;
    justify-content: flex-start;
    align-items: center;
  }
  .battle-card-emoji  { font-size: 38px; margin: 0; flex-shrink: 0; line-height: 1; }
  .battle-card-title  { font-size: 14px; -webkit-line-clamp: 2; }
  .battle-card-release{ font-size: 11px; }
  /* タイプバッジを左寄せに */
  .battle-card-type   { margin-top: 4px; }
  /* カード内テキスト群 */
  .battle-card-info   { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; overflow: hidden; }

  .sort-steps { flex-direction: column; gap: 8px; }
  .sort-step  { max-width: 100%; width: 100%; flex-direction: row; padding: 16px 20px; gap: 16px; }
  .sort-step-icon { font-size: 28px; }
  .sort-step-body { text-align: left; }
  .sort-step-arrow { transform: rotate(90deg); padding: 0; font-size: 18px; }

  .top3-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .top3-card,
  .top3-card.rank-1 {
    min-height: auto;
    transform: none;
  }
  .top3-card.rank-1 {
    order: -1;
  }
  .top3-card:hover,
  .top3-card.rank-1:hover {
    transform: translateY(-4px);
  }
  .top3-card {
    border-radius: 24px;
    padding: 18px 16px 16px;
  }
  .top3-card-main {
    gap: 12px;
  }
  .top3-emoji,
  .top3-card.rank-1 .top3-emoji {
    width: 56px;
    min-width: 56px;
    font-size: 38px;
  }
  .top3-title,
  .top3-card.rank-1 .top3-title { font-size: 20px; }
  .top3-points,
  .top3-card.rank-1 .top3-points { font-size: 21px; }

  .ranking-top3 { grid-template-columns: 1fr; }
  .result-stats { grid-template-columns: repeat(3, 1fr); }
  .stat-box-num { font-size: 18px; }
  .stat-box-lbl { font-size: 10px; }
  .stat-box { padding: 10px 6px; }

  .rank-item {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: start;
    padding: 10px 12px;
  }
  .rank-item-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .rank-item-sub {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.35;
  }
  .rank-item-lower {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: start;
  }
  .rank-item-title-lower {
    font-size: 12px;
    line-height: 1.45;
  }

  .result-wrap { padding: 28px 16px; }
  .ranking-wrap { padding: 28px 16px; }
  .result-actions { flex-direction: column; align-items: stretch; }
  .result-actions .btn { text-align: center; justify-content: center; }

  .filter-tabs { gap: 4px; }
  .filter-tab { padding: 5px 10px; font-size: 11px; }
}
