/* 比赛评分端统一样式：裁判视图 + 裁判长视图共用（原裁判端与裁判长端样式表合并）。 */

:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --ok: #22c55e;
  --danger: #ef4444;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
#app { max-width: 720px; margin: 0 auto; padding: 20px 16px; }
/* 裁判长的汇总矩阵列数多，单独放宽内容宽度 */
#app[data-role="chief"] { max-width: 900px; padding: 20px 14px; }
/* 横屏放宽内容区（PRD 4.5）：只用媒体查询切布局，不监听 resize/旋转事件重渲染，避免清空未保存输入 */
@media (orientation: landscape) {
  #app { max-width: 1040px; }
  #app[data-role="chief"] { max-width: 1180px; }
}

/* ---- 登录页 ---- */
.login-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.field input { width: 100%; padding: 13px 14px; font-size: 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.field input:focus { outline: none; border-color: var(--accent); }

/* ---- 按钮 ---- */
.btn { width: 100%; padding: 14px; font-size: 17px; font-weight: 700; background: var(--accent); color: #1e293b; border: none; border-radius: 12px; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 10px 16px; font-size: 14px; min-height: 44px; }
.btn.danger { background: var(--danger); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }

/* ---- 顶栏 ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar .who { font-size: 16px; font-weight: 700; color: var(--accent-2); }
.topbar .logout { font-size: 13px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; min-height: 44px; cursor: pointer; }

/* ---- 卡片与空态 ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; }

/* ---- 裁判视图：逐要素打分 ---- */
.dim-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dim-row:last-child { border-bottom: none; }
.dim-name { flex: 1; font-size: 16px; }
.dim-max { color: var(--muted); font-size: 12px; }
.dim-row input { width: 120px; min-height: 48px; padding: 12px; font-size: 20px; text-align: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.dim-row input:focus { outline: none; border-color: var(--accent); }
.dim-row .saved { color: var(--ok); font-size: 12px; width: 40px; text-align: right; }

/* ---- 裁判长视图：汇总矩阵与加减分 ---- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.judge-name { text-align: left; white-space: nowrap; }
td input { width: 64px; min-height: 44px; padding: 9px; font-size: 15px; text-align: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
td input:focus { outline: none; border-color: var(--accent); }
td.total { font-weight: 700; color: var(--accent-2); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.adjust-row { display: flex; gap: 8px; margin-bottom: 8px; }
.adjust-row input { padding: 10px 12px; min-height: 44px; font-size: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.adjust-row .an { flex: 1; }
.adjust-row .av { width: 120px; }

/* ---- 分数预览（两套视图共用）---- */
.preview { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.preview strong { font-size: 26px; color: var(--accent-2); }

/* ---- 提示条 ---- */
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #334155; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; }
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }

/* ===========================================================================
   裁判长端一屏布局
   —— 全部规则限定在 #app[data-role="chief"] 之下，裁判打分页完全不受影响。
   目标：7 名裁判（矩阵 8 行含表头）+ 控场按钮 + 扣分加分，在 11 英寸平板横屏
   （约 1280×800 CSS px）一屏内全部可见。
   =========================================================================== */

/* 顶栏与控场条压缩，为矩阵让出竖直空间 */
#app[data-role="chief"] .topbar { margin-bottom: 10px; }
#app[data-role="chief"] .chief-flow { padding: 10px 14px; margin-bottom: 10px; }
#app[data-role="chief"] .chief-flow-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px;
  font-size: 16px; margin-bottom: 8px;
}
#app[data-role="chief"] .chief-status { font-weight: 700; font-size: 17px; color: var(--accent-2); }
#app[data-role="chief"] .chief-flow .actions { margin: 0; }

/* 汇总卡片：矩阵与侧栏 */
#app[data-role="chief"] .chief-scoring { padding: 12px 14px; margin-bottom: 0; }
#app[data-role="chief"] .chief-scoring h2 { font-size: 18px; margin-bottom: 8px; }
#app[data-role="chief"] .chief-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
#app[data-role="chief"] .chief-side { min-width: 0; }
#app[data-role="chief"] .chief-side .preview { margin: 0 0 10px; }
#app[data-role="chief"] .chief-side .actions { margin: 10px 0 0; }

/* 横屏平板：两栏并排 + 行高压缩，保证一屏装下 7 名裁判 */
@media (orientation: landscape) and (min-width: 820px) {
  #app[data-role="chief"] { max-width: none; padding: 10px 16px; }
  #app[data-role="chief"] .chief-grid { grid-template-columns: minmax(0, 1fr) 340px; }

  /* 矩阵压紧：7 名裁判 + 表头共 8 行也能轻松落在一屏内 */
  /* 三列一起收窄，把宽度让给右侧的扣分/加分 */
  #app[data-role="chief"] th,
  #app[data-role="chief"] td { padding: 4px 3px; font-size: 15px; }
  #app[data-role="chief"] th { font-size: 15px; padding: 5px 3px; }
  #app[data-role="chief"] td.judge-name,
  #app[data-role="chief"] th.judge-name { padding-left: 0; }
  #app[data-role="chief"] td input { width: 62px; min-height: 36px; padding: 3px; font-size: 16px; }
  #app[data-role="chief"] td.total { font-size: 16px; }
  #app[data-role="chief"] td.judge-name { font-size: 17px; }

  /* 侧栏控件同样收紧 */
  #app[data-role="chief"] .preview strong { font-size: 34px; }
  #app[data-role="chief"] .adjust-row { margin-bottom: 6px; flex-wrap: wrap; }
  #app[data-role="chief"] .adjust-row input { min-height: 38px; padding: 6px 8px; font-size: 16px; min-width: 0; }
  /* 关键：input 是 flex 子项，默认 min-width:auto 不会收缩到固有宽度以下，
     会把整行顶出页面。显式 min-width:0 才允许压缩。 */
  #app[data-role="chief"] .adjust-row .an { flex: 1 1 90px; min-width: 0; }
  #app[data-role="chief"] .adjust-row .av { flex: 0 0 84px; width: 84px; }
  #app[data-role="chief"] .btn.small { padding: 9px 16px; min-height: 42px; font-size: 16px; }

/* ===========================================================================
   P5b：按裁判组切换的打分界面（扣分制 / 难度确认）
   新增类名，不改动打分制用到的任何规则 —— 那条路径是 e2e 的契约。
   =========================================================================== */

.code-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0 6px;
}
.code-sum strong {
  font-size: 22px;
  color: var(--accent-2, #4ea1ff);
  font-variant-numeric: tabular-nums;
}

.code-list { display: flex; flex-direction: column; }

.code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line, #2a3550);
}
.code-row:last-child { border-bottom: none; }

.code-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.code-no {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  color: var(--muted, #93a4c4);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 1px 7px;
}
.code-name { font-size: 16px; }
.code-note { font-size: 12px; color: var(--muted, #93a4c4); }

.code-ops { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.code-count {
  min-width: 34px;
  text-align: center;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.code-fixed {
  font-size: 16px;
  color: #ff9d8a;
  font-variant-numeric: tabular-nums;
  min-width: 62px;
  text-align: right;
}
.code-value {
  width: 84px;
  min-height: 42px;
  padding: 8px;
  font-size: 17px;
  text-align: center;
  background: var(--panel-2, #1b2436);
  border: 1px solid var(--line, #2a3550);
  border-radius: 9px;
  color: var(--text, #e8eefc);
}
.code-value:focus { outline: none; border-color: var(--accent, #4f8cff); }

/* 步进按钮：平板手指点选，命中区要大 */
.code-ops .mini {
  min-width: 46px;
  min-height: 42px;
  font-size: 20px;
  line-height: 1;
}

/* 难度确认：整行可点 */
.diff-row { cursor: pointer; }
.diff-row input[type="checkbox"] {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  margin-right: 4px;
  accent-color: var(--accent, #4f8cff);
}

/* ===========================================================================
   P5c：裁判长端的分组提交情况（仅多组项目渲染）
   单组项目（v1 形态）不走这段，表格与列头保持逐字不变。
   =========================================================================== */

.group-cell {
  text-align: center;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--muted, #93a4c4);
}

.panel-strips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.panel-strip {
  border: 1px solid var(--line, #2a3550);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
}

.ps-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ps-code { font-weight: 700; font-size: 16px; color: var(--accent-2, #4ea1ff); }
.ps-name { font-size: 15px; }
.ps-mode {
  font-size: 12px;
  border: 1px solid var(--line, #2a3550);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--muted, #93a4c4);
}
.ps-spacer { flex: 1; }
.ps-count { font-size: 13px; color: var(--muted, #93a4c4); }

.ps-lines { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.ps-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.ps-none { font-size: 13px; color: var(--muted, #93a4c4); }
.ps-detail { color: var(--muted, #93a4c4); }
.ps-code-chip {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  padding: 1px 7px;
}
/* 未达确认门槛：不生效，但要让人看得见，否则现场查不出"分为什么不对" */
.ps-warn { color: #fbbf24; font-size: 13px; }

  /* 兜底：裁判特别多时矩阵区域内滚动，不撑破整页布局 */
  #app[data-role="chief"] .table-wrap { max-height: calc(100vh - 250px); overflow-y: auto; }
}

