:root {
  color-scheme: light;
  --red: #c51f32;
  --red-dark: #991525;
  --red-soft: #fff0f1;
  --blue: #1769aa;
  --ink: #211a1a;
  --muted: #746b6b;
  --line: #eadfda;
  --paper: #fffdf9;
  --canvas: #f4eee7;
  --shadow: 0 20px 55px rgba(92, 45, 37, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(197, 31, 50, 0.12), transparent 32%),
    radial-gradient(circle at 92% 45%, rgba(23, 105, 170, 0.08), transparent 28%),
    var(--canvas);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

.page-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(30px, env(safe-area-inset-top)) 18px
    max(28px, env(safe-area-inset-bottom));
}

.hero {
  padding: 12px 6px 26px;
}

.hero__eyebrow,
.section-kicker {
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.hero__eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #31a66a;
  box-shadow: 0 0 0 5px rgba(49, 166, 106, 0.12);
}

.hero h1 {
  margin: 18px 0 12px;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: clamp(38px, 11vw, 56px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.hero h1 span {
  color: var(--red);
}

.hero p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.top-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(229, 215, 208, 0.9);
  border-radius: 15px;
  background: rgba(255, 253, 249, 0.82);
}

.home-nav {
  margin-bottom: 14px;
}

.top-nav a {
  padding: 10px 5px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.top-nav a.is-current {
  color: #fff;
  background: var(--red);
  box-shadow: 0 5px 12px rgba(197, 31, 50, 0.18);
}

.logout-form {
  display: flex;
  margin-top: 7px;
  justify-content: flex-end;
}

.logout-form button {
  padding: 5px 4px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  cursor: pointer;
}

.generator-card,
.rules-card {
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 26px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: var(--shadow);
}

.generator-card {
  padding: 22px 16px 18px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 0 4px 18px;
}

.section-kicker {
  margin: 0 0 5px;
  font-size: 10px;
}

.card-heading h2 {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 23px;
}

.history-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #e8d9d3;
  border-radius: 12px;
  text-align: right;
}

.history-badge strong {
  display: block;
  color: var(--red);
  font-size: 15px;
  line-height: 1;
}

.history-badge span {
  color: var(--muted);
  font-size: 9px;
}

.number-list {
  display: grid;
  gap: 9px;
}

.number-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 11px 10px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  transition: transform 180ms ease, opacity 180ms ease;
}

.number-row.is-entering {
  opacity: 0;
  transform: translateY(8px);
}

.group-index {
  width: 22px;
  color: #a99d98;
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
  text-align: center;
}

.balls {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.ball {
  display: grid;
  width: clamp(28px, 9.3vw, 38px);
  height: clamp(28px, 9.3vw, 38px);
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(12px, 3.8vw, 16px);
  font-weight: 700;
  box-shadow: inset 0 -3px 7px rgba(70, 0, 0, 0.18), 0 4px 9px rgba(80, 20, 20, 0.14);
}

.ball--red {
  background: var(--red);
}

.ball--blue {
  background: var(--blue);
  box-shadow: inset 0 -3px 7px rgba(0, 35, 80, 0.2), 0 4px 9px rgba(10, 55, 90, 0.16);
}

.ball-separator {
  width: 1px;
  height: 20px;
  flex: 0 0 auto;
  margin: 0 2px;
  background: var(--line);
}

.action-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 9px;
  margin-top: 18px;
}

.generate-button,
.save-button {
  display: flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 11px 24px rgba(197, 31, 50, 0.25);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.generate-button {
  background: var(--red);
  box-shadow: 0 11px 24px rgba(197, 31, 50, 0.25);
}

.save-button {
  border: 1px solid #e4c7c8;
  color: var(--red-dark);
  background: #fff6f5;
  box-shadow: none;
  font-size: 15px;
}

.generate-button:active,
.save-button:active {
  transform: scale(0.985);
}

.generate-button:active {
  background: var(--red-dark);
}

.save-button:active {
  background: #fbe8e8;
}

.generate-button:disabled,
.save-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.generate-button svg,
.save-button svg,
.verification-note svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.generate-button.is-loading svg {
  animation: spin 700ms linear infinite;
}

.exclude-button {
  display: flex;
  width: 100%;
  margin-top: 11px;
  padding: 12px 14px;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.exclude-button > span:last-child {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.exclude-button small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.toggle-indicator {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: #d9ceca;
  transition: background 160ms ease;
}

.toggle-indicator::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(40, 20, 15, 0.2);
  content: "";
  transition: transform 160ms ease;
}

.exclude-button.is-active {
  border-color: #e3bdc2;
  color: var(--red-dark);
  background: var(--red-soft);
}

.exclude-button.is-active .toggle-indicator {
  background: var(--red);
}

.exclude-button.is-active .toggle-indicator::after {
  transform: translateX(14px);
}

.verification-note {
  display: flex;
  margin: 14px 0 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.verification-note svg {
  width: 16px;
  color: #31a66a;
}

.error-message {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #efc8cc;
  border-radius: 13px;
  color: #8f1725;
  background: var(--red-soft);
  font-size: 13px;
  line-height: 1.5;
}

.success-message {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #bde3cf;
  border-radius: 13px;
  color: #17683e;
  background: #effaf4;
  font-size: 13px;
  line-height: 1.5;
}

.is-hidden {
  display: none;
}

.list-page {
  width: min(100%, 560px);
}

.list-hero {
  padding: 30px 5px 22px;
}

.list-hero h1 {
  margin: 4px 0 8px;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 38px;
  line-height: 1.2;
}

.list-hero p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.history-list,
.draw-list {
  display: grid;
  gap: 12px;
}

.batch-card,
.draw-card,
.empty-state {
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  background: rgba(255, 253, 249, 0.96);
  box-shadow: 0 12px 30px rgba(92, 45, 37, 0.08);
}

.batch-card {
  overflow: hidden;
}

.batch-card__header,
.draw-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.batch-card__header {
  padding: 14px 15px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff9f6;
}

.batch-card__header > div {
  display: grid;
  gap: 2px;
}

.batch-label {
  color: var(--red);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.batch-card__header strong {
  font-family: Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.batch-card time,
.draw-card time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.batch-numbers {
  display: grid;
  gap: 8px;
  padding: 12px 10px 14px;
}

.history-number-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
}

.balls--history .ball {
  width: clamp(27px, 8.8vw, 35px);
  height: clamp(27px, 8.8vw, 35px);
  font-size: clamp(11px, 3.5vw, 14px);
}

.draw-card {
  padding: 14px;
}

.draw-card__header {
  margin-bottom: 12px;
}

.draw-card__header > div {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
}

.draw-card__header strong {
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 20px;
}

.empty-state {
  padding: 42px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 21px;
}

.empty-state p {
  margin: 8px 0 18px;
  font-size: 12px;
  line-height: 1.6;
}

.empty-state a {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 12px;
  color: #fff;
  background: var(--red);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  margin-top: 18px;
  align-items: center;
  gap: 10px;
}

.pagination a,
.pagination > span:not(.pagination__status) {
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--red-dark);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.pagination > :last-child {
  grid-column: 3;
}

.pagination .is-disabled {
  color: #b9afaa;
  background: rgba(255, 255, 255, 0.45);
}

.pagination__status {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.login-body {
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(100%, 430px);
  padding: max(24px, env(safe-area-inset-top)) 18px
    max(24px, env(safe-area-inset-bottom));
}

.login-card {
  padding: 34px 24px 28px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  background: rgba(255, 253, 249, 0.96);
  box-shadow: var(--shadow);
}

.login-mark {
  display: flex;
  width: 72px;
  margin-bottom: 26px;
  align-items: center;
}

.login-mark span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 7px 16px rgba(197, 31, 50, 0.22);
}

.login-mark span:last-child {
  margin-left: -10px;
  background: var(--blue);
  box-shadow: 0 7px 16px rgba(23, 105, 170, 0.22);
}

.login-card h1 {
  margin: 5px 0 8px;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 38px;
}

.login-intro {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.password-field {
  display: flex;
  overflow: hidden;
  border: 1px solid #ddcfca;
  border-radius: 14px;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.password-field:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(197, 31, 50, 0.09);
}

.password-field input {
  min-width: 0;
  min-height: 52px;
  flex: 1;
  padding: 0 14px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 16px;
}

.password-field button {
  width: 54px;
  border: 0;
  color: var(--red);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.login-button {
  min-height: 54px;
  margin-top: 6px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 10px 22px rgba(197, 31, 50, 0.22);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.login-note {
  margin: 18px 0 0;
  color: #9a8f8a;
  font-size: 10px;
  text-align: center;
}

.rules-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  margin-top: 14px;
  padding: 17px 14px;
  box-shadow: 0 12px 35px rgba(92, 45, 37, 0.08);
}

.rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.rule__number {
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 700;
}

.rule__number--blue {
  color: var(--blue);
}

.rule span:last-child {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.rule-divider {
  width: 1px;
  background: var(--line);
}

footer {
  padding: 23px 8px 0;
  color: #8d817c;
  font-size: 11px;
  line-height: 1.65;
  text-align: center;
}

footer p {
  margin: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 370px) {
  .page-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .generator-card {
    padding-right: 11px;
    padding-left: 11px;
  }

  .number-row {
    gap: 5px;
    padding-right: 7px;
    padding-left: 7px;
  }

  .balls {
    gap: 3px;
  }

  .ball-separator {
    margin: 0;
  }
}

@media (min-width: 700px) {
  .page-shell {
    padding-top: 55px;
    padding-bottom: 55px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
