:root {
  --bg: #fff5ea;
  --card: #ffffff;
  --ink: #2a2622;
  --muted: #85786c;
  --line: #eddccb;
  --brand: #e67a2e;
  --brand-deep: #b04e16;
  --brand-soft: #fff0e0;
  --accent: #f0a73a;
  --sky: #4f8fb8;
  --pos: #2f8a68;
  --neg: #c44a3a;
  --gold: #e0a82e;
  --warn: #d97706;
  --ok: #2f8a68;
  --name-w: 7.2rem;
  --display: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(920px 440px at 8% -12%, #ffd9a8 0%, transparent 56%),
    radial-gradient(700px 340px at 100% 0%, rgba(79, 143, 184, 0.14) 0%, transparent 52%),
    linear-gradient(180deg, #fff8f0 0%, var(--bg) 48%, #ffe8cc 100%);
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.brand-kicker {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--brand);
  font-weight: 800;
}

h1 {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.15;
}

.sub {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav button, .chip, .btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.48rem 1rem;
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nav button:hover, .btn:hover { transform: translateY(-1px); }

.nav button.active, .btn {
  background: linear-gradient(120deg, #f0a73a 0%, #e67a2e 62%, #4f8fb8 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(230, 122, 46, 0.24);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin: 0.35rem 0 1rem;
}

.rank-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  font: inherit;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
}

.chip-btn.active {
  background: #fff0e0;
  border-color: #e67a2e;
  color: var(--brand-deep);
  box-shadow: inset 0 0 0 1px rgba(79, 143, 184, 0.12);
}

.chip {
  background: #fff6e8;
  border-color: #f0d59a;
  color: #9a6218;
  font-weight: 700;
  font-size: 0.88rem;
}

.status {
  min-height: 1.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.status.ok { color: var(--ok); }
.status.err { color: #b91c1c; }
.status.saving { color: var(--warn); }

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 1.7rem 1.4rem 1.5rem;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.16), transparent 40%),
    linear-gradient(125deg, #f0a73a 0%, #e67a2e 52%, #4f8fb8 100%);
  margin-bottom: 1.15rem;
  animation: rise-in 0.5s ease both;
  box-shadow: 0 16px 36px rgba(176, 78, 22, 0.2);
}

.hero-eyebrow {
  margin: 0;
  opacity: 0.95;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
}

.hero h2 {
  margin: 0.35rem 0 0.45rem;
  font-family: var(--display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 400;
}

.hero-desc {
  margin: 0;
  max-width: 38rem;
  line-height: 1.55;
  opacity: 0.96;
  font-size: 0.95rem;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.95rem;
}

.hero-tags span {
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.podium-wrap {
  margin-bottom: 1.15rem;
  animation: rise-in 0.6s ease 0.05s both;
}

.podium-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.podium-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 400;
}

.podium-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.podium {
  display: grid;
  grid-template-columns: 1fr 1.18fr 1fr;
  gap: 0.8rem;
  align-items: end;
}

.podium-card {
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.15rem 0.75rem 1.05rem;
  box-shadow: 0 10px 24px rgba(196, 92, 42, 0.06);
}

.podium-card.gold {
  transform: translateY(-14px);
  background: linear-gradient(180deg, #fff6df, #fff);
  border-color: #f0d59a;
}

.podium-card.silver { border-color: #d7e3ea; }
.podium-card.bronze { border-color: #f0c9b0; }

.medal-emoji {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.avatar {
  width: 58px;
  height: 58px;
  margin: 0.15rem auto 0.55rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.35rem;
  background: linear-gradient(145deg, #ffb347, #ff6b3d);
  box-shadow: 0 6px 14px rgba(230, 122, 46, 0.28);
}

.podium-card.gold .avatar { box-shadow: 0 6px 14px rgba(240, 167, 58, 0.35); }
.podium-card.silver .avatar { box-shadow: 0 6px 14px rgba(90, 140, 180, 0.28); }
.podium-card.bronze .avatar { box-shadow: 0 6px 14px rgba(212, 122, 74, 0.3); }

.podium-card .name {
  font-weight: 900;
  font-size: 1.05rem;
}

.podium-card .place-label {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.podium-card .score {
  margin-top: 0.55rem;
  font-family: var(--display);
  font-size: 1.85rem;
  color: var(--brand-deep);
}

.podium-card .delta {
  color: var(--muted);
  font-size: 0.82rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.track-panel { animation: rise-in 0.7s ease 0.08s both; }

.hint {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  background: #fff8f1;
}

.hint strong { color: var(--brand-deep); }

.table-wrap {
  max-height: calc(100vh - 220px);
  overflow: auto;
  position: relative;
}

.entry-panel {
  animation: rise-in 0.45s ease both;
  box-shadow: 0 12px 28px rgba(196, 92, 42, 0.07);
}

#view-entry .table-wrap {
  max-height: calc(100vh - 180px);
}

table.data.entry-table th,
table.data.entry-table td {
  padding: 0.62rem 0.7rem;
  border-right-color: #f0e4d8;
  border-bottom-color: #f0e4d8;
}

table.data.entry-table th {
  background: linear-gradient(180deg, #fff4e6, #ffe8d0);
  color: #9a6218;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 0 rgba(240, 138, 75, 0.12);
}

table.data.entry-table th.col-name,
table.data.entry-table td.col-name {
  min-width: 8.4rem;
}

table.data.entry-table th.col-name {
  background: linear-gradient(180deg, #f0a73a, #e67a2e);
  color: #fff;
  z-index: 5;
}

table.data.entry-table td.col-name {
  background: #fff8f1;
}

table.data.entry-table tr.alt td {
  background: #fffcf8;
}

table.data.entry-table tr.alt td.col-name {
  background: #fff2e6;
}

table.data.entry-table tr:hover td {
  background: #fff5ea;
}

table.data.entry-table tr:hover td.col-name {
  background: #ffe8d4;
}

.name-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.name-avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  background: linear-gradient(145deg, #ffb347, #ff6b3d);
  flex: 0 0 auto;
  box-shadow: 0 2px 6px rgba(230, 122, 46, 0.25);
}

.name-text { font-weight: 800; }

table.data.entry-table th.col-delta,
table.data.entry-table th.col-total {
  background: linear-gradient(180deg, #eef5fa, #dceaf3);
  color: #3d6f90;
}

.delta.pos { color: var(--pos); }
.delta.neg { color: var(--neg); }
.delta.zero { color: var(--muted); }

input.score {
  width: 4.35rem;
  padding: 0.42rem 0.35rem;
  border: 1px solid #eadfce;
  border-radius: 12px;
  text-align: center;
  font: inherit;
  font-weight: 700;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input.score:hover {
  border-color: #f0b35a;
}

input.score:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(240, 138, 75, 0.2);
  background: #fffaf3;
}

input.score.is-pos {
  color: var(--pos);
  background: #f2faf6;
  border-color: #b7d9cd;
}

input.score.is-neg {
  color: var(--neg);
  background: #fff5f2;
  border-color: #f0c4ba;
}

.entry-table .badge {
  min-width: 3rem;
  padding: 0.28rem 0.62rem;
  background: linear-gradient(180deg, #fff6e8, #ffe8d0);
  color: var(--brand-deep);
  border: 1px solid rgba(240, 138, 75, 0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

@media (max-width: 860px) {
  #view-entry .table-wrap {
    max-height: calc(100vh - 200px);
  }
}

table.data {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
}

table.data th,
table.data td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  white-space: nowrap;
  background: #fff;
  text-align: center;
  vertical-align: middle;
}

table.data th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff8ef;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

table.data th:first-child,
table.data td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  min-width: var(--name-w);
  background: #fffaf5;
  font-weight: 700;
}

table.data th:first-child {
  z-index: 5;
  background: #ffe8d0;
}

table.data tr:last-child td { border-bottom: none; }
table.data th:last-child,
table.data td:last-child { border-right: none; }

input.score, .field {
  width: 4.35rem;
  padding: 0.42rem 0.35rem;
  border: 1px solid #eadfce;
  border-radius: 12px;
  text-align: center;
  font: inherit;
  background: #fff;
}

.field {
  width: auto;
  flex: 1;
  text-align: left;
  padding: 0.5rem 0.7rem;
  font-weight: 400;
}

input.score:focus, .field:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(240, 138, 75, 0.2);
}

.total { font-weight: 700; }
.badge {
  display: inline-block;
  min-width: 2.6rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 700;
  border: 1px solid rgba(240, 138, 75, 0.2);
}

.rank-list {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
  background: #fff8f1;
}

.rank-row {
  display: grid;
  grid-template-columns: 2.6rem 2.6rem 1fr auto auto;
  gap: 0.65rem 0.75rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.rank-row.top1 { background: linear-gradient(90deg, #fff6df, #fff); border-color: #f0d59a; }
.rank-row.top2 { background: linear-gradient(90deg, #eef5fa, #fff); border-color: #b9d2e4; }
.rank-row.top3 { background: linear-gradient(90deg, #fff1e6, #fff); border-color: #f0c3a0; }

.place-num {
  font-weight: 900;
  color: var(--brand-deep);
  text-align: center;
}

.rank-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(145deg, #ffb347, #ff6b3d);
  font-size: 0.95rem;
  box-shadow: 0 3px 8px rgba(230, 122, 46, 0.25);
}

.rank-row .name { font-weight: 800; }
.rank-row .msg { color: var(--brand); font-size: 0.78rem; margin-top: 0.15rem; font-weight: 600; }
.rank-row .tag {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: #fff1e4;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.bar {
  grid-column: 1 / -1;
  height: 9px;
  border-radius: 999px;
  background: #f0e4d8;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0a73a 0%, #e67a2e 55%, #4f8fb8 100%);
  transform-origin: left center;
  animation: bar-grow 0.75s ease both;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.settings-body { padding: 1rem; }
.add-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.admin-list { display: grid; gap: 0.55rem; }
.admin-item, .admin-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.admin-item .field, .admin-row .field { flex: 1; }
.btn-danger {
  background: #fff;
  color: #be123c;
  border: 1px solid #fecdd3;
  border-radius: 999px;
  padding: 0.42rem 0.8rem;
  font: inherit;
  cursor: pointer;
  font-weight: 700;
}
.btn-danger:hover { background: #fff1f2; }

.hidden { display: none !important; }

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

@keyframes bar-grow {
  from { transform: scaleX(0.15); opacity: 0.4; }
  to { transform: scaleX(1); opacity: 1; }
}

@media (max-width: 720px) {
  .podium { grid-template-columns: 1fr; }
  .podium-card.gold { transform: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .rank-row {
    grid-template-columns: 2.2rem 2.2rem 1fr auto;
  }
  .rank-row .badge { grid-column: 4; }
}
