/* ============ 基础 ============ */
:root {
  --bg: #080b10;
  --bg-soft: #0e131b;
  --card: #141a24;
  --card-2: #1a2230;
  --line: #242e3d;
  --line-soft: #1b2331;
  --text: #e9eef6;
  --text-2: #97a3b6;
  --text-3: #64707f;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, .14);
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 14px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ============ 布局 ============ */
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
}

.view { padding: 0 16px 24px; }

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(8, 11, 16, 0));
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.page-sub {
  font-size: 13px;
  color: var(--text-2);
  margin: 2px 0 0;
  font-weight: 400;
}

/* ============ 顶部品牌栏 ============ */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 0 6px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, #ff6b35, #ff9a3d);
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(255, 107, 53, .35);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.brand-tag { font-size: 11px; color: var(--text-3); letter-spacing: 1.5px; text-transform: uppercase; }

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-link { display: block; transition: transform .12s, border-color .12s; }
.card-link:active { transform: scale(.985); border-color: var(--line); }

/* ============ 数据导入导出 ============ */
.drop-zone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  background: var(--bg-soft);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.drop-zone:active { background: var(--card); }
.drop-zone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dz-ico { font-size: 26px; color: var(--accent); line-height: 1; margin-bottom: 10px; }
.dz-title { font-size: 14px; font-weight: 600; color: var(--text); }
.dz-desc { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.6; }

.dz-actions { display: flex; gap: 8px; margin-top: 10px; }
.dz-actions .btn { flex: 1; }

.exp-title { font-size: 14px; font-weight: 600; color: var(--text); }
.exp-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.55; }
.exp-arrow { font-size: 12px; color: var(--accent); font-weight: 700; flex: 0 0 auto; }

.section-label {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
  margin: 22px 0 10px;
}

/* ============ 球队 / 球员行 ============ */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  margin-bottom: 10px;
  transition: border-color .12s, transform .1s;
}
.row:active { transform: scale(.99); }

.team-dot {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex: 0 0 auto;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.row-arrow { color: var(--text-3); font-size: 18px; flex: 0 0 auto; }

.jersey {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-2);
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

/* ============ 按钮 ============ */
.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 11px;
  font-weight: 600;
  font-size: 14.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .1s, opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #14090a; }
.btn-primary:hover { background: #ff7d4d; }
.btn-ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: rgba(239, 68, 68, .14); color: #ff7b7b; border: 1px solid rgba(239, 68, 68, .3); }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

.fab {
  position: fixed;
  right: max(18px, calc(50vw - 320px + 18px));
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 18px;
  background: var(--accent);
  color: #14090a;
  font-size: 28px;
  font-weight: 300;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(255, 107, 53, .4);
  z-index: 40;
  transition: transform .12s;
}
.fab:active { transform: scale(.93); }

/* ============ 表单 ============ */
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
  margin-bottom: 7px;
  letter-spacing: .3px;
}
.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
  font-size: 15px;
  appearance: none;
}
.input:focus { border-color: var(--accent); background: var(--card); }
select.input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%2397a3b6' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
textarea.input { padding: 12px 14px; min-height: 80px; resize: vertical; }

.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; margin-bottom: 0; }

/* 颜色选择 */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 2px solid transparent;
  position: relative;
  transition: transform .1s;
}
.swatch:active { transform: scale(.93); }
.swatch.is-on { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.swatch.is-on::after {
  content: '✓';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #fff; font-size: 16px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* 分段选择 */
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1;
  min-height: 46px;
  border-radius: 11px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-weight: 600;
  transition: all .15s;
}
.seg button.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ============ 底部导航 ============ */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  background: rgba(12, 16, 23, .92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 58px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  transition: color .15s;
}
.tabbar a .ico { font-size: 19px; line-height: 1; }
.tabbar a.is-active { color: var(--accent); }

/* ============ 提示与弹窗 ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: #1f2937;
  color: #fff;
  padding: 11px 20px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  max-width: 80vw;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: #7f1d1d; }

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 300;
  opacity: 0;
  transition: opacity .16s;
}
.modal-mask.is-open { opacity: 1; }
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px 18px;
  transform: scale(.95);
  transition: transform .16s;
}
.modal-mask.is-open .modal { transform: scale(1); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.modal-body { font-size: 14px; color: var(--text-2); line-height: 1.6; margin-bottom: 6px; }
.modal-input {
  width: 100%;
  min-height: 46px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 13px;
  margin: 10px 0 4px;
  outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ============ 空状态 ============ */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-3);
}
.empty-ico { font-size: 40px; margin-bottom: 14px; opacity: .5; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-desc { font-size: 13px; line-height: 1.6; }

/* ============ 统计概览 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-box {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}
.stat-num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat-lbl { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

/* ============ 记分牌 ============ */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #161d28, #10151d);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 14px;
  margin-bottom: 12px;
}
.sb-side { text-align: center; min-width: 0; }
.sb-team {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  font-weight: 600;
}
.sb-score {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform .18s;
}
.sb-score.bump { transform: scale(1.18); }
.sb-mid { text-align: center; padding: 0 4px; }
.sb-clock {
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
.sb-quarter { font-size: 11px; color: var(--text-3); margin-top: 2px; font-weight: 600; }
.sb-fouls { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.sb-target { font-size: 11px; color: var(--accent); margin-top: 4px; font-weight: 700; letter-spacing: .3px; }
.sb-qpts { font-size: 11px; margin-top: 5px; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .9; }

/* ============ 现场记录 ============ */
.rec-wrap { padding-bottom: 8px; }

.rec-teams { display: flex; gap: 10px; margin-bottom: 12px; }
.rec-team {
  flex: 1;
  min-height: 52px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
  transition: all .15s;
  padding: 0 10px;
  overflow: hidden;
}
.rec-team.is-on { border-width: 2px; color: var(--text); }
.rec-team-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.rec-team-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.player-chip {
  min-height: 62px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: all .13s;
  padding: 6px 4px;
  position: relative;
}
.player-chip:active { transform: scale(.95); }
.player-chip.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.pc-num { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pc-name {
  font-size: 10.5px;
  color: var(--text-2);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.pc-pts {
  position: absolute;
  top: 4px; right: 5px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(255,107,53,.15);
  border-radius: 5px;
  padding: 0 4px;
  line-height: 14px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.action-btn {
  min-height: 54px;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .1s;
  position: relative;
}
.action-btn:active { transform: scale(.95); background: var(--line); }
.action-btn:disabled { opacity: .35; }
.action-btn .kbd {
  position: absolute;
  top: 3px; right: 5px;
  font-size: 9px;
  color: var(--text-3);
  font-weight: 700;
  background: rgba(255,255,255,.05);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 13px;
}
.action-btn.a-score { background: rgba(34, 197, 94, .1); border-color: rgba(34,197,94,.28); color: #7ee2a8; }
.action-btn.a-miss { background: rgba(148, 163, 184, .07); border-color: var(--line); color: var(--text-2); }
.action-btn.a-foul { background: rgba(239, 68, 68, .1); border-color: rgba(239,68,68,.28); color: #ff9b9b; }

.clock-controls { display: flex; gap: 8px; margin-bottom: 10px; }
.clock-controls .btn { flex: 1; }

.event-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
}
.event-strip::-webkit-scrollbar { display: none; }
.ev-pill {
  flex: 0 0 auto;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.ev-pill b { color: var(--text); font-weight: 700; }
.ev-pill .ev-t {
  font-style: normal;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
  font-size: 10.5px;
}
.ev-pill.ev-mark {
  color: var(--text-3);
  background: transparent;
  border-style: dashed;
  font-size: 11px;
}

.rec-latest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 600;
  margin: 16px 0 0;
}
.rec-latest a { color: var(--accent); font-weight: 700; }

/* ============ 比赛时间线 ============ */
.tl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
}
.tl-sep { opacity: .5; }

.tl-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 2px 0 8px;
}
.tl-bar button {
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 600;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  min-height: 28px;
}

.tl-q {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--line);
}
.tl-q .tl-qn { font-size: 13px; font-weight: 800; color: var(--text); letter-spacing: .3px; }
.tl-q .tl-qs { font-size: 12px; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-q .tl-qc { margin-left: auto; font-size: 11px; color: var(--text-3); }

.tl-row {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.tl-t {
  flex: 0 0 42px;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding-top: 2px;
}
.tl-c { flex: 1; min-width: 0; }
.tl-m { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.tl-m b { font-variant-numeric: tabular-nums; }
.tl-s {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.tl-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 2px;
}
.tl-act { color: var(--text); font-weight: 600; }
.tl-act.is-score { color: var(--green); }
.tl-row.tl-score .tl-m { color: var(--text); }
.tl-row.tl-mark {
  justify-content: center;
  border-bottom: none;
  padding: 10px 0;
}
.tl-row.tl-mark .tl-c {
  flex: 0 0 auto;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 600;
  letter-spacing: .3px;
}

.hint {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  padding: 8px 0 4px;
  line-height: 1.5;
}

/* ============ 统计表 ============ */
.table-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.stats th {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  text-align: center;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}
table.stats th:first-child, table.stats td:first-child { text-align: left; padding-left: 4px; position: sticky; left: 0; background: var(--bg); z-index: 2; }
table.stats td {
  padding: 11px 6px;
  text-align: center;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-2);
}
table.stats tr:last-child td { border-bottom: none; }
table.stats .col-name { color: var(--text); font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
table.stats .col-pts { color: var(--text); font-weight: 700; }
table.stats tfoot td { border-top: 1px solid var(--line); color: var(--text); font-weight: 700; background: var(--card); }

.team-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
}
.team-head .bar { width: 4px; height: 18px; border-radius: 2px; }
.team-head .nm { font-weight: 700; font-size: 15px; }
.team-head .sc { margin-left: auto; font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }

/* ============ 兼容 ============ */
@media (min-width: 641px) {
  body { background: #05070a; }
  .app { background: var(--bg); min-height: 100vh; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .tabbar { width: 100%; max-width: 640px; left: 50%; right: auto; transform: translateX(-50%); }
}

/* ============ 记录页：选中球员提示条 ============ */
.sel-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 10px;
}
.sel-bar.is-on {
  background: var(--accent-soft);
  border-color: rgba(255, 107, 53, .35);
  color: var(--accent);
}

/* 记录页沉浸模式：隐藏底部导航 */
body.immersive { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
body.immersive .tabbar { display: none; }
