:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #5d6763;
  --line: #d9d6cd;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --accent-soft: #e2f0eb;
  --warn: #b4531c;
  --warn-soft: #fbeadf;
  --danger: #b3261e;
  --disabled: #c9c9c9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1d2321;
    --text: #ecefed;
    --muted: #a3ada9;
    --line: #34403b;
    --accent: #4fb89a;
    --accent-text: #0d1f19;
    --accent-soft: #1d3a31;
    --warn: #f0a26f;
    --warn-soft: #3a281c;
    --danger: #ff8a80;
    --disabled: #4a4f4d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
main { max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
h1 { font-size: 1.5rem; line-height: 1.35; margin: 12px 0; }
h2 { font-size: 1.15rem; margin: 20px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.small { font-size: .82rem; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: .02em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}

/* ボタン: 主=アクセント色、ふつう=白地＋縁。グレーは無効状態だけ */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  font: inherit; font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); }
button.danger { border-color: var(--danger); color: var(--danger); }
button:disabled, .btn[aria-disabled="true"] {
  background: var(--disabled); border-color: var(--disabled); color: #fff; cursor: not-allowed;
}
.block { display: flex; width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }

.steam-btn { background: #171a21; border-color: #171a21; color: #fff; }

/* モード選択 */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.mode {
  flex-direction: column; align-items: flex-start; justify-content: flex-start;
  min-height: 132px; padding: 16px; text-align: left;
  border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow);
}
.mode:hover, .mode:focus-visible { border-color: var(--accent); }
.mode .em { font-size: 1.8rem; line-height: 1; }
.mode b { font-size: 1.05rem; margin-top: 8px; }
.mode span.d { font-weight: 400; font-size: .82rem; color: var(--muted); }

/* ゲームカード */
.game { overflow: hidden; padding: 0; }
.game img.cover { display: block; width: 100%; aspect-ratio: 460 / 215; object-fit: cover; background: var(--accent-soft); }
.game .body { padding: 14px 16px 16px; }
.game h3 { margin: 0 0 4px; font-size: 1.15rem; line-height: 1.35; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--text); }
.chip.warn { background: var(--warn-soft); }
.game.selectable { cursor: pointer; border-width: 2px; }
.game.selected { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
.answer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }

/* リスト */
.filters { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0; }
.filters button { min-height: 36px; padding: 4px 12px; font-size: .88rem; white-space: nowrap; }
.filters button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.item { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item img { width: 92px; aspect-ratio: 460 / 215; object-fit: cover; border-radius: 6px; background: var(--accent-soft); }
.item .t { font-weight: 700; line-height: 1.35; }
.seg { display: inline-flex; border: 1.5px solid var(--accent); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 32px; padding: 2px 12px; border: 0; border-radius: 0; font-size: .85rem; }
.seg button + button { border-left: 1.5px solid var(--accent); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.item .ctrls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
select, input[type="text"], input[type="url"], input[type="search"] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; min-height: 40px; padding: 6px 10px;
}
select { padding-right: 28px; }
input[type="text"], input[type="url"], input[type="search"] { width: 100%; }
.search-results { list-style: none; padding: 0; margin: 8px 0 0; }
.search-results li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.search-results img { width: 64px; border-radius: 4px; }
.search-results span { flex: 1; }
.search-results button { min-height: 36px; padding: 4px 12px; flex: none; }

/* 手順 */
ol.steps { padding-left: 1.4em; }
ol.steps li { margin: 8px 0; }
.note { background: var(--warn-soft); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.ok { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
.progress { height: 8px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* 実績 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 14px 6px; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }

/* 設定 */
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; margin-bottom: 6px; }
label.opt { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.days { display: flex; gap: 5px; flex-wrap: wrap; }
.days label { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1.5px solid var(--accent); border-radius: 50%; cursor: pointer; font-weight: 700; color: var(--accent); background: var(--surface); }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days input:checked + span { color: var(--accent-text); }
.days label:has(input:checked) { background: var(--accent); }
.days label:has(input:focus-visible) { outline: 3px solid var(--accent-soft); }

/* 下タブ */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; padding: 8px 0 6px; font-size: .75rem; color: var(--muted); text-decoration: none; }
.tabs a .ic { font-size: 1.25rem; line-height: 1.2; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 20;
}
.toast.err { background: var(--danger); color: #fff; }

footer.legal { margin-top: 32px; text-align: center; font-size: .78rem; color: var(--muted); }
footer.legal a { color: var(--muted); }
[hidden] { display: none !important; }
@media (prefers-color-scheme: dark) { .steam-btn { border-color: #66c0f4; } }
/* 3本提示はコンパクトに並べ、選んだものに印を付ける */
.game.compact { display: grid; grid-template-columns: 120px 1fr; align-items: center; position: relative; }
.game.compact img.cover { height: 100%; aspect-ratio: auto; min-height: 76px; }
.game.compact .body { padding: 10px 12px; }
.game.compact h3 { font-size: 1rem; }
.game.compact .chips { margin-bottom: 0; }
.game.selected { border-color: var(--accent); background: var(--accent-soft); }
.game.selected::after {
  content: "✓"; position: absolute; top: 6px; left: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 800;
}
