* { box-sizing: border-box; }
html { background: #fff; }
body {
  margin: 0 auto;
  max-width: 480px;
  min-height: 100vh;
  background: #fff;
  color: #111;
  font: 16px/1.45 "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { min-height: 100vh; }
.hide { display: none !important; }

.hero {
  padding: 26px 20px 36px;
  background: linear-gradient(165deg, #0c5c34 0%, #12884a 72%, #1aa35a 100%);
  color: #fff;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
}
.hero h1 { margin: 0; font-size: 28px; letter-spacing: 0.04em; }
.hero p { margin: 6px 0 0; opacity: 0.88; }

.page { padding: 0 16px 120px; margin-top: 16px; }
.day-head { margin: 8px 4px 10px; font-size: 20px; font-weight: 700; letter-spacing: 0.02em; color: #1c2b24; }
.detail-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 0;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}
.detail-head .topbar { position: static; }
.seg {
  display: flex;
  padding: 4px 12px 0;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  min-height: 44px;
  color: #66756c;
  border-bottom: 2px solid transparent;
}
.seg button.on {
  color: #0e6b3c;
  font-weight: 700;
  border-bottom-color: #0e6b3c;
}
.topbar h1 { flex: 1; margin: 0; font-size: 18px; text-align: center; }
.icon-btn, .text-btn {
  border: 0;
  background: transparent;
  min-width: 44px;
  min-height: 44px;
  color: #0e6b3c;
}
.subpage { padding: 8px 16px 120px; }

.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.chip, .filters button, .choices button, .preset {
  border: 0;
  background: #fff;
  color: #315244;
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 1px 0 rgba(14, 107, 60, 0.06);
}
.filters button.on, .choices button.on {
  background: #0e6b3c;
  color: #fff;
}
.choices button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 4px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: #e7eee9;
}
.faces { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.faces.win .avatar { box-shadow: 0 0 0 2px #0e6b3c; }

.card, .match, .person, .rank-row {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 0;
  padding: 14px;
  margin-bottom: 10px;
}
.when { min-width: 0; color: #111; }
.datebox {
  width: 58px;
  flex: none;
  border-radius: 12px;
  background: #e7f5ec;
  color: #0e6b3c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}
.datebox strong { font-size: 22px; line-height: 1.1; }
.datebox span { font-size: 12px; }
.card-main { flex: 1; min-width: 0; }
.card h2, .card-main h2, .block h2 { margin: 0 0 4px; font-size: 17px; }
.muted { color: #66756c; font-size: 13px; }
.card-top, .row, .person, .score-line, .danger-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-top h2 { flex: 1; min-width: 0; }
.badge {
  flex: none;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e7f5ec;
  color: #0e6b3c;
}
.badge.full { background: #fff4df; color: #9a6700; }
.badge.play { background: #e7f0ff; color: #1d4f91; }
.badge.done { background: #eef1ef; color: #66756c; }

.block {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}
.block h2 { font-size: 16px; }
.kv { margin: 0; }
.kv div { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid #eef3f0; }
.kv div:first-child { border-top: 0; }
.kv dt { width: 72px; flex: none; color: #66756c; }
.kv dd { margin: 0; }

.person { padding: 10px 12px; margin-top: 8px; background: #fafafa; }
.person b { flex: 1; }
.person b.me { color: #0e6b3c; }
.tag {
  font-size: 12px;
  color: #3d6b52;
  background: #e7f5ec;
  border-radius: 999px;
  padding: 2px 8px;
}
.tag.org { color: #9a6700; background: #fff4df; }
.linkish { border: 0; background: transparent; color: #a33b32; padding: 0; }

.bout-list { display: flex; flex-direction: column; gap: 10px; }
.bout.live { cursor: pointer; }
.bout {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  border: 0;
  background: #f6f7f6;
  text-align: left;
  padding: 12px 8px;
  box-shadow: none;
  border-radius: 14px;
}
.grip {
  width: 22px;
  height: 36px;
  flex: none;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  touch-action: none;
}
.grip span {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: #9aa69f;
}
.bout.dragging {
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  border-radius: 14px;
  z-index: 30;
}
.bout-placeholder {
  border-radius: 14px;
  background: #eef6f1;
}
.bout-main {
  flex: 1;
  min-width: 0;
  margin-left: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  box-shadow: none;
}
.bout-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.bout-side .faces { flex-wrap: nowrap; justify-content: center; gap: 4px; }
.bout-side .avatar { width: 34px; height: 34px; }
.side-names { width: 100%; min-width: 0; text-align: center; }
.side-names span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.25;
  color: #243028;
}
.bout .vs {
  flex: none;
  color: #b7c0ba;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.bout-meta {
  flex: none;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding-left: 8px;
  border-left: 1px solid #e3e8e5;
}
.bout-round {
  width: auto;
  font-size: 12px;
  font-weight: 500;
  color: #8d9892;
}
.bout-court { color: #8d9892; font-size: 11px; }
.avatar-hit {
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  border-radius: 50%;
  line-height: 0;
}
.avatar-hit.on .avatar { box-shadow: 0 0 0 2px #0e6b3c; }
.court-filter {
  position: fixed;
  z-index: 9;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}
.court-filter.above-action { bottom: calc(62px + env(safe-area-inset-bottom)); }
.court-filter-label { color: #3d4f45; font-weight: 700; }
.filter-sep { color: #8aa094; }
.filter-chip { position: relative; display: inline-flex; }
.filter-chip .avatar { width: 36px; height: 36px; }
.filter-x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: #a33b32;
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  padding: 0;
  box-shadow: none;
}
.filter-spacer { height: 72px; }
.filter-spacer.tall { height: 136px; }
.bout-score {
  font-size: 15px;
  font-weight: 700;
  color: #9aa39e;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bout-score .hi { color: #e06a12; }
.bout-score .colon { font-weight: 500; color: #c5ccc8; }
.sit { margin: -6px 0 8px 58px; }

.rank-block { background: transparent; border: 0; padding: 0; }
.rank-table {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #f0f2f1;
}
.rank-head, .rank-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 58px 36px 48px;
  column-gap: 4px;
  align-items: center;
}
.rank-head {
  padding: 12px 10px 8px;
  color: #9aa39e;
  font-size: 13px;
}
.rank-head span:nth-child(n + 3) { text-align: center; }
.rank-row {
  padding: 11px 10px;
  border-top: 1px solid #f3f4f4;
}
.rank-medal { font-size: 22px; line-height: 1; text-align: center; }
.rank-no {
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  color: #243028;
}
.rank-player { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank-player .avatar { width: 36px; height: 36px; flex: none; }
.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
}
.rank-wl, .rank-diff, .pts {
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: #243028;
}
.rank-wl.hot { color: #e06a12; font-weight: 700; }
.share-shot {
  width: 100%;
  border-radius: 12px;
  display: block;
  -webkit-touch-callout: default;
}

.field { display: block; margin-bottom: 12px; }
.field span { display: block; margin-bottom: 6px; color: #3d4f45; font-size: 14px; }
input, textarea, select {
  width: 100%;
  border: 1px solid #d5e0d9;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  outline: none;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus { border-color: #0e6b3c; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { color: #66756c; font-size: 13px; margin-top: 0; }
.hint.ok { color: #0e6b3c; font-weight: 700; }

.btn, .ghost {
  border-radius: 12px;
  min-height: 46px;
  padding: 0 16px;
  border: 0;
}
.btn { background: #0e6b3c; color: #fff; width: 100%; }
.btn.rank-share {
  margin-top: 16px;
  border-radius: 999px;
  background: #ffb400;
  font-weight: 700;
}
.btn:disabled { opacity: 0.45; }
.ghost { background: #fff; color: #0e6b3c; border: 1px solid #b7d7c4; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn, .btn-row .ghost { flex: 1; }

.actionbar, .tabbar, .fab {
  position: fixed;
  width: min(480px, 100%);
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
}
.actionbar, .tabbar {
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}
.tabbar {
  display: flex;
  justify-content: center;
}
.tabbar button {
  flex: none;
  border: 0;
  background: #0e6b3c;
  color: #fff;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 28px;
  font-weight: 700;
}

.mask {
  position: fixed;
  inset: 0;
  background: rgba(18, 36, 27, 0.46);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.sheet {
  width: min(480px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.score-edit { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.score-edit span { flex: 1; }
.score-edit input { width: 84px; text-align: center; font-size: 22px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: rgba(20, 32, 26, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  z-index: 40;
  max-width: min(420px, 86%);
  text-align: center;
}
.code {
  font-size: 28px;
  letter-spacing: 0.28em;
  text-align: center;
  margin: 8px 0;
  color: #0e6b3c;
}
.empty { text-align: center; color: #66756c; padding: 28px 10px; }
.gate { padding: 48px 20px 24px; }
.gate h1 { margin-bottom: 8px; }
.danger {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.danger .linkish, .center-link {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px;
}
.score-board { display: flex; flex-direction: column; gap: 2px; }
.score-side { display: flex; align-items: center; gap: 12px; }
.score-names { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.score-person { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 16px; font-weight: 700; }
.score-vs { text-align: center; color: #66756c; padding: 4px 0; }
.score-side .wheel-frame,
.score-side .wheel { width: 108px; flex: none; }
.wheel-frame { position: relative; height: 120px; }
.wheel {
  height: 120px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-item {
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 18px;
  color: #8aa094;
  scroll-snap-align: center;
}
.wheel-item.on { color: #0e6b3c; font-size: 28px; font-weight: 700; }
.wheel-spacer { height: 40px; }
.wheel-band {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 40px;
  height: 40px;
  border-top: 1px solid #b7d7c4;
  border-bottom: 1px solid #b7d7c4;
  background: rgba(14, 107, 60, 0.06);
  border-radius: 8px;
  pointer-events: none;
}
.score-preview {
  margin: 8px 0 12px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #0e6b3c;
}
.test-box {
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed #b7d7c4;
  border-radius: 12px;
}
.test-box .btn-row { margin-top: 8px; }
.test-box .ghost { min-height: 40px; }
.form-seg { padding: 0 0 8px; }
.form-seg button { background: transparent; }
.add-one { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.add-one input { flex: 1; }
.add-one .ghost { flex: none; min-width: 72px; }
