:root {
  --bg: #f4f1e8;
  --ink: #1d231f;
  --muted: #6b7068;
  --field: #0f2a1d;
  --field-2: #184030;
  --chalk: #fffdf6;
  --line: #d9d3c2;
  --ok: #1f7a4c;
  --ok-bg: #e3f3e9;
  --bad: #b3372b;
  --accent: #d9a21b;
  --radius: 12px;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  background: var(--field); color: var(--chalk);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px calc(14px) 16px; padding-top: max(14px, env(safe-area-inset-top));
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .06em; font-weight: 800; }
.brand .sub { margin: 2px 0 0; font-size: 12px; opacity: .75; letter-spacing: .04em; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid currentColor;
  background: transparent; font-weight: 700; line-height: 1; opacity: .85;
}

main { max-width: 560px; margin: 0 auto; padding: 16px 12px 40px; }

.board {
  display: grid; grid-template-columns: minmax(0, 0.9fr) repeat(3, minmax(0, 1fr)); gap: 6px;
}
.corner { display: grid; place-items: center; font-size: 26px; }
.head {
  min-height: 64px; display: grid; place-items: center; text-align: center;
  padding: 6px 4px; border-radius: 8px; font-weight: 700; font-size: 14px; line-height: 1.25;
  background: var(--field-2); color: var(--chalk);
}
.head.t-award { background: #5b3b0c; }
.head.t-stat { background: #23395d; }
.head.t-attr { background: #4a2a4f; }
.head.row { font-size: 13px; }
.head.long { font-size: 12px; letter-spacing: -.02em; }
.cell {
  aspect-ratio: 1; border-radius: var(--radius); border: 2px solid var(--line);
  background: var(--chalk); display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px; transition: transform .08s, border-color .15s;
}
.cell:not(:disabled):hover { border-color: var(--field-2); }
.cell:not(:disabled):active { transform: scale(.97); }
.cell:disabled:not(.ok) { background: #ebe7dc; cursor: default; }
.cell.ok { background: var(--ok-bg); border-color: var(--ok); cursor: default; }
.cell .pname { font-weight: 800; font-size: 14px; line-height: 1.25; text-align: center; word-break: keep-all; overflow-wrap: anywhere; }
.cell .pct { margin-top: 4px; font-size: 12px; color: var(--ok); font-weight: 700; }

.status { display: flex; justify-content: space-between; margin: 14px 4px 6px; font-size: 15px; }
.status b { font-size: 20px; }
.actions { display: flex; gap: 10px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.btn {
  border: none; background: var(--field); color: var(--chalk); padding: 11px 20px;
  border-radius: 999px; font-weight: 700; letter-spacing: .03em;
}
.btn.ghost { background: transparent; color: var(--field); border: 1.5px solid var(--field); }
.note { font-size: 11px; color: var(--muted); line-height: 1.6; margin-top: 20px; }

/* ダイアログ */
dialog.sheet {
  border: none; padding: 0; width: min(560px, 100vw); max-width: 100vw; max-height: 88vh;
  border-radius: 16px 16px 0 0; margin: auto auto 0; background: var(--chalk); color: var(--ink);
}
@media (min-width: 600px) { dialog.sheet { border-radius: 16px; margin: auto; } }
dialog::backdrop { background: rgba(10, 20, 14, .55); }
.sheet-inner { padding: 16px; display: flex; flex-direction: column; max-height: 88vh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-head .icon-btn { color: var(--muted); flex: none; }
.search-cond { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.search-cond span { color: var(--muted); }
#search-input {
  width: 100%; font-size: 17px; padding: 12px 14px; border-radius: 10px;
  border: 2px solid var(--line); background: #fff; outline: none;
}
#search-input:focus { border-color: var(--field-2); }
.results { list-style: none; margin: 8px 0 0; padding: 0; overflow-y: auto; min-height: 40vh; }
.result {
  width: 100%; text-align: left; border: none; background: none; padding: 11px 6px;
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px;
}
.result:hover { background: #f1eee4; }
.result:disabled { opacity: .45; cursor: default; }
.result .rn { font-weight: 700; font-size: 16px; }
.result .rm { font-size: 12px; color: var(--muted); }
.results .empty { padding: 16px 6px; color: var(--muted); }

.score { display: flex; justify-content: space-around; text-align: center; margin: 6px 0 12px; }
.score b { font-size: 34px; display: block; line-height: 1.1; }
.score small { color: var(--muted); }
.share-preview { background: #f1eee4; border-radius: 10px; padding: 12px; font-size: 14px; white-space: pre-wrap; margin: 0; }
#answers-body { overflow-y: auto; }
.ans h3 { font-size: 14px; margin: 14px 0 6px; }
.ans h3 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.ans ol { margin: 0; padding-left: 22px; font-size: 13px; columns: 2; column-gap: 18px; }
.ans li { break-inside: avoid; padding: 2px 0; }
.ans li span { color: var(--muted); margin-left: 6px; font-size: 11px; }
.ans li.mine { font-weight: 800; color: var(--ok); }
.help { padding-left: 20px; line-height: 1.8; font-size: 14px; margin: 0; }
.loading { color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  transition: all .2s; pointer-events: none; z-index: 10; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: var(--ok); }
.toast.bad { background: var(--bad); }

@media (max-width: 380px) {
  .head { font-size: 12px; min-height: 56px; }
  .cell .pname { font-size: 12px; }
}

.wrong { margin-top: 14px; }
.wrong h3 { font-size: 14px; margin: 0 0 4px; }
.wrong p { font-size: 12px; color: var(--muted); margin: 0 0 6px; line-height: 1.5; }
.wrong ul { list-style: none; margin: 0; padding: 0; }
.wrong li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.wrong li span { display: flex; flex-direction: column; }
.wrong li small { color: var(--muted); font-size: 11px; }
.mini { border: 1.5px solid var(--bad); color: var(--bad); background: none; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700; flex: none; }
.mini:disabled { border-color: var(--line); color: var(--muted); }

.ad { margin: 18px auto 0; min-height: 100px; text-align: center; }
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 10px 0 30px; }
.footer a { color: inherit; margin: 0 8px; }
.page { max-width: 720px; margin: 0 auto; padding: 20px 16px 50px; line-height: 1.8; font-size: 15px; }
.page h2 { font-size: 17px; margin-top: 28px; }
.page a.back { font-size: 14px; }

/* ナビ */
.topnav { display: flex; align-items: center; gap: 14px; }
.topnav a { color: var(--chalk); font-size: 13px; text-decoration: none; opacity: .9; border-bottom: 1px solid rgba(255,255,255,.35); }
.badge { background: var(--accent); color: var(--field); font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 4px; font-weight: 700; }
.daynav { max-width: 560px; margin: 10px auto 0; padding: 0 12px; display: flex; justify-content: space-between; font-size: 13px; }
.daynav a { color: var(--field-2); text-decoration: none; font-weight: 700; }
.daynav a.today { background: var(--field); color: var(--chalk); padding: 2px 12px; border-radius: 999px; }
a.btn { text-decoration: none; display: inline-block; }

/* 一覧・回答・結果ページ */
.page.wide { max-width: 760px; }
.page-title { font-size: 21px; margin: 4px 0 10px; }
.page-title small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.lead { color: var(--muted); font-size: 14px; margin-top: 0; }
.archive { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.archive li { background: var(--chalk); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.archive li.played { border-color: var(--ok); }
.archive li.playing { border-color: var(--accent); }
.arc-main { display: block; padding: 12px 14px 8px; color: inherit; text-decoration: none; }
.arc-head { display: flex; align-items: baseline; gap: 10px; }
.arc-head b { font-size: 18px; }
.arc-head span { color: var(--muted); font-size: 13px; }
.arc-mine { margin-left: auto; font-style: normal; font-size: 13px; font-weight: 700; color: var(--ok); }
.archive li.playing .arc-mine { color: #9a6d00; }
.arc-conds { font-size: 13px; margin-top: 4px; line-height: 1.6; }
.arc-conds .c-team { font-weight: 700; }
.arc-conds .x { color: var(--muted); margin: 0 4px; }
.arc-foot { display: flex; justify-content: space-between; gap: 10px; padding: 7px 14px; background: #f1eee4; font-size: 12px; color: var(--muted); }
.arc-foot a { color: var(--field-2); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin: 10px 0 16px; }
.stats > div { background: var(--chalk); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: 10px 6px; }
.stats b { display: block; font-size: 24px; line-height: 1.2; }
.stats small { color: var(--muted); font-size: 12px; }
.spoiler { background: #fff6dc; border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.spoiler p { margin: 0 0 4px; font-size: 14px; }
.blurred { filter: blur(9px); pointer-events: none; user-select: none; }

.ans-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) repeat(3, minmax(0, 1fr)); gap: 6px; }
.ans-cell { aspect-ratio: 1.15; border-radius: var(--radius); border: 2px solid var(--line); background: var(--chalk);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 6px;
  color: inherit; text-decoration: none; gap: 2px; }
.ans-cell b { font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.ans-grid .head { min-height: 52px; }
.ans-cell small { font-size: 11px; color: var(--muted); }
.ans-cell.ok { background: var(--ok-bg); border-color: var(--ok); }
.ans-cell.ok small { color: var(--ok); font-weight: 700; }
.ans-cell.empty { background: #ebe7dc; }
.hint { font-size: 12px; color: var(--muted); }
.ans-detail { background: var(--chalk); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; scroll-margin-top: 12px; }
.ans-detail h2 { font-size: 15px; margin: 0 0 4px; }
.ans-detail .meta { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.ans-detail .rare { font-size: 13px; margin: 0 0 8px; color: #6b4a00; }
.ans-list { list-style: none; padding: 0; margin: 0; font-size: 13px; columns: 2; column-gap: 18px; }
.ans-list li { display: grid; grid-template-columns: 1fr 50px 44px; align-items: center; gap: 6px; padding: 3px 0; break-inside: avoid; }
.ans-list li.zero { color: var(--muted); }
.ans-list .bar { height: 6px; background: #ebe7dc; border-radius: 3px; overflow: hidden; }
.ans-list .bar i { display: block; height: 100%; background: var(--ok); }
.ans-list .v { text-align: right; font-size: 12px; color: var(--muted); }
@media (max-width: 520px) { .ans-list { columns: 1; } .topnav a { font-size: 12px; } .stats b { font-size: 20px; } .ans-cell b { font-size: 12px; } .ans-grid .head { font-size: 12px; } }

/* スマホ: 検索は全画面にして、キーボードで候補が隠れないようにする */
@media (max-width: 599px) {
  #dlg-search { height: 100dvh; max-height: 100dvh; width: 100vw; margin: 0; border-radius: 0; }
  #dlg-search .sheet-inner { height: 100%; max-height: 100dvh; padding-top: max(16px, env(safe-area-inset-top)); }
  #dlg-search .results { flex: 1; min-height: 0; }
}
.cell, .btn, .result, .icon-btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
dialog.sheet .sheet-inner { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
.topnav a { white-space: nowrap; }
.brand .sub { white-space: nowrap; }
@media (min-width: 900px) { main { max-width: 500px; } }
@media (max-width: 380px) {
  .top { padding-left: 12px; padding-right: 12px; }
  .brand h1 { font-size: 17px; }
  .brand .sub { font-size: 11px; }
  .badge { font-size: 10px; padding: 0 5px; }
  .topnav { gap: 8px; }
  .icon-btn { width: 30px; height: 30px; }
}

/* レア度ランク */
:root { --ssr: #c98a00; --ssr-bg: #fff3cf; --sr: #8e44ad; --sr-bg: #f3e6f8; --r: #2e6fb5; --r-bg: #e3eefa; }
.cell .tier, .ans-cell .tier { font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 1px 7px; border-radius: 999px; margin-bottom: 3px; color: #fff; background: var(--ok); }
.cell.ok.tier-ssr, .ans-cell.ok.tier-ssr { background: var(--ssr-bg); border-color: var(--ssr); box-shadow: 0 0 0 2px rgba(201,138,0,.25), 0 0 14px rgba(201,138,0,.35); }
.cell.ok.tier-ssr .tier, .ans-cell.tier-ssr .tier { background: linear-gradient(90deg, #d9a21b, #f0c84b, #d9a21b); color: #3a2a00; }
.cell.ok.tier-ssr .pct, .ans-cell.tier-ssr small { color: var(--ssr); }
.cell.ok.tier-sr, .ans-cell.ok.tier-sr { background: var(--sr-bg); border-color: var(--sr); }
.cell.ok.tier-sr .tier, .ans-cell.tier-sr .tier { background: var(--sr); }
.cell.ok.tier-sr .pct, .ans-cell.tier-sr small { color: var(--sr); }
.cell.ok.tier-r, .ans-cell.ok.tier-r { background: var(--r-bg); border-color: var(--r); }
.cell.ok.tier-r .tier, .ans-cell.tier-r .tier { background: var(--r); }
.cell.ok.tier-r .pct, .ans-cell.tier-r small { color: var(--r); }
.cell.ok { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.85); } 70% { transform: scale(1.05); } 100% { transform: scale(1); } }

.status .right { position: relative; }
.status .max { color: var(--muted); font-size: 12px; }
.gain { position: absolute; right: 0; top: -6px; font-weight: 800; color: var(--ok); animation: rise 1.3s ease-out forwards; pointer-events: none; }
@keyframes rise { 0% { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }

.title-badge { text-align: center; margin: 0 0 6px; }
.title-badge, .page .title-badge { font-weight: 800; font-size: 18px; color: #6b4a00; }
.title-badge::before, .title-badge::after { content: '★'; color: var(--accent); margin: 0 8px; font-size: 14px; }
.tier-sum { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: -4px 0 12px; }
.tier-sum span, .chip { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; color: #fff; display: inline-block; }
.chip { font-size: 11px; padding: 0 7px; }
.t-ssr { background: linear-gradient(90deg, #d9a21b, #f0c84b); color: #3a2a00 !important; }
.t-sr { background: var(--sr); }
.t-r { background: var(--r); }
.t-n { background: var(--ok); }
.toast.tier-ssr { background: linear-gradient(90deg, #b07800, #d9a21b); color: #fff; font-weight: 700; }
.toast.tier-sr { background: var(--sr); }
.toast.tier-r { background: var(--r); }

/* 一番乗り（そのマスでその選手を最初に答えた） */
.cell { position: relative; overflow: hidden; }
.cell.first { box-shadow: 0 0 0 2px rgba(217,162,27,.35), 0 4px 14px rgba(217,162,27,.35); }
.ribbon {
  position: absolute; top: 9px; right: -26px; transform: rotate(38deg);
  width: 96px; text-align: center; font-size: 9px; font-weight: 800; letter-spacing: .08em; line-height: 16px;
  color: #3a2a00; background: linear-gradient(90deg, #e9b730, #fff0b0 50%, #e9b730);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.ribbon::before { content: '★ '; font-size: 8px; }

/* 一覧・選手ページ */
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--field-2); }
.page-title small { font-size: 13px; }
.sub-title { font-size: 16px; margin: 22px 0 8px; padding-left: 10px; border-left: 4px solid var(--field-2); }
.list-table { overflow-x: auto; }
.list-table table { border-collapse: collapse; width: 100%; background: var(--chalk); font-size: 14px; margin-bottom: 10px; }
.list-table th, .list-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
.list-table th { background: #ebe7dc; font-size: 12px; white-space: nowrap; }
.list-table td.teams { font-size: 12px; color: var(--muted); }
.list-table a, .link-list a, .lists-team a, .ans-detail h2 a, .ans-list a.n { color: var(--field-2); }
.link-list { padding-left: 20px; line-height: 1.9; font-size: 14px; }
.muted { color: var(--muted); font-size: 12px; }
.lists-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.lists-team { background: var(--chalk); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.lists-team h3 { font-size: 13px; margin: 0 0 6px; }
.lists-team ul { list-style: none; padding: 0; margin: 0; font-size: 13px; columns: 2; column-gap: 10px; }
.lists-team li { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; break-inside: avoid; }
.lists-team li span { color: var(--muted); font-size: 11px; }
.ans-list a.n { text-decoration: none; }

@media (max-width: 480px) { .topnav .hide-sm { display: none; } .top .brand h1 { white-space: nowrap; } }

.btn-x { background: #000; color: #fff; padding-left: 22px; padding-right: 22px; }
.btn-x .x-mark { font-weight: 700; margin-right: 4px; }
