/* 字体全部自托管，不依赖 Google Fonts（大陆打不开）。中文用系统自带黑体。 */
@font-face { font-family: 'Bebas Neue'; font-weight: 400; font-display: swap; src: url(vendor/bebas-neue-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Oswald'; font-weight: 500; font-display: swap; src: url(vendor/oswald-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Oswald'; font-weight: 700; font-display: swap; src: url(vendor/oswald-latin-700-normal.woff2) format('woff2'); }

:root {
  --cn: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', 'Source Han Sans SC', 'Heiti SC', sans-serif;
  --bg: #0a0a0b;
  --panel: #131315;
  --panel2: #1c1c20;
  --line: #2c2c33;
  --text: #ecebe7;
  --dim: #85858f;
  --red: #ff3b1f;
  --red-dark: #b3200b;
  --yellow: #f5b700;
  --ok: #7cff4f;
  --cut: 14px;
  --display: 'Bebas Neue', 'Oswald', var(--cn);
  --num: 'Oswald', var(--cn);
  --body: var(--cn);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: hidden; }
button, a, input, select, label { touch-action: manipulation; }
body {
  margin: 0;
  color: var(--text);
  font: 500 15px/1.5 var(--body);
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(255, 59, 31, .16), transparent 70%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.018) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.018) 0 2px, transparent 2px 7px),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.hazard {
  height: 8px;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 12px, #111 12px 24px);
}

.top {
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 16px 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.logo {
  font: 400 52px/0.9 var(--display);
  letter-spacing: 2px;
  transform: skewX(-8deg);
}
.logo em { font-style: normal; color: var(--red); text-shadow: 0 0 24px rgba(255,59,31,.45); }
.slogan { font-weight: 900; color: var(--dim); letter-spacing: 2px; font-size: 13px; }
.slogan b { color: var(--yellow); font-family: var(--num); }

main { max-width: 920px; margin: 0 auto; padding: 8px 16px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }

.card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  padding: 18px 16px 20px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  position: relative;
}
.card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--red);
}

h2 {
  margin: 0 0 14px;
  font-weight: 900;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 1px;
}
h2 i {
  font: 400 20px/1 var(--display);
  background: var(--red);
  color: #000;
  padding: 4px 7px 2px;
  font-style: normal;
  transform: skewX(-10deg);
}
h2 small { font: 400 16px var(--display); color: var(--dim); letter-spacing: 2px; margin-left: auto; }

/* members */
.members { display: flex; flex-wrap: wrap; gap: 10px; }
.member {
  flex: 1 1 140px;
  min-width: 0;
  text-align: left;
  background: #0d0d0f;
  border: 2px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 2px;
  transition: border-color .15s, transform .15s;
}
.member:hover { transform: translateY(-1px); }
.member .nm { font-weight: 900; font-size: 18px; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .dot { width: 10px; height: 10px; flex: none; transform: rotate(45deg); }
.member .big3 { font: 500 12px var(--num); color: var(--dim); letter-spacing: 1px; }
.member .big3 b { color: var(--text); font-size: 16px; }
.member .big3 em { font-style: normal; color: var(--yellow); font-family: var(--cn); font-weight: 700; }
.member.on { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c), 0 0 22px -6px var(--c); }
.member.on .nm::after { content: 'ME'; font: 400 13px var(--display); background: var(--c); color: #000; padding: 1px 5px 0; margin-left: auto; }
.member.add { flex: 0 0 auto; place-items: center; color: var(--dim); border-style: dashed; font-weight: 900; min-width: 90px; }
.member.add:hover { color: var(--text); border-color: var(--dim); }

.session {
  margin-top: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--dim); font-weight: 700;
}
.session span { flex: 1 1 auto; }
.session b { font-weight: 900; }
.session button { border: 1px solid var(--line); background: #0d0d0f; color: var(--text); padding: 5px 10px; font-weight: 900; font-size: 13px; }
.session button:hover { border-color: var(--dim); }

.dev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dev-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #0d0d0f; border: 1px solid var(--line); padding: 10px; }
.dev-list b { font-weight: 900; }
.dev-list i { font-style: normal; font: 400 13px var(--display); background: var(--ok); color: #000; padding: 1px 5px 0; margin-left: 8px; letter-spacing: 1px; }
.dev-list small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }
.dev-list button { flex: none; border: 1px solid var(--red); background: transparent; color: var(--red); padding: 5px 10px; font-weight: 900; }

/* 内卷 */
.alert {
  padding: 12px 14px 12px 16px;
  font-weight: 700;
  font-size: 15px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--dim);
}
.alert b { font-weight: 900; }
.alert.alarm {
  border-color: var(--red);
  background: repeating-linear-gradient(-45deg, rgba(255,59,31,.16) 0 12px, rgba(255,59,31,.06) 12px 24px), var(--panel2);
  animation: alarm 1.6s ease-in-out 3;
}
.alert.alarm b { color: var(--red); }
.alert.win { border-color: var(--yellow); background: rgba(245,183,0,.1); }
.alert.win b { color: var(--yellow); }
@keyframes alarm { 50% { box-shadow: 0 0 0 3px rgba(255,59,31,.5); } }

.juan-tip { margin: -6px 0 10px; color: var(--dim); font-size: 13px; font-weight: 700; }
.juan-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.juan-list li { display: grid; grid-template-columns: minmax(70px, 30%) 1fr auto; align-items: center; gap: 10px; }
.juan-list .jn { font-weight: 900; font-size: 16px; display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.juan-list .jn i { font-style: normal; font-size: 11px; background: var(--yellow); color: #000; padding: 1px 5px; flex: none; }
.juan-list .jbar { height: 14px; background: #0d0d0f; border: 1px solid var(--line); }
.juan-list .jbar span { display: block; height: 100%; background: var(--c); min-width: 2px; transition: width .4s; }
.juan-list .jc { font: 500 13px var(--num); color: var(--dim); text-align: right; white-space: nowrap; }
.juan-list .jc b { font-size: 22px; color: var(--text); }
.juan-list .jc small { display: block; font-size: 11px; }
.juan-list .none { display: block; color: var(--dim); }
.history .juan { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 900; color: var(--yellow); border: 1px solid var(--yellow); padding: 0 4px; vertical-align: 1px; }

/* exercise grid */
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin-bottom: 18px; }
.ex {
  background: #0d0d0f;
  border: 1px solid var(--line);
  padding: 9px 10px 8px;
  text-align: left;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  display: grid;
  gap: 1px;
  transition: background .15s, border-color .15s;
}
.ex:hover { border-color: #555; }
.ex .n { font-weight: 900; font-size: 15px; }
.ex .e { font: 400 13px var(--display); color: var(--dim); letter-spacing: 1px; }
.ex .pr { font: 500 12px var(--num); color: var(--yellow); min-height: 18px; }
.ex.on { background: var(--red); border-color: var(--red); color: #000; }
.ex.on .e, .ex.on .pr { color: rgba(0,0,0,.7); }
.ex.egg .n::after { content: ' ∞'; color: var(--yellow); }
.ex.egg.on .n::after { color: #000; }

/* form */
.ex-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.ex-name { font-weight: 900; font-size: 30px; line-height: 1.1; }
.ex-en { font: 400 18px var(--display); color: var(--red); letter-spacing: 3px; }
.rule {
  font-weight: 900;
  font-size: 13px;
  padding: 6px 10px;
  border: 2px solid var(--yellow);
  color: var(--yellow);
  letter-spacing: 1px;
}
.rule:empty { display: none; }
.rule.bad { border-color: var(--red); color: #fff; background: var(--red); }

.seg-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; border: 2px solid var(--line); background: #0d0d0f; }
.seg button { border: 0; background: transparent; padding: 8px 16px; font-weight: 900; color: var(--dim); letter-spacing: 1px; }
.seg button.on { background: var(--text); color: #000; }
.seg.small button { padding: 6px 12px; font-size: 13px; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.f { display: grid; gap: 6px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f > span { font-size: 12px; font-weight: 700; color: var(--dim); letter-spacing: 1px; }
.f input, select {
  width: 100%;
  font-size: 16px; /* <16px 时 iPhone 聚焦会自动放大页面 */
  -webkit-appearance: none;
  appearance: none;
  background: #0b0b0d;
  border: 2px solid var(--line);
  padding: 10px 12px;
  border-radius: 0;
  outline: none;
  min-width: 0;
}
.f input:focus, select:focus { border-color: var(--red); }
.f input[type=date] { color-scheme: dark; font-family: var(--num); min-height: 48px; text-align: left; }
.f input[type=date]::-webkit-date-and-time-value { text-align: left; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(-45deg, transparent 50%, var(--dim) 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.unit-input { position: relative; }
.unit-input input, .stepper input { font: 700 26px var(--num); padding: 6px 12px; }
.unit-input input { padding-right: 52px; }
.unit-input .u { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 400 18px var(--display); color: var(--dim); letter-spacing: 1px; pointer-events: none; }
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; }
.stepper input { text-align: center; border-left: 0; border-right: 0; }
.stepper button { border: 2px solid var(--line); background: #222227; font: 700 24px var(--num); }
.stepper button:active { background: var(--red); color: #000; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.infinite {
  display: flex; align-items: center; gap: 18px;
  border: 2px dashed var(--yellow);
  padding: 4px 18px;
  margin-bottom: 14px;
  background: rgba(245,183,0,.06);
}
.inf-sym { font: 700 84px/1 var(--num); color: var(--yellow); text-shadow: 0 0 30px rgba(245,183,0,.5); animation: pulse 2.2s ease-in-out infinite; }
.inf-txt { font-weight: 900; font-size: 17px; }
.inf-txt span { font: 400 15px var(--display); color: var(--dim); letter-spacing: 2px; }
@keyframes pulse { 50% { transform: scale(1.08); text-shadow: 0 0 46px rgba(245,183,0,.8); } }

.preview {
  margin: 16px 0 12px;
  padding: 12px 14px;
  background: #0b0b0d;
  border-left: 4px solid var(--red);
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.preview .big { font: 700 40px/1 var(--num); }
.preview .big small { font: 400 22px var(--display); color: var(--red); margin-left: 4px; letter-spacing: 1px; }
.preview .formula { font: 500 14px var(--num); color: var(--dim); letter-spacing: .5px; }
.preview .warn { color: var(--red); font-weight: 900; }
.preview .dim { color: var(--dim); font-weight: 700; }

.go {
  width: 100%;
  border: 0;
  background: var(--red);
  color: #000;
  font: 400 26px var(--display);
  letter-spacing: 3px;
  padding: 14px 10px 11px;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  transition: filter .15s, transform .1s;
}
.go:hover { filter: brightness(1.12); }
.go:active { transform: scale(.985); }
.go:disabled { background: #34343a; color: #6b6b73; cursor: not-allowed; }

/* board */
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.board { width: 100%; border-collapse: collapse; }
.board th:first-child, .board td:first-child { position: sticky; left: 0; background: #17171a; z-index: 1; }
.board th, .board td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.board th:first-child, .board td:first-child { text-align: left; }
.board thead th { font-weight: 900; font-size: 14px; border-bottom: 2px solid var(--text); }
.board thead th span { display: inline-block; width: 8px; height: 8px; transform: rotate(45deg); margin-right: 6px; vertical-align: middle; }
.board td:first-child { font-weight: 900; }
.board td:first-child small { display: block; font: 400 12px var(--display); color: var(--dim); letter-spacing: 1px; }
.board td { font: 700 18px var(--num); }
.board td .r { font-size: 12px; color: var(--dim); font-weight: 500; }
.board td.empty { color: #444; }
.board td.king { color: var(--yellow); }
.board td.king::before { content: '👑 '; font-size: 14px; }
.board tr.total td { border-top: 2px solid var(--red); border-bottom: 0; }

/* chart */
.chart-ctrl { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: stretch; }
.chart-ctrl select { flex: 1 1 160px; width: auto; font-weight: 700; }
.chart-box { position: relative; height: 320px; }
.chart-empty { position: absolute; inset: 0; display: none; place-items: center; text-align: center; color: var(--dim); font-weight: 900; font-size: 18px; }
.chart-empty.show { display: grid; }
.chart-empty .inf-sym { font-size: 120px; }

/* history */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: #0d0d0f;
  border: 1px solid var(--line);
  border-left: 4px solid var(--c);
  padding: 8px 10px;
}
.history .d { font: 500 13px var(--num); color: var(--dim); line-height: 1.25; text-align: center; }
.history .d b { display: block; font-size: 18px; color: var(--text); }
.history .who { min-width: 0; }
.history .who b { font-weight: 900; }
.history .who .x { color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .w { font: 700 20px var(--num); text-align: right; white-space: nowrap; }
.history .w small { font-size: 12px; color: var(--dim); font-weight: 500; display: block; }
.history .del { border: 0; background: transparent; color: #555; font-size: 20px; padding: 4px 6px; }
.history .del:hover { color: var(--red); }
.history .none { grid-template-columns: 1fr; text-align: center; color: var(--dim); border-left-color: var(--line); padding: 20px; }

.more { display: block; width: 100%; margin-top: 10px; padding: 12px; background: transparent; border: 2px dashed var(--line); color: var(--dim); font-weight: 900; letter-spacing: 2px; }
.more:hover { color: var(--text); border-color: var(--dim); }

.foot { text-align: center; padding: 10px 16px 40px; font: 400 16px var(--display); letter-spacing: 4px; color: #44444b; }

/* dialogs */
dialog {
  border: 2px solid var(--red);
  background: var(--panel2);
  color: var(--text);
  padding: 20px;
  width: min(360px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.75); }
dialog h3 { margin: 0 0 10px; font-weight: 900; font-size: 22px; }
dialog p { margin: 0 0 12px; color: var(--dim); }
dialog .riddle { color: var(--text); font-weight: 900; font-size: 17px; border-left: 3px solid var(--yellow); padding-left: 10px; }
dialog .pass-err { color: var(--red); font-weight: 900; margin: 10px 0 0; }
dialog input + input, dialog #pin2Row { margin-top: 10px; }
dialog input.pin { font-family: var(--num); letter-spacing: 6px; font-size: 22px; }
dialog input.pin::placeholder { letter-spacing: 1px; font-size: 16px; font-family: var(--cn); }
dialog input { width: 100%; -webkit-appearance: none; border-radius: 0; background: #0b0b0d; border: 2px solid var(--line); padding: 10px 12px; font-size: 18px; font-weight: 700; outline: none; }
dialog input:focus { border-color: var(--red); }
.dlg-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.dlg-btns button { border: 2px solid var(--line); background: transparent; padding: 8px 18px; font-weight: 900; }
.dlg-btns .primary { background: var(--red); border-color: var(--red); color: #000; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 10;
  transform: translate(-50%, calc(100% + 80px));
  visibility: hidden;
  background: var(--text); color: #000;
  font-weight: 900; padding: 12px 20px;
  max-width: calc(100vw - 32px);
  transition: transform .25s, visibility .25s;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.pr { background: var(--yellow); font-size: 18px; letter-spacing: 1px; }
.toast.err { background: var(--red); }

[hidden] { display: none !important; }

@media (max-width: 520px) {
  .top { padding-top: 16px; }
  .logo { font-size: 44px; }
  .slogan { font-size: 12px; }
  main { padding-left: 12px; padding-right: 12px; gap: 14px; }
  .card { padding: 16px 12px 18px 14px; }
  h2 { font-size: 20px; }
  h2 small { font-size: 14px; letter-spacing: 1px; white-space: nowrap; }
  .member { flex-basis: calc(50% - 5px); padding: 8px 10px; }
  .member .nm { font-size: 16px; }
  .member.add { flex-basis: 100%; min-height: 40px; padding: 6px; }
  /* 动作：三列紧凑，隐藏英文名，减少滑动 */
  .ex-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .ex { padding: 8px 7px 6px; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%); }
  .ex .n { font-size: 14px; line-height: 1.25; }
  .ex .e { display: none; }
  .ex { min-height: 54px; align-content: start; }
  .ex .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ex .pr { font-size: 11px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ex .pr:empty { display: none; }
  .inf-txt { font-size: 15px; }
  .inf-txt span { font-size: 13px; }
  .ex-name { font-size: 24px; }
  .ex-en { font-size: 16px; }
  .rule { font-size: 12px; padding: 4px 8px; }
  .seg-row { display: grid; grid-template-columns: auto 1fr; }
  .seg button { padding: 9px 12px; }
  #segMode { display: grid; grid-template-columns: 1fr 1fr; }
  .fields { grid-template-columns: 1fr 1fr; gap: 10px; }
  .unit-input input, .stepper input { font-size: 24px; }
  .stepper { grid-template-columns: 40px 1fr 40px; }
  .preview .big { font-size: 34px; }
  .go { font-size: 24px; padding: 14px 10px 11px; }
  .board th, .board td { padding: 8px 5px; }
  .board td { font-size: 16px; }
  .board thead th { font-size: 13px; }
  .board td:first-child { font-size: 14px; }
  .board td:first-child small { display: none; }
  .board td.king::before { font-size: 11px; }
  .chart-box { height: 260px; }
  .history li { grid-template-columns: auto 1fr auto; }
  .history .del { grid-column: 3; grid-row: 1; align-self: start; }
  .history .w { grid-column: 2 / 4; text-align: left; }
  .inf-sym { font-size: 64px; }
}
