/* Apple風。白基調に淡い水色・水色・青、文字は紺、1位だけ金。公式の素材は使わない。 */
:root {
  --white: #ffffff;
  --bg: #f3f9fe;
  --sky-50: #eaf5fd;
  --sky-100: #d7edfb;
  --sky-200: #b5ddf7;
  --sky-400: #5bb8f0;
  --blue: #1a86f0;
  --blue-deep: #0f62c4;
  --navy: #1c2b41;
  --muted: #687c95;
  --line: #dbe8f3;
  --gold: #f4b400;
  --gold-ink: #3b2b00;
  --danger: #d93f52;
  --card-shadow: 0 1px 2px rgb(16 40 80 / 0.05), 0 8px 20px rgb(16 40 80 / 0.07);
  --panel-shadow: 0 1px 2px rgb(16 40 80 / 0.04), 0 8px 24px rgb(16 40 80 / 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--navy);
  background: linear-gradient(180deg, var(--white) 0, var(--bg) 360px) no-repeat, var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Inter", "Noto Sans JP", sans-serif;
  line-height: 1.55;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--sky-400); outline-offset: 2px; }

/* ---------- ヘッダー・フッター ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgb(255 255 255 / 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgb(0 0 0 / 0.06);
}
.header-inner, main, .site-footer { max-width: 1120px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.site-title { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.title-sub { color: var(--blue); font-weight: 600; }
.title-link { color: inherit; text-decoration: none; }
.title-link:hover { opacity: 0.75; }
/* トップ: 順位付けの途中が残っているときの案内（見出しの代わり） */
.resume {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 8px 0 20px; padding: 12px 14px 12px 18px; border-radius: 16px;
  background: var(--sky-50); box-shadow: inset 0 0 0 1px var(--sky-200);
}
.resume-text { flex: 1 1 220px; margin: 0; font-weight: 700; }
/* 進み具合（押せるボタンに見えないよう、番号と矢印でつなぐ） */
.steps { display: flex; align-items: center; margin: 0; padding: 0; list-style: none; cursor: default; user-select: none; }
.steps li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.steps li + li::before { content: ""; width: 6px; height: 6px; margin: 0 12px 0 10px; border-top: 1.5px solid var(--sky-200); border-right: 1.5px solid var(--sky-200); transform: rotate(45deg); }
.step-no {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted);
}
.steps li.current { color: var(--navy); font-weight: 600; }
.steps li.current .step-no { background: var(--blue); color: #fff; box-shadow: none; }
.steps li.done .step-no { background: var(--sky-100); color: var(--blue-deep); box-shadow: none; }

main { padding-top: 20px; padding-bottom: 120px; }
.site-footer { padding-bottom: 100px; font-size: 12px; color: var(--muted); }
.site-footer p { margin: 2px 0; }
.status { color: var(--muted); }
.status.error { color: var(--danger); }

/* ---------- 共通の部品 ---------- */
.lead { margin: 12px 0 24px; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
/* 見出しは字詰め（Apple の日本語の見出しに寄せる） */
.lead, .h, .ask, .result-title, .site-title, .resume-text { font-feature-settings: "palt"; }
.h { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.h.small { font-size: 15px; }
.h-note { font-size: 14px; font-weight: 400; color: var(--muted); }
.panel { background: var(--white); border-radius: 20px; padding: 22px; box-shadow: var(--panel-shadow); }
.empty { margin: 0; padding: 24px 0; text-align: center; color: var(--muted); grid-column: 1 / -1; }

.chip {
  flex: none; white-space: nowrap;
  border: 0; border-radius: 999px; padding: 7px 14px; font-size: 14px;
  background: var(--sky-50); color: var(--navy);
  transition: background 0.2s, color 0.2s;
}
.chip:hover { background: var(--sky-100); }
.chip[aria-pressed="true"] { background: var(--blue); color: #fff; font-weight: 600; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: #dfe6ee; transition: background 0.2s; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.2); transition: transform 0.2s; }
.switch input:checked + .switch-ui { background: var(--sky-400); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--sky-400); outline-offset: 2px; }

/* 主ボタン（始める・決定・画像保存）と、控えめなボタン */
.cta, .btn.primary {
  border: 0; border-radius: 999px; padding: 15px 24px;
  background: var(--blue); color: #fff; font-size: 17px; font-weight: 600;
  box-shadow: 0 4px 14px rgb(26 134 240 / 0.3);
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}
.cta:hover:not(:disabled), .btn.primary:hover:not(:disabled) { background: var(--blue-deep); }
.cta:active:not(:disabled), .btn.primary:active:not(:disabled) { transform: scale(0.98); }
.cta:disabled, .btn.primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn { border: 0; border-radius: 999px; padding: 10px 20px; background: var(--sky-50); color: var(--blue-deep); font-weight: 600; transition: background 0.2s; }
.btn:hover:not(:disabled) { background: var(--sky-100); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { padding: 11px 28px; font-size: 16px; }
.btn.danger { color: var(--danger); background: transparent; }
.btn.danger:hover:not(:disabled) { background: #fdecee; }
.btn.small { padding: 6px 14px; font-size: 14px; }
.ghost { border: 0; background: none; color: var(--blue); font-size: 14px; padding: 4px 0; }
.ghost:disabled { opacity: 0.4; }
.link { display: block; margin: 12px auto 0; border: 0; background: none; color: var(--blue); font-size: 15px; padding: 4px 0; }
.back-link { margin: 4px 0 0; }
.back-link .link { margin: 0; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgb(255 255 255 / 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgb(0 0 0 / 0.06);
}
/* 順位付け画面はカードのすぐ下に置く。画面からはみ出すときだけ下に貼り付く */
.bar.rank-bar { position: sticky; margin: 20px -20px 0; }
.rank-bar .bar-inner { flex-wrap: nowrap; }
.rank-bar .bar-info { flex: 1 1 0; }
.bar-inner { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.bar-info { flex: 1 1 160px; font-size: 14px; }
.bar-info strong { font-size: 20px; font-weight: 700; color: var(--blue); }
.bar-hint { display: block; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 92px; z-index: 30; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 14px;
  background: rgb(28 43 65 / 0.88); color: #fff; font-size: 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  display: flex; align-items: center; gap: 14px;
}
.toast[hidden] { display: none; }
.toast-action { border: 0; background: none; padding: 2px 0; color: #8fd0ff; font-weight: 700; white-space: nowrap; }

/* ---------- キャラの画像 ---------- */
.portrait { position: relative; aspect-ratio: 200 / 226; overflow: hidden; border-radius: 12px; background: var(--sky-50); }
.portrait.icon { aspect-ratio: 1; border-radius: 50%; }
.portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }
.portrait .fallback { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 8px; text-align: center; font-size: 14px; font-weight: 600; color: var(--muted); }
.portrait.noimg img { display: none; }
.portrait.noimg .fallback { display: flex; }

/* ---------- 1 トップ ---------- */
/* PC は2列。右のカードは固定して、左の絞り込みが変わっても動かない */
.start-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.panel.start-card { position: sticky; top: 76px; }

.frow { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); align-items: center; gap: 8px; min-height: 48px; }
.flabel { font-size: 13px; color: var(--muted); }
.fhint { margin: 0; font-size: 13px; color: var(--muted); }
/* 選択肢は1行の横スクロール。行の高さが変わらない */
.scroller { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px; scrollbar-width: thin; scrollbar-color: transparent transparent; mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.search { width: 100%; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 12px; background: var(--sky-50); font-size: 15px; }
.search::placeholder { color: var(--muted); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: 12px; background: var(--sky-50); }
.seg { display: flex; flex-direction: column; align-items: center; border: 0; border-radius: 10px; padding: 8px 4px; background: transparent; transition: background 0.2s, box-shadow 0.2s; }
.seg strong { font-size: 15px; font-weight: 600; }
.seg small { font-size: 11px; color: var(--muted); }
.seg[aria-checked="true"] { background: var(--white); box-shadow: 0 1px 3px rgb(16 40 80 / 0.12), 0 2px 8px rgb(16 40 80 / 0.06); }
.seg[aria-checked="true"] strong { color: var(--blue); }

.preview-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.preview-head .h { margin: 0; }
.preview { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; min-height: 120px; }
.pcard { text-align: center; }
.pname { display: block; margin-top: 4px; font-size: 11px; line-height: 1.2; color: var(--muted); word-break: break-all; }
.start-card .cta { display: block; width: 100%; margin-top: 20px; }
.cta-note { margin: 8px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.cta-note.sub { margin-top: 2px; font-size: 12px; }
.h-sub { margin: -6px 0 12px; font-size: 13px; color: var(--muted); }

/* ---------- 1' 一覧から選ぶ ---------- */
.filters { margin-bottom: 16px; }
.grid-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.grid-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.pick {
  position: relative; border: 0; border-radius: 16px; padding: 8px 6px; text-align: center;
  background: var(--white); box-shadow: var(--card-shadow); transition: box-shadow 0.2s, transform 0.2s;
}
.pick .name { display: block; margin-top: 6px; font-size: 12px; line-height: 1.25; min-height: 2.5em; word-break: break-all; }
.pick[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--blue), 0 6px 16px rgb(26 134 240 / 0.18); }
.pick[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
}

/* ---------- 2 順位付け ---------- */
.progress-head { display: flex; justify-content: space-between; font-size: 14px; }
.progress-head span:first-child { font-weight: 600; }
.progress-head span:last-child { color: var(--muted); }
.progress { height: 8px; margin: 8px 0 16px; overflow: hidden; border-radius: 999px; background: var(--sky-100); }
.progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--sky-400), var(--blue)); transition: width 0.3s; }

.slots { --cols: 5; --gap: 8px; display: flex; justify-content: center; gap: var(--gap); margin: 0 0 12px; padding: 0; list-style: none; }
.slot {
  flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)); min-width: 0; display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 4px 10px 4px 6px; border-radius: 14px; font-size: 13px;
  background: var(--white); box-shadow: inset 0 0 0 1px var(--line);
}
.slot .portrait.icon, .slot-empty { flex: none; width: 30px; height: 30px; border-radius: 50%; }
.slot-empty { background: var(--sky-50); }
.slot-rank { flex: none; font-weight: 700; color: var(--muted); }
.slot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.next { background: var(--sky-50); box-shadow: inset 0 0 0 2px var(--sky-400); }
.slot.filled { box-shadow: inset 0 0 0 1px var(--sky-200); }
.slot.filled .slot-rank { color: var(--blue); }
.slot.filled:first-child { box-shadow: inset 0 0 0 1.5px var(--gold); }
.slot.filled:first-child .slot-rank { color: #b98600; }

/* 「残りをまとめて外す」が出ても高さは変えない（カードの位置がずれないように） */
.ask-row { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.ask-row .ask { flex: 1 1 auto; min-width: 0; margin: 0; }
.ask-actions { flex: none; display: flex; gap: 16px; white-space: nowrap; }
.ask { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 14px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.ask-note { font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; }

/* 1回の人数が減ってもカードの大きさは変えない（常に5人ぶんの幅で、中央に寄せる） */
.rank-grid { --cols: 5; --gap: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); }
.rank-grid > .rank-card { flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)); min-width: 0; }
.rank-card { position: relative; border-radius: 18px; background: var(--white); box-shadow: var(--card-shadow); transition: transform 0.2s, box-shadow 0.2s; }
.rank-card.ranked { box-shadow: 0 0 0 3px var(--blue), 0 8px 20px rgb(26 134 240 / 0.18); }
.rank-card.first { box-shadow: 0 0 0 3px var(--gold), 0 8px 20px rgb(244 180 0 / 0.2); }
.rank-hit { display: block; width: 100%; border: 0; border-radius: 18px; padding: 8px; background: none; text-align: center; }
.rank-hit .name { display: block; padding: 8px 4px 2px; font-weight: 700; font-size: 14px; line-height: 1.3; }
.rank-card .badge {
  position: absolute; z-index: 2; top: 14px; left: 14px;
  display: none; place-items: center; min-width: 40px; height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 14px;
}
.rank-card.ranked .badge { display: grid; }
.rank-card.first .badge { background: var(--gold); color: var(--gold-ink); }
.rank-skip {
  position: absolute; z-index: 2; top: 14px; right: 14px;
  border: 0; border-radius: 999px; padding: 4px 10px; font-size: 12px;
  background: rgb(255 255 255 / 0.82); color: var(--navy);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
/* 外した子: 灰色にしてその場に残し、「戻す」で戻せる。「戻す」は「外す」と同じ右上（押す場所をそろえる） */
.rank-card.excluded { box-shadow: inset 0 0 0 1.5px var(--line); background: var(--bg); }
.rank-card.excluded .rank-hit { cursor: default; filter: grayscale(1); opacity: 0.55; }
.excluded-label { position: absolute; z-index: 2; top: 14px; left: 14px; padding: 3px 10px; border-radius: 999px; font-size: 12px; background: rgb(28 43 65 / 0.75); color: #fff; }
.rank-restore {
  position: absolute; z-index: 2; top: 14px; right: 14px;
  border: 0; border-radius: 999px; padding: 4px 12px;
  background: var(--white); color: var(--blue-deep); font-weight: 700; font-size: 12px; white-space: nowrap;
  box-shadow: 0 4px 14px rgb(16 40 80 / 0.18);
}
/* 動く・色が変わるホバーはマウスのある端末だけ（スマホはタップ後もホバーが残り、カードがずれて見える） */
@media (hover: hover) {
  /* 横に流れる選択肢のスクロールバーは、マウスを乗せたときだけ薄く出す（Apple 風。普段は右端のフェードで続きを示す） */
  .scroller:hover { scrollbar-color: rgb(28 43 65 / 0.22) transparent; }
  .pick:hover { transform: translateY(-1px); }
  .rank-card:not(.excluded):hover { transform: translateY(-2px); }
  .rank-skip:hover { background: #fff; color: var(--danger); }
  .rank-restore:hover { background: var(--sky-50); }
}

/* ---------- 3 結果 ---------- */
.result-title { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.result-sub { margin: 4px 0 20px; color: var(--muted); }
.top-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
/* 1〜3位は1位をひと回り大きく、下揃え */
.top-grid.podium { grid-template-columns: 1.3fr 1fr 1fr; align-items: end; gap: 16px; max-width: 820px; margin: 0 auto 14px; }
.top-card { position: relative; border-radius: 18px; padding: 8px; text-align: center; background: var(--white); box-shadow: var(--card-shadow); }
.top-card .name { display: block; padding: 6px 4px 2px; font-weight: 700; font-size: 13px; line-height: 1.3; word-break: break-all; }
.podium .top-card .name { font-size: 16px; }
.podium .top-card.r1 .name { font-size: 19px; }
.top-card .school { display: block; padding-bottom: 2px; font-size: 12px; color: var(--muted); }
.top-card.r1 { box-shadow: 0 0 0 3px var(--gold), 0 10px 28px rgb(244 180 0 / 0.22); }
.top-card .rank {
  position: absolute; z-index: 2; top: 14px; left: 14px;
  display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px;
  background: rgb(255 255 255 / 0.92); color: var(--navy); font-weight: 700; font-size: 14px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.15);
}
.top-card.r1 .rank { background: var(--gold); color: var(--gold-ink); }
.podium .top-card.r1 .rank { min-width: 38px; height: 38px; font-size: 18px; }
/* 前回からの変化 */
.change { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.change.up { background: var(--sky-100); color: var(--blue-deep); }
.change.down { background: #edf1f5; color: var(--muted); }
.change.new { background: #fff3cf; color: #8a6400; }
.top-card .change { position: absolute; z-index: 2; top: 16px; right: 14px; }
/* 結果を外に出すボタン（結果のすぐ下・中央） */
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 24px 0 28px; }
.result-actions .btn { min-width: 160px; }
/* 11位から: 顔アイコン付きの一覧 */
.rest-list { background: var(--white); border-radius: 20px; padding: 18px 22px; box-shadow: var(--panel-shadow); }
.rest-list h3 { margin: 0 0 10px; font-size: 15px; }
.rest-list ol { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 20px; margin: 0; padding: 0; list-style: none; }
.rest-list li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 3px 0; }
.rest-rank { flex: none; width: 2.2em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rest-list .portrait.icon { flex: none; width: 32px; height: 32px; border-radius: 50%; }
.rest-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 次にすること（控えめに） */
.result-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 24px; margin: 28px 0 0; }
.result-links .link { margin: 0; }
/* 過去の結果 */
.history { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; border-radius: 16px; background: var(--white); box-shadow: var(--card-shadow); }
.history-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; border: 0; padding: 0; background: none; text-align: left; }
.history-faces { flex: none; display: flex; }
.history-faces .portrait.icon { width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 0 0 2px var(--white); }
.history-faces .portrait.icon + .portrait.icon { margin-left: -10px; }
.history-text { min-width: 0; display: flex; flex-direction: column; }
.history-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-text small { color: var(--muted); font-size: 13px; }
.history-del { flex: none; background: transparent; color: var(--muted); }
.result-note { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
/* みんなのランキングに送る旨とスイッチ */
.stats-note { max-width: 520px; margin: 22px auto 0; padding: 14px 16px; border-radius: 16px; background: var(--white); box-shadow: var(--panel-shadow); text-align: center; }
.stats-note .switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 35%, transparent); transition: background 0.2s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform 0.2s; }
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--blue); outline-offset: 2px; }
.stats-text { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.stats-status { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.stats-status:empty { display: none; }
.stats-status.warn { color: var(--danger); }
.result-stats { margin: 6px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.result-stats.warn { color: var(--danger); }

.turnstile-slot .turnstile-box { display: flex; justify-content: center; margin-top: 8px; }
/* 送る旨の枠が無い画面では、画面の下に出す */
body > .turnstile-box { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; }
/* PC のシェア（画像を見せてから選んでもらう） */
.share-dialog { width: min(560px, calc(100% - 32px)); border: 0; border-radius: 22px; padding: 22px; color: var(--navy); background: var(--white); box-shadow: 0 24px 60px rgb(16 40 80 / 0.25); }
.share-dialog::backdrop { background: rgb(28 43 65 / 0.35); backdrop-filter: blur(4px); }
.share-dialog h3 { margin: 0 0 12px; font-size: 19px; font-feature-settings: "palt"; }
.share-preview { display: grid; place-items: center; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--sky-50); }
.share-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.share-note { margin: 14px 0 16px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.share-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.share-buttons .ghost-btn { margin-left: auto; background: transparent; color: var(--muted); }
.start-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px; }

/* ---------- 開始時のアニメーション（トップの5人 → 順位付けの画面） ---------- */
::view-transition-group(*) { animation-duration: 0.45s; animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.25s; }

/* ---------- 狭い画面 ---------- */
/* 2列は広い画面だけ。1060px 前後で2列にすると、右の列の顔が小さく左の列の下が空く（user 指摘）。1列は中央に寄せる */
@media (max-width: 1100px) {
  .start-layout { grid-template-columns: 1fr; }
  .start-layout, main > :has(+ .start-layout) { max-width: 820px; margin-left: auto; margin-right: auto; }
  .panel.start-card { position: static; }
}
@media (max-width: 640px) {
  .header-inner, main, .site-footer { padding-left: 16px; padding-right: 16px; }
  .steps { display: none; }
  .lead { font-size: 18px; margin: 4px 0 16px; }
  .panel { padding: 16px; border-radius: 16px; }
  .preview { gap: 5px; }
  .bar-inner { padding: 10px 16px; gap: 8px; }
  .bar.rank-bar { margin: 16px -16px 0; }
  .toast { bottom: 150px; }

  .slots { --gap: 4px; }
  .slot { flex-direction: column; justify-content: center; gap: 2px; padding: 4px; border-radius: 10px; font-size: 11px; }
  .slot .portrait.icon, .slot-empty { width: 28px; height: 28px; }
  .slot-name { display: none; }
  .ask { font-size: 20px; }
  .ask-note, .ask-lead { display: none; } /* 幅が足りず2行になり、カードの位置がずれるため */
  .rank-grid { --cols: 3; --gap: 8px; }
  /* 4人の回は T 字（3人＋1人）にせず、2人×2段に。幅はそのまま、2人目の後で改行する */
  .rank-grid.n4 { row-gap: 0; } /* 改行用の空の行に上下の隙間が付かないよう、下の段は margin で離す */
  .rank-grid.n4::before { content: ""; order: 1; flex-basis: 100%; height: 0; }
  .rank-grid.n4 > .rank-card:nth-child(n + 3) { order: 2; margin-top: var(--gap); }
  .rank-card, .rank-hit { border-radius: 14px; }
  .rank-hit { padding: 5px; }
  .rank-hit .name { font-size: 12px; padding-top: 6px; }
  .rank-card .badge { top: 9px; left: 9px; min-width: 32px; height: 24px; font-size: 12px; }
  .rank-skip { top: 9px; right: 9px; padding: 2px 8px; font-size: 11px; }
  .excluded-label { display: none; } /* 狭くて「戻す」と重なるため。灰色で外したと分かる */
  .rank-restore { top: 9px; right: 9px; padding: 2px 9px; font-size: 11px; }

  .result-title { font-size: 26px; }
  .top-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .top-grid.podium { gap: 8px; }
  .podium .top-card.r1 .name { font-size: 15px; }
  .podium .top-card.r1 .rank { min-width: 30px; height: 30px; font-size: 14px; }
  .top-card .school { font-size: 10px; }
  .top-card .change { top: 9px; right: 8px; padding: 0 5px; font-size: 10px; }
  .rest-list { padding: 14px 16px; }
  .rest-list ol { grid-template-columns: 1fr 1fr; gap: 4px 10px; }
  .rest-list li { gap: 6px; font-size: 13px; }
  .rest-list .portrait.icon { width: 28px; height: 28px; }
  .top-card { padding: 5px; border-radius: 14px; }
  .top-card .name { font-size: 11px; }
  .podium .top-card .name { font-size: 13px; }
  .top-card .rank { top: 9px; left: 9px; min-width: 24px; height: 24px; font-size: 12px; }
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
}
