:root {
  --ink: #14201c;
  --muted: #5a6b63;
  --paper: #f3f7f4;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(20, 32, 28, 0.1);
  --accent: #0f766e;
  --accent-deep: #0b4f4a;
  --up: #15803d;
  --up-bg: #e8f7ef;
  --down: #b42318;
  --down-bg: #fdecea;
  --same: #6b7280;
  --shadow: 0 18px 50px rgba(15, 45, 40, 0.08);
  --radius: 18px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "ZCOOL XiaoWei", "Noto Sans SC", serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background: var(--paper);
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 118, 110, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 20%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  inset: auto auto 10% -10%;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.16), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.site-header,
main,
footer {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  padding: 3.5rem 0 1.5rem;
  animation: rise 0.7s ease both;
}

.brand {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: 0.04em;
  color: var(--accent-deep);
  line-height: 1;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 700;
}

.lede {
  margin: 0.85rem 0 0;
  max-width: 36rem;
  color: var(--muted);
  line-height: 1.7;
}

.upload-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  animation: rise 0.8s ease 0.08s both;
}

.upload-card {
  position: relative;
  padding: 1.4rem 1.35rem 1.25rem;
  border: 1.5px dashed rgba(15, 118, 110, 0.35);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.upload-card.dragover {
  border-color: var(--accent);
  background: rgba(232, 247, 239, 0.9);
  transform: translateY(-2px);
}

.upload-card.ready {
  border-style: solid;
  border-color: rgba(15, 118, 110, 0.45);
}

.upload-label {
  display: inline-block;
  margin-bottom: 0.55rem;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.upload-card strong {
  display: block;
  font-size: 1.05rem;
}

.upload-card p {
  margin: 0.4rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.upload-card input[type="file"] {
  display: none;
}

.file-meta {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  color: var(--accent-deep);
  font-size: 0.92rem;
  line-height: 1.5;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, color 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.ghost {
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-deep);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: end;
  margin-top: 1.35rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  animation: rise 0.55s ease both;
}

.mapping {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
}

.mapping label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.mapping select,
.mapping input {
  min-width: 10rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.actions {
  display: flex;
  gap: 0.6rem;
}

.podium,
.results,
.help {
  margin-top: 1.75rem;
  animation: rise 0.65s ease both;
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 400;
}

.section-head p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.section-head.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 0.9rem;
}

.podium-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
}

.podium-list li {
  position: relative;
  padding: 1.25rem 1.1rem 1.1rem;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.podium-list li::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
}

.podium-list li.rank-1::before { background: linear-gradient(90deg, #eab308, #f59e0b); }
.podium-list li.rank-2::before { background: linear-gradient(90deg, #94a3b8, #64748b); }
.podium-list li.rank-3::before { background: linear-gradient(90deg, #d97706, #b45309); }
.podium-list li.rank-rest::before { background: linear-gradient(90deg, #0f766e, #0b4f4a); }

.podium-place {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.podium-name {
  margin: 0.45rem 0 0.2rem;
  font-size: 1.35rem;
  font-weight: 900;
}

.podium-delta {
  color: #15803d;
  font-weight: 800;
  font-size: 1.1rem;
}

.podium-detail {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.tag.up { background: var(--up-bg); color: #15803d; }
.tag.down { background: var(--down-bg); color: var(--down); }
.tag.same { background: #eef2f7; color: var(--same); }
.tag.miss { background: #fff7ed; color: #c2410c; }
.tag.top {
  background: #fef3c7;
  color: #92400e;
  margin-left: 0.35rem;
}

.table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f8fbf9;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}

tbody tr:hover {
  background: rgba(15, 118, 110, 0.04);
}

tbody tr.top-improve {
  background: linear-gradient(90deg, rgba(254, 243, 199, 0.7), rgba(255, 255, 255, 0));
}

.delta-up { color: #15803d; font-weight: 800; }
.delta-down { color: var(--down); font-weight: 800; }
.delta-same { color: var(--same); font-weight: 700; }
.delta-miss { color: #c2410c; font-weight: 700; }

.help {
  padding: 1.25rem 1.3rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
}

.help h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.help p, .help li {
  color: var(--muted);
  line-height: 1.7;
}

.help ul {
  margin: 0.4rem 0 0.8rem;
  padding-left: 1.2rem;
}

footer {
  padding: 2.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .podium-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .upload-section,
  .podium-list {
    grid-template-columns: 1fr;
  }

  .controls {
    align-items: stretch;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    width: 100%;
  }
}
