:root {
  color-scheme: light;
  --ink: #18241f;
  --muted: #7c8781;
  --green: #237a5b;
  --green-dark: #173f35;
  --green-soft: #eaf5ef;
  --red: #c4514e;
  --red-soft: #fff0ed;
  --paper: #ffffff;
  --background: #f3f5f1;
  --line: #e9ede8;
  --shadow: 0 8px 28px rgba(28, 55, 44, 0.055);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--background);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(202, 222, 208, 0.36), transparent 28rem),
    var(--background);
  font-size: 15px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 0 16px calc(30px + env(safe-area-inset-bottom));
}

.app-header {
  margin: 0 -16px;
  padding: calc(28px + env(safe-area-inset-top)) 22px 60px;
  color: #fff;
  background:
    radial-gradient(circle at 88% 5%, rgba(145, 202, 168, 0.2), transparent 13rem),
    var(--green-dark);
  border-radius: 0 0 28px 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  place-content: center;
  gap: 5px;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.09);
}

.brand-mark span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b9dfc5;
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3) {
  background: #fff;
}

.eyebrow,
.section-kicker {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.14em;
}

.eyebrow {
  color: #a9c9bb;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0.08em;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 5px 9px;
  color: #d5e7dd;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  white-space: nowrap;
}

.local-badge i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #83d6a4;
}

.header-note {
  margin: 20px 0 0 59px;
  color: #a9c0b6;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.stats {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  margin: -32px 0 16px;
  padding: 18px 8px;
  border: 1px solid rgba(231, 237, 231, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.stat-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
}

.stat-item strong {
  font-size: 23px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.stat-item .zero-total {
  color: var(--green);
}

.stat-divider {
  width: 1px;
  height: 26px;
  background: var(--line);
}

.storage-warning {
  margin: 0 0 14px;
  padding: 10px 13px;
  color: #99433f;
  border-radius: 10px;
  background: var(--red-soft);
  font-size: 12px;
}

.card {
  margin-bottom: 16px;
  padding: 21px 18px;
  border: 1px solid rgba(230, 235, 230, 0.9);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
}

.section-kicker {
  color: #9aa59f;
  letter-spacing: 0.16em;
}

h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.section-note {
  color: var(--muted);
  font-size: 11px;
}

.text-button {
  padding: 6px 0 6px 8px;
  color: var(--green);
  border: 0;
  background: transparent;
  font-size: 12px;
}

.current-time {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding: 9px 11px;
  color: #64736b;
  border-radius: 10px;
  background: #f6f8f5;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.current-time svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.auto-time {
  margin-left: auto;
  color: #98a29c;
  font-size: 10px;
}

.player-columns,
.player-row,
.common-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 104px;
  gap: 9px;
  align-items: center;
}

.player-columns {
  margin-bottom: 6px;
  padding: 0 3px;
  color: #939e98;
  font-size: 11px;
}

.player-columns span:last-child {
  text-align: center;
}

.player-rows {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.player-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #78857e;
  border-radius: 9px;
  background: #eef2ed;
  font-size: 12px;
  font-weight: 650;
}

.player-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid #e8ede8;
  outline: none;
  border-radius: 11px;
  background: #fafbf9;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.player-input::placeholder {
  color: #b1b9b4;
}

.player-input:focus {
  border-color: #76ab92;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(35, 122, 91, 0.09);
}

.name-input {
  font-size: 14px;
}

.score-input {
  text-align: center;
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

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

.common-row {
  margin-top: 11px;
  padding-top: 13px;
  border-top: 1px dashed #dfe7e0;
}

.common-badge {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #fff;
  border-radius: 9px;
  background: #6c8d7c;
  font-size: 12px;
  font-weight: 650;
}

.common-copy {
  min-width: 0;
  padding-left: 2px;
}

.common-copy strong,
.common-copy small {
  display: block;
}

.common-copy strong {
  color: #465a4f;
  font-size: 13px;
}

.common-copy small {
  margin-top: 1px;
  color: #98a19c;
  font-size: 10px;
}

.score-tip {
  margin: 11px 0 15px 39px;
  color: #98a19c;
  font-size: 11px;
}

.total-panel {
  padding: 13px 14px;
  border: 1px solid #e9eee9;
  border-radius: 12px;
  background: #f8faf7;
}

.total-panel > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.total-panel span {
  color: #65726b;
  font-size: 12px;
  font-weight: 600;
}

.total-panel strong {
  font-size: 24px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.total-panel p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.total-panel[data-state="success"] {
  border-color: #d4e9dc;
  background: var(--green-soft);
}

.total-panel[data-state="success"] strong,
.total-panel[data-state="success"] p {
  color: var(--green);
}

.total-panel[data-state="error"] {
  border-color: #f1d9d4;
  background: #fff9f7;
}

.total-panel[data-state="error"] strong,
.total-panel[data-state="error"] p {
  color: var(--red);
}

.form-actions {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 10px;
  margin-top: 16px;
}

.primary-button,
.secondary-button {
  height: 47px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  border: 0;
  background: var(--green);
  box-shadow: 0 5px 13px rgba(35, 122, 91, 0.18);
}

.primary-button:active:not(:disabled) {
  background: #1b694d;
  transform: translateY(1px);
}

.primary-button:disabled {
  color: #a6afa9;
  background: #e5e9e5;
  box-shadow: none;
}

.primary-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.secondary-button {
  color: #6c7871;
  border: 1px solid #e3e8e3;
  background: #fff;
}

.empty-state {
  padding: 23px 10px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  padding-top: 12px;
}

.empty-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 10px;
  place-items: center;
  color: #86a293;
  border: 1px dashed #b8c9be;
  border-radius: 13px;
  background: #f5f8f5;
  font-size: 18px;
}

.empty-state p {
  margin: 0 0 4px;
  color: #6f7d75;
  font-size: 13px;
}

.empty-state span {
  font-size: 11px;
}

.summary-list {
  display: flex;
  flex-direction: column;
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 1px;
  border-top: 1px solid var(--line);
}

.summary-row:first-child {
  padding-top: 4px;
  border-top: 0;
}

.summary-row:last-child {
  padding-bottom: 2px;
}

.avatar {
  display: grid;
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  place-items: center;
  color: #386a55;
  border-radius: 12px;
  background: #edf4ef;
  font-size: 14px;
  font-weight: 650;
}

.summary-info {
  min-width: 0;
  flex: 1;
}

.summary-name {
  overflow: hidden;
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-meta {
  color: var(--muted);
  font-size: 10px;
}

.summary-score {
  min-width: 55px;
  text-align: right;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.score-positive {
  color: var(--green);
}

.score-negative {
  color: var(--red);
}

.score-zero {
  color: #7c8781;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.round-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfa;
}

.round-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f6f8f5;
}

.round-number {
  color: #50635a;
  font-size: 11px;
  font-weight: 650;
}

.round-time {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.round-players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px 18px;
  padding: 13px 12px;
}

.round-player {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  font-size: 12px;
}

.round-player-name {
  overflow: hidden;
  color: #5d6b63;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-player-score {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.round-common {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 12px;
  padding: 9px 0 11px;
  color: #6d7c73;
  border-top: 1px dashed #e2e8e2;
  font-size: 11px;
}

footer {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 5px 18px 0;
  color: #929d96;
  text-align: center;
  font-size: 10px;
}

.footer-dot {
  width: 4px;
  height: 4px;
  flex: 0 0 auto;
  margin-top: 6px;
  border-radius: 50%;
  background: #a8b4ac;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 20px;
  width: fit-content;
  max-width: min(90vw, 440px);
  margin: auto;
  padding: 11px 17px;
  color: #fff;
  border-radius: 11px;
  background: rgba(23, 48, 40, 0.94);
  box-shadow: 0 8px 28px rgba(20, 38, 31, 0.2);
  text-align: center;
  font-size: 13px;
  animation: toast-in 180ms ease-out;
}

.toast[data-type="error"] {
  background: rgba(150, 57, 52, 0.96);
}

.noscript {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 12px;
  color: #fff;
  border-radius: 10px;
  background: var(--red);
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 350px) {
  .app-shell { padding-right: 11px; padding-left: 11px; }
  .app-header { margin-right: -11px; margin-left: -11px; padding-right: 17px; padding-left: 17px; }
  .local-badge { padding-right: 7px; padding-left: 7px; font-size: 10px; }
  .card { padding-right: 14px; padding-left: 14px; }
  .player-columns, .player-row, .common-row { grid-template-columns: 28px minmax(0, 1fr) 88px; gap: 7px; }
  .header-note { margin-left: 0; }
}

@media (min-width: 600px) {
  .app-shell { padding-top: 20px; }
  .app-header { border-radius: 26px 26px 28px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
