:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: #fffaf2;
  --text: #2f241f;
  --muted: #7b685f;
  --accent: #c85c2f;
  --accent-soft: #f3d7c8;
  --border: #e8d8cb;
  --shadow: 0 12px 30px rgba(90, 58, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at top, #fff6df 0%, transparent 36%),
    linear-gradient(180deg, #f8f2e9 0%, #f2e6d7 100%);
  color: var(--text);
}

.app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.page-header h1,
.panel h2 {
  margin: 0;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.panel {
  margin-top: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.ranking-list,
.detail-content {
  margin-top: 14px;
}

.ranking-list {
  display: grid;
  gap: 12px;
  padding-top: 6px;
}

.ranking-item {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdfa 0%, #fff3e8 100%);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.ranking-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  transition: width 180ms ease;
}

.ranking-item:hover {
  border-color: #d8b4a2;
  box-shadow: 0 10px 24px rgba(126, 83, 58, 0.12);
}

.ranking-item:hover::before {
  width: 100%;
}

.ranking-item:active {
  transform: scale(0.99);
}

.ranking-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 14px 28px rgba(200, 92, 47, 0.18);
}

.ranking-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.ranking-main {
  display: grid;
  gap: 4px;
}

.ranking-name {
  font-size: 17px;
  font-weight: 700;
}

.ranking-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.ranking-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.ranking-item.top-1 {
  background: linear-gradient(135deg, #fff6d6 0%, #ffe7a1 100%);
  border-color: #e1ba4c;
  transform: translateY(-8px);
  box-shadow:
    0 18px 34px rgba(180, 134, 27, 0.22),
    0 0 0 1px rgba(255, 245, 204, 0.55) inset;
}

.ranking-item.top-2 {
  background: linear-gradient(135deg, #f6f6f8 0%, #dedfe6 100%);
  border-color: #b9beca;
  transform: translateY(-2px);
  box-shadow:
    0 14px 26px rgba(103, 112, 130, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.55) inset;
}

.ranking-item.top-3 {
  background: linear-gradient(135deg, #f7e7da 0%, #e7c0a2 100%);
  border-color: #cd9769;
  box-shadow:
    0 12px 24px rgba(151, 96, 57, 0.16),
    0 0 0 1px rgba(255, 247, 241, 0.45) inset;
}

.ranking-item.top-1::after,
.ranking-item.top-2::after,
.ranking-item.top-3::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 0;
  height: 6px;
  border-radius: 0 0 999px 999px;
}

.ranking-item.top-1::after {
  background: linear-gradient(90deg, #e2ae1f 0%, #fff1a5 50%, #c58b00 100%);
}

.ranking-item.top-2::after {
  background: linear-gradient(90deg, #96a1b2 0%, #f6f8fb 50%, #8a95a8 100%);
}

.ranking-item.top-3::after {
  background: linear-gradient(90deg, #b26a38 0%, #f4cfad 50%, #955522 100%);
}

.ranking-item.top-1 .ranking-order {
  background: #fff0b8;
  color: #9a6a00;
  box-shadow:
    0 6px 18px rgba(185, 131, 8, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.ranking-item.top-2 .ranking-order {
  background: #edf1f7;
  color: #5e6876;
  box-shadow:
    0 6px 18px rgba(116, 124, 142, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.ranking-item.top-3 .ranking-order {
  background: #f3d5bc;
  color: #8b4f24;
  box-shadow:
    0 6px 18px rgba(145, 92, 58, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.ranking-item.top-1 .ranking-badge {
  background: linear-gradient(180deg, rgba(255, 250, 214, 0.95), rgba(255, 236, 171, 0.95));
  color: #8c6400;
}

.ranking-item.top-2 .ranking-badge {
  background: linear-gradient(180deg, rgba(249, 250, 252, 0.95), rgba(227, 231, 239, 0.95));
  color: #5e6876;
}

.ranking-item.top-3 .ranking-badge {
  background: linear-gradient(180deg, rgba(251, 236, 220, 0.95), rgba(237, 200, 171, 0.95));
  color: #8b4f24;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.member-card {
  display: grid;
  gap: 18px;
}

.member-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.member-label,
.section-heading span,
.stat-label {
  color: var(--muted);
}

.member-label {
  margin: 0 0 8px;
  font-size: 13px;
}

.member-title,
.section-heading h4 {
  margin: 0;
}

.member-title {
  font-size: 26px;
}

.balance-pill {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #efe7de;
}

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

.stat-card,
.meal-row {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffefb 0%, #fff6ed 100%);
}

.stat-card {
  padding: 14px;
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.stat-value {
  font-size: 22px;
}

.detail-section {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.meal-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.meal-name,
.meal-amount {
  font-weight: 700;
}

.meal-amount,
.tone-positive {
  color: #1f7a43;
}

.tone-negative {
  color: #b4411d;
}

.tone-neutral {
  color: var(--text);
}

@media (min-width: 768px) {
  .app {
    padding: 28px 20px 40px;
  }
}

@media (max-width: 520px) {
  .ranking-item.top-1,
  .ranking-item.top-2,
  .ranking-item.top-3 {
    transform: none;
  }

  .member-hero,
  .section-heading,
  .meal-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
