:root {
  --ink: #171717;
  --ink-soft: #303030;
  --paper: #f6f1e7;
  --paper-strong: #fffaf0;
  --line: #d7cbb7;
  --signal: #d83b2d;
  --signal-dark: #a92318;
  --mint: #0e7c73;
  --gold: #c8942d;
  --blue: #2563eb;
  --shadow: 0 20px 60px rgba(23, 23, 23, 0.16);
  --radius: 8px;
  --gap: 16px;
  --font-display: "STSong", "Noto Serif CJK SC", "Songti SC", serif;
  --font-body: "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 23, 23, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(23, 23, 23, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: var(--font-body);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 48px);
  border-bottom: 2px solid var(--ink);
  background: rgba(246, 241, 231, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--paper-strong);
  background: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--signal);
  font-family: var(--font-display);
  font-size: 24px;
}

.brand h1,
.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  overflow: hidden;
  font-size: clamp(20px, 2vw, 30px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.nav a,
.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-strong);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.nav a,
.button {
  padding: 0 14px;
}

.nav a[aria-current="page"],
.button.primary {
  background: var(--signal);
  color: #fff;
}

.button.mint {
  background: var(--mint);
  color: #fff;
}

.button.ghost {
  background: transparent;
}

.button.danger {
  background: var(--signal-dark);
  color: #fff;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.nav a:hover,
.button:hover,
.icon-button:hover {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(2px, 2px);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 24px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 48px;
}

.panel {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.panel-header,
.panel-body {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
}

.panel-header h2,
.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 23px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 94px;
  padding: 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-strong);
}

.metric strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.field-stack {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.input,
.textarea {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fffdfa;
  color: var(--ink);
  outline: none;
}

.input {
  height: 44px;
  padding: 0 12px;
}

.textarea {
  min-height: 82px;
  resize: vertical;
  padding: 10px 12px;
}

.input:focus,
.textarea:focus {
  box-shadow: 0 0 0 4px rgba(14, 124, 115, 0.18);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}

.qr-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  background: #fffdfa;
}

.qr-box img {
  width: min(260px, 100%);
  aspect-ratio: 1;
  image-rendering: crisp-edges;
}

.copy-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
}

.copy-line code {
  overflow: hidden;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f5ead7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-stack {
  display: grid;
  gap: 22px;
}

.prize-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.prize-card,
.winner-card,
.participant-row {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fffdfa;
}

.prize-card {
  display: grid;
  gap: 14px;
  min-height: 194px;
  padding: 16px;
  box-shadow: 4px 4px 0 var(--gold);
}

.prize-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
}

.prize-card p,
.empty,
.muted {
  color: var(--ink-soft);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 28px;
  padding: 0 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #f5ead7;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.participant-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.participant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.participant-row strong {
  display: block;
}

.participant-row small {
  color: var(--ink-soft);
}

.draw-stage {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 24px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 48px;
}

.stage-board {
  position: relative;
  min-height: 580px;
  padding: clamp(22px, 4vw, 42px);
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(216, 59, 45, 0.13), transparent 36%),
    linear-gradient(315deg, rgba(14, 124, 115, 0.13), transparent 40%),
    #fffdfa;
  box-shadow: var(--shadow);
}

.hero-title {
  max-width: 780px;
  font-size: clamp(42px, 8vw, 112px);
  line-height: 0.92;
}

.ticker {
  display: grid;
  min-height: 110px;
  margin: 28px 0;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper-strong);
  font-family: var(--font-display);
  font-size: clamp(30px, 6vw, 76px);
  text-align: center;
}

.ticker.rolling {
  animation: pulse 180ms linear infinite alternate;
}

@keyframes pulse {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

.winner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.winner-card {
  padding: 16px;
  background: #f8efe0;
}

.winner-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
}

.join-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.join-card {
  width: min(100%, 460px);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-strong);
  box-shadow: 8px 8px 0 var(--mint);
}

.join-card header,
.join-card form,
.join-card .success {
  padding: 24px;
}

.join-card header {
  border-bottom: 2px solid var(--ink);
  background: var(--signal);
  color: #fff;
}

.join-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 10vw, 50px);
  line-height: 1;
}

.join-card p {
  margin: 10px 0 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 16px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper-strong);
  box-shadow: 5px 5px 0 var(--signal);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.55);
  text-align: center;
}

@media (max-width: 920px) {
  .topbar,
  .main-grid,
  .draw-stage {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .nav {
    justify-content: flex-start;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    position: static;
  }

  .brand h1 {
    white-space: normal;
  }

  .split,
  .copy-line,
  .participant-row {
    grid-template-columns: 1fr;
  }

  .button,
  .nav a {
    width: 100%;
  }

  .nav {
    width: 100%;
  }
}
