:root {
  color-scheme: light;
  --bg: #fff7de;
  --ink: #302315;
  --muted: #7f6751;
  --paper: #fffdf7;
  --coral: #ff6f61;
  --berry: #d93654;
  --mint: #4bbd9b;
  --sky: #5aaee8;
  --lemon: #ffd766;
  --line: rgba(48, 35, 21, 0.14);
  --shadow: 0 26px 80px rgba(119, 72, 36, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 111, 97, 0.22), transparent 24rem),
    radial-gradient(circle at 88% 8%, rgba(90, 174, 232, 0.22), transparent 22rem),
    linear-gradient(135deg, #fff8df 0%, #fffdf7 48%, #e9f8ef 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 42px;
}

.generator {
  position: relative;
  min-height: min(560px, calc(100vh - 64px));
  display: grid;
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
  gap: 0;
  align-items: center;
  text-align: center;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.date-mark {
  margin: 0 0 18px;
  color: var(--berry);
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  display: grid;
  gap: 0.08em;
  max-width: 12ch;
  margin: 0 auto;
  font-size: clamp(3rem, 6.8vw, 5.8rem);
  line-height: 1;
  letter-spacing: 0;
}

h1 span {
  display: block;
}

.promise {
  max-width: 520px;
  margin: 24px auto 30px;
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  line-height: 1.7;
}

.name-form {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.name-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

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

input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid rgba(48, 35, 21, 0.18);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  outline: none;
}

input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px rgba(255, 111, 97, 0.16);
}

button {
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--berry);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(217, 54, 84, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(217, 54, 84, 0.3);
}

button:active {
  transform: translateY(0);
}

.party-dots {
  position: relative;
  z-index: 0;
  height: 1px;
}

.party-dots span {
  content: "";
  position: absolute;
  display: block;
  border-radius: 999px;
  opacity: 0.75;
}

.party-dots span:nth-child(1) {
  width: 72px;
  height: 72px;
  left: 6%;
  top: -310px;
  background: rgba(255, 111, 97, 0.22);
}

.party-dots span:nth-child(2) {
  width: 24px;
  height: 24px;
  right: 12%;
  top: -260px;
  background: var(--lemon);
}

.party-dots span:nth-child(3) {
  width: 38px;
  height: 38px;
  left: 16%;
  top: -40px;
  background: rgba(75, 189, 155, 0.3);
}

.party-dots span:nth-child(4) {
  width: 18px;
  height: 18px;
  right: 24%;
  top: -68px;
  background: rgba(90, 174, 232, 0.35);
}

.party-dots span:nth-child(5) {
  width: 12px;
  height: 12px;
  right: 8%;
  top: -110px;
  background: var(--coral);
}

.ticket-zone {
  margin-top: -18px;
  padding: 22px 0 10px;
}

.empty-ticket,
.ticket {
  width: min(860px, 100%);
  margin: 0 auto;
}

.empty-ticket {
  display: grid;
  gap: 6px;
  min-height: 170px;
  place-content: center;
  border: 2px dashed rgba(48, 35, 21, 0.2);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 253, 247, 0.5);
}

.empty-ticket span {
  color: var(--mint);
  font-weight: 800;
}

.empty-ticket strong {
  font-size: 1.25rem;
}

.ticket {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  overflow: hidden;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.ticket-stub {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 240px;
  color: white;
  text-align: center;
  background:
    linear-gradient(160deg, rgba(255, 215, 102, 0.28), transparent 42%),
    var(--coral);
}

.ticket-stub span {
  font-weight: 800;
  writing-mode: vertical-rl;
}

.ticket-stub strong {
  font-size: 1.75rem;
}

.ticket-main {
  position: relative;
  padding: 28px;
  border: 1px solid rgba(48, 35, 21, 0.1);
  border-left: 0;
}

.ticket-main::after {
  content: "";
  position: absolute;
  right: 24px;
  top: 24px;
  width: 86px;
  height: 86px;
  border: 10px solid rgba(75, 189, 155, 0.22);
  border-radius: 50%;
}

.ticket-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.ticket h2 {
  max-width: 520px;
  margin: 22px 0 12px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.06;
  letter-spacing: 0;
}

.ticket-gift {
  margin: 0;
  color: var(--berry);
  font-size: 1.24rem;
  font-weight: 900;
}

.ticket-rule {
  max-width: 500px;
  margin: 10px 0 24px;
  color: var(--muted);
  line-height: 1.7;
}

.code-block {
  display: grid;
  gap: 7px;
  width: fit-content;
  min-width: min(100%, 360px);
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid rgba(48, 35, 21, 0.14);
  background: linear-gradient(135deg, rgba(255, 215, 102, 0.26), rgba(90, 174, 232, 0.16));
}

.code-block span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.code-block strong {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.3rem, 4vw, 2rem);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.actions .ghost {
  color: var(--ink);
  background: rgba(255, 253, 247, 0.82);
  border: 1px solid var(--line);
  box-shadow: none;
}

.status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 22px, 560px);
    padding-top: 18px;
  }

  .generator {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 18px;
  }

  h1 {
    max-width: 9ch;
    font-size: clamp(2.72rem, 14.2vw, 4.8rem);
    gap: 0.1em;
    line-height: 1.02;
  }

  .promise {
    margin: 18px 0 20px;
  }

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

  .party-dots span:nth-child(1) {
    left: -2%;
    top: -270px;
  }

  .party-dots span:nth-child(2) {
    right: 2%;
    top: -220px;
  }

  .ticket-zone {
    margin-top: 0;
  }

  .ticket {
    grid-template-columns: 1fr;
  }

  .ticket-stub {
    min-height: 76px;
    grid-template-columns: auto auto;
  }

  .ticket-stub span {
    writing-mode: horizontal-tb;
  }

  .ticket-main {
    padding: 22px;
    border-left: 1px solid rgba(48, 35, 21, 0.1);
    border-top: 0;
  }

  .ticket-main::after {
    width: 62px;
    height: 62px;
    border-width: 8px;
    right: 16px;
    top: 18px;
  }
}

@media print {
  body {
    background: white;
  }

  .generator,
  .actions,
  .status,
  .empty-ticket {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    padding: 0;
  }

  .ticket-zone {
    margin: 0;
    padding: 0;
  }

  .ticket {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
