:root {
  --bg: #061513;
  --panel: rgba(10, 34, 29, 0.84);
  --panel-strong: #0e2f29;
  --surface: #143c34;
  --surface-soft: rgba(20, 60, 52, 0.55);
  --accent: #37d39a;
  --accent-strong: #8df5cd;
  --gold: #f6cf74;
  --text: #eef9f3;
  --muted: #9cc8b8;
  --danger: #ff6e74;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --max-width: 1240px;
}

@font-face {
  font-family: "LuckyOrbitSans";
  src: url("./assets/fonts/NotoSansCJKsc-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "LuckyOrbitSans";
  src: url("./assets/fonts/NotoSansCJKsc-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(55, 211, 154, 0.18), transparent 28%),
    radial-gradient(circle at left center, rgba(246, 207, 116, 0.1), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: "LuckyOrbitSans", "Microsoft YaHei", "PingFang SC", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 21, 19, 0.2), rgba(6, 21, 19, 0.72)),
    url("./assets/images/ticket-texture.png") center/780px repeat;
  opacity: 0.18;
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.page-shell {
  width: min(var(--max-width), calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
  position: relative;
  z-index: 1;
}

.topbar,
.history-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 30%, rgba(246, 207, 116, 0.95), rgba(246, 207, 116, 0) 34%),
    linear-gradient(135deg, #215f4f, #0a231f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.brand span,
.nav-links a,
.meta-chip,
.field-hint,
.result-meta,
time,
.table-empty,
.list-card span,
.history-item span {
  color: var(--muted);
}

.brand strong,
.section-heading h2,
.hero-copy h1,
.draw-panel h2,
.panel-card h2 {
  font-family: "LuckyOrbitSans", "Segoe UI", "PingFang SC", sans-serif;
}

.nav-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-links a {
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  transition: 160ms ease;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--text);
  background: rgba(55, 211, 154, 0.18);
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.mode-badge::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(246, 207, 116, 0.14);
}

.mode-badge[data-mode="server"]::before {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(55, 211, 154, 0.14);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.draw-panel,
.panel-card,
.history-panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero-copy {
  padding: 30px;
}

.hero-copy::after {
  content: "";
  position: absolute;
  inset: auto -14% -24% auto;
  width: 320px;
  height: 320px;
  background: url("./assets/images/prize-glow.png") center/cover no-repeat;
  opacity: 0.2;
}

.eyebrow {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: rgba(246, 207, 116, 0.12);
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.hero-copy h1 {
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  line-height: 0.98;
  margin: 16px 0 12px;
}

.hero-copy p {
  max-width: 620px;
  font-size: 1.02rem;
  line-height: 1.72;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.metric-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 16px;
}

.metric-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-card strong {
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.mode-hint {
  margin-top: 18px;
  color: var(--muted);
}

.draw-panel {
  padding: 20px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 16px;
}

.draw-stage {
  min-height: 360px;
  padding: 24px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(6, 21, 19, 0.1), rgba(6, 21, 19, 0.78)),
    url("./assets/images/lottery-hero.png") center/cover no-repeat;
  display: flex;
  align-items: flex-end;
  position: relative;
}

.draw-stage::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.stage-ball {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--bg);
  background: radial-gradient(circle at 30% 30%, #fff5d6, var(--gold));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  margin-left: auto;
  margin-bottom: 8px;
}

.stage-ball.is-spinning {
  animation: wobble 0.32s linear infinite;
}

.draw-controls {
  display: grid;
  gap: 12px;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #04251d;
  font-weight: 700;
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.secondary-button,
.ghost-button {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.ghost-button {
  padding: 10px 12px;
}

.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.95fr;
  gap: 22px;
}

.panel-card,
.history-panel {
  padding: 20px;
}

.panel-card::before,
.history-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("./assets/images/ticket-texture.png") center/520px repeat;
  opacity: 0.08;
  pointer-events: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.48rem;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stack-form,
.field-grid {
  display: grid;
  gap: 12px;
}

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

.stack-form input,
.stack-form textarea,
.stack-form select,
.field-grid input,
.field-grid textarea,
.field-grid select {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.stack-form textarea {
  min-height: 116px;
  resize: vertical;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.list-shell {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.list-card,
.prize-card,
.history-item,
.history-detail-card,
.empty-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
}

.prize-card,
.history-detail-card {
  align-items: flex-start;
}

.prize-card.is-finished {
  opacity: 0.62;
}

.list-card strong,
.prize-card strong,
.history-item strong,
.history-detail-card strong {
  display: block;
  margin-bottom: 6px;
}

.prize-card p,
.history-detail-card p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.55;
}

.prize-card span {
  color: var(--gold);
  font-size: 0.88rem;
}

.prize-side {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.prize-side b {
  font-size: 1.2rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.history-panel .section-heading {
  align-items: flex-start;
}

.modal-shell {
  width: min(520px, calc(100% - 24px));
  border: 0;
  padding: 0;
  border-radius: 28px;
  background: transparent;
}

.modal-shell::backdrop {
  background: rgba(4, 12, 10, 0.78);
  backdrop-filter: blur(6px);
}

.result-card {
  padding: 26px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(7, 27, 23, 0.95), rgba(7, 27, 23, 0.98)),
    url("./assets/images/prize-glow.png") right bottom / 280px no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.result-card h3 {
  margin: 8px 0 10px;
  font-size: 2rem;
}

.result-card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.result-card menu {
  display: flex;
  justify-content: flex-end;
  padding: 0;
  margin: 22px 0 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(9, 27, 23, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
  z-index: 20;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-type="success"] {
  border-color: rgba(55, 211, 154, 0.3);
}

.toast[data-type="error"] {
  border-color: rgba(255, 110, 116, 0.4);
}

.history-layout {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  gap: 22px;
}

.filters-card,
.table-card {
  border-radius: var(--radius-xl);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  padding: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.history-table th,
.history-table td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.history-table th {
  color: var(--muted);
  font-weight: 500;
}

.table-empty {
  text-align: center;
  padding: 28px 0;
}

.utility-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

@keyframes wobble {
  0% {
    transform: translateX(-4px) rotate(-9deg);
  }
  50% {
    transform: translateX(6px) rotate(10deg);
  }
  100% {
    transform: translateX(-4px) rotate(-9deg);
  }
}

@media (max-width: 1199px) {
  .hero-grid,
  .section-grid,
  .history-layout {
    grid-template-columns: 1fr;
  }

  .section-grid {
    gap: 18px;
  }
}

@media (max-width: 767px) {
  .page-shell {
    width: min(var(--max-width), calc(100% - 20px));
    padding-top: 16px;
  }

  .topbar,
  .history-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-grid,
  .summary-grid,
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .draw-stage {
    min-height: 280px;
  }

  .stage-ball {
    width: 84px;
    height: 84px;
    font-size: 2rem;
  }
}

@media (max-width: 560px) {
  .stat-grid,
  .summary-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .draw-panel,
  .panel-card,
  .history-panel,
  .filters-card,
  .table-card {
    padding: 18px;
    border-radius: 22px;
  }

  .utility-row,
  .history-item,
  .list-card,
  .prize-card {
    align-items: stretch;
    flex-direction: column;
  }

  .prize-side {
    width: 100%;
    justify-items: stretch;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
