:root {
  --bg: #070b10;
  --panel: #0c131b;
  --panel-2: #101a24;
  --line: #263746;
  --line-soft: #1a2833;
  --text: #e7eef3;
  --muted: #8294a3;
  --gold: #e4c46d;
  --gold-dim: #9f8746;
  --blue: #5ab3ff;
  --blue-dim: #1d4a73;
  --red: #ff7268;
  --red-dim: #6e2a27;
  --green: #58d68d;
  --font: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { overflow: hidden; }

#app {
  width: 100vw;
  height: 100vh;
  min-width: 1280px;
  min-height: 720px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(49, 104, 146, .18), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(228, 196, 109, .06), transparent 70%),
    #070b10;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: 0 0 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 22, 30, .98), rgba(8, 13, 18, .98));
  box-shadow: 0 2px 18px rgba(0, 0, 0, .45);
}
.brand { min-width: 0; }
.logo {
  font-size: 10px;
  letter-spacing: 3px;
  font-weight: 900;
  color: var(--gold);
  white-space: nowrap;
}
.logo span { color: var(--muted); font-weight: 700; letter-spacing: 2px; }
.brand h1 {
  margin: 3px 0 1px;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: .5px;
  outline: none;
  white-space: nowrap;
}
.brand h1:empty::before { content: "赛事名称"; color: #53616c; }
.subtitle {
  font-size: 11px;
  color: var(--muted);
  outline: none;
  white-space: nowrap;
}
.toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar button {
  border: 1px solid #2c3e4c;
  background: linear-gradient(#17242e, #0e171e);
  color: #cfdae2;
  border-radius: 4px;
  padding: 7px 10px;
  font: 700 11px var(--font);
  cursor: pointer;
  white-space: nowrap;
}
.toolbar button:hover { border-color: var(--gold-dim); color: #fff; }
.toolbar button.gold { border-color: #7f6a36; color: var(--gold); }
.toolbar button.danger:hover { border-color: #a3443e; color: #ff9b92; }
#save-status { font-size: 10px; color: #6e7f8c; width: 64px; text-align: right; }

/* ---------------- 主区域 ---------------- */
main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 12px;
  padding: 12px;
}
.groups-area { min-height: 0; display: flex; flex-direction: column; gap: 10px; }

.panel-head {
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .018);
}
.panel-head > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.panel-title { font-size: 14px; font-weight: 900; letter-spacing: 1px; }
.panel-hint { font-size: 10px; color: var(--muted); white-space: nowrap; }
.group-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 3px;
  font: 900 11px var(--font);
  letter-spacing: 1px;
}
.group-badge.blue { color: #dff2ff; background: var(--blue-dim); border: 1px solid #2d6c9e; }
.group-badge.red { color: #ffe9e6; background: var(--red-dim); border: 1px solid #98443e; }
.playoff-badge {
  padding: 3px 7px;
  border-radius: 3px;
  color: #1a1509;
  background: linear-gradient(#f0d486, #c9a64f);
  font: 900 10px var(--font);
  letter-spacing: 1px;
}

.group-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #293947;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(16, 27, 36, .97), rgba(8, 13, 18, .98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03), 0 6px 22px rgba(0, 0, 0, .28);
  overflow: hidden;
}
.group-panel[data-group="A"] { border-top: 2px solid #2c6a99; }
.group-panel[data-group="B"] { border-top: 2px solid #8d3d37; }

.group-bracket {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 7px;
  padding: 7px 9px 8px;
  overflow: hidden;
}
.lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.lines path { fill: none; stroke: #32485a; stroke-width: 1.2; }
.lines path.dashed { stroke: #5d4d2e; stroke-dasharray: 4 4; }

.round { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.round-title {
  flex: 0 0 18px;
  text-align: center;
  font-size: 9px;
  letter-spacing: .5px;
  color: #7f919f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.round-matches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 5px; }

.match {
  border: 1px solid #2d4050;
  border-radius: 3px;
  background: linear-gradient(180deg, #14222d, #0d161e);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
  overflow: hidden;
}
.match.is-final { border-color: var(--gold-dim); background: linear-gradient(180deg, #1c2019, #0f130d); }
.match.is-lower { border-color: #453b2b; }
.match-label {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 4px;
  color: #728493;
  background: rgba(255, 255, 255, .025);
  border-bottom: 1px solid rgba(255, 255, 255, .045);
  font-size: 8px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
}
.match-label b { color: var(--gold); font-weight: 800; }
.match-row {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 19px;
  padding: 0 4px;
  border-bottom: 1px solid rgba(255, 255, 255, .035);
}
.match-row:last-child { border-bottom: none; }
.match-row.winner { background: linear-gradient(90deg, rgba(228, 196, 109, .16), transparent); }
.match-row.winner .name { color: #ffe9a7; font-weight: 900; }
.match-row.winner .score { color: #ffe9a7; }

.name {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  cursor: text;
}
.name:empty::before { content: attr(data-placeholder); color: #516472; font-weight: 500; }
.score {
  flex: 0 0 20px;
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  color: #aab8c2;
  outline: none;
  cursor: text;
}
.outcome {
  padding: 2px 4px;
  border-top: 1px solid rgba(228, 196, 109, .2);
  color: #b79f60;
  font-size: 8px;
  text-align: center;
  white-space: nowrap;
}

/* ---------------- 季后赛 ---------------- */
.playoffs-area {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #354354;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(18, 25, 33, .98), rgba(8, 12, 16, .99));
  box-shadow: inset 0 0 0 1px rgba(228, 196, 109, .04), 0 6px 26px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.playoffs-area > .panel-head { border-bottom-color: #3b4654; }
.playoff-bracket {
  position: relative;
  flex: 1;
  min-height: 250px;
  display: flex;
  gap: 9px;
  padding: 12px 12px 6px;
}
.po-round { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.po-title { flex: 0 0 17px; text-align: center; font-size: 9px; color: #8e9ca8; letter-spacing: .5px; }
.po-matches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 8px; }
.po-match {
  border: 1px solid #334656;
  border-radius: 4px;
  background: linear-gradient(180deg, #16242f, #0d161e);
  overflow: hidden;
}
.po-match.qf { border-color: #355d7a; }
.po-match.sf { border-color: #6f5a2f; }
.po-match.final { border-color: var(--gold); box-shadow: 0 0 16px rgba(228, 196, 109, .12); }
.po-match .match-row { height: 22px; gap: 4px; }
.po-match .name { font-size: 12px; }
.po-match .score { font-size: 12px; }
.po-match .match-label { font-size: 9px; padding: 3px 5px; }
.po-connect-note { font-size: 9px; color: #6c7d89; text-align: center; margin-top: 3px; }

/* ---------------- 地图与提示 ---------------- */
.map-rules {
  flex: 0 0 auto;
  margin: 0 12px 8px;
  border: 1px solid #2c3b48;
  border-radius: 4px;
  background: rgba(0, 0, 0, .22);
  overflow: hidden;
}
.map-title {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 900;
  color: var(--gold);
  border-bottom: 1px solid #2c3b48;
  display: flex;
  justify-content: space-between;
}
.map-title span { color: var(--muted); font-size: 9px; font-weight: 500; }
.map-row {
  display: grid;
  grid-template-columns: 38px 64px 1fr 1fr;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-bottom: 1px solid rgba(255, 255, 255, .045);
  font-size: 10px;
  color: #aab8c2;
}
.map-row:last-child { border-bottom: none; }
.map-row.map-head { padding: 3px 7px; color: #637582; font-size: 9px; background: rgba(255, 255, 255, .02); }
.map-row b { color: #dbe5eb; }
.map-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid #2b3b47;
  border-radius: 3px;
  background: #0b1319;
  color: #e7eef3;
  font: 600 10px var(--font);
  padding: 4px 5px;
  outline: none;
}
.map-row input:focus { border-color: var(--gold-dim); }
.map-row input::placeholder { color: #4f616e; }
.tips {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px 10px;
  color: #667985;
  font-size: 9px;
}

/* ---------------- 其他 ---------------- */
[contenteditable="true"] { caret-color: var(--gold); }
[contenteditable="true"]:focus, input:focus { outline: 1px solid rgba(228, 196, 109, .55); outline-offset: 1px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  padding: 8px 14px;
  border: 1px solid #4a5b3f;
  border-radius: 4px;
  background: rgba(10, 16, 11, .95);
  color: #e9f2d9;
  font-size: 12px;
  transition: .18s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1500px) {
  main { grid-template-columns: minmax(0, 1fr) 450px; gap: 9px; padding: 9px; }
  .group-bracket { gap: 5px; padding: 5px 6px; }
  .name { font-size: 10px; }
  .score { font-size: 10px; }
  .panel-hint { display: none; }
  .toolbar button { padding: 6px 8px; font-size: 10px; }
  #save-status { display: none; }
}

@media (max-width: 1280px) {
  main { grid-template-columns: minmax(0, 1fr) 380px; }
  .brand h1 { font-size: 20px; }
  .logo { font-size: 9px; }
}

@media print {
  @page { size: A4 landscape; margin: 6mm; }
  html, body { background: #070b10 !important; }
  body { overflow: visible; }
  #app { width: 100%; height: auto; min-width: 0; min-height: 0; }
  .topbar { height: auto; padding: 4px 0 8px; border-bottom: 1px solid #263746; }
  .toolbar, .toast, .tips { display: none !important; }
  main { padding: 0; gap: 6px; grid-template-columns: minmax(0, 1fr) 360px; }
  .groups-area { gap: 6px; }
  .group-panel { break-inside: avoid; }
  .group-bracket { min-height: 190px; }
  .panel-head { min-height: 24px; }
  .name, .score, input { color: #e7eef3 !important; }
  .playoff-bracket { min-height: 200px; }
}
