/* ============================================================
   竞彩比分 · iPhone 主屏版
   ============================================================ */
:root {
  --bg-a: #1a1f28;
  --bg-b: #0b0e13;
  --fg: #e9eef7;
  --fg-dim: #8d98ab;
  --fg-faint: #626d7f;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.13);
  --accent: #23d69b;
  --accent-dim: rgba(35, 214, 155, 0.14);
  --live: #ff5c62;
  --live-dim: rgba(255, 92, 98, 0.14);
  --pre: #7fa6ff;
}

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg-b);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.hidden { display: none !important; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(35, 214, 155, 0.10), transparent 58%),
    radial-gradient(110% 70% at 100% 0%, rgba(90, 130, 255, 0.10), transparent 55%),
    linear-gradient(163deg, var(--bg-a) 0%, var(--bg-b) 100%);
  padding-top: env(safe-area-inset-top);
}

/* ---------- 顶栏 ---------- */
#titlebar {
  position: relative;
  flex: 0 0 auto;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { width: 19px; height: 19px; color: var(--accent); flex: 0 0 auto; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.4px; white-space: nowrap; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px 0 7px;
  border-radius: 10px;
  background: var(--live-dim);
  color: var(--live);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 92, 98, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(255, 92, 98, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 92, 98, 0); }
}

.tools { margin-left: auto; display: flex; gap: 2px; }

.tool {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.tool svg { width: 20px; height: 20px; }
.tool:active { background: rgba(255, 255, 255, 0.1); transform: scale(0.94); }

.sound-btn .slash { display: none; }
.sound-btn.sound-off { color: var(--fg-faint); }
.sound-btn.sound-off .wave { display: none; }
.sound-btn.sound-off .slash { display: inline; }

.tool.spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#progress {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, transparent, var(--accent));
  opacity: 0.75;
}

/* ---------- 筛选 ---------- */
#filters {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 9px;
  border-bottom: 1px solid var(--line);
}

.chip {
  height: 30px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--fg-dim);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chip.is-active {
  background: var(--accent-dim);
  border-color: rgba(35, 214, 155, 0.35);
  color: var(--accent);
  font-weight: 700;
}

.grow { flex: 1 1 auto; }

.fav-toggle {
  width: 34px; height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 15px;
  background: transparent;
  color: var(--fg-faint);
  font-size: 15px;
  cursor: pointer;
}

.fav-toggle[aria-pressed="true"] {
  color: #ffce3a;
  border-color: rgba(255, 206, 58, 0.35);
  background: rgba(255, 206, 58, 0.1);
}

/* ---------- 列表 ---------- */
#list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px;
}

.match {
  position: relative;
  margin: 3px 8px;
  padding: 10px 12px 11px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.15s;
}

.match:active { background: rgba(255, 255, 255, 0.05); }
.match.is-live { background: linear-gradient(90deg, rgba(255, 92, 98, 0.055), transparent 62%); }

.match.is-live::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 2px;
  background: var(--live);
  opacity: 0.85;
}

.m-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-faint);
  line-height: 16px;
}

.m-num { font-weight: 700; color: var(--fg-dim); }
.m-num .n { color: var(--accent); }
.m-league { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-dot { opacity: 0.4; }

.m-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.m-status .mini-pulse { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: pulse 1.8s ease-out infinite; }
.m-status.live { color: var(--live); }
.m-status.ft { color: var(--fg-faint); font-weight: 600; }
.m-status.pre { color: var(--pre); font-weight: 600; }
.m-status.warn { color: #ffb020; font-weight: 600; }

.m-star {
  width: 24px; height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg-faint);
  font-size: 14px;
  opacity: 0.45;
}

.m-star.is-fav { opacity: 1; color: #ffce3a; }

.m-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.m-team {
  font-size: 16px;
  font-weight: 600;
  line-height: 21px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #dfe7f4;
}

.m-team.home { text-align: right; }
.m-team.away { text-align: left; }
.m-team.win { color: #fff; }
.m-team.lose { color: #97a2b4; }

.m-score {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
  color: #cfd8e6;
  min-width: 60px;
  justify-content: center;
}

.m-score .sep { font-size: 13px; font-weight: 500; color: var(--fg-faint); letter-spacing: 0; }
.match.is-live .m-score { color: var(--live); text-shadow: 0 0 16px rgba(255, 92, 98, 0.35); }
.match.is-pre .m-score { color: var(--fg-faint); font-weight: 600; font-size: 15px; }

.m-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--fg-faint);
  line-height: 15px;
}

.m-odds { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.m-odds i { font-style: normal; opacity: 0.75; }
.m-odds b { font-weight: 600; color: #b9c4d4; }
.m-odds b.h { color: #ff9a8b; }
.m-odds b.a { color: #8bb9ff; }
.m-kick { margin-left: auto; font-variant-numeric: tabular-nums; }

.m-extra {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease, margin 0.22s ease;
  font-size: 11.5px;
  color: var(--fg-faint);
  line-height: 17px;
}

.match.is-open .m-extra {
  max-height: 80px;
  opacity: 1;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.m-extra .row { display: flex; gap: 8px; justify-content: space-between; }
.m-extra b { color: #c3ccdb; font-weight: 600; }

.match.goal { animation: goal 1.6s ease-out; }
@keyframes goal {
  0%   { background: rgba(35, 214, 155, 0.34); }
  60%  { background: rgba(35, 214, 155, 0.10); }
  100% { background: transparent; }
}

/* ---------- 空态 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; height: 60vh; color: var(--fg-faint); font-size: 13px; text-align: center; padding: 20px;
}
.empty .big { font-size: 30px; opacity: 0.35; }
.empty button {
  margin-top: 6px; height: 34px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: 17px;
  background: rgba(255, 255, 255, 0.05); color: var(--fg);
  font-family: inherit; font-size: 13px;
}

.skeleton { padding: 8px 10px; }
.sk-row {
  height: 68px; margin: 7px 0; border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,0.035) 25%, rgba(255,255,255,0.075) 37%, rgba(255,255,255,0.035) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 状态栏 ---------- */
#statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 16px calc(env(safe-area-inset-bottom) * 0.5);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.18);
}

#statusText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#countdown { margin-left: auto; opacity: 0.8; }

/* ---------- 设置面板 ---------- */
.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(170deg, #191e27, #0b0e13);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 20;
  padding-top: env(safe-area-inset-top);
}

.panel:not([hidden]) { transform: translateY(0); }
.panel[hidden] { display: flex; }

.panel-head {
  flex: 0 0 auto;
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 18px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  font-weight: 700;
}

.panel-head .tool { margin-left: auto; }

.panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 18px calc(24px + env(safe-area-inset-bottom));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.field > span { display: flex; align-items: center; justify-content: space-between; }
.field em { font-style: normal; color: var(--accent); font-variant-numeric: tabular-nums; }

.field.row-switch { flex-direction: row; align-items: center; justify-content: space-between; }

.field select,
.field input[type="url"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #141922;
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
}

.field input[type="url"] { font-size: 13px; }

.field select:focus, .field input[type="url"]:focus { border-color: rgba(35, 214, 155, 0.5); }

.hint { font-size: 12px; line-height: 1.6; color: var(--fg-faint); }

.field input[type="range"] {
  width: 100%; height: 5px;
  -webkit-appearance: none; appearance: none;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(35, 214, 155, 0.18);
}

.switch {
  -webkit-appearance: none; appearance: none;
  position: relative;
  width: 46px; height: 27px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.18s;
  flex: 0 0 auto;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #dfe6f2;
  transition: transform 0.18s;
}

.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(19px); background: #04150f; }

.panel-tip {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.9;
  color: var(--fg-faint);
}

.panel-actions { display: flex; gap: 10px; margin-top: 18px; }

.ghost-btn {
  flex: 1 1 0;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
}

.ghost-btn:active { background: rgba(255, 255, 255, 0.1); }

.panel-version { margin-top: 14px; text-align: center; font-size: 11px; color: rgba(255, 255, 255, 0.2); }

.source-note {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  line-height: 1.65;
  color: var(--fg-faint);
}

.source-note.warn { color: #ffb020; border-color: rgba(255, 176, 32, 0.25); background: rgba(255, 176, 32, 0.06); }

.vol-row { display: flex; align-items: center; gap: 12px; }
.vol-row input[type="range"] { flex: 1 1 auto; width: auto; min-width: 0; }

.mini-btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
}

.mini-btn:active { background: rgba(35, 214, 155, 0.16); }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(48px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  max-width: 86%;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255, 92, 98, 0.94);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.toast.goal {
  background: linear-gradient(135deg, #2be3a5, #10b57f);
  color: #04160f;
  font-weight: 700;
  box-shadow: 0 8px 26px rgba(35, 214, 155, 0.38);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
