:root {
  --paper: #f5f1e8;
  --paper-deep: #ebe4d7;
  --ink: #1f2925;
  --muted: #68706b;
  --line: #cfc7b8;
  --accent: #9b3d2d;
  --accent-dark: #7d2d21;
  --success: #2d6a4f;
  --white: #fffdf8;
  --danger: #a33225;
  --shadow: 0 18px 50px rgba(48, 38, 26, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(120, 101, 72, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 101, 72, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

.hero {
  max-width: 700px;
  padding-bottom: 34px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

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

h1 {
  margin-bottom: 14px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.intro {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
}

.self-group-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 28px;
  align-items: center;
  margin-top: 24px;
  padding: 18px 20px;
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}

.self-group-panel label {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
  font-weight: 700;
}

.self-group-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

#self-group {
  width: 100%;
  padding: 11px 34px 11px 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #bbaa94;
  border-radius: 3px;
  outline: 0;
}

#self-group:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 61, 45, 0.11);
}

#self-group:disabled {
  color: #9b9285;
  cursor: wait;
}

.progress-panel {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr);
  gap: 28px;
  align-items: center;
  margin: 28px 0 20px;
  padding: 16px 0;
}

.progress-panel > div:first-child {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.progress-label {
  color: var(--muted);
  font-size: 13px;
}

.progress-panel strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  background: var(--paper-deep);
  border: 1px solid #d8d0c3;
  border-radius: 999px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 220ms ease;
}

.group-list {
  display: grid;
  gap: 14px;
}

.loading {
  margin: 48px 0;
  color: var(--muted);
  text-align: center;
}

.group-card {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 156px;
  gap: 22px;
  align-items: center;
  min-height: 132px;
  padding: 24px;
  overflow: hidden;
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.group-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: transparent;
  content: "";
  transition: background 160ms ease;
}

.group-card:focus-within {
  border-color: #9d8f7b;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.group-card.is-complete::before {
  background: var(--success);
}

.group-card.is-own-group {
  background: rgba(235, 228, 215, 0.62);
}

.group-card.is-own-group::before {
  background: #b5a68f;
}

.group-number {
  color: #a99d8b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.group-content {
  position: relative;
  min-width: 0;
  padding-right: 56px;
}

.group-content h2 {
  margin-bottom: 8px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 23px;
  line-height: 1.2;
}

.group-topic {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.65;
}

.member-names {
  margin-bottom: 0;
  color: #4f5853;
  font-size: 14px;
  line-height: 1.8;
}

.member-count {
  position: absolute;
  top: 2px;
  right: 0;
  color: #8c8377;
  font-size: 12px;
}

.score-control {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 9px;
  align-items: center;
}

.score-control label {
  color: var(--muted);
  font-size: 13px;
}

.input-wrap {
  display: flex;
  align-items: center;
  grid-column: 1 / -1;
  padding: 0 12px;
  background: var(--white);
  border: 1px solid #bbaa94;
  border-radius: 3px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 61, 45, 0.11);
}

.input-wrap input {
  width: 100%;
  min-width: 0;
  padding: 12px 2px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.input-wrap input::-webkit-inner-spin-button,
.input-wrap input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.input-wrap input::placeholder {
  color: #b1a899;
  font-size: 16px;
  font-weight: 400;
}

.input-wrap input.invalid {
  color: var(--danger);
}

.input-wrap:has(input:disabled) {
  background: rgba(255, 253, 248, 0.46);
  border-color: #d1c7b8;
}

.input-wrap input:disabled::placeholder {
  color: #9d9487;
  font-size: 14px;
}

.score-unit {
  flex: none;
  color: var(--muted);
  font-size: 13px;
}

.score-hint {
  grid-column: 1 / -1;
  min-height: 18px;
  color: #918779;
  font-size: 11px;
  text-align: right;
}

.score-control:has(input.invalid) .score-hint {
  color: var(--danger);
}

.submit-panel {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px 0 12px;
}

.submit-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

#submit-button {
  position: relative;
  min-width: 188px;
  padding: 14px 22px;
  overflow: hidden;
  color: var(--white);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

#submit-button:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: translateY(-1px);
}

#submit-button:focus-visible {
  outline: 3px solid rgba(155, 61, 45, 0.22);
  outline-offset: 3px;
}

#submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.is-loading .button-label {
  display: none;
}

.is-loading .button-spinner {
  display: inline-block;
}

.form-error {
  margin-top: 16px;
  padding: 13px 16px;
  color: #84291e;
  background: #f8e7e2;
  border-left: 3px solid var(--danger);
  font-size: 14px;
}

.success-view {
  max-width: 620px;
  margin: 76px auto 64px;
  padding: 54px 32px;
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid var(--line);
  text-align: center;
}

.success-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 22px;
  place-items: center;
  color: var(--white);
  background: var(--success);
  border-radius: 50%;
  font-size: 27px;
}

.success-view h2 {
  margin-bottom: 10px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 30px;
}

.success-view p {
  margin-bottom: 0;
  color: var(--muted);
}

.footer {
  padding: 46px 0 0;
  border-top: 1px solid rgba(207, 199, 184, 0.7);
  color: #847b6f;
  font-size: 12px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .self-group-panel {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .hero {
    padding-bottom: 26px;
  }

  h1 {
    font-size: 40px;
  }

  .progress-panel {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
  }

  .group-card {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px 14px;
    min-height: 0;
    padding: 20px 18px;
  }

  .group-number {
    align-self: start;
    font-size: 23px;
  }

  .group-content {
    padding-right: 0;
  }

  .group-content h2 {
    padding-right: 48px;
    font-size: 21px;
  }

  .score-control {
    grid-column: 2;
    grid-template-columns: 42px minmax(0, 1fr);
    margin-top: 2px;
  }

  .score-hint {
    text-align: left;
  }

  .submit-panel {
    align-items: stretch;
    flex-direction: column;
  }

  #submit-button {
    width: 100%;
  }
}

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