:root {
  --green-900: #073f2a;
  --green-700: #118957;
  --green-500: #29ad72;
  --gold: #f2b341;
  --orange: #f06435;
  --red: #d92625;
  --cream: #fff7e5;
  --paper: rgba(255, 255, 255, 0.9);
  --ink: #173329;
  --muted: #6c7d73;
  --line: rgba(17, 137, 87, 0.16);
  --shadow: 0 18px 38px rgba(16, 86, 55, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(242, 179, 65, 0.22), transparent 34rem),
    linear-gradient(180deg, #f7ffe9 0%, #fff7e5 45%, #eef9ee 100%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

.hero {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border-radius: 8px;
  background-image:
    linear-gradient(180deg, rgba(246, 255, 235, 0.26), rgba(246, 255, 235, 0.9)),
    url("/assets/duanwu-telegram/miniapp-home-hero.png");
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
}

.brand-mark {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(217, 38, 37, 0.22);
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding: 88px 20px 0;
}

.eyebrow,
.label {
  display: block;
  color: var(--green-700);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  color: var(--green-900);
  font-size: 38px;
  line-height: 1.04;
}

.hero-copy p:last-child {
  max-width: 260px;
  margin-top: 10px;
  color: #355a48;
  font-size: 15px;
  line-height: 1.5;
}

.hero-mascot {
  position: absolute;
  right: -36px;
  bottom: -26px;
  width: 300px;
  max-width: 72%;
  filter: drop-shadow(0 24px 28px rgba(28, 91, 57, 0.24));
  animation: mascot-bob 3s ease-in-out infinite;
}

@keyframes mascot-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.balance-panel,
.claim-card,
.rank-strip,
.records-section,
.share-section,
.staff-panel,
.prize-card,
.leaderboard-list-section,
.my-rank-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(17, 137, 87, 0.08);
}

.balance-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
}

.balance-panel strong {
  display: block;
  color: var(--red);
  font-size: 42px;
  line-height: 1;
}

.balance-stats {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.balance-stats b {
  color: var(--green-900);
}

.claim-card {
  display: grid;
  grid-template-columns: 126px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.claim-card img {
  width: 126px;
  height: 126px;
  border-radius: 8px;
  object-fit: cover;
}

.claim-card h2,
.records-section h2,
.staff-panel h2,
.prize-card h2,
.leaderboard-list-section h2 {
  font-size: 18px;
  line-height: 1.2;
}

.claim-card p,
.staff-panel p,
.my-rank-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  color: white;
  background: linear-gradient(135deg, var(--orange), var(--red));
  box-shadow: 0 12px 22px rgba(240, 100, 53, 0.24);
}

.secondary-button {
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  box-shadow: 0 12px 22px rgba(17, 137, 87, 0.24);
}

/* 用 <a> 套按钮样式时：去掉链接默认样式，文字居中、白色、不换行 */
a.primary-button,
a.secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-decoration: none;
  color: white;
  font-size: 15px;
}

.primary-button:disabled {
  opacity: 0.58;
  cursor: default;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--green-900);
  background: rgba(41, 173, 114, 0.12);
  text-decoration: none;
  white-space: nowrap;
}

.icon-button {
  width: 36px;
  height: 36px;
  color: var(--green-900);
  background: rgba(41, 173, 114, 0.12);
  font-size: 18px;
}

.rank-strip {
  position: relative;
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  overflow: hidden;
}

.rank-strip img {
  width: 100px;
  height: 74px;
  border-radius: 8px;
  object-fit: cover;
}

.rank-strip strong {
  display: block;
  margin-top: 2px;
  color: var(--green-900);
  font-size: 22px;
}

.rank-strip p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.task-grid article {
  min-width: 0;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.task-grid strong,
.task-grid small {
  display: block;
}

.task-grid strong {
  margin-top: 6px;
  font-size: 12px;
}

.task-grid small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.task-icon {
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 8px;
  background-image: url("/assets/duanwu-telegram/task-icon-sprite.png");
  background-size: 300% 200%;
}

.icon-claim {
  background-position: 0% 0%;
}

.icon-share {
  background-position: 50% 0%;
}

.icon-group {
  background-position: 100% 0%;
}

.icon-redeem {
  background-position: 50% 100%;
}

.records-section,
.prize-card,
.leaderboard-list-section {
  padding: 14px;
}

.records-section header,
.leaderboard-list-section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.records-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.record-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 247, 229, 0.78);
}

.record-row strong {
  font-size: 14px;
}

.record-row span,
.record-row time {
  color: var(--muted);
  font-size: 12px;
}

.record-row .delta {
  color: var(--green-700);
  font-weight: 900;
}

.record-row .delta.negative {
  color: var(--red);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state[hidden] {
  display: none;
}

.empty-state img {
  width: 132px;
  border-radius: 8px;
}

.share-section {
  overflow: hidden;
  padding-bottom: 14px;
}

.share-section img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  object-position: top;
}

.share-section button {
  width: calc(100% - 28px);
  margin: 14px;
}

.staff-panel {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.staff-panel[hidden] {
  display: none;
}

.staff-panel img {
  width: 118px;
  height: 86px;
  border-radius: 8px;
  object-fit: cover;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 63, 42, 0.48);
}

.modal[hidden] {
  display: none;
}

.modal-sheet {
  width: min(100%, 390px);
  border-radius: 8px;
  background: white;
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}

.modal-sheet img {
  width: 100%;
  max-height: 360px;
  border-radius: 8px;
  object-fit: cover;
}

.modal-sheet h2 {
  margin-top: 12px;
  font-size: 24px;
}

.modal-sheet p {
  margin-top: 6px;
  color: var(--muted);
}

.leaderboard-hero {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.leaderboard-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leaderboard-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(7, 63, 42, 0.76), rgba(7, 63, 42, 0.12));
}

.leaderboard-hero div {
  position: relative;
  z-index: 1;
  max-width: 260px;
  padding: 28px 18px;
  color: white;
}

.leaderboard-hero .eyebrow {
  color: #ffe6a1;
}

.leaderboard-hero h1 {
  color: white;
  font-size: 34px;
}

.leaderboard-hero p:last-child {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  line-height: 1.5;
}

.prize-rules {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.prize-rule {
  padding: 10px;
  border-radius: 8px;
  background: rgba(242, 179, 65, 0.14);
}

.prize-rule strong {
  display: block;
  color: var(--red);
  font-size: 18px;
}

.prize-rule span {
  color: var(--green-900);
  font-size: 12px;
  font-weight: 800;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 60px;
  padding: 10px;
  border-radius: 8px;
  background: white;
  border: 1px solid rgba(17, 137, 87, 0.12);
}

.leaderboard-row.current {
  border-color: var(--gold);
  background: #fff6d9;
}

.rank-badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  font-weight: 900;
}

.leaderboard-row:nth-child(1) .rank-badge {
  background: linear-gradient(135deg, #f9cf5a, #e28b19);
}

.leaderboard-row:nth-child(2) .rank-badge {
  background: linear-gradient(135deg, #d9e2e8, #8295a3);
}

.leaderboard-row:nth-child(3) .rank-badge {
  background: linear-gradient(135deg, #e8a46d, #a5532f);
}

.leaderboard-row strong {
  display: block;
  font-size: 15px;
}

.leaderboard-row span {
  color: var(--muted);
  font-size: 12px;
}

.score {
  color: var(--red);
  font-size: 18px;
  font-weight: 900;
  text-align: right;
}

.score small {
  display: block;
  color: var(--green-700);
  font-size: 11px;
}

.my-rank-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.my-rank-card img {
  width: 92px;
  height: 92px;
  object-fit: contain;
}

.my-rank-card strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
}

/* ── 双类型余额面板 ─────────────────────────────────────── */
.balance-panel-dual {
  flex-direction: row;
  align-items: stretch;
  padding: 0;
}

.balance-type-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
}

.balance-type-col strong {
  display: block;
  color: var(--red);
  font-size: 36px;
  line-height: 1;
}

.balance-divider {
  width: 1px;
  background: var(--line);
  align-self: stretch;
}

/* ── 排行榜 Tab 切换 ───────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.tab-btn {
  flex: 1;
  min-height: 44px;
  padding: 10px 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--green-900);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tab-btn.active {
  border-color: var(--green-700);
  background: var(--green-700);
  color: white;
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 10px;
  }

  .claim-card,
  .rank-strip,
  .staff-panel {
    grid-template-columns: 1fr;
  }

  .claim-card img,
  .rank-strip img,
  .staff-panel img {
    width: 100%;
    height: 180px;
  }

  .task-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .prize-rules {
    grid-template-columns: 1fr;
  }
}

