/* ============================================================
   竞技赛在线评分系统 · 设计系统
   移动优先：320px 起步 → 576 / 768 / 992 / 1200 渐进增强
   间距：8px 基线   字号：12–48px 模块化刻度
   ============================================================ */

:root {
  /* 主色（中国石油蓝）50–900 */
  --blue-50:  #eef4ff;
  --blue-100: #dbe7ff;
  --blue-200: #bcd2ff;
  --blue-300: #90b4ff;
  --blue-400: #5d8dfb;
  --blue-500: #3563e9;
  --blue-600: #1f47d1;
  --blue-700: #1a3aa8;
  --blue-800: #1a3385;
  --blue-900: #1b3069;

  /* 品牌红（中国石油红） */
  --red-50:  #fdeef0;
  --red-100: #fbd9de;
  --red-500: #d0021b;
  --red-600: #b8001a;
  --red-700: #96001a;

  /* 语义色 */
  --success: #0f7b46;
  --success-bg: #e7f6ee;
  --warning: #a35a00;
  --warning-bg: #fdf1de;
  --danger: #b3261e;
  --danger-bg: #fdecea;

  /* 中性灰 */
  --gray-0:  #ffffff;
  --gray-25: #fafbfc;
  --gray-50: #f4f6f9;
  --gray-100:#eaedf2;
  --gray-200:#dde1e8;
  --gray-300:#c6ccd6;
  --gray-400:#9aa3b2;
  --gray-500:#6b7688;
  --gray-600:#4d5768;
  --gray-700:#39414f;
  --gray-800:#252b36;
  --gray-900:#141922;

  /* 语义 token */
  --bg: var(--gray-50);
  --surface: var(--gray-0);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --primary-soft: var(--blue-50);
  --accent: var(--red-500);

  /* 间距（8px 基线） */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 40px; --sp-8: 48px;

  /* 圆角 / 阴影 */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --shadow-1: 0 1px 2px rgba(20, 25, 34, .06), 0 1px 3px rgba(20, 25, 34, .04);
  --shadow-2: 0 2px 6px rgba(20, 25, 34, .08), 0 8px 24px rgba(20, 25, 34, .06);
  --shadow-3: 0 12px 32px rgba(20, 25, 34, .14);

  /* 动效：仅 transform / opacity，0.2–0.3s */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: .22s;

  --header-h: 56px;
  --maxw: 1080px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p  { margin: 0; }

a { color: var(--primary); text-decoration: none; }

/* ------------------------------- 布局 ------------------------------- */

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-4); }

.appbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  color: #fff;
  box-shadow: var(--shadow-1);
}
.appbar__inner {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-3);
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-4);
}
.appbar__title { font-size: 16px; font-weight: 600; letter-spacing: .2px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar__back { color: #fff; opacity: .95; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.appbar__chip {
  font-size: 12px; background: rgba(255,255,255,.18); border-radius: var(--r-full);
  padding: 2px 10px; white-space: nowrap;
}

.main { padding: var(--sp-4) 0 var(--sp-8); }

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--sm { gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.grid { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; }
@media (min-width: 576px) { .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 992px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }

/* ------------------------------- 卡片 ------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
}
.card + .card { margin-top: var(--sp-3); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.card__title { font-size: 15px; font-weight: 600; }
.card__sub { font-size: 12px; color: var(--text-muted); font-weight: 400; }

.section-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  letter-spacing: .4px; margin: var(--sp-5) 0 var(--sp-2);
}
.section-title::before {
  content: ''; width: 3px; height: 13px; border-radius: 2px; background: var(--primary);
}

/* ------------------------------- 按钮 ------------------------------- */

.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 500; line-height: 1.2;
  padding: 10px 16px; min-height: 44px;
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { transform: scale(1.05); }
.btn:active:not(:disabled) { transform: scale(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--blue-300); outline-offset: 2px; }

.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-1); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover:not(:disabled) { background: var(--red-600); }

.btn--ghost { background: var(--surface); color: var(--primary); border-color: var(--blue-200); }
.btn--ghost:hover:not(:disabled) { background: var(--primary-soft); }

.btn--soft { background: var(--gray-100); color: var(--gray-700); }
.btn--soft:hover:not(:disabled) { background: var(--gray-200); }

.btn--danger { background: var(--surface); color: var(--danger); border-color: #f0c4c0; }
.btn--danger:hover:not(:disabled) { background: var(--danger-bg); }

.btn--block { width: 100%; }
.btn--lg { min-height: 52px; font-size: 17px; font-weight: 600; border-radius: var(--r-lg); }
.btn--sm { min-height: 34px; font-size: 13px; padding: 6px 12px; }

/* ------------------------------- 表单 ------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.field__hint { font-size: 12px; color: var(--text-muted); }

.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: 16px; /* 16px 防 iOS 自动缩放 */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 10px 12px; min-height: 44px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  -webkit-appearance: none; appearance: none;
}
.select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7688' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.textarea { min-height: 76px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--blue-100);
}
.input:disabled, .select:disabled { background: var(--gray-50); color: var(--text-muted); }
.input--lg { font-size: 22px; font-weight: 600; text-align: center; min-height: 56px; }

/* ------------------------------- 徽章 ------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; line-height: 1;
  padding: 4px 8px; border-radius: var(--r-sm);
  background: var(--gray-100); color: var(--gray-600); white-space: nowrap;
}
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg); color: var(--danger); }
.badge--accent  { background: var(--red-50); color: var(--red-600); }

.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 700; background: var(--gray-100); color: var(--gray-600);
}
.rank--1 { background: linear-gradient(135deg, #f7c948, #e8a808); color: #fff; }
.rank--2 { background: linear-gradient(135deg, #cfd8e3, #aab6c6); color: #fff; }
.rank--3 { background: linear-gradient(135deg, #e0a06a, #c8813f); color: #fff; }

/* ------------------------------- 列表项 ------------------------------- */

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.item:hover { border-color: var(--blue-300); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.item:active { transform: scale(.99); }
.item:focus-visible { outline: 3px solid var(--blue-300); outline-offset: 2px; }
.item--done { background: var(--success-bg); border-color: #bfe3ce; }
.item--locked { opacity: .62; cursor: not-allowed; }
.item--locked:hover { transform: none; border-color: var(--border); box-shadow: none; }
.item__main { flex: 1; min-width: 0; }
.item__title { font-size: 15px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item__meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__side { text-align: right; flex-shrink: 0; }
.item__score { font-size: 20px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ------------------------------- 打分控件 ------------------------------- */

.dim { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); background: var(--surface); }
.dim + .dim { margin-top: var(--sp-3); }
.dim__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.dim__name { font-size: 16px; font-weight: 600; }
.dim__max { font-size: 12px; color: var(--text-muted); }
.dim__desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.dim__value { font-size: 26px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; line-height: 1.1; }
.dim__value small { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); margin-top: var(--sp-3); }
@media (min-width: 480px) { .levels { grid-template-columns: repeat(4, 1fr); } }
.level {
  border: 1.5px solid var(--border-strong); background: var(--surface);
  border-radius: var(--r-md); padding: var(--sp-2);
  font: inherit; cursor: pointer; text-align: left; min-height: 56px;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.level:active { transform: scale(.97); }
.level:focus-visible { outline: 3px solid var(--blue-300); outline-offset: 2px; }
.level__top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.level__label { font-size: 13px; font-weight: 600; }
.level__range { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.level__desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; display: none; }
@media (min-width: 768px) { .level__desc { display: block; } }
.level.is-active { border-color: var(--primary); background: var(--primary-soft); }
.level.is-active .level__label { color: var(--primary); }

.slider { width: 100%; margin: var(--sp-3) 0 0; accent-color: var(--primary); height: 28px; }
.slider:focus-visible { outline: 3px solid var(--blue-300); outline-offset: 4px; border-radius: var(--r-sm); }

/* ------------------------------- 汇总条 ------------------------------- */

.totalbar {
  position: sticky; bottom: 0; z-index: 15;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(20, 25, 34, .08);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
}
.totalbar__inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: var(--sp-3); }
.totalbar__num { font-size: 30px; font-weight: 800; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; }
.totalbar__num small { font-size: 14px; font-weight: 500; color: var(--text-muted); }

/* ------------------------------- 表格 ------------------------------- */

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--gray-25); position: sticky; top: 0; }
.table td { font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--gray-25); }
.table .num { text-align: right; font-weight: 600; }
.table .score { color: var(--primary); font-weight: 700; }

/* ------------------------------- 提示 ------------------------------- */

.notice {
  border-radius: var(--r-md); padding: var(--sp-3); font-size: 13px; line-height: 1.55;
  background: var(--primary-soft); color: var(--blue-800); border: 1px solid var(--blue-200);
}
.notice--warning { background: var(--warning-bg); color: var(--warning); border-color: #f2d9b0; }
.notice--danger  { background: var(--danger-bg); color: var(--danger); border-color: #f0c4c0; }
.notice--success { background: var(--success-bg); color: var(--success); border-color: #bfe3ce; }

.empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--text-muted); }
.empty__icon { font-size: 32px; opacity: .35; }
.empty__text { font-size: 14px; margin-top: var(--sp-2); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px);
  background: var(--gray-900); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: var(--r-full); box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none; z-index: 100; max-width: 88vw; text-align: center;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast--ok { background: var(--success); }
.toast--err { background: var(--danger); }

/* ------------------------------- 首页入口 ------------------------------- */

.hero {
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500) 60%, var(--blue-400));
  color: #fff; padding: var(--sp-6) 0 var(--sp-7); border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.hero h1 { font-size: 24px; letter-spacing: .3px; }
.hero p { margin-top: var(--sp-2); opacity: .92; font-size: 14px; }
@media (min-width: 768px) { .hero h1 { font-size: 32px; } .hero p { font-size: 16px; } }

.entry {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-4); box-shadow: var(--shadow-1); width: 100%;
  text-align: left; font: inherit; color: inherit; cursor: pointer; text-decoration: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.entry:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--blue-300); }
.entry:active { transform: scale(.98); }
.entry:focus-visible { outline: 3px solid var(--blue-300); outline-offset: 2px; }
.entry__icon {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--r-md);
  display: grid; place-items: center; font-size: 22px; background: var(--primary-soft);
}
.entry__icon--accent { background: var(--red-50); }
.entry__icon--soft { background: var(--gray-100); }
.entry__name { font-size: 16px; font-weight: 600; }
.entry__desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ------------------------------- 大屏 ------------------------------- */

.board-body { background: #0d1420; min-height: 100vh; }
.board-title { color: #fff; }
.podium { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; }
@media (min-width: 768px) { .podium { grid-template-columns: repeat(3, 1fr); } }
.pcard {
  border-radius: var(--r-lg); padding: var(--sp-4); color: #fff;
  background: linear-gradient(160deg, #1d2942, #131c2c);
  border: 1px solid rgba(255,255,255,.08);
}
.pcard--1 { background: linear-gradient(160deg, #7a5a12, #3d2c07); border-color: rgba(247,201,72,.45); }
.pcard--2 { background: linear-gradient(160deg, #3c4a63, #232c3c); border-color: rgba(207,216,227,.35); }
.pcard--3 { background: linear-gradient(160deg, #6b4526, #3a2415); border-color: rgba(224,160,106,.35); }
.pcard__rank { font-size: 12px; opacity: .85; letter-spacing: 1px; }
.pcard__name { font-size: 18px; font-weight: 700; margin-top: 4px; }
.pcard__score { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: 6px; }

.brow {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md); background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07); color: #fff;
}
.brow + .brow { margin-top: var(--sp-2); }
.brow__name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow__meta { font-size: 12px; opacity: .62; }
.brow__score { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.brow--top1 { background: rgba(247,201,72,.14); border-color: rgba(247,201,72,.4); }

.bar { height: 6px; border-radius: var(--r-full); background: rgba(255,255,255,.12); overflow: hidden; margin-top: 6px; }
.bar__fill { height: 100%; background: linear-gradient(90deg, var(--blue-400), #59d0ff); border-radius: var(--r-full);
  transition: width .5s var(--ease); }
.pcard .bar__fill { background: rgba(255,255,255,.65); }

.tabs { display: flex; gap: var(--sp-2); background: rgba(255,255,255,.07); padding: 4px; border-radius: var(--r-full); }
.tab {
  flex: 1; border: 0; background: transparent; color: rgba(255,255,255,.72);
  font: inherit; font-size: 14px; font-weight: 500; padding: 8px 12px; min-height: 40px;
  border-radius: var(--r-full); cursor: pointer; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab.is-active { background: #fff; color: #0d1420; font-weight: 600; }
.tab:focus-visible { outline: 3px solid var(--blue-300); outline-offset: 2px; }

/* ------------------------------- 二维码 ------------------------------- */

.qrbox { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.qrbox__img { background: #fff; padding: var(--sp-3); border-radius: var(--r-md); border: 1px solid var(--border); }
.qrbox__url { font-size: 13px; color: var(--primary); word-break: break-all; text-align: center; font-variant-numeric: tabular-nums; }

/* ------------------------------- 工具类 ------------------------------- */

.muted { color: var(--text-muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.bold { font-weight: 600; }
.tnum { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.mb-3 { margin-bottom: var(--sp-3); }
.hide { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (min-width: 992px) {
  .main { padding: var(--sp-6) 0 var(--sp-8); }
  .card { padding: var(--sp-5); }
}
