:root {
  --bg: #14161c;
  --panel: #1d2029;
  --panel2: #252935;
  --line: #333847;
  --text: #e9ebf1;
  --muted: #9aa1b3;
  --accent: #f2b33d;
  --cost: #3d8bf2;
  --power: #f26d3d;
  --ok: #4cc38a;
  --ng: #e5534b;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6f8; --panel: #ffffff; --panel2: #eef0f4; --line: #d9dce4;
    --text: #1b1e26; --muted: #5d6475; --accent: #b77a07;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  line-height: 1.7; font-size: 15px;
}
a { color: var(--accent); }
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.brand span { color: var(--accent); margin-left: 4px; font-size: 14px; }
#nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
#nav::-webkit-scrollbar { display: none; }
#nav a {
  color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 999px;
  white-space: nowrap; font-size: 14px;
}
#nav a.on { background: var(--panel2); color: var(--text); }
main { max-width: 1040px; margin: 0 auto; padding: 16px; min-height: 70vh; }
h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 6px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.loading { color: var(--muted); }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; padding: 16px; text-align: center; }
.foot p { margin: 4px 0; }

/* フォーム */
input[type=search], input[type=text], textarea, select {
  width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
button, .btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.primary { background: var(--accent); color: #1b1300; border-color: var(--accent); font-weight: 700; }
button:disabled { opacity: .5; cursor: default; }
.filters { display: grid; gap: 8px; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px;
  padding: 3px 11px; font-size: 13px; cursor: pointer; user-select: none;
}
.chip.on { background: var(--accent); color: #1b1300; border-color: var(--accent); font-weight: 700; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 0 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.count { color: var(--muted); font-size: 13px; }

/* カード */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px;
  text-decoration: none; color: inherit; position: relative;
}
.card:hover { border-color: var(--accent); }
.card.owned::after {
  content: "所持"; position: absolute; top: 8px; right: 8px; font-size: 11px; color: var(--ok);
  border: 1px solid var(--ok); border-radius: 4px; padding: 0 5px; line-height: 1.6;
}
.stats { display: flex; flex-direction: column; gap: 4px; align-items: center; padding-top: 2px; }
.cost, .power {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #fff;
}
.cost { background: var(--cost); }
.power { background: var(--power); border-radius: 8px; }
.cname { font-weight: 700; padding-right: 36px; line-height: 1.4; }
.cen { color: var(--muted); font-size: 12px; }
.cdesc { grid-column: 1 / -1; font-size: 13px; color: var(--text); opacity: .92; }
.cdesc b { color: var(--accent); }
.meta { grid-column: 1 / -1; display: flex; gap: 8px; font-size: 12px; color: var(--muted); }
.stars { color: var(--accent); letter-spacing: 1px; }

/* 詳細 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.detail-head { display: flex; gap: 14px; align-items: flex-start; }
.detail-head .cost, .detail-head .power { width: 44px; height: 44px; font-size: 20px; }
.detail-desc { font-size: 16px; margin: 12px 0; }
.detail-desc b { color: var(--accent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* デッキ */
.tier { display: inline-block; font-weight: 800; font-size: 12px; border-radius: 6px; padding: 1px 8px; margin-right: 6px; }
.t1 { background: #f2b33d; color: #1b1300; }
.t2 { background: #8fa3c7; color: #10151f; }
.t3 { background: #5d6475; color: #fff; }
.deck-list { display: grid; gap: 10px; }
.deck {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; text-decoration: none; color: inherit;
}
.deck:hover { border-color: var(--accent); }
.deck .dname { font-weight: 700; font-size: 16px; }
.deck .den { color: var(--muted); font-size: 12px; margin-left: 6px; }
.deck .dcards { color: var(--muted); font-size: 13px; margin-top: 4px; }
.have { font-size: 13px; }
.have.full { color: var(--ok); font-weight: 700; }
.mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.mini a {
  display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; text-decoration: none; color: inherit; font-size: 13px;
}
.mini a.missing { border-style: dashed; opacity: .6; }
.mini .cost { width: 24px; height: 24px; font-size: 12px; flex: none; }
.code {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all;
  background: var(--panel2); border-radius: 8px; padding: 8px 10px; color: var(--muted);
}
ul.tips { margin: 6px 0; padding-left: 20px; }

/* 口コミ */
.reviews { margin-top: 24px; }
.rv { border-top: 1px solid var(--line); padding: 10px 0; }
.rv:first-child { border-top: 0; }
.rv-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.rv-name { font-weight: 700; }
.rv-date { color: var(--muted); font-size: 12px; }
.rv-body { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; }
.rv-report { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 12px; padding: 0; text-decoration: underline; }
.rate-input { display: flex; gap: 2px; }
.rate-input button { background: none; border: 0; font-size: 26px; padding: 0 2px; color: var(--line); line-height: 1; }
.rate-input button.on { color: var(--accent); }
.form { display: grid; gap: 8px; margin-top: 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.note { font-size: 12px; color: var(--muted); }

/* 用語 */
.gl { display: grid; gap: 8px; }
.gl .item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.gl .term { font-weight: 700; }
.gl .en { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* トップ */
.hero { padding: 18px 0 6px; }
.hero h1 { font-size: 26px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: inherit; }
.tile:hover { border-color: var(--accent); }
.tile strong { display: block; font-size: 16px; margin-bottom: 4px; }
.tile span { color: var(--muted); font-size: 13px; }
.latest { margin-top: 6px; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; }

@media (max-width: 560px) {
  body { font-size: 14px; }
  .top { padding: 8px 16px; gap: 6px; }
  .grid { grid-template-columns: 1fr; }
  .detail-head .cost, .detail-head .power { width: 38px; height: 38px; font-size: 17px; }
}
