:root {
  --bg: #fdfcfa;
  --surface: #ffffff;
  --surface-2: #f4f2ed;
  --text: #2c2c2a;
  --text-sub: #6b6a65;
  --border: #ddd9d0;
  --accent: #7c4818;
  --accent-soft: #f0e4d8;
  --played: #1d9e75;
  --have: #ba7517;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1a;
    --surface: #262521;
    --surface-2: #2f2e29;
    --text: #e8e6df;
    --text-sub: #a3a199;
    --border: #403e38;
    --accent: #d9a066;
    --accent-soft: #3a3128;
    --played: #5dcaa5;
    --have: #efa63a;
  }
}

* { box-sizing: border-box; }

/* hidden 属性で出し入れする要素（絞り込み・バナー・順位表示）のための保険。
 * UA スタイルの [hidden]{display:none} は詳細度が同じ 0,1,0 なので、
 * .game{display:flex} のようなクラス指定に負けて効かなくなる。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 16px 64px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

main, header, section, footer { max-width: 820px; margin-inline: auto; }

.hero { padding: 40px 0 24px; text-align: center; }
.hero h1 { margin: 0 0 12px; font-size: 30px; line-height: 1.3; color: var(--accent); }
.hero h1 small { font-size: 18px; color: var(--text); font-weight: 500; }
.lead { margin: 0; color: var(--text-sub); font-size: 15px; }

/* 使い方。hero は中央寄せなので、箇条書きだけ左寄せに戻す。 */
.howto {
  max-width: 560px; margin: 18px auto 0;
  padding: 12px 18px 12px 34px;
  text-align: left; font-size: 13px; line-height: 1.9; color: var(--text-sub);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.howto strong { color: var(--text); font-weight: 600; }

/* ---- スコアバー（追従） ---- */
.scorebar {
  position: sticky;
  top: 0;
  z-index: 10;
  max-width: 820px;
  margin: 0 auto 20px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.scores { display: flex; gap: 8px; }
.score { flex: 1; text-align: center; }
.score .label { display: block; font-size: 12px; color: var(--text-sub); }
.score .value { display: block; font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.score:first-child .value { color: var(--accent); font-size: 34px; }
.bar { height: 6px; margin-top: 8px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.rank { margin: 8px 0 0; font-size: 13px; text-align: center; color: var(--text-sub); }

/* ---- ツールバー ---- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
#filter {
  flex: 1 1 240px; min-width: 0; padding: 10px 12px;
  font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.bulk { display: flex; gap: 8px; }
.bulk button, .post {
  padding: 10px 14px; font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
}
.bulk button:hover, .post:hover { background: var(--surface-2); }

/* ---- ゲーム一覧 ---- */
.games { list-style: none; margin: 0; padding: 0; }
.game {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.game.hit { border-color: var(--accent); }
.game .titles { flex: 1 1 240px; min-width: 0; cursor: pointer; }
.game .title { display: block; font-size: 16px; }
.game .sub { display: block; font-size: 12px; color: var(--text-sub); }
.game .rate { flex: 0 0 auto; font-size: 12px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
.game .actions { display: flex; align-items: center; gap: 6px; }

.chk { position: relative; }
.chk input { position: absolute; opacity: 0; width: 0; height: 0; }
.chk span {
  display: inline-block; padding: 6px 12px; font-size: 13px; white-space: nowrap;
  color: var(--text-sub); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  user-select: none;
}
.chk input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chk.p input:checked + span { color: #fff; background: var(--played); border-color: var(--played); }
.chk.h input:checked + span { color: #fff; background: var(--have); border-color: var(--have); }

/* ボタンではなくリンクとして見せる。上下の padding はタップ領域の確保用で、
 * 枠も背景も付けないので見た目はテキストリンクのまま。 */
.extlink {
  padding: 6px 2px; font-size: 12px; color: var(--text-sub);
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--border);
}
.extlink:hover { color: var(--accent); text-decoration-color: var(--accent); }
.extlink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.extlink-sample {
  font-size: 12px; color: var(--text-sub);
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--border);
}

/* ---- 共有 ---- */
.share { margin-top: 28px; text-align: center; }
/* 中身は <a>。アプリ内ブラウザ（X など）では window.open が塞がれるため、
 * ブラウザ標準の遷移に任せる。見た目だけボタンに寄せる。 */
.post {
  display: inline-block; text-decoration: none;
  padding: 14px 28px; font-size: 17px; color: #fff;
  background: var(--accent); border-color: var(--accent);
}
.post:hover { opacity: .88; background: var(--accent); }
.morelink { margin: 20px 0 0; font-size: 14px; }
.morelink a {
  color: var(--accent); text-decoration: underline; text-underline-offset: 4px;
  text-decoration-color: var(--accent-soft);
}
.morelink a:hover { text-decoration-color: var(--accent); }

.notice { margin: 14px auto 0; max-width: 520px; font-size: 12px; color: var(--text-sub); }
.notice + .notice { margin-top: 6px; }

.empty { text-align: center; color: var(--text-sub); }
footer { margin-top: 40px; font-size: 12px; color: var(--text-sub); text-align: center; }
footer a { color: inherit; }
footer .credit { margin-bottom: 10px; }

@media (max-width: 560px) {
  .game { gap: 8px; }
  .game .titles { flex-basis: 100%; }
  .game .actions { flex: 1; }
  .hero h1 { font-size: 24px; }
}
