/* ── 颜色与变量 ──────────────────────────────────────── */
:root {
  --bg:        #f5f0e8;
  --surface:   #ffffff;
  --border:    #e0d9ce;
  --text:      #2c2416;
  --text-muted:#7a6e5f;
  --accent:    #8b1a1a;

  /* 番数层级颜色 */
  --c88: #7b0000;
  --c64: #b71c1c;
  --c48: #e65100;
  --c32: #ef6c00;
  --c24: #c79200;
  --c16: #2e7d32;
  --c12: #00695c;
  --c8:  #1565c0;
  --c6:  #6a1b9a;
  --c4:  #37474f;
  --c2:  #546e7a;
  --c1:  #78909c;
  --c0:  #0277bd;

  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.10);
  --header-h: 56px;
  --filter-h: 108px;
}

/* ── 基础重置 ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  /* space for sticky header + filter bar */
  padding-top: calc(var(--header-h) + var(--filter-h));
  padding-bottom: 80px;
}
button { cursor: pointer; font-family: inherit; }
input  { font-family: inherit; }

/* ── 标题栏 ─────────────────────────────────────────── */
#site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.header-inner {
  display: flex; align-items: center; gap: 10px;
  height: 100%; padding: 0 20px;
}
#site-header h1 {
  font-size: 1.05rem; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}
#search-input {
  flex: 1; min-width: 0;
  height: 34px; padding: 0 12px;
  border: none; border-radius: 17px;
  background: rgba(255,255,255,.18); color: #fff;
  font-size: .9rem;
}
#search-input::placeholder { color: rgba(255,255,255,.65); }
#search-input:focus { outline: none; background: rgba(255,255,255,.28); }

/* ── 筛选栏 ─────────────────────────────────────────── */
#filter-bar {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
  padding: 6px 14px 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.filter-row {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-label {
  font-size: .7rem; color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
  padding-right: 2px;
}
.filter-actions { justify-content: flex-end; margin-top: 2px; }
.chip-group { display: flex; gap: 5px; }

/* Chips */
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 14px;
  font-size: .75rem; white-space: nowrap;
  border: 1.5px solid var(--border);
  background: transparent; color: var(--text-muted);
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}
.chip.fan-chip.active { color: #fff; border-color: transparent; }

/* ── 结果摘要 ────────────────────────────────────────── */
#results-summary {
  text-align: center; padding: 8px 14px 2px;
  font-size: .78rem; color: var(--text-muted);
  min-height: 24px;
}

/* ── 主内容区 ────────────────────────────────────────── */
#fan-list {
  padding: 4px 10px 20px;
}

/* ── 页脚 ───────────────────────────────────────────── */
#site-footer {
  padding: 18px 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .72rem;
  color: var(--text-muted);
  line-height: 1.8;
}
#site-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── 番数分区 ─────────────────────────────────────────── */
.fan-tier { margin-bottom: 16px; }

.tier-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid var(--border);
  cursor: pointer; user-select: none;
}
.tier-header:hover { background: #faf7f2; }
.tier-fan-badge {
  font-size: 1rem; font-weight: 800;
  min-width: 42px; text-align: center;
  border-radius: 6px; padding: 1px 6px;
  color: #fff;
}
.tier-label {
  font-size: .8rem; color: var(--text-muted);
  font-weight: 400;
}
.tier-count {
  font-size: .78rem; color: var(--text-muted);
  margin-left: auto;
}
.tier-arrow {
  font-size: .7rem; color: var(--text-muted);
  transition: transform .2s;
  margin-left: 4px;
}
.fan-tier.collapsed .tier-arrow { transform: rotate(-90deg); }
.fan-tier.collapsed .fan-grid { display: none; }

/* ── 卡片网格 ────────────────────────────────────────── */
.fan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

/* ── 单张卡片 ────────────────────────────────────────── */
.fan-card {
  background: var(--surface);
  padding: 12px 14px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.fan-card:hover { background: #fefcf8; }
.fan-card.expanded { background: #fefcf8; }
.fan-card.calc-selected { background: #fff8e1; }

.card-top {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 5px;
}
.fan-badge {
  display: inline-block;
  font-size: .7rem; font-weight: 800;
  padding: 1px 6px; border-radius: 5px;
  color: #fff; flex-shrink: 0;
}
.card-name {
  font-size: .95rem; font-weight: 700;
  flex: 1;
}
.card-name-alt {
  font-size: .75rem; color: var(--text-muted);
  font-weight: 400;
}
.card-source {
  font-size: .68rem; color: var(--text-muted);
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 4px; padding: 0 4px;
}

.card-desc {
  font-size: .82rem; color: #4a3f30;
  margin-bottom: 7px; line-height: 1.5;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: .65rem; padding: 1px 6px;
  border-radius: 10px;
  background: #f0ece4; color: var(--text-muted);
  border: 1px solid #e0d9ce;
}
.tag.tag-门清  { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.tag.tag-日麻  { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }
.tag.tag-村规  { background: #fce4ec; color: #880e4f; border-color: #f8bbd0; }
.tag.tag-立直  { background: #e8eaf6; color: #283593; border-color: #c5cae9; }
.tag.tag-一色  { background: #fff8e1; color: #c79200; border-color: #ffe082; }
.tag.tag-字牌  { background: #f3e5f5; color: #6a1b9a; border-color: #e1bee7; }
.tag.tag-暗刻,
.tag.tag-暗杠  { background: #efebe9; color: #4e342e; border-color: #d7ccc8; }
.tag.tag-特殊牌型,
.tag.tag-特殊和牌 { background: #fff3e0; color: #e65100; border-color: #ffe0b2; }
.tag.tag-流局  { background: #eceff1; color: #546e7a; border-color: #cfd8dc; }
.tag.tag-DLC   { background: #fce4ec; color: #880e4f; border-color: #f8bbd0;
                  font-style: italic; }

/* ── 展开详情 ────────────────────────────────────────── */
.card-details {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  display: none;
  font-size: .8rem; line-height: 1.65;
}
.fan-card.expanded .card-details { display: block; }

.detail-row {
  display: grid; grid-template-columns: 3.5em 1fr;
  gap: 4px; padding: 2px 0;
}
.detail-row strong {
  color: var(--text-muted); font-weight: 600;
  font-size: .72rem; padding-top: 2px;
}
.detail-excludes span { color: #b71c1c; }
.card-notes {
  margin-top: 6px; padding: 6px 8px;
  background: #fffbf0; border-left: 3px solid #f0c040;
  border-radius: 0 4px 4px 0;
  font-size: .76rem; color: #5a4a20; line-height: 1.5;
}

/* ── 牌型展示 ────────────────────────────────────────── */
.tile-primary {
  margin: 8px 0 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding: 2px 1px;
  text-align: center;
}
.tile-primary::-webkit-scrollbar { display: none; }

.tile-row {
  display: inline-flex; flex-wrap: nowrap; align-items: flex-end;
  gap: 1px; vertical-align: bottom; text-align: left;
}

.tile-example > .tile-row {
  display: flex;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding: 2px 1px;
}
.tile-example > .tile-row::-webkit-scrollbar { display: none; }
.tile {
  width: 36px; height: 48px;
  padding: 1px;
  box-sizing: border-box;
  border-radius: 3px;
  object-fit: contain;
  display: block; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.55);
}
.tile-text {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 37px;
  background: #fffdf0; border: 1px solid #d4b96a;
  border-radius: 4px;
  font-size: .65rem; color: #5a4a20; line-height: 1.2;
  flex-shrink: 0;
  writing-mode: vertical-rl; text-orientation: mixed;
}
.tile-sep { width: 7px; flex-shrink: 0; }

/* 横置牌（副露捡牌） */
.tile-rotated-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 37px; height: 28px;
  flex-shrink: 0;
}
.tile-rotated-wrap .tile {
  transform: rotate(90deg);
}

/* 牌河 */
.tile-river-wrap {
  margin-top: 10px;
  margin-bottom: 4px;
}
.tile-river-label {
  font-size: .68rem; font-weight: 600; white-space: nowrap;
  color: #b71c1c; background: #ffebee;
  border: 1px solid #ffcdd2; border-radius: 4px;
  padding: 1px 6px; display: inline-block;
  margin-bottom: 3px;
}
.tile-river {
  display: grid;
  grid-template-columns: repeat(10, auto);
  gap: 1px;
  padding: 2px 1px;
  width: fit-content;
}
.tile-river-mark {
  box-shadow: 0 0 0 2px #b71c1c;
}

/* 听牌候选 */
.tile-wait-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 3px; margin-top: 5px; padding: 2px 1px;
}
.tile-wait-label {
  font-size: .68rem; font-weight: 600; white-space: nowrap;
  color: #2e7d32; background: #e8f5e9;
  border: 1px solid #c8e6c9; border-radius: 4px;
  padding: 1px 6px; flex-shrink: 0; align-self: flex-start;
}
.tile-wait-mark {
  box-shadow: 0 0 0 2px #2e7d32;
}

.tile-examples { margin: 8px 0 4px; }
.tile-example { margin-bottom: 10px; }
.tile-example-label {
  font-size: .68rem; color: var(--text-muted); margin-bottom: 3px;
}
.card-tips {
  margin: 6px 0; padding: 6px 10px;
  background: #e3f2fd; border-left: 3px solid #1565c0;
  border-radius: 0 4px 4px 0;
  font-size: .76rem; color: #1a3a5c; line-height: 1.55;
}

/* ── 计番模式 ────────────────────────────────────────── */
.calc-check-wrap {
  display: none; margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed var(--border);
}
body.calc-mode .calc-check-wrap { display: flex; align-items: center; gap: 8px; }
body.calc-mode .fan-card { cursor: default; }
body.calc-mode .fan-card:not(.expanded) { cursor: pointer; }

.calc-checkbox {
  width: 18px; height: 18px; accent-color: var(--accent);
  cursor: pointer; flex-shrink: 0;
}
.calc-check-label {
  font-size: .8rem; color: var(--text-muted); cursor: pointer;
}

#calc-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--accent); color: #fff;
  box-shadow: 0 -2px 8px rgba(0,0,0,.2);
  padding: 10px 16px;
}
.calc-bar-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  font-size: .88rem;
}
.calc-sep { opacity: .4; }
.calc-bar-inner strong { font-size: 1rem; }

/* ── 버튼 ────────────────────────────────────────────── */
.btn-outline {
  padding: 5px 12px; border-radius: 16px;
  border: 1.5px solid currentColor;
  background: transparent; font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.btn-outline:hover { color: var(--accent); }
.btn-ghost {
  padding: 5px 10px; border-radius: 16px;
  border: none; background: transparent;
  font-size: .78rem; color: var(--text-muted);
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--accent); }
.btn-sm { font-size: .75rem; padding: 4px 10px; }

#site-header .btn-outline {
  color: rgba(255,255,255,.9);
  border-color: rgba(255,255,255,.75);
}
#site-header .btn-outline:hover {
  color: rgba(255,255,255,.5);
  border-color: rgba(255,255,255,.35);
}
#calc-bar .btn-outline {
  border-color: rgba(255,255,255,.5); color: rgba(255,255,255,.85);
}
#calc-bar .btn-outline:hover { border-color: #fff; color: #fff; }
#calc-bar .btn-ghost { color: rgba(255,255,255,.7); }
#calc-bar .btn-ghost:hover { color: #fff; }

/* ── 空状态 ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: .9rem;
}

/* ── 番数颜色辅助类 ──────────────────────────────────── */
.tier-88, .badge-88  { background-color: var(--c88); }
.tier-64, .badge-64  { background-color: var(--c64); }
.tier-48, .badge-48  { background-color: var(--c48); }
.tier-32, .badge-32  { background-color: var(--c32); }
.tier-24, .badge-24  { background-color: var(--c24); }
.tier-16, .badge-16  { background-color: var(--c16); }
.tier-12, .badge-12  { background-color: var(--c12); }
.tier-8,  .badge-8   { background-color: var(--c8);  }
.tier-6,  .badge-6   { background-color: var(--c6);  }
.tier-4,  .badge-4   { background-color: var(--c4);  }
.tier-2,  .badge-2   { background-color: var(--c2);  }
.tier-1,  .badge-1   { background-color: var(--c1);  }
.tier-0,  .badge-0   { background-color: var(--c0);  }

/* 对 fan chip 使用对应番数色 */
.chip.fan-chip[data-fan="88"]  { --chip-color: var(--c88); }
.chip.fan-chip[data-fan="64"]  { --chip-color: var(--c64); }
.chip.fan-chip[data-fan="48"]  { --chip-color: var(--c48); }
.chip.fan-chip[data-fan="32"]  { --chip-color: var(--c32); }
.chip.fan-chip[data-fan="24"]  { --chip-color: var(--c24); }
.chip.fan-chip[data-fan="16"]  { --chip-color: var(--c16); }
.chip.fan-chip[data-fan="12"]  { --chip-color: var(--c12); }
.chip.fan-chip[data-fan="8"]   { --chip-color: var(--c8);  }
.chip.fan-chip[data-fan="6"]   { --chip-color: var(--c6);  }
.chip.fan-chip[data-fan="4"]   { --chip-color: var(--c4);  }
.chip.fan-chip[data-fan="2"]   { --chip-color: var(--c2);  }
.chip.fan-chip[data-fan="1"]   { --chip-color: var(--c1);  }
.chip.fan-chip[data-fan="0"]   { --chip-color: var(--c0);  }
.chip.fan-chip.active { background: var(--chip-color, var(--accent)); }

/* ── 术语高亮与弹窗 ──────────────────────────────────── */
.term {
  background: #fff3cd;
  border-radius: 2px;
  padding: 0 1px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.term:hover { background: #ffe082; }

#term-popup {
  position: absolute;
  z-index: 500;
  width: 250px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  padding: 10px 12px;
  font-size: .82rem;
  line-height: 1.5;
}
#term-popup.hidden { display: none; }

.term-popup-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 5px;
}
.term-popup-badge { font-size: .68rem !important; flex-shrink: 0; }
.term-popup-name  { font-size: .9rem; font-weight: 700; }
.term-popup-desc  { font-size: .8rem; color: #4a3f30; margin-bottom: 8px; }

.term-popup-goto {
  display: block; width: 100%;
  padding: 4px 8px; border-radius: 5px;
  background: var(--accent); color: #fff;
  border: none; font-size: .78rem;
  cursor: pointer; text-align: center;
}
.term-popup-goto:hover { background: #a52020; }

.card-highlight {
  box-shadow: inset 0 0 0 4px var(--accent);
  animation: card-hl .4s ease-out;
}
@keyframes card-hl {
  0%   { box-shadow: inset 0 0 0 10px var(--accent); }
  100% { box-shadow: inset 0 0 0 4px var(--accent); }
}

#back-to-origin {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 300;
  padding: 7px 14px;
  font-size: .84rem;
  white-space: nowrap;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}

/* ── 辅助类 ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── 响应式：手机小屏 ───────────────────────────────── */
@media (max-width: 480px) {
  .tile, .tile-text { width: 20px; height: 27px; }
  .tile-text { font-size: .55rem; }
  .tile-rotated-wrap { width: 27px; height: 20px; }
}
@media (min-width: 481px) and (max-width: 639px) {
  .tile, .tile-text { width: 32px; height: 48px; }
  .tile-rotated-wrap { width: 48px; height: 32px; }
}

/* ── 响应式：桌面 ────────────────────────────────────── */
@media (min-width: 640px) {
  :root { --filter-h: 72px; }
  #filter-bar {
    display: grid;
    grid-template-areas: "fan fan" "tag actions";
    grid-template-columns: 1fr auto;
    padding: 5px 14px 6px;
    gap: 3px 10px;
  }
  #fan-filter-row { grid-area: fan; }
  #tag-filter-row  { grid-area: tag; }
  .filter-actions  { grid-area: actions; align-self: center; margin-top: 0; }
  .fan-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

@media (min-width: 900px) {
  body { padding-left: 16px; padding-right: 16px; }
  .fan-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 滚动锚点偏移（跳转定位用）────────────────────────── */
.fan-tier { scroll-margin-top: calc(var(--header-h) + var(--filter-h) + 8px); }

/* ═══════════════════════════════════════════════════════
   手牌计番页面  (.hc-*)
   ═══════════════════════════════════════════════════════ */

/* 页面容器（全屏覆盖） */
.hc-page {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.hc-page.hidden { display: none; }

/* 顶栏 */
.hc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.hc-title { font-weight: 700; font-size: .95rem; }
.hc-btn-ghost {
  background: none;
  border: none;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--accent);
  font-size: .85rem;
  border-radius: 6px;
}
.hc-btn-ghost:hover { background: var(--border); }

/* 可滚动内容区 */
.hc-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 12px;
}

/* 各分区 */
.hc-section { margin-bottom: 10px; }
.hc-section-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hc-win-row { display: flex; align-items: center; gap: 10px; }
.hc-win-row .hc-section-label { margin-bottom: 0; white-space: nowrap; }

/* 牌行（立牌/副露缓冲） */
.hc-tile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 40px;
  align-items: center;
}

/* ── 牌元素（SVG img 版本）── */
.hc-tile {
  display: inline-block;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  vertical-align: top;
  flex-shrink: 0;
  padding: 1px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px #fff, 0 0 0 3px rgba(0,0,0,.6);
}
.hc-tile img {
  display: block;
  border-radius: 3px;
  object-fit: contain;
}
.hc-tile:active img { opacity: .7; }
.hc-tile.hc-tile-np { padding: 0; overflow: hidden; background: #8b2020; box-shadow: 0 0 0 2px rgba(0,0,0,.5); }

/* 牌背图片不需要内边距（背景色会直接贴边） */
.tile[src$="X.svg"] { padding: 0; }

/* 大号（选牌器） */
.hc-tile-lg img { width: 32px; height: 42px; }

/* 中号（手牌区）：22px img + 1px padding×2 = 24px total */
.hc-tile-md img { width: 22px; height: 29px; }

/* 牌背（hc-tile-np）：外框与普通牌等大，img 铺满无白边
   lg: 32+2=34×44, md: 22+2=24×31 */
.hc-tile-lg.hc-tile-np { width: 34px; height: 44px; }
.hc-tile-md.hc-tile-np { width: 24px; height: 31px; }
.hc-tile-np img { width: 100%; height: 100%; border-radius: 0; object-fit: fill; }

/* 空槽（无图片）：与普通牌等大 */
.hc-empty {
  border: 1.5px dashed var(--border);
  border-radius: 3px;
  opacity: .45;
  cursor: default;
  box-shadow: none;
}
.hc-tile-lg.hc-empty { width: 34px; height: 44px; }
.hc-tile-md.hc-empty { width: 24px; height: 31px; }

.hc-win-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-muted);
  cursor: default;
}

/* 选中（待替换） */
.hc-selected img {
  box-shadow: 0 0 0 2.5px var(--accent), 0 0 0 1px rgba(0,0,0,.35);
}

/* 暗杠遮盖 */
.hc-concealed img { opacity: .3; }

/* 待替换槽：显示牌背 + accent 描边 */
.hc-tile.hc-replacing { opacity: .75; cursor: pointer; }
.hc-tile.hc-replacing img {
  box-shadow: 0 0 0 2.5px var(--accent), 0 0 0 1px rgba(0,0,0,.25);
}

/* 已达4张上限：变暗且禁用 */
.hc-exhausted { opacity: .22; pointer-events: none; }

/* ── 副露卡片 ── */
.hc-meld-row { display: flex; flex-wrap: wrap; gap: 6px; }
.hc-meld-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 6px;
}
.hc-meld-tiles { display: flex; gap: 4px; }
.hc-meld-ctrl  { display: flex; align-items: center; gap: 4px; }
.hc-meld-lbl   { font-size: .72rem; color: var(--text-muted); }
.hc-btn-sm {
  font-size: .7rem;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  color: var(--text);
}
.hc-btn-sm:hover { background: var(--border); }
.hc-btn-del { color: #b71c1c; border-color: #e57373; }
.hc-btn-xs {
  font-size: .68rem;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  color: var(--text-muted);
}

/* ── 设置区 ── */
.hc-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.hc-check { display: flex; align-items: center; gap: 4px; font-size: .82rem; cursor: pointer; }
.hc-winds {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: .82rem;
}
.hc-winds label { display: flex; align-items: center; gap: 4px; }
.hc-winds select, .hc-winds input[type=number] {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 4px;
  background: var(--surface);
  color: var(--text);
  font-size: .82rem;
}
.hc-winds input[type=number] { width: 44px; }

/* ── 计算按钮 ── */
.hc-calc-row { display: flex; justify-content: center; padding: 4px 0; }
.hc-calc-btn {
  width: 100%;
  max-width: 320px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .1em;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.hc-calc-btn:disabled { opacity: .4; cursor: not-allowed; }
.hc-calc-btn:not(:disabled):hover { filter: brightness(1.1); }

/* ── 结果区 ── */
.hc-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 4px;
}
.hc-result-total {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.hc-result-list { display: flex; flex-direction: column; gap: 4px; }
.hc-result-row  { display: flex; justify-content: space-between; font-size: .85rem; }
.hc-result-name { color: var(--text); }
.hc-result-val  { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hc-result-none { color: var(--text-muted); font-size: .85rem; }
.hc-err { color: #b71c1c; font-size: .85rem; }

/* ── 底部固定栏（模式按钮 + 选牌器） ── */
.hc-bottom {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px 8px;
}

/* 模式按钮 */
.hc-mode-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.hc-mode-btn {
  flex: 1;
  padding: 6px 2px;
  font-size: .76rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.hc-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.hc-mode-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

/* 选牌器 */
.hc-picker { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.hc-picker-row { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }

/* ── Toast ── */
.hc-toast {
  position: fixed;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: .85rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 600;
  white-space: nowrap;
}
.hc-toast.hc-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .hc-tile { box-shadow: 0 0 0 1px #000, 0 0 0 3px rgba(255,255,255,.35); }
}

/* ── 计番器：桌面尺寸（必须在所有基础规则之后） ──────────── */
@media (min-width: 640px) {
  .hc-tile-lg img   { width: 40px; height: 52.5px; }
  .hc-tile-md img   { width: 40px; height: 52.5px; }
  .hc-tile-lg.hc-empty { width: 42px; height: 54.5px; }
  .hc-tile-md.hc-empty { width: 42px; height: 54.5px; }
  .hc-tile-lg.hc-tile-np { width: 42px; height: 54.5px; }
  .hc-tile-md.hc-tile-np { width: 42px; height: 54.5px; }
  .hc-picker        { display: grid; grid-template-columns: auto auto; justify-content: center; gap: 6px 12px; align-items: start; }
  .hc-picker-row    { gap: 6px; justify-content: center; }

  .hc-section-label { font-size: 1.2rem; }
  .hc-check         { font-size: 1.2rem; }
  .hc-meld-lbl      { font-size: 1.2rem; }
  .hc-winds         { font-size: 1.2rem; }
  .hc-mode-btn      { font-size: 0.9rem; padding: 8px 4px; }
  .hc-result-total  { font-size: 1.25rem; }
  .hc-result-row,
  .hc-result-none,
  .hc-err           { font-size: 1.3rem; }
}
