:root {
  --paper: #f7f3ec;
  --paper-deep: #eee7dc;
  --ink: #172033;
  --muted: #687083;
  --line: rgba(23, 32, 51, 0.12);
  --white: #fffdf9;
  --red: #d94b3f;
  --red-dark: #a92d26;
  --blue: #2f6fd0;
  --blue-dark: #174b9f;
  --gold: #a66a16;
  --shadow: 0 24px 70px rgba(55, 43, 28, 0.11);
  color-scheme: light;
  font-family:
    "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(217, 75, 63, 0.11), transparent 28rem),
    radial-gradient(circle at 95% 8%, rgba(47, 111, 208, 0.12), transparent 26rem),
    linear-gradient(180deg, #faf7f1 0%, var(--paper) 58%, #f2ede4 100%);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--blue-dark);
  text-underline-offset: 3px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0 36px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  padding: 18px 8px 42px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 18px;
  font-family: "STSong", "Songti SC", "Microsoft YaHei", serif;
  font-size: clamp(2.5rem, 7vw, 5.3rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.hero-description {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.75;
}

.hero-mark {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  margin-top: 18px;
  transform: rotate(5deg);
}

.mark-ball {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  color: white;
  font-family: "STSong", "Songti SC", serif;
  font-size: 1.5rem;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(23, 32, 51, 0.17);
}

.mark-red {
  background: var(--red);
}

.mark-blue {
  margin-top: 20px;
  background: var(--blue);
}

.control-panel,
.results-section,
.method-note {
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  background: rgba(255, 253, 249, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.control-panel {
  padding: clamp(22px, 4vw, 36px);
}

.control-heading,
.section-heading,
.form-actions,
.method-note-title,
.ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.control-heading {
  margin-bottom: 24px;
}

.control-heading h2,
.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #edf3ec;
  color: #386246;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-pill.is-loading {
  background: #eef2f8;
  color: var(--blue-dark);
}

.status-pill.is-warning {
  background: #fff4de;
  color: #8a5d13;
}

.status-pill.is-error {
  background: #fdecea;
  color: var(--red-dark);
}

.candidate-form {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  align-items: end;
  gap: 26px;
}

.count-field {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.number-stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.number-stepper button {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
}

.number-stepper input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  appearance: textfield;
}

.number-stepper input::-webkit-inner-spin-button {
  appearance: none;
}

.field-hint {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.form-actions {
  justify-content: flex-start;
}

.button {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.number-stepper button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgba(47, 111, 208, 0.28);
  outline-offset: 3px;
}

.button:disabled,
.number-stepper button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button-primary {
  background: var(--ink);
  color: white;
  box-shadow: 0 10px 22px rgba(23, 32, 51, 0.16);
}

.button-primary:hover:not(:disabled) {
  background: #0c1322;
}

.button-secondary {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.data-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 24px 0 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 253, 249, 0.72);
}

.data-item {
  display: grid;
  gap: 6px;
  padding: 18px 22px;
  border-right: 1px solid var(--line);
}

.data-item:last-child {
  border-right: 0;
}

.data-item span {
  color: var(--muted);
  font-size: 0.75rem;
}

.data-item strong {
  overflow: hidden;
  font-size: 1.08rem;
  text-overflow: ellipsis;
  white-space: pre-line;
}

.results-section {
  padding: clamp(24px, 4vw, 40px);
}

.section-heading {
  align-items: end;
  margin-bottom: 24px;
}

.result-summary {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.ticket-grid,
.loading-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ticket-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.96), rgba(249, 246, 240, 0.9));
  animation: rise-in 350ms ease both;
}

.ticket-card::after {
  position: absolute;
  right: -26px;
  bottom: -34px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(217, 75, 63, 0.05);
  content: "";
}

.ticket-header {
  position: relative;
  z-index: 1;
  margin-bottom: 18px;
}

.ticket-rank {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.ticket-score {
  color: var(--muted);
  font-size: 0.72rem;
}

.ball-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ball {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  color: white;
  font-size: 1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 15px rgba(23, 32, 51, 0.16);
}

.ball-red {
  background: var(--red);
}

.ball-blue {
  background: var(--blue);
}

.blue-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 3px;
}

.ball-plus {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

.skeleton {
  height: 128px;
  border-radius: 20px;
  background: linear-gradient(100deg, #eee9e1 25%, #f8f5f0 45%, #eee9e1 65%);
  background-size: 220% 100%;
  animation: shimmer 1.25s infinite linear;
}

.message-card {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
  padding: 17px 18px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.error-card {
  border: 1px solid rgba(169, 45, 38, 0.2);
  background: #fdf0ee;
  color: var(--red-dark);
}

.warning-card {
  border: 1px solid rgba(166, 106, 22, 0.22);
  background: #fff6e7;
  color: #785015;
}

.text-button {
  width: fit-content;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.method-note {
  display: grid;
  grid-template-columns: minmax(110px, 0.28fr) 1fr;
  gap: 8px 24px;
  margin-top: 24px;
  padding: 24px 28px;
  box-shadow: none;
}

.method-note-title {
  align-self: start;
  justify-content: flex-start;
  color: var(--ink);
  font-size: 0.86rem;
}

.method-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(166, 106, 22, 0.12);
}

.method-note p {
  grid-column: 2;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}

.backtest-summary {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.site-footer {
  display: grid;
  gap: 3px;
  padding: 30px 8px 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

.site-footer p {
  margin-bottom: 0;
}

[hidden] {
  display: none !important;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 22px, 680px);
    padding-top: 24px;
  }

  .hero {
    padding-bottom: 28px;
  }

  .hero-mark {
    display: none;
  }

  h1 {
    font-size: clamp(2.15rem, 9.4vw, 3.1rem);
  }

  .control-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .candidate-form {
    grid-template-columns: 1fr;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .button {
    padding: 0 14px;
  }

  .data-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .data-item:nth-child(2) {
    border-right: 0;
  }

  .data-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .ticket-grid,
  .loading-grid {
    grid-template-columns: 1fr;
  }

  .result-summary {
    text-align: left;
  }

  .method-note {
    grid-template-columns: 1fr;
  }

  .method-note p {
    grid-column: 1;
  }
}

@media (max-width: 440px) {
  .form-actions {
    grid-template-columns: 1fr;
  }

  .ball {
    width: 33px;
    height: 33px;
    flex-basis: 33px;
    font-size: 0.82rem;
  }

  .ball-row {
    gap: 3px;
  }

  .blue-group {
    gap: 3px;
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
