:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --text: #2b2a27;
  --muted: #6b675f;
  --line: #e4ded3;
  --accent: #b5452f;
  --accent-soft: #fbeee9;
  --link: #1f5fa8;
  --now: #fff3c4;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --surface: #25231f;
    --text: #ece8e1;
    --muted: #a49f95;
    --line: #3a3731;
    --accent: #e57b62;
    --accent-soft: #3a2722;
    --link: #8ab8f0;
    --now: #4a3f1a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[id] { scroll-margin-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
a { color: var(--link); }
img { max-width: 100%; }

.inner { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header .inner { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.logo { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.05rem; letter-spacing: .04em; }
.logo::before { content: ""; display: inline-block; width: .6em; height: .6em; background: var(--accent); border-radius: 2px; margin-right: .45em; vertical-align: .05em; }
.head-nav a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: 12px 0 12px 12px; }

.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 0 48px; font-size: .85rem; color: var(--muted); }
.site-footer a { color: var(--muted); }
.foot-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 8px; }
.foot-nav a { padding: 6px 0; }

/* breadcrumbs */
.crumbs ol { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin: 0 .45em; }
.crumbs a { color: var(--muted); }

/* typography */
main { padding-bottom: 16px; }
h1 { font-size: 1.4rem; line-height: 1.45; margin: .5em 0 .4em; }
h1 small { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); margin-top: .2em; }
h2 { font-size: 1.18rem; line-height: 1.5; margin: 2.2em 0 .7em; padding-left: .6em; border-left: 4px solid var(--accent); }
h3 { font-size: 1.02rem; margin: 1.6em 0 .4em; }
p { margin: .6em 0; }
.lead { color: var(--muted); }
.note { font-size: .85rem; color: var(--muted); }
ul { padding-left: 1.3em; }

/* summary card */
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px 14px; margin: 16px 0; }
.summary .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.summary .k { color: var(--muted); font-size: .88rem; flex-shrink: 0; }
.summary .v { font-weight: 700; text-align: right; }
.summary .v small { display: block; font-weight: 400; font-size: .82rem; color: var(--muted); }
.big { font-size: 1.7rem; color: var(--accent); line-height: 1.3; }
.live { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin: 12px 0 0; font-size: .92rem; }
.live:empty { display: none; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0; }
table { border-collapse: collapse; width: 100%; background: var(--surface); font-size: .9rem; line-height: 1.6; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
thead th { background: var(--accent-soft); white-space: nowrap; font-weight: 700; }
tbody th { font-weight: 600; white-space: nowrap; }
tr.is-now td, tr.is-now th, td.is-now { background: var(--now); }
.era-row th { background: var(--bg); font-size: .95rem; padding-top: 14px; }
.nowrap { white-space: nowrap; }
.tag { display: inline-block; font-size: .7rem; padding: 0 7px; border-radius: 999px; margin-left: 4px; vertical-align: 1px; line-height: 1.7; font-weight: 600; }
.tag.past { background: var(--line); color: var(--muted); }
.tag.now { background: var(--accent); color: #fff; }

/* tool widgets */
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 18px 0; }
.tool-card h2 { margin: 0 0 .6em; border: 0; padding: 0; font-size: 1.08rem; }
.fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select, input, button {
  font: inherit; font-size: 16px; /* iOSのズーム防止 */
  padding: 10px 12px; min-height: 46px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
input[type="number"] { width: 7em; }
select[name="y"] { flex: 1 1 11em; }
select[name="m"], select[name="d"] { flex: 1 1 5em; }
button { background: var(--accent); color: #fff; border: 0; font-weight: 700; padding: 10px 20px; cursor: pointer; flex: 1 1 100%; }
button:active { transform: translateY(1px); }
output { font-weight: 700; }
.conv { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.conv output { flex-basis: 100%; min-height: 1.8em; color: var(--accent); }

dl.kv { margin: 14px 0 0; }
dl.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
dl.kv dt { color: var(--muted); font-size: .88rem; flex-shrink: 0; }
dl.kv dd { margin: 0; font-weight: 700; text-align: right; }

/* navigation */
.pager { display: flex; gap: 8px; margin: 24px 0; }
.pager a, .pager span { flex: 1; text-align: center; padding: 12px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); font-size: .92rem; }
.pager span { visibility: hidden; }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; margin: 8px 0 16px; }
.year-grid a { display: block; text-align: center; padding: 9px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); font-size: .9rem; line-height: 1.3; }
.year-grid a small { display: block; font-size: .7rem; color: var(--muted); }
.cards { display: grid; gap: 10px; }
.card { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.card .t { display: block; font-weight: 700; }
.card .d { display: block; color: var(--muted); font-size: .88rem; }
a.card:hover { border-color: var(--accent); }
.card.soon { opacity: .55; }
.card.soon .t::after { content: "準備中"; font-size: .7rem; font-weight: 600; margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: var(--line); color: var(--muted); }

.related, .partners { margin-top: 32px; }
ul.cols { columns: 2; column-gap: 24px; }
ul.cols li { break-inside: avoid; }
li.is-now { font-weight: 700; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; font-size: .92rem; }
.toc ol { margin: 0; padding-left: 1.3em; }

@media (min-width: 600px) {
  h1 { font-size: 1.65rem; }
  button { flex: 0 0 auto; }
  .cards { grid-template-columns: 1fr 1fr; }
}

/* ---------- ルーレット・くじ・チーム分け ---------- */
textarea {
  display: block; width: 100%; font: inherit; font-size: 16px; line-height: 1.6;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); resize: vertical; margin: 6px 0;
}
button.sub { background: var(--surface); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
button.sub:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
.tool-card > button { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.actions[hidden] { display: none; }
.actions button { flex: 1 1 auto; }
.fields { margin: 10px 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); flex: 1 1 7em; }
.field.grow { flex: 2 1 12em; }
.field input, .field select { width: 100%; color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: .92rem; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
button.chip { flex: 0 0 auto; min-height: 36px; padding: 4px 12px; font-size: .85rem; font-weight: 600; border-radius: 999px; background: var(--accent-soft); color: var(--text); border: 0; }

.wheel-wrap { position: relative; width: min(100%, 340px); aspect-ratio: 1; margin: 6px auto 4px; }
.wheel-wrap canvas { width: 100%; height: 100%; display: block; cursor: pointer; filter: drop-shadow(0 2px 6px rgba(0,0,0,.12)); }
.pointer { position: absolute; top: -4px; left: 50%; transform: translateX(-50%); width: 0; height: 0;
  border-left: 14px solid transparent; border-right: 14px solid transparent; border-top: 26px solid var(--accent);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.result { text-align: center; min-height: 3.2em; margin: 8px 0; font-size: 1.05rem; }
.result strong { display: block; font-size: 1.8rem; line-height: 1.3; color: var(--accent); }
.history { margin: 4px 0 0; padding-left: 1.6em; max-height: 12em; overflow-y: auto; font-size: .92rem; }

.kuji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin: 12px 0 4px; }
button.kuji-card {
  flex: none; min-height: 72px; padding: 6px 4px; border-radius: 10px; font-size: 1.25rem; font-weight: 700;
  background: var(--surface); color: var(--text); border: 2px dashed var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25;
}
button.kuji-card small { font-size: .7rem; font-weight: 500; color: inherit; opacity: .75; }
button.kuji-card.open { border-style: solid; font-size: .95rem; animation: flip .35s ease; }
button.kuji-card.win { background: var(--accent); border-color: var(--accent); color: #fff; }
button.kuji-card.lose { background: var(--bg); border-color: var(--line); color: var(--muted); }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: none; } }

.order-list { font-size: 1.05rem; padding-left: 2em; margin: 12px 0 0; }
.order-list li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.order-list li::marker { font-weight: 700; color: var(--accent); }

details.numbers { margin: 6px 0 10px; font-size: .92rem; }
details.numbers summary { cursor: pointer; color: var(--link); padding: 6px 0; }
.teams { display: grid; gap: 10px; margin: 14px 0 0; }
.team { background: var(--bg); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 10px; padding: 8px 14px 10px; }
.team:nth-child(4n+2) { border-top-color: #4b8bbe; }
.team:nth-child(4n+3) { border-top-color: #5a9e6f; }
.team:nth-child(4n+4) { border-top-color: #c79a2e; }
.team h3 { margin: 0 0 4px; font-size: 1rem; }
.team ul { margin: 0; padding-left: 1.2em; columns: 2; column-gap: 16px; }
@media (min-width: 600px) { .teams { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { button.kuji-card.open { animation: none; } }

/* ---------- 日付ツール・祝日一覧 ---------- */
input[type="date"] { width: 100%; min-width: 0; color: var(--text); }
.tabs { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
button.tab { flex: 1 1 0; background: none; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; font-weight: 700; padding: 10px 6px; min-height: 46px; }
button.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
[data-panel][hidden] { display: none; }
.result .tag { margin: 4px 0 0; font-size: .8rem; }
table.holidays td.sun { color: #c0392b; font-weight: 700; }
table.holidays td.sat { color: #2f6fb0; font-weight: 700; }
@media (prefers-color-scheme: dark) {
  table.holidays td.sun { color: #f08a7e; }
  table.holidays td.sat { color: #8ab8f0; }
}
details.numbers .check { margin: 6px 0; }
details.numbers .field { margin: 8px 0; }
