/* Badugi 全ハンド厳密EQ — viewer styles.
 * Card rendering follows the four-colour convention used by chai-po.com
 * (solid suit-coloured tile, white rank, 44x64, 5px radius). The markup, the
 * classes and every rule here are this project's own; no asset is copied.
 */
:root {
  --bg: #101319;
  --panel: #171b23;
  --panel2: #1e232d;
  --line: #2b3240;
  --fg: #e8eaf0;
  --muted: #98a2b3;
  --accent: #4ea1ff;
  --good: #35c07a;
  --warn: #ffb020;
  --bad: #ff6b6b;
  --card-s: #505055;
  --card-h: #bd160e;
  --card-d: #283acb;
  --card-c: #08ac26;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 Inter, "Noto Sans JP", system-ui, -apple-system, sans-serif;
}

h1 { font-size: 19px; margin: 0; letter-spacing: .01em; }
h2 { font-size: 15px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
h3 { font-size: 13px; margin: 18px 0 8px; color: var(--fg); }
h4 { font-size: 12.5px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
p { margin: 8px 0; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #cbd5e1; }

/* ------------------------------------------------------------- header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--card-h), var(--card-d) 55%, var(--card-c));
}
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.status { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.status.ok { color: var(--good); border: 1px solid #1d4030; }
.status.err { color: var(--bad); border: 1px solid #4a2222; }

.provenance { padding: 8px 20px; background: #141922; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.provenance .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.provenance b { color: var(--fg); font-weight: 600; }

.badge { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; }
.badge.exact { background: #14361f; color: var(--good); border: 1px solid #23543a; }
.badge.withheld { background: #3a2a12; color: var(--warn); border: 1px solid #5b431c; }
.pill { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--fg); }

/* --------------------------------------------------------------- tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 20px 0; background: var(--bg); position: sticky; top: 63px; z-index: 15; }
.tab {
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); padding: 6px 14px; border-radius: 8px 8px 0 0; cursor: pointer; font-size: 13px;
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--panel2); color: var(--fg); border-bottom-color: var(--panel2); font-weight: 600; }

main { padding: 4px 20px 60px; }
.view { display: none; }
.view.active { display: block; }
.note { color: var(--muted); font-size: 12.5px; }
.hint { color: var(--muted); font-size: 11.5px; }

/* --------------------------------------------------------- category cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 12px 0; }
.cat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.cat-card .big { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }
.cat-card .meta { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); }
.tag.badugi_4card { color: #7ee0a4; border-color: #23543a; }
.tag.three_card { color: #8fc4ff; border-color: #24405e; }
.tag.two_card { color: #ffce7a; border-color: #5b431c; }
.tag.one_card { color: #ff9d9d; border-color: #4a2222; }

.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 2px 0; color: var(--muted); }
.kv span:last-child { color: var(--fg); }

.scale { margin: 10px 0; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 130px; align-items: center; gap: 10px; margin: 4px 0; font-size: 12px; }
.bar-row .label { color: var(--muted); }
.bar-track { position: relative; height: 14px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.bar-fill.c4 { background: linear-gradient(90deg, #2b7a4b, #7ee0a4); }
.bar-fill.c3 { background: linear-gradient(90deg, #2c5480, #8fc4ff); }
.bar-fill.c2 { background: linear-gradient(90deg, #7a5a1e, #ffce7a); }
.bar-fill.c1 { background: linear-gradient(90deg, #6d3030, #ff9d9d); }
.bar-row .range { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.duel { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin: 12px 0; }
.duel .side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.duel .side.best { border-color: #23543a; }
.duel .side.worst { border-color: #4a2222; }
.duel .slots { display: flex; gap: 4px; margin: 8px 0; }

/* --------------------------------------------------------- playing cards */
.pcard {
  width: 44px; height: 64px; flex: none; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 750; color: #fff; background: var(--card-s);
  user-select: none; line-height: 1;
}
.pcard.h { background: var(--card-h); }
.pcard.d { background: var(--card-d); }
.pcard.c { background: var(--card-c); }
.pcard.sm { width: 30px; height: 44px; font-size: 18px; border-radius: 4px; }
.pcard.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.pcard.excl { opacity: .28; }
.pcard.must { outline: 2px solid var(--warn); outline-offset: 1px; }
.hand-slots { display: flex; gap: 6px; min-height: 68px; align-items: center; }
.slot { width: 44px; height: 64px; border-radius: 5px; border: 1px dashed var(--line); background: #12151c; }

.card-grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; margin: 6px 0; max-width: 660px; }
.card-grid .pcard { width: 100%; height: auto; aspect-ratio: 44 / 64; font-size: 15px; cursor: pointer; }
.card-grid .pcard:hover { filter: brightness(1.25); }
.card-grid.compact { max-width: 480px; }
.card-grid.compact .pcard { font-size: 12px; }
.grid-legend { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.sw-excl { background: #444c5c; opacity: .5; }
.sw-must { background: var(--warn); }

/* -------------------------------------------------------------- controls */
.controls, .bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; margin: 10px 0; font-size: 12.5px;
}
.controls label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
input[type="text"], input[type="number"], select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 6px; padding: 4px 8px; font-size: 12.5px; font-family: inherit;
}
input[type="text"] { min-width: 130px; }
input[type="number"] { width: 68px; }
.count { margin-left: auto; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--fg); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
button.mini, button.preset, button.more {
  background: var(--panel2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
button.mini:hover, button.preset:hover, button.more:hover { border-color: var(--accent); color: var(--accent); }
button.preset.on { border-color: var(--accent); color: var(--accent); }
button.more { margin: 10px 0; }

.field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.field .lbl { color: var(--muted); font-size: 12px; min-width: 62px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap.tall { max-height: 620px; }
table.grid, table.plain { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th, table.plain th {
  position: sticky; top: 0; background: var(--panel2); color: var(--muted);
  text-align: left; padding: 7px 10px; font-weight: 600; font-size: 11.5px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.grid td, table.plain td { padding: 5px 10px; border-bottom: 1px solid #1c212b; }
table.grid tbody tr:hover { background: #1a1f29; }
table.grid tbody tr.sel { background: #1d2836; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.hand { font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
td.hand .pcard { display: inline-flex; vertical-align: middle; margin-right: 3px; }
.eq-cell { position: relative; min-width: 108px; }
.eq-bar { position: absolute; left: 0; top: 2px; bottom: 2px; background: #1f3b57; border-radius: 3px; }
.eq-cell span { position: relative; padding-left: 6px; }
.plain td:first-child { color: var(--muted); }

/* ------------------------------------------------------------ range view */
.range-layout { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .range-layout { grid-template-columns: 1fr; } }
.range-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  position: sticky; top: 110px;
}
.range-main { min-width: 0; }
.cmp-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .cmp-layout { grid-template-columns: 1fr; } }
.cmp-side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.cmp-result { margin-top: 16px; }

.warn { background: #2a2312; border: 1px solid #5b431c; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin: 10px 0; }
.warn strong { color: var(--warn); }
.boundary-block { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.boundary-block h3 { margin-top: 0; }
.boundary-block .ex { color: var(--muted); font-size: 12px; margin-top: 6px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.split ul { margin: 4px 0 0; padding-left: 18px; }
.split li { font-size: 12.5px; }
ul.note { color: var(--muted); font-size: 12.5px; }
