:root {
  --red: #c1272d;
  --red-deep: #8f1b20;
  --gold: #c9a227;
  --ink: #2a1d1a;
  --muted: #a08b84;
  --line: rgba(193, 39, 45, 0.16);
  --paper: #fdf8f4;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: clamp(20px, 5vh, 56px) clamp(16px, 4vw, 32px);
  background:
    radial-gradient(90% 55% at 50% 0%, #ffffff 0%, rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, var(--paper) 0%, #fbf3ee 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  overflow-x: hidden;
}

/* 右下角一枚淡淡的囍字，只做气氛，不抢内容 */
.paper-mark {
  position: fixed;
  right: -4vw;
  bottom: -10vh;
  z-index: 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: min(50vh, 42vw);
  line-height: 1;
  color: rgba(193, 39, 45, 0.035);
  pointer-events: none;
  user-select: none;
}

.stage {
  position: relative;
  z-index: 1;
  width: min(860px, 100%);
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.4vh, 22px);
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- 顶栏 ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(0.95rem, 1.7vh, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--red);
}

.masthead-side {
  display: flex;
  align-items: center;
  gap: 14px;
}

.range {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.range-word {
  letter-spacing: 0.1em;
}

.range-input {
  width: 3.4em;
  padding: 4px 2px;
  font: inherit;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--red);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  appearance: textfield;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.2s ease;
}

.range-input:focus {
  border-bottom-color: var(--red);
}

.range-input::-webkit-outer-spin-button,
.range-input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.sound {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--red);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.sound[aria-pressed="false"] {
  color: var(--muted);
  opacity: 0.6;
}

.sound[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 1px;
  background: currentColor;
  transform: rotate(-45deg);
}

/* ---------- 号码舞台 ---------- */

.board {
  position: relative;
  padding: clamp(30px, 7vh, 62px) 20px clamp(24px, 5vh, 44px);
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow:
    0 30px 60px -40px rgba(143, 27, 32, 0.45),
    0 1px 2px rgba(143, 27, 32, 0.05);
  overflow: hidden;
}

/* 内嵌一道细线，像请柬的压边 */
.board::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(193, 39, 45, 0.12);
  border-radius: 18px;
  pointer-events: none;
}

.number {
  position: relative;
  font-family: "Baskerville", "Times New Roman", "Songti SC", "STSong", serif;
  font-size: clamp(5rem, 21vmin, 14rem);
  line-height: 1.04;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--red);
}

.number[data-state="idle"] {
  color: rgba(193, 39, 45, 0.26);
  font-family: "Songti SC", "STSong", "SimSun", serif;
}

.number[data-state="land"] {
  animation: land 720ms cubic-bezier(0.22, 1.3, 0.36, 1) both;
}

@keyframes land {
  0% {
    transform: scale(1.26);
    opacity: 0;
  }
  55% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.meta {
  position: relative;
  margin: clamp(10px, 2vh, 18px) 0 0;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------- 抽奖按钮 ---------- */

.draw {
  appearance: none;
  width: 100%;
  padding: clamp(16px, 2.6vh, 24px) 20px;
  font-family: inherit;
  font-size: clamp(1.05rem, 2.4vh, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: #fff;
  background: linear-gradient(180deg, #d33339 0%, #c1272d 55%, #b02127 100%);
  border: 0;
  border-radius: 999px;
  box-shadow:
    0 18px 34px -18px rgba(193, 39, 45, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.2s ease, color 0.2s ease;
}

.draw:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 22px 40px -18px rgba(193, 39, 45, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.draw:active:not(:disabled) {
  transform: translateY(1px);
}

.draw:disabled {
  background: #eddcd5;
  color: #96786e;
  box-shadow: none;
  cursor: not-allowed;
}

.draw.is-busy {
  opacity: 0.94;
  cursor: wait;
}

/* ---------- 已抽记录 ---------- */

.history {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.history h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.count {
  margin-left: 0.15em;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}

.tools {
  display: flex;
  gap: 16px;
}

.tools button {
  padding: 4px 0;
  font: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.tools button:hover:not(:disabled) {
  color: var(--red);
  border-bottom-color: rgba(193, 39, 45, 0.35);
}

.tools button:disabled {
  opacity: 0.35;
  cursor: default;
}

.tools button.armed {
  color: var(--red);
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: min(112px, 20vh);
  padding: 2px 0 4px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.chips:empty::after {
  content: "暂无记录";
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  color: rgba(160, 139, 132, 0.7);
}

.chip {
  padding: 5px 11px;
  font: inherit;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--red);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.chip:hover {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
  transform: translateY(-1px);
}

.chip.fresh {
  animation: pop 400ms cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .number[data-state="land"],
  .chip.fresh {
    animation: none;
  }
}

@media (max-width: 560px) {
  .board {
    padding-left: 14px;
    padding-right: 14px;
  }

  .board::before {
    inset: 7px;
    border-radius: 14px;
  }

  .number {
    font-size: clamp(4.5rem, 30vw, 9rem);
  }

  .draw {
    letter-spacing: 0.4em;
    text-indent: 0.4em;
  }
}
