:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1f2321;
  --muted: #5f6763;
  --line: #dcdcd4;
  --accent: #2f6f62;
  --accent-text: #ffffff;
  --accent-soft: #e2efeb;
  --swap: #b4462c;
  --swap-soft: #fbe9e3;
  --mark: #8a5a00;
  --mark-soft: #fff3d6;
  --bar: #2f6f62;
  --bar-bg: #e7e7df;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917;
    --surface: #202422;
    --text: #e8ebe9;
    --muted: #a3aba7;
    --line: #353b38;
    --accent: #5fb8a5;
    --accent-text: #0f1a17;
    --accent-soft: #23362f;
    --swap: #f08a6c;
    --swap-soft: #3a2620;
    --mark: #f2c76b;
    --mark-soft: #3a3120;
    --bar: #5fb8a5;
    --bar-bg: #2c322f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
a { color: var(--accent); }
button { font: inherit; }

.site-header, .page, .site-footer { max-width: 560px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.site-header { padding-top: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.site-name { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: .9rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.site-nav a[aria-current="page"] { color: var(--accent); font-weight: 700; }

.page { padding-top: 16px; padding-bottom: 32px; min-height: 60vh; }
h1 { font-size: 1.3rem; margin: 0 0 12px; line-height: 1.4; }
h2 { font-size: 1.05rem; margin: 24px 0 8px; }
.muted { color: var(--muted); font-size: .9rem; }
.loading { color: var(--muted); }
.notice { background: var(--mark-soft); color: var(--text); border-radius: var(--radius); padding: 8px 12px; font-size: .9rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: .85rem; background: var(--surface); }
.tag.turn { border-color: var(--accent); color: var(--accent); }
.tag.old { background: var(--mark-soft); border-color: var(--mark); color: var(--mark); }
.tag.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.btn {
  display: inline-block; text-align: center; text-decoration: none; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: var(--radius);
  padding: 12px 18px; font-weight: 700; min-height: 48px; width: 100%;
}
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); font-weight: 600; }
.btn-row { display: grid; gap: 10px; margin-top: 16px; }

/* 手札 */
.hand { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.hand-card {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--text); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; min-height: 56px;
}
.hand-card .cost {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.hand-card .name { flex: 1 1 auto; font-weight: 600; word-break: break-all; }
.hand-card .state { flex: 0 0 auto; font-size: .85rem; font-weight: 700; color: var(--muted); }
.hand-card[aria-pressed="true"] { border-color: var(--swap); background: var(--swap-soft); }
.hand-card[aria-pressed="true"] .name { text-decoration: line-through; text-decoration-thickness: 2px; }
.hand-card[aria-pressed="true"] .state { color: var(--swap); }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }

fieldset { border: 0; padding: 0; margin: 20px 0 0; }
legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.ranks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ranks label {
  text-align: center; line-height: 1.3; padding: 6px 2px;
  display: grid; place-items: center; min-height: 48px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: .95rem;
}
.ranks input { position: absolute; opacity: 0; pointer-events: none; }
.ranks input:checked + span { color: var(--accent); }
.ranks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ranks label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

details.recipe { margin-top: 16px; }
details.recipe summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 8px 0; }
.recipe-list { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.recipe-list li { display: flex; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.recipe-list .c { width: 2.2em; color: var(--muted); }
.recipe-list .n { flex: 1; }
.recipe-list .x { color: var(--muted); }
.recipe-list li.in-hand .n { font-weight: 700; }

/* 結果 */
.result-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.result-row:last-child { border-bottom: 0; }
.result-head { display: flex; align-items: baseline; gap: 8px; }
.result-head .name { flex: 1; font-weight: 600; word-break: break-all; }
.result-head .rate { font-weight: 700; font-size: 1.1rem; }
.bar { height: 10px; background: var(--bar-bg); border-radius: 999px; overflow: hidden; margin: 4px 0; }
.bar span { display: block; height: 100%; background: var(--bar); }
.ranks-line { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .85rem; color: var(--muted); }
.mark { display: inline-block; background: var(--mark-soft); color: var(--mark); border-radius: 6px; padding: 0 6px; font-size: .8rem; font-weight: 700; }
.mine { display: inline-block; font-size: .8rem; font-weight: 700; border-radius: 6px; padding: 0 6px; }
.mine.keep { background: var(--accent-soft); color: var(--accent); }
.mine.swap { background: var(--swap-soft); color: var(--swap); }
table.compare { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.compare th, table.compare td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.compare th:first-child, table.compare td:first-child { text-align: left; }
.ai-comment { border-left: 4px solid var(--accent); }
.ai-label { font-weight: 700; color: var(--accent); font-size: .9rem; }

/* 一覧 */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters label { font-size: .85rem; color: var(--muted); display: grid; gap: 2px; }
.filters select { font: inherit; padding: 8px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 100%; }
.problem-list { list-style: none; padding: 0; margin: 0; }
.problem-list a { display: block; text-decoration: none; color: inherit; }
.problem-list .card:hover { border-color: var(--accent); }
.problem-title { font-weight: 700; }

.site-footer { border-top: 1px solid var(--line); padding-top: 16px; padding-bottom: 32px; font-size: .82rem; color: var(--muted); }
.site-footer p { margin: 4px 0; }
.site-footer a { word-break: break-all; }
.copyright { font-weight: 700; }

.about h2 { border-left: 4px solid var(--accent); padding-left: 8px; }
.about ul { padding-left: 1.2em; }
