:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --text: #2b2622;
  --muted: #7a716a;
  --line: #ece4da;
  --accent: #e2604a;
  --star: #f2a516;
  --nt: #8a6fd1;   /* 分析家 */
  --nf: #3aa676;   /* 外交官 */
  --sj: #3d8bd4;   /* 番人 */
  --sp: #e0a225;   /* 探検家 */
  --shadow: 0 2px 12px rgba(60, 40, 20, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17151a;
    --surface: #221f26;
    --text: #f1ece6;
    --muted: #a59d96;
    --line: #34303a;
    --accent: #ff7a63;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #17151a; --surface: #221f26; --text: #f1ece6; --muted: #a59d96;
  --line: #34303a; --accent: #ff7a63; --shadow: none;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  line-height: 1.7;
}
main, .site-header, .site-footer { max-width: 640px; margin: 0 auto; padding: 0 16px; }

.site-header { text-align: center; padding-top: 32px; padding-bottom: 8px; }
.site-header h1 { font-size: 1.9rem; font-weight: 800; margin: 0; letter-spacing: .02em; }
.date { margin: 0; color: var(--accent); font-weight: 700; }
.lead { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

h2 { font-size: 1.15rem; margin: 32px 0 12px; }

/* 1位 */
.top {
  margin-top: 20px;
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 2px solid var(--star);
  text-align: center;
}
.top .crown { font-size: 2rem; line-height: 1; }
.top .label { color: var(--muted); font-size: .85rem; margin: 4px 0 0; }
.top .type { font-size: 2.4rem; font-weight: 800; margin: 0; letter-spacing: .05em; }
.top .nick { color: var(--muted); margin: 0 0 8px; }
.top .msg { margin: 0; }

/* タイプ選択 */
.picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.picker button {
  font: inherit; font-weight: 700; font-size: .95rem;
  padding: 10px 0; border-radius: 12px; cursor: pointer;
  border: 2px solid transparent;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
  border-bottom: 4px solid var(--g);
}
.picker button[aria-pressed="true"] { background: var(--g); color: #fff; }
.picker button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 詳細 */
.detail {
  margin-top: 16px;
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  border-top: 6px solid var(--g);
}
.detail-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.detail-head .rank { font-size: 2rem; font-weight: 800; color: var(--g); }
.detail-head .type { font-size: 1.5rem; font-weight: 800; }
.detail-head .nick { color: var(--muted); }
.detail .msg { margin: 8px 0 16px; }
.scores { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 0 0 16px; }
.scores dt { color: var(--muted); }
.scores dd { margin: 0; }
.stars { color: var(--star); letter-spacing: .1em; }
.stars .off { color: var(--line); }
.lucky { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.lucky div { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.lucky span { display: block; color: var(--muted); font-size: .8rem; }
.lucky strong { font-size: 1rem; }
.advice { background: var(--bg); border-radius: 12px; padding: 12px; margin: 0 0 16px; }
.advice::before { content: "💡 "; }
.share {
  display: inline-block; text-decoration: none; font-weight: 700;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
}

/* ランキング */
.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ranking li button {
  width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 2.6em 4.2em 1fr auto; align-items: center; gap: 8px;
  background: var(--surface); border: none; border-left: 5px solid var(--g);
  border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow);
}
.ranking .r { font-weight: 800; font-size: 1.1rem; }
.ranking .t { font-weight: 800; }
.ranking .n { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking li:nth-child(-n+3) .r { color: var(--star); }

.site-footer { color: var(--muted); font-size: .8rem; text-align: center; padding-top: 40px; padding-bottom: 40px; }
.error { text-align: center; color: var(--muted); }

@media (max-width: 380px) {
  .ranking li button { grid-template-columns: 2.2em 3.8em 1fr; }
  .ranking .stars { display: none; }
}
