:root {
  color-scheme: light;
  --ink: #17312d;
  --muted: #64706c;
  --paper: #fffaf0;
  --jade: #0d7a67;
  --jade-dark: #095b4d;
  --reed: #d9b35f;
  --rice: #fff7df;
  --warm: #c84d35;
  --shadow: 0 18px 50px rgba(16, 49, 43, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 216, 136, 0.45), transparent 28%),
    linear-gradient(135deg, #e7f6ee 0%, #fff6df 45%, #f6e1d1 100%);
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.name-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.name-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(13, 122, 103, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.name-card h1 {
  margin-bottom: 22px;
}

.entry-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.entry-field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(13, 122, 103, 0.24);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  font-size: 1.1rem;
  outline: 0;
}

.entry-field input:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px rgba(13, 122, 103, 0.13);
}

.name-card button {
  width: 100%;
  height: 48px;
  margin-top: 18px;
  border: 1px solid var(--jade);
  border-radius: 8px;
  background: var(--jade);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--jade);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.1rem, 6vw, 4.8rem);
}

h2 {
  font-size: 1.25rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.stats span {
  min-width: 116px;
  padding: 12px 14px;
  border: 1px solid rgba(13, 122, 103, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.8);
  box-shadow: 0 8px 24px rgba(13, 122, 103, 0.08);
  color: var(--muted);
  text-align: center;
}

.stats strong {
  color: var(--jade-dark);
  font-size: 1.35rem;
}

.player-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(13, 122, 103, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.8);
  box-shadow: 0 8px 24px rgba(13, 122, 103, 0.08);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.player-box strong {
  color: var(--jade-dark);
}

.draw-status {
  margin: -8px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(13, 122, 103, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.78);
  color: var(--jade-dark);
  font-weight: 800;
}

.draw-status.locked {
  border-color: rgba(201, 77, 53, 0.28);
  background: rgba(255, 241, 208, 0.88);
  color: var(--warm);
}

.stage {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(13, 122, 103, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(13, 122, 103, 0.08) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(180deg, rgba(255, 250, 240, 0.92), rgba(255, 247, 223, 0.86));
  box-shadow: var(--shadow);
}

.river {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  pointer-events: none;
  color: rgba(13, 122, 103, 0.06);
  font-size: clamp(5rem, 16vw, 13rem);
  font-weight: 900;
}

.card-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
}

.draw-card {
  aspect-ratio: 3 / 4;
  min-width: 0;
}

.card-button {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}

.card-button:focus-visible {
  outline: 3px solid var(--warm);
  outline-offset: 4px;
  border-radius: 8px;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  backface-visibility: hidden;
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.card-back {
  border: 1px solid rgba(255, 250, 240, 0.45);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 38%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 8px, transparent 8px 18px),
    linear-gradient(160deg, var(--jade), var(--jade-dark));
  box-shadow: 0 12px 24px rgba(9, 91, 77, 0.2);
  color: #fff9e8;
}

.card-number {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.85rem;
  font-weight: 800;
  opacity: 0.82;
}

.knot {
  color: var(--reed);
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  line-height: 1;
}

.back-title {
  font-size: clamp(0.92rem, 2vw, 1.08rem);
  font-weight: 900;
}

.card-front {
  padding: 10px;
  border: 1px solid rgba(201, 77, 53, 0.2);
  background: linear-gradient(160deg, #fffaf0, #fff1d0);
  box-shadow: 0 12px 24px rgba(201, 77, 53, 0.13);
  transform: rotateY(180deg);
  text-align: center;
}

.draw-card.revealed .card-back {
  transform: rotateY(180deg);
}

.draw-card.revealed .card-front {
  transform: rotateY(360deg);
}

.draw-card.revealed .card-button {
  cursor: default;
}

.card-button:disabled {
  cursor: not-allowed;
}

.card-button:disabled .card-back {
  filter: grayscale(0.45);
  opacity: 0.58;
}

.prize-icon {
  min-height: 36px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1;
}

.result {
  min-height: 42px;
  color: var(--jade-dark);
  font-size: clamp(0.88rem, 1.7vw, 1.03rem);
  font-weight: 900;
  line-height: 1.25;
}

.name-field {
  display: none;
  width: 100%;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.name-field input {
  width: 100%;
  height: 32px;
  margin-top: 4px;
  padding: 0 8px;
  border: 1px solid rgba(13, 122, 103, 0.22);
  border-radius: 6px;
  background: #fffefa;
  color: var(--ink);
  text-align: center;
  outline: 0;
}

.name-field input:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px rgba(13, 122, 103, 0.13);
}

.draw-card.gift .name-field {
  display: block;
}

.draw-card.empty .prize-icon {
  color: var(--reed);
}

.panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(13, 122, 103, 0.14);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.86);
  box-shadow: 0 12px 34px rgba(16, 49, 43, 0.1);
}

.panel-head,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.actions button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--jade);
  border-radius: 8px;
  background: var(--jade);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.actions .ghost {
  background: transparent;
  color: var(--jade-dark);
}

.winner-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 45px;
}

.winner-item,
.empty-state {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(13, 122, 103, 0.14);
  border-radius: 8px;
  background: #fffefa;
}

.winner-item {
  display: grid;
  gap: 4px;
}

.winner-name {
  color: var(--jade-dark);
  font-weight: 900;
}

.winner-prize {
  color: var(--muted);
  font-size: 0.88rem;
}

.empty-state {
  grid-column: 1 / -1;
  color: var(--muted);
}

@media (max-width: 900px) {
  .card-grid,
  .winner-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 20px, 560px);
    padding-top: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .player-box {
    justify-content: space-between;
  }

  .stats {
    justify-content: stretch;
  }

  .stats span {
    flex: 1;
  }

  .stage {
    padding: 12px;
  }

  .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button {
    flex: 1;
  }

  .winner-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
