/* 本地部署补充样式：不改动原版观感，只处理离线环境的细节。 */
.boot {
  max-width: 560px;
  margin: 18vh auto;
  padding: 0 24px;
  text-align: center;
  color: var(--muted, #6b6b76);
}
.boot h2 { color: var(--text, #1d1b22); }

/* 本地会显示局域网地址，便于分享 */
.local-share { word-break: break-all; }

/* “当前最优解”：位置在回合标题与“起始 …”之间，字体/字号与玩家答案一致，颜色为黄色。 */
.round-result .optimal-solution {
  font-family: var(--font-roll, 'Space Mono', monospace);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  color: #b8860b;
  margin: 2px 0 12px;
}
[data-theme=dark] .round-result .optimal-solution { color: #ffd400; }

@media (max-width: 640px) {
  .round-result .optimal-solution { font-size: 18px; }
}

/* ------------------------------------------------------------------
   多人（2~6）对局：等待开局界面
   ------------------------------------------------------------------ */
.waiting-lobby {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.waiting-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border: 1px solid var(--outline);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}
.waiting-player h3 { font-size: 14px; margin: 0; overflow-wrap: anywhere; }
.waiting-player .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-raised); color: var(--prose);
  font-size: 18px; font-weight: 600; text-transform: uppercase;
}
.waiting-player.is-ready { border-color: #16a34a; box-shadow: inset 0 0 0 1px #16a34a; }
.waiting-player.is-ready .avatar { background: #dcfce7; color: #166534; }
.waiting-player.is-ready .pill.green { background: #16a34a; color: #fff; border-color: #16a34a; }
.waiting-player.is-empty { opacity: .55; border-style: dashed; }
[data-theme=dark] .waiting-player.is-ready .avatar { background: #14532d; color: #bbf7d0; }
.waiting-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--outline);
}
.waiting-controls .control-note { flex: 1 1 220px; margin: 0; }
.waiting-capacity { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; }
.waiting-capacity select { width: auto; min-width: 84px; }

/* ------------------------------------------------------------------
   多人（2~6）对局：回合结果（每人一列，徽章压缩显示）
   ------------------------------------------------------------------ */
.round-result { min-width: 0; }
.round-results {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.round-results .round-result-player { flex: 1 1 0; min-width: 0; }
.round-result-player .compact-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  margin-top: 8px;
}
.round-result-player .compact-badges .badge-chip {
  font-size: 10px;
  padding: 2px 5px;
  max-width: 100%;
}
.round-result-player .compact-badges .badge-chip strong { font-size: 10px; }
.round-result-player .compact-badges .badge-chip small { font-size: 9px; }
.badge-more { font-size: 10px; color: var(--muted); }
.player-you { font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------------
   结束页：所有人分数与名次
   ------------------------------------------------------------------ */
.final-standings { margin-top: 12px; }
.final-standings table { font-size: 13px; }
.final-standings td, .final-standings th { padding: 8px 10px; }
.final-place {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-raised);
  font-family: var(--font-roll, 'Space Mono', monospace);
  color: var(--prose);
}
.final-place.is-first { background: var(--ep-bg); color: var(--ep-text); border: 1px solid var(--ep-line); }
.final-self td { background: var(--surface-dim); }
.final-resigned td { color: var(--muted); }
.final-resigned .player-link { text-decoration: line-through; }
.final-tag { display: block; font-size: 10px; color: var(--muted); }

/* ------------------------------------------------------------------
   回合总计：把「当前名次」做成主角（与分数同级的大字）
   原来的“领先/落后平均分”已按需求移除；颜色只由分数符号决定（.ahead/.behind）。
   ------------------------------------------------------------------ */
.target-total.rank-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
  /* 原版 .target-total 是 float:right 的小卡片；这里要的是独立成行的大号名次。
     不取消浮动的话，「回合结果」标题会被压到窄列里换行。
     做法：让父容器变成 flex 容器（标题占满剩余宽度），并让本元素弹性占用右侧。 */
  float: none;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 0 6px;
}
/* 把包含它的容器变成 flex 行：标题自然占满左侧，不再被压窄 */
.round-log:has(> .target-total.rank-hero) {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 16px;
}
.round-log:has(> .target-total.rank-hero) > *:not(.target-total) {
  flex: 1 1 60%;
  min-width: 0;
}
.round-log:has(> .target-total.rank-hero) > .target-total.rank-hero {
  flex: 0 1 auto;
}
.rank-hero .rank-hero-label {
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
}
.rank-hero .rank-hero-value {
  font-family: var(--font-roll, 'Space Mono', monospace);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.05;
}
.rank-hero .rank-hero-total {
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 640px) {
  .rank-hero .rank-hero-value { font-size: 32px; }
  .target-total.rank-hero { margin-bottom: 10px; }
}

/* ------------------------------------------------------------------
   沙箱页（#lookup）：输入数字看 EP 与徽章
   参考 rng.cubityfir.st 的 Roll 视图，用本站的主题变量重做
   ------------------------------------------------------------------ */
.sb-page { max-width: 720px; margin: 0 auto; padding: 8px 0 48px; }
.sb-head { text-align: center; margin-bottom: 24px; }
.sb-head h1 { margin: 0 0 8px; font-size: 22px; }
.sb-head p { margin: 0 auto; max-width: 54ch; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sb-head strong { color: var(--prose-2, inherit); font-weight: 600; }

/* 号码机：大号数字 + 透明输入框叠在上面（与原站一致，点哪都能输入） */
.sb-machine { display: flex; flex-direction: column; align-items: center; }
.sb-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  margin-bottom: 18px;
  cursor: text;
}
.sb-digits,
.sb-input {
  font-family: var(--font-roll, 'Space Mono', monospace);
  font-size: clamp(40px, 9vw, 60px);
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.1;
  text-align: center;
}
.sb-digits {
  color: var(--prose, inherit);
  user-select: none;
  transition: color .15s;
}
.sb-digits.is-empty {
  color: var(--muted);
  animation: sb-shimmer 2.4s ease-in-out infinite;
}
@keyframes sb-shimmer {
  0%, 100% { opacity: .35; }
  50% { opacity: .75; }
}
@media (prefers-reduced-motion: reduce) {
  .sb-digits.is-empty { animation: none; opacity: .5; }
}
.sb-input {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--prose, inherit);
  outline: none;
  padding: 0;
}
.sb-input::placeholder { color: transparent; }

.sb-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.sb-actions .button { min-width: 148px; }
.sb-roll {
  background: var(--prose, #111);
  color: var(--surface, #fff);
  border-color: var(--prose, #111);
  font-weight: 700;
  letter-spacing: .04em;
}
.sb-roll:hover { filter: brightness(1.15); }
.sb-hint { margin: 14px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

/* 结果区 */
.sb-results { margin-top: 26px; }
.sb-results:empty { display: none; }
.sb-rarity { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sb-tier {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.sb-pct { font-size: 12px; color: var(--muted); font-weight: 600; }

.sb-ep { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin-bottom: 8px; }
.sb-ep b {
  font-family: var(--font-roll, 'Space Mono', monospace);
  font-size: clamp(38px, 8vw, 54px);
  font-weight: 700;
  line-height: 1;
}
.sb-ep span { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .1em; }
.sb-ep-note { margin: 0 0 22px; text-align: center; font-size: 12px; color: var(--muted); }

/* 段位配色 */
.sb-tier.is-trash { color: #7c5a2e; background: rgba(200, 168, 124, .18); }
.sb-tier.is-common { color: #475569; background: rgba(100, 116, 139, .14); }
.sb-tier.is-uncommon { color: #047857; background: rgba(16, 185, 129, .14); }
.sb-tier.is-rare { color: #1d4ed8; background: rgba(59, 130, 246, .14); }
.sb-tier.is-epic { color: #6d28d9; background: rgba(139, 92, 246, .16); }
.sb-tier.is-anomaly { color: #b91c1c; background: rgba(239, 68, 68, .14); }
.sb-tier.is-mythic { color: #a16207; background: rgba(234, 179, 8, .18); }
:root[data-theme=dark] .sb-tier.is-trash { color: #e7cfa8; }
:root[data-theme=dark] .sb-tier.is-common { color: #cbd5e1; }
:root[data-theme=dark] .sb-tier.is-uncommon { color: #6ee7b7; }
:root[data-theme=dark] .sb-tier.is-rare { color: #93c5fd; }
:root[data-theme=dark] .sb-tier.is-epic { color: #c4b5fd; }
:root[data-theme=dark] .sb-tier.is-anomaly { color: #fca5a5; }
:root[data-theme=dark] .sb-tier.is-mythic { color: #fde68a; }

/* 徽章明细 */
.sb-breakdown { margin-top: 8px; }
.sb-breakdown-head { text-align: center; margin-bottom: 14px; }
.sb-breakdown-head h3 { margin: 0 0 4px; font-size: 15px; }
.sb-breakdown-head p { margin: 0; font-size: 12px; color: var(--muted); }
.sb-empty-note { text-align: center; color: var(--muted); font-size: 13px; }
.sb-error {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #c2410c;
  border-radius: 0 6px 6px 0;
  background: rgba(194, 65, 12, .08);
  color: #c2410c;
  font-size: 13px;
}

.sb-groups { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sb-group { display: flex; flex-direction: column; gap: 6px; }
.sb-badge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: var(--surface-raised);
}
.sb-badge-icon { font-size: 18px; line-height: 1.25; flex: 0 0 auto; }
.sb-badge-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sb-badge-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sb-badge-title strong { font-size: 13px; }
.sb-badge-rarity,
.sb-badge-family {
  font-size: 10px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--outline);
  color: var(--muted);
  white-space: nowrap;
}
.sb-badge-desc { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.sb-badge-ep {
  flex: 0 0 auto;
  align-self: center;
  font-family: var(--font-roll, 'Space Mono', monospace);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ep-text, #6d28d9);
  white-space: nowrap;
}
.sb-badge-ep.is-zero { color: var(--muted); font-weight: 400; }
/* 计分徽章按稀有度描边（与原站一致的「发光感」，用描边代替阴影） */
.sb-badge.is-uncommon { border-color: rgba(16, 185, 129, .45); }
.sb-badge.is-rare { border-color: rgba(59, 130, 246, .5); }
.sb-badge.is-epic { border-color: rgba(139, 92, 246, .55); }
.sb-badge.is-anomaly { border-color: rgba(239, 68, 68, .5); }
.sb-badge.is-mythic { border-color: rgba(234, 179, 8, .6); }

/* 被压制的徽章：缩进 + 淡化 */
.sb-group-rest { list-style: none; margin: 0 0 0 22px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sb-group-rest .sb-badge { padding: 8px 10px; background: transparent; opacity: .75; }
.sb-group-rest .sb-badge-icon { font-size: 15px; }
.sb-group-rest .sb-badge-title strong { font-size: 12px; font-weight: 500; }
.sb-group-rest .sb-badge-desc { font-size: 11px; }

@media (max-width: 640px) {
  .sb-page { padding-bottom: 32px; }
  .sb-slot { min-height: 62px; }
  .sb-actions .button { min-width: 0; flex: 1 1 140px; }
  .sb-badge { padding: 10px 12px; gap: 8px; }
  .sb-group-rest { margin-left: 14px; }
}

/* 已认输的玩家（房间等待界面与进行中的玩家卡片） */
.player.is-resigned, .waiting-player.is-resigned { opacity: .6; }
.player.is-resigned h3, .waiting-player.is-resigned h3 { text-decoration: line-through; }

/* ------------------------------------------------------------------
   回放页：多人局最终名次表（原版只有 1v1 的“正分/负分偏向”）
   ------------------------------------------------------------------ */
.replay-final-standings { margin-top: 0; }
.replay-final-standings table { font-size: 13px; }
.replay-final-standings td, .replay-final-standings th { padding: 8px 10px; }
.replay-final-standings .final-resigned td { color: var(--muted); }
.replay-final-standings .final-tag { display: block; font-size: 10px; color: var(--muted); }

/* ------------------------------------------------------------------
   限时收集（2~6 人）：结算区块里的“各自保存的数字”
   ------------------------------------------------------------------ */
.collect-save-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.collect-save-grid article h4 { margin: 0 0 6px; font-size: 13px; overflow-wrap: anywhere; }
.collect-save-list { margin: 0; padding-left: 18px; font-size: 13px; }
.collect-save-list li { display: flex; justify-content: space-between; gap: 8px; }
.collect-save-list li span { color: var(--muted); font-size: 12px; }
.round-log .final-self td { background: var(--surface-dim); }
