:root {
  color-scheme: light;
  --ink: #2c1e36;
  --muted: #685c71;
  --line: #e5dce9;
  --paper: #faf7fb;
  --accent: #793a69;
  --accent-deep: #542745;
  --hk: #ffb5a3;
  --sh: #d7c5ff;
  --hk-light: #fbe5de;
  --hk-text: #853d32;
  --sh-light: #ede5fa;
  --sh-text: #563273;
  --soft: #f4eef6;
  --shadow: 0 8px 28px #3c234a0a;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 100% 0, #f7eaf4 0, transparent 510px),
    radial-gradient(ellipse at 0 24%, #f8efeb 0, transparent 490px), var(--paper);
}

button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }

:focus-visible {
  outline: 3px solid #965ab2;
  outline-offset: 3px;
}
[hidden] { display: none !important; }

header { background: #fffcff; border-bottom: 1px solid var(--line); }
.shell { width: min(100% - 36px, 960px); margin-inline: auto; }
.bar, .heading, .section-heading, .cardhead, .team, .actions, .detail-total, .bonusbox {
  display: flex;
  align-items: center;
}
.bar { height: 63px; justify-content: space-between; gap: 8px; }
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.055em;
  white-space: nowrap;
}
.brand img { border-radius: 10px; object-fit: cover; }
.brand b { color: var(--accent); }
.bar-controls { display: flex; align-items: center; gap: 12px; }
.bar-controls select {
  width: auto;
  min-height: 36px;
  padding: 5px 27px 5px 8px;
  font-size: 14px;
  border-radius: 10px;
}
#connection { font-size: 13px; color: var(--muted); white-space: nowrap; }
#connection::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #b76e3a;
}
#connection.online::before { background: #3c865c; }

main { padding-bottom: 52px; }
.heading { justify-content: space-between; gap: 12px; margin: 30px 0 18px; }
#role { color: var(--accent); font-size: 14px; font-weight: 700; }
h1 {
  margin: 3px 0 0;
  font-size: clamp(28px, 4.5vw, 44px);
  font-weight: 800;
  letter-spacing: -.048em;
  line-height: 1.12;
}
html[lang=en] .heading h1 { font-size: clamp(25px, 4.5vw, 42px); }
.heading a {
  flex: 0 0 auto;
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 650;
  text-underline-offset: 4px;
}

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #68476c;
  border-radius: 23px;
  color: #fff7ff;
  background: radial-gradient(ellipse at 93% 6%, #82577c 0, transparent 55%),
    linear-gradient(117deg, #30243f, #4a2a4c 58%, #533854);
  padding: 20px 24px 25px;
  box-shadow: 0 12px 26px #46305426;
}
.hero-title { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 750; }
.hero-title small {
  color: #f0dfed;
  border-left: 1px solid #af8ea9;
  padding-left: 9px;
  font-size: 13px;
  font-weight: 450;
}
.court {
  position: absolute;
  width: clamp(200px, 40%, 390px);
  right: clamp(-38px, 3%, 22px);
  top: -18px;
  z-index: -1;
  transform: rotate(-12deg);
  color: #f6cede;
  opacity: .22;
  pointer-events: none;
}
.court-wall {
  height: 84px;
  margin: 0 12%;
  border: 2px solid currentColor;
  background: linear-gradient(transparent 43%, currentColor 43% calc(43% + 2px), transparent calc(43% + 2px)),
    linear-gradient(transparent 80%, currentColor 80% calc(80% + 2px), transparent calc(80% + 2px));
}
.court-floor {
  position: relative;
  height: 136px;
  margin: -2px 12% 0;
  border: 2px solid currentColor;
  transform-origin: top;
  transform: perspective(155px) rotateX(43deg);
}
.court-floor::before {
  content: '';
  position: absolute;
  inset: 49% 0 0;
  border-top: 2px solid currentColor;
  background: linear-gradient(90deg, transparent calc(50% - 1px), currentColor calc(50% - 1px) calc(50% + 1px),
    transparent calc(50% + 1px));
}
.court-floor i::before, .court-floor i::after {
  content: '';
  position: absolute;
  top: calc(49% + 2px);
  width: 22%;
  height: 22%;
  border: 2px solid currentColor;
  border-top: 0;
}
.court-floor i::before { left: -2px; }
.court-floor i::after { right: -2px; }
.squash-ball {
  position: absolute;
  top: 13px;
  right: 16px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #5d5168, #261d30 62%, #1b1423);
  box-shadow: 0 2px 5px #21172d76;
  transform: rotate(-38deg);
}
.squash-ball::before, .squash-ball::after {
  content: '';
  position: absolute;
  top: 13px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #f8d46b;
}
.squash-ball::before { left: 8px; }
.squash-ball::after { left: 14px; }
.versus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.side {
  text-align: center;
  border: 1px solid #f4d8f435;
  border-radius: 15px;
  background: #fae1f310;
  padding: 11px 3px 8px;
}
.team { justify-content: center; gap: 7px; font-size: 16px; font-weight: 680; }
.team i { width: 8px; height: 8px; border-radius: 50%; background: var(--hk); }
.SH .team i { background: var(--sh); }
.side strong {
  display: block;
  color: var(--hk);
  font: 750 clamp(45px, 8vw, 78px)/1.04 "Arial Narrow", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.06em;
}
.side.SH strong { color: var(--sh); }
.side .long-score { font-size: clamp(29px, 6vw, 60px); }
.vs {
  color: #f7e4f0;
  font: 650 12px/1 Arial, sans-serif;
  letter-spacing: .06em;
}

nav {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  background: #efe8f1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin: 19px 0 15px;
}
nav:empty { display: none; }
nav button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  min-height: 38px;
  padding: 7px 12px;
}
nav button[aria-pressed=true] {
  background: #fff;
  color: var(--accent-deep);
  box-shadow: 0 1px 5px #321c4420;
}

h2 { font-size: 22px; letter-spacing: -.035em; margin: 19px 0 12px; }
h2 small { font-size: 13px; color: var(--muted); margin-left: 9px; letter-spacing: 0; font-weight: 500; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr)); gap: 14px; }
.card, .ranking, .formbox {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cardhead { background: var(--soft); padding: 12px 16px; gap: 9px; font-size: 14px; }
.cardhead span {
  background: var(--accent-deep);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 20px;
}
.scoreline { display: flex; align-items: center; gap: 10px; margin: 0 16px; min-height: 62px; }
.scoreline + .scoreline { border-top: 1px solid var(--line); }
.scoreline > b { flex: 1; font-size: 17px; line-height: 1.25; }
.scoreline strong, .rankline strong, .bonusbox strong, .detail-total strong {
  font: 700 30px/1 Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.tag { display: inline-block; padding: 5px 7px; border-radius: 6px; font: 700 13px/1 Arial, sans-serif; }
.tag.HK, .add.HK { background: var(--hk-light); color: var(--hk-text); }
.tag.SH, .add.SH { background: var(--sh-light); color: var(--sh-text); }
.add { font-size: 21px; font-weight: 750; min-width: 53px; min-height: 44px; border: 0; border-radius: 10px; }
.actions { gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--line); }
.actions button, .primary {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 14px;
  min-height: 42px;
  padding: 8px 12px;
}
.actions .finish { margin-left: auto; background: var(--soft); color: var(--accent-deep); }
.actions .primary, .primary { color: white; background: var(--accent-deep); border-color: var(--accent-deep); font-weight: 700; }
.empty { padding: 15px 0; color: var(--muted); }

.section-heading { justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; }
.section-heading select { width: auto; min-height: 39px; }
.rankline {
  width: 100%;
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 17px;
  background: white;
  border: 0;
  text-align: left;
}
.rankline + .rankline { border-top: 1px solid var(--line); }
.rankhead { background: var(--soft); font-size: 13px; font-weight: 650; color: var(--muted); }
.ranknum { font: 700 20px Arial, sans-serif; }
.ranknum small, .identity small { font: 400 12px/1.55 system-ui, sans-serif; color: var(--muted); }
.ranknum small { margin-left: 3px; }
.identity small { display: block; }
.rankline strong { font-size: 22px; }

.formbox { max-width: 560px; padding: 18px; display: grid; gap: 15px; }
.formbox label { display: grid; gap: 6px; font-size: 14px; font-weight: 650; }
.formbox .actions { padding: 12px 0 0; }
.formbox .actions button { flex: 1; }
.bonusbox, .detail-total { justify-content: space-between; }
.bonusbox { padding: 10px 0; }
.formbox input, select {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #cdbed5;
  border-radius: 9px;
  background: white;
  width: 100%;
  font-size: 16px;
}
select {
  appearance: none;
  padding-right: 29px;
  background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 14px) 51%/5px 5px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 9px) 51%/5px 5px no-repeat, #fff;
}

dialog {
  width: min(92%, 412px);
  max-height: 85dvh;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 19px;
  padding: 24px;
  box-shadow: 0 18px 80px #25122e66;
}
dialog::backdrop { background: #35214470; }
#close {
  position: absolute;
  right: 10px;
  top: 10px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  width: 40px;
  height: 40px;
  font-size: 24px;
}
dialog h2 { margin: 12px 0 3px; }
dialog p { margin: 0; font-size: 14px; color: var(--muted); }
h3 { font-size: 15px; margin: 19px 0 7px; }
.cells { display: flex; gap: 5px; }
.cells div { flex: 1; background: var(--soft); text-align: center; padding: 8px 2px; border-radius: 6px; font-size: 12px; }
.cells b { display: block; font-size: 19px; margin-top: 3px; }
.detail-total { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; font-weight: 700; }
#message:not(:empty) {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 90%;
  padding: 10px 16px;
  background: var(--accent-deep);
  color: white;
  border-radius: 9px;
  z-index: 3;
}

@media (max-width: 480px) {
  .shell { width: calc(100% - 28px); }
  .bar { height: 54px; }
  .bar-controls { gap: 8px; }
  .brand { gap: 6px; font-size: 20px; }
  .brand img { width: 30px; height: 30px; }
  .heading { margin: 20px 0 14px; }
  .hero { padding: 15px 13px 16px; border-radius: 18px; }
  .versus { gap: 8px; margin-top: 12px; }
  .team { font-size: 14px; }
  nav button { padding-inline: 8px; }
  .cardhead { padding: 10px 13px; }
  .scoreline { margin: 0 13px; }
  .card .actions { gap: 6px; padding-inline: 12px; }
  .card .actions button { padding-inline: 9px; font-size: 13px; }
  .rankline { padding-inline: 13px; gap: 6px; }
}
