:root {
  color-scheme: light;
  --bg: #fff7f5;
  --card: #ffffff;
  --text: #271b1b;
  --muted: #7a6666;
  --red: #e43d3d;
  --blue: #246bfe;
  --line: #f0dada;
  --shadow: 0 18px 50px rgba(132, 30, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 97, 97, 0.25), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(36, 107, 254, 0.16), transparent 28rem),
    var(--bg);
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top)) 0 calc(48px + env(safe-area-inset-bottom));
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.05;
}

.subtitle {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.install-card {
  max-width: 720px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  line-height: 1.7;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.field label,
.rules label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

select,
input[type="number"] {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.rules {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  color: var(--muted);
}

.rules label {
  margin: 0;
  font-weight: 500;
}

button {
  height: 48px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}

.primary {
  background: linear-gradient(135deg, #ff3d3d, #c71932);
  color: #fff;
  box-shadow: 0 12px 24px rgba(228, 61, 61, 0.25);
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.full {
  grid-column: 1 / -1;
}

.copy-ticket {
  width: auto;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(39, 27, 27, 0.9);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.tips {
  margin-bottom: 20px;
  box-shadow: none;
}

.history-panel {
  margin-bottom: 18px;
}

.history-panel h2 {
  margin: 0 0 10px;
}

.helper {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.7;
}

textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
}

.history-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.issue-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.add-draw {
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffafa;
}

.add-draw h3 {
  margin: 0 0 12px;
}

.add-grid {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr auto;
  gap: 10px;
}

.add-grid input[type="text"] {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
}

.history-item strong {
  color: var(--red);
}

.tips h2 {
  margin: 0 0 10px;
}

.tips ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.results {
  display: grid;
  gap: 14px;
}

.ticket {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 12px 30px rgba(80, 35, 35, 0.08);
}

.ticket-index {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff0f0;
  color: var(--red);
  font-weight: 900;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ball {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.12);
}

.ball.red {
  background: linear-gradient(145deg, #ff6969, #d8162f);
}

.ball.blue {
  background: linear-gradient(145deg, #69a0ff, #1557e8);
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .app {
    padding: 28px 0;
  }

  .controls,
  .rules,
  .issue-range,
  .history-actions,
  .history-stats,
  .add-grid,
  .ticket {
    grid-template-columns: 1fr;
  }

  .ticket-index {
    width: auto;
    border-radius: 14px;
  }
}
