*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c0a10;
  --text: #faf6f0;
  --muted: rgba(250, 246, 240, 0.52);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #f0a830;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 200, 120, 0.14);
  --wechat: #07c160;
  --alipay: #1677ff;
  --qq: #12b7f5;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'DM Sans', 'Noto Serif SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bg-glow {
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: min(90vw, 600px);
  height: 60vh;
  background: radial-gradient(ellipse, rgba(240, 168, 48, 0.12) 0%, transparent 70%);
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black, transparent);
}

.page {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  padding: clamp(3rem, 10vw, 4rem) 1.25rem 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.back-link {
  position: fixed;
  top: calc(0.85rem + env(safe-area-inset-top, 0px));
  left: 1rem;
  z-index: 10;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 10, 16, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.back-link:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.22);
}

.hero {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.hero-title {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.hero-desc {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 28em;
  margin: 0 auto;
}

.donate-panel {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease), background 0.3s var(--ease);
}

.tab:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.tab.is-active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--text);
}

.tab-icon {
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-icon svg,
.tab-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.tab.is-active .tab-icon.wechat { color: var(--wechat); }

.tab-icon.alipay svg,
.tab-icon.qq svg {
  opacity: 0.55;
  transition: opacity 0.3s var(--ease);
}

.tab.is-active .tab-icon.alipay svg,
.tab.is-active .tab-icon.qq svg {
  opacity: 1;
}

.panels {
  position: relative;
  min-height: 340px;
}

.panel {
  display: none;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.35s var(--ease);
}

.panel.is-active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.qr-frame {
  width: min(100%, 260px);
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

.qr-frame[data-tab="wechat"] { border-color: rgba(7, 193, 96, 0.28); }
.qr-frame[data-tab="alipay"] { border-color: rgba(22, 119, 255, 0.28); }
.qr-frame[data-tab="qq"] { border-color: rgba(18, 183, 245, 0.28); }

.qr-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  -webkit-touch-callout: default;
  user-select: auto;
  -webkit-user-select: auto;
}

.panel-tip {
  margin-top: 1rem;
  margin-bottom: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.action-bar {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
  width: 100%;
}

.btn-full {
  width: 100%;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.82rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-primary {
  border: 1px solid rgba(240, 168, 48, 0.35);
  background: rgba(240, 168, 48, 0.12);
  color: var(--accent);
  font-weight: 500;
}

.btn-primary:hover {
  background: rgba(240, 168, 48, 0.2);
}

.qr-status {
  margin-top: 0.65rem;
  font-size: 0.72rem;
  color: rgba(250, 246, 240, 0.35);
  text-align: center;
  line-height: 1.5;
  min-height: 1.1em;
}

.qr-status.is-error {
  color: rgba(255, 140, 120, 0.75);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 20;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: rgba(20, 18, 24, 0.92);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  max-width: min(90vw, 360px);
  text-align: center;
}

.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.note {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: rgba(250, 246, 240, 0.35);
  text-align: center;
  line-height: 1.6;
}

.sponsors {
  width: 100%;
  margin-top: 1.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1rem 0 0.75rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}

.sponsors-label {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
  margin-bottom: 0.75rem;
  padding: 0 1rem;
}

.sponsors-viewport {
  height: 168px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent, black 12%, black 88%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 12%, black 88%, transparent);
}

.sponsors-track {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1rem;
  animation: sponsorScroll var(--scroll-duration, 24s) linear infinite;
}

.sponsors-track:hover {
  animation-play-state: paused;
}

.sponsor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.82rem;
}

.sponsor-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.sponsor-avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 500;
  background: rgba(240, 168, 48, 0.15);
  color: var(--accent);
}

.sponsor-info {
  min-width: 0;
}

.sponsor-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sponsor-time {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.sponsor-amount {
  flex-shrink: 0;
  font-weight: 500;
  color: var(--accent);
}

@keyframes sponsorScroll {
  from { transform: translateY(0); }
  to { transform: translateY(-50%); }
}

.footer {
  position: relative;
  z-index: 1;
  width: 100%;
  text-align: center;
  padding: 1.5rem 1.25rem calc(1.5rem + var(--safe-bottom));
  border-top: 1px solid var(--border);
}

.copyright {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.icp {
  font-size: 0.72rem;
}

.icp a {
  color: rgba(250, 246, 240, 0.38);
  text-decoration: none;
  transition: color 0.25s var(--ease);
}

.icp a:hover {
  color: var(--muted);
}

@media (max-width: 380px) {
  .tabs { gap: 0.35rem; }
  .tab { padding: 0.6rem 0.25rem; font-size: 0.75rem; }
  .qr-frame { width: min(100%, 220px); }
}
