:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #eef6f7;
  --ink: #111827;
  --muted: #667085;
  --line: #d6e0ea;
  --red: #c91f37;
  --red-deep: #8f1025;
  --red-soft: #fff1f0;
  --blue: #0f64d8;
  --blue-deep: #073b91;
  --blue-soft: #eef4ff;
  --green: #087a5a;
  --green-deep: #07553f;
  --gold: #b7791f;
  --shadow: 0 22px 70px rgba(17, 24, 39, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #f8fbff 0%, #edf7f4 46%, #fff7f4 100%);
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 28px;
  overflow: hidden;
}

.hero-scene {
  position: absolute;
  inset: 0 0 auto;
  height: 430px;
  overflow: hidden;
  pointer-events: none;
}

.hero-scene::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(248, 251, 255, 0.2), rgba(248, 251, 255, 0.92) 80%, #f8fbff),
    linear-gradient(90deg, rgba(248, 251, 255, 0.94), rgba(248, 251, 255, 0.42), rgba(248, 251, 255, 0.9));
}

.hero-scene img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.72;
}

.workspace {
  position: relative;
  width: min(1120px, 100%);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
  min-height: 220px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.9) 42%, rgba(255, 255, 255, 0.28) 100%),
    url("./assets/lottery-hero.png") right center / 58% auto no-repeat;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.subtitle {
  max-width: 460px;
  margin: 10px 0 0;
  color: #475467;
  font-size: 15px;
  line-height: 1.6;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.game-tabs {
  align-self: flex-start;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 6px;
  padding: 5px;
  background: rgba(238, 246, 247, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.game-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.game-tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 6px rgba(16, 24, 40, 0.1);
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.summary-band > div {
  min-height: 82px;
  padding: 18px 24px;
  background: rgba(251, 252, 254, 0.88);
}

.summary-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.summary-band strong {
  font-size: 18px;
}

.result-panel {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 18px;
  padding: 24px 28px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 249, 252, 0.92)),
    radial-gradient(circle at 20% 0%, rgba(201, 31, 55, 0.08), transparent 24rem),
    radial-gradient(circle at 88% 10%, rgba(15, 100, 216, 0.1), transparent 20rem);
}

.result-group {
  min-height: 98px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(246, 249, 252, 0.78)),
    radial-gradient(circle at top right, rgba(183, 121, 31, 0.18), transparent 16rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 28px rgba(17, 24, 39, 0.06);
}

.result-title {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 42px;
}

.ball {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  box-shadow:
    inset 7px 9px 14px rgba(255, 255, 255, 0.3),
    inset -9px -12px 18px rgba(0, 0, 0, 0.24),
    0 14px 22px rgba(17, 24, 39, 0.18);
}

.ball.red {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.95) 0 9%, transparent 10%),
    radial-gradient(circle at 35% 28%, #ff7586 0%, var(--red) 45%, var(--red-deep) 100%);
}

.ball.blue {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.95) 0 9%, transparent 10%),
    radial-gradient(circle at 35% 28%, #74b7ff 0%, var(--blue) 48%, var(--blue-deep) 100%);
}

.ball.green {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.95) 0 9%, transparent 10%),
    radial-gradient(circle at 35% 28%, #52d6ad 0%, var(--green) 48%, var(--green-deep) 100%);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 28px 24px;
  border-bottom: 1px solid var(--line);
}

.primary-action,
.save-action,
.ghost-action {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  color: #fff;
  background: #101828;
  border: 1px solid #101828;
}

.save-action {
  color: #fff;
  background: linear-gradient(135deg, var(--green), #0a8f72);
  border: 1px solid #0a7a61;
}

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

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 252, 0.9)),
    radial-gradient(circle at 12% 22%, rgba(8, 122, 90, 0.06), transparent 26rem);
}

.picker-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 350px);
  gap: 22px;
}

body[data-game="kl8"] .result-panel,
body[data-game="kl8"] .picker-area {
  grid-template-columns: 1fr;
}

body[data-game="kl8"] .number-grid {
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
}

.number-section {
  min-width: 0;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 252, 0.86));
  border: 1px solid rgba(214, 224, 234, 0.95);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.06);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.number-section .section-heading {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(214, 224, 234, 0.72);
}

.section-heading span {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 14px 12px;
  padding-top: 16px;
}

.number-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
}

.number-btn {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid #d5e2ee;
  border-radius: 50%;
  color: #111827;
  background:
    radial-gradient(circle at 32% 24%, #ffffff 0 13%, transparent 14%),
    radial-gradient(circle at 34% 28%, #ffffff 0%, #f8fbff 42%, #dfeaf4 100%);
  cursor: pointer;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  box-shadow:
    inset 7px 8px 12px rgba(255, 255, 255, 0.94),
    inset -8px -10px 14px rgba(75, 100, 130, 0.14),
    0 10px 18px rgba(17, 24, 39, 0.09);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}

.number-btn::after {
  position: absolute;
  inset: 8%;
  z-index: -1;
  content: "";
  border-radius: inherit;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.58), transparent 58%);
  pointer-events: none;
}

.number-btn:hover {
  border-color: #9bb2c8;
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    inset 7px 8px 12px rgba(255, 255, 255, 0.94),
    inset -8px -10px 14px rgba(75, 100, 130, 0.14),
    0 15px 26px rgba(17, 24, 39, 0.13);
}

.number-btn.selected.red {
  color: #fff;
  background:
    radial-gradient(circle at 31% 23%, rgba(255, 255, 255, 0.98) 0 12%, transparent 13%),
    radial-gradient(circle at 36% 28%, #ff8795 0%, var(--red) 46%, var(--red-deep) 100%);
  border-color: var(--red);
  text-shadow: 0 1px 2px rgba(72, 0, 12, 0.55);
}

.number-btn.selected.blue {
  color: #fff;
  background:
    radial-gradient(circle at 31% 23%, rgba(255, 255, 255, 0.98) 0 12%, transparent 13%),
    radial-gradient(circle at 36% 28%, #7dc4ff 0%, var(--blue) 48%, var(--blue-deep) 100%);
  border-color: var(--blue);
  text-shadow: 0 1px 2px rgba(0, 31, 86, 0.55);
}

.number-btn.selected.green {
  color: #fff;
  background:
    radial-gradient(circle at 31% 23%, rgba(255, 255, 255, 0.98) 0 12%, transparent 13%),
    radial-gradient(circle at 36% 28%, #5de2b8 0%, var(--green) 48%, var(--green-deep) 100%);
  border-color: var(--green);
  text-shadow: 0 1px 2px rgba(0, 61, 43, 0.55);
}

.number-btn.selected {
  box-shadow:
    inset 8px 9px 13px rgba(255, 255, 255, 0.3),
    inset -10px -13px 18px rgba(0, 0, 0, 0.25),
    0 16px 26px rgba(17, 24, 39, 0.2);
}

.records-panel {
  min-width: 0;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(247, 250, 252, 0.82));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.06);
}

.text-action {
  border: 0;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.record-list {
  display: grid;
  gap: 12px;
  max-height: 620px;
  overflow: auto;
  padding-right: 2px;
}

.empty-records {
  margin: 0;
  padding: 22px 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed #b8c4d0;
  border-radius: 8px;
  line-height: 1.6;
}

.record-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 252, 0.9));
  border: 1px solid rgba(214, 224, 234, 0.95);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.05);
}

.record-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.record-game {
  color: var(--ink);
  font-weight: 900;
}

.record-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mini-action {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(16, 24, 40, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 780px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .result-panel,
  .content-grid,
  .picker-area {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .summary-band {
    grid-template-columns: 1fr;
  }

  .content-grid,
  .topbar {
    padding: 20px;
  }

  .result-panel,
  .actions {
    padding-left: 20px;
    padding-right: 20px;
  }

  .number-grid,
  .number-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 12px 10px;
  }
}
