:root {
  color-scheme: dark;
  --bg: #07101f;
  --panel: rgba(15, 28, 48, .92);
  --panel-2: rgba(23, 40, 64, .9);
  --line: rgba(148, 180, 219, .22);
  --text: #f7fbff;
  --muted: #9fb1c8;
  --accent: #56d4ff;
  --accent-2: #7c5cff;
  --danger: #ff5e74;
  --success: #42d49a;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: radial-gradient(circle at 10% 0, #15345b 0, transparent 38%), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
input, select {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(4, 13, 26, .82); color: var(--text); padding: 10px 12px; font-size: 16px;
}
label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
.loading-card, .empty-card { margin: 14vh auto; max-width: 520px; padding: 28px; text-align: center; color: var(--muted); }
.shell { width: min(1180px, 100%); margin: auto; padding: 20px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.sport-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 25px; box-shadow: 0 12px 40px rgba(42, 158, 219, .3); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: clamp(22px, 4vw, 34px); }
.subtitle, .muted { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); padding: 18px; box-shadow: 0 18px 60px rgba(0, 0, 0, .18); }
.panel h2 { margin-bottom: 14px; font-size: 18px; }
.setup { max-width: 760px; margin: 7vh auto; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.primary, .secondary, .danger, .score-button, .quick-button, .sport-card {
  border: 0; border-radius: 13px; min-height: 46px; padding: 10px 14px; color: #fff; font-weight: 750;
}
.primary { background: linear-gradient(135deg, #168ed5, #6756e9); }
.secondary, .quick-button { background: #203a59; border: 1px solid rgba(151, 190, 229, .2); }
.danger { background: rgba(255, 78, 104, .18); color: #ff9aaa; border: 1px solid rgba(255, 94, 116, .32); }
.score-button { min-height: 76px; font-size: 20px; background: linear-gradient(135deg, #0d91c4, #4c5be4); }
.score-button.away { background: linear-gradient(135deg, #d05b43, #aa3f79); }
.button-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.button-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.score-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); }
.score-card.is-active { outline: 2px solid var(--accent); }
.team-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 10px; background: rgba(255,255,255,.08); }
.team-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.big-score { font-size: clamp(36px, 8vw, 58px); line-height: 1; font-variant-numeric: tabular-nums; font-weight: 900; }
.metric-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.metric { padding: 6px 9px; border-radius: 9px; background: rgba(7, 17, 32, .62); color: var(--muted); font-size: 13px; }
.metric b { color: #fff; }
.base-diamond { width: 118px; height: 82px; position: relative; margin: 16px auto 8px; }
.base { position: absolute; width: 31px; height: 31px; border: 2px solid #61758e; transform: rotate(45deg); background: #172940; }
.base.on { background: #ffd055; border-color: #fff2ad; box-shadow: 0 0 18px rgba(255,208,85,.5); }
.base[data-base="0"] { left: 72px; top: 42px; }
.base[data-base="1"] { left: 43px; top: 10px; }
.base[data-base="2"] { left: 14px; top: 42px; }
.count-row { display: flex; justify-content: center; gap: 14px; font-weight: 850; }
.dot-group { display: inline-flex; gap: 5px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #23364d; border: 1px solid #52677f; }
.dot.on.ball { background: #5bde7d; }
.dot.on.strike { background: #ffd35c; }
.dot.on.out { background: #ff6678; }
.link-list { display: grid; gap: 8px; }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.link-row input { min-width: 0; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #f7fbff; color: #0b1729; border-radius: 999px; padding: 10px 16px; font-weight: 750; transition: .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sport-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; max-width: 920px; margin: 10vh auto; }
.sport-card { min-height: 170px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; display: grid; place-items: center; gap: 6px; font-size: 20px; }
.sport-card span { font-size: 42px; }
.viewer { width: min(980px, 100%); margin: auto; padding: 24px; }
.viewer .panel { margin-top: 12vh; }
body[data-page="cast"] { background: transparent !important; overflow: hidden; }
.cast-root { position: fixed; inset: 0; pointer-events: none; background: transparent; }
.scorebug { position: absolute; width: min(720px, calc(100vw - 128px)); color: #fff; filter: drop-shadow(0 8px 20px rgba(0,0,0,.45)); }
.scorebug[data-template="top-left"] { left: 64px; top: 48px; }
.scorebug[data-template="top-right"] { right: 64px; top: 48px; }
.scorebug[data-template="bottom"] { left: 50%; bottom: 64px; transform: translateX(-50%); width: min(980px, calc(100vw - 128px)); }
.bug-head { display: flex; justify-content: space-between; gap: 18px; padding: 9px 15px; background: linear-gradient(90deg, rgba(10,28,48,.96), rgba(30,65,96,.94)); border-radius: 13px 13px 0 0; font-weight: 750; }
.bug-teams { background: rgba(6,15,27,.94); border: 1px solid rgba(170,211,247,.25); border-radius: 0 0 13px 13px; overflow: hidden; }
.bug-team { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid rgba(170,211,247,.15); }
.bug-team img { width: 30px; height: 30px; object-fit: contain; }
.bug-team strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 24px; }
.bug-score { font-size: 32px; font-weight: 950; font-variant-numeric: tabular-nums; }
.bug-meta { display: flex; flex-wrap: wrap; gap: 7px; padding: 8px 14px; background: rgba(13,32,52,.95); border-radius: 0 0 12px 12px; color: #cae4fb; }
.bug-meta span { white-space: nowrap; }
body[data-page="cast"] .scorebug[hidden] { display: none; }
@media (max-width: 720px) {
  .shell { padding-top: 12px; }
  .topbar { align-items: flex-start; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .sport-list { grid-template-columns: 1fr; margin: 4vh 16px; }
  .button-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { flex-direction: column; }
  .scorebug { width: calc(100vw - 32px); }
  .scorebug[data-template="top-left"] { left: 16px; top: 16px; }
  .scorebug[data-template="top-right"] { right: 16px; top: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
