:root {
  --page-bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dfe5ef;
  --line-strong: #ccd5e3;
  --text: #364968;
  --text-strong: #27406f;
  --muted: #7385a3;
  --blue: #3d73d9;
  --blue-strong: #2f62cb;
  --blue-soft: #eaf2ff;
  --red: #ef4a4a;
  --green: #10b981;
  --shadow: 0 14px 32px rgba(39, 64, 111, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html.landing-picker-preload .skip-link,
html.landing-picker-preload .page-shell {
  display: none;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(253, 254, 255, 0.98), rgba(244, 247, 252, 0.98)),
    repeating-linear-gradient(
      90deg,
      rgba(32, 75, 154, 0.018) 0,
      rgba(32, 75, 154, 0.018) 1px,
      transparent 1px,
      transparent 40px
    );
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.45;
}

a {
  color: var(--blue-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -40px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
}

.skip-link:focus {
  top: 12px;
  outline: none;
}

.page-shell {
  position: relative;
  width: min(1480px, calc(100vw - 16px));
  margin: 0 auto;
  padding: 8px 0 14px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mini-brand-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.mini-brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mini-brand-copy h1,
.surface-head h2,
.guide-head h2 {
  margin: 0;
  color: var(--text-strong);
  line-height: 1.1;
}

.mini-brand-copy h1 {
  font-size: 20px;
}

.mini-brand-copy p,
.eyebrow,
.guide-body p,
.lottery-info p,
.guide-list,
.guide-links {
  margin: 4px 0 0;
  color: var(--muted);
}

.mini-brand-copy p {
  font-size: 13px;
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  color: #7d8fb0;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.tool-button,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff, #f5f8fd);
  color: var(--text-strong);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  font-size: 13px;
}

.icon-button {
  width: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.tool-button:hover,
.tool-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--blue);
  box-shadow: 0 8px 16px rgba(47, 98, 203, 0.08);
  outline: none;
}

.page-main {
  display: grid;
  gap: 8px;
}

.status-strip,
.surface,
.guide-modal,
.lottery-modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.status-strip {
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at right 8% bottom 18%, rgba(61, 115, 217, 0.08) 0, rgba(61, 115, 217, 0.08) 2px, transparent 2px, transparent 10px),
    radial-gradient(circle at left -8% top -30%, rgba(61, 115, 217, 0.06), transparent 46%),
    radial-gradient(circle at right 105% top -15%, rgba(47, 98, 203, 0.08), transparent 38%),
    linear-gradient(180deg, #ffffff, #f8fbff);
}

.status-brand-title {
  color: var(--text-strong);
  font-size: clamp(24px, 2.4vw, 40px);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.status-hero {
  position: relative;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(160px, 0.75fr) minmax(220px, 1fr) minmax(330px, 1fr);
  align-items: center;
  padding: 8px 20px 6px;
}

.status-hero-center,
.status-hero-result {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.status-label {
  color: var(--muted);
  font-size: 14px;
}

.status-hero-center {
  justify-items: center;
  text-align: center;
}

.status-hero-result {
  justify-items: end;
  text-align: right;
}

.status-hero-center .status-label,
.status-hero-result .status-label {
  font-size: 15px;
}

.status-hero-center .status-label strong {
  color: var(--text-strong);
  font-size: 1em;
}

.hero-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.hero-countdown strong {
  color: #ab6812;
  font-size: 56px;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.hero-countdown span {
  color: #ab6812;
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

.status-inline-note {
  grid-column: 1 / -1;
  min-height: 0;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-ball-stage {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
}

.hero-balls {
  gap: 8px;
  flex-wrap: nowrap;
}

.ball-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 46px;
  align-items: center;
}

.ball-row.compact {
  gap: 7px;
  min-height: 40px;
}

.ball,
.ball-placeholder {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ball-row.compact .ball,
.ball-row.compact .ball-placeholder,
.result-balls .ball,
.result-balls .ball-placeholder {
  width: 34px;
  height: 34px;
  font-size: 17px;
}

.hero-balls .ball,
.hero-balls .ball-placeholder {
  width: 50px;
  height: 50px;
  font-size: 28px;
  border: 3px solid #d8e2f4;
  box-shadow: inset 0 4px 12px rgba(255, 255, 255, 0.18);
}

.ball {
  color: #ffffff;
  background: linear-gradient(180deg, #4e88ef, #3569d6);
  box-shadow: inset 0 4px 10px rgba(255, 255, 255, 0.16);
}

.ball-green {
  background: linear-gradient(180deg, #34c98d, #159a66);
}

.ball-blue {
  background: linear-gradient(180deg, #4e88ef, #3569d6);
}

.ball-red {
  background: linear-gradient(180deg, #ff6b6b, #df3a3a);
}

.ball-placeholder {
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  background: #f6f8fb;
}

.draw-loading {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(61, 115, 217, 0.18);
  border-radius: 999px;
  background: #f7faff;
  color: var(--blue-strong);
  font-size: 14px;
  font-weight: 700;
}

.mini-countdown {
  display: flex;
  gap: 8px;
}

.mini-time-box {
  min-width: 64px;
  min-height: 64px;
  padding: 7px 8px;
  border: 1px solid #e3e8f2;
  border-radius: var(--radius-sm);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 5px;
  background: linear-gradient(180deg, #fbfdff, #f6f8fc);
}

.mini-time-box strong {
  min-width: 44px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  background: var(--red);
  color: #ffffff;
  font-size: 24px;
  text-align: center;
}

.mini-time-box span {
  color: var(--muted);
  font-size: 12px;
}

.surface {
  padding: 12px;
}

.surface-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.content-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1.02fr) minmax(340px, 0.98fr);
  align-items: start;
}

.history-surface,
.ai-surface {
  height: clamp(620px, 70vh, 760px);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ai-surface {
  max-height: none;
  position: relative;
}

.history-head,
.ai-head {
  flex-wrap: wrap;
}

.ai-warning {
  margin: 0;
  max-width: 240px;
  color: var(--red);
  display: grid;
  gap: 2px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
}

.ai-warning span {
  display: block;
}

.history-table-wrap {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  scrollbar-gutter: stable;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.history-table th,
.history-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.history-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #fafbfd;
}

.history-table td strong {
  color: var(--text-strong);
}

.result-balls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.result-balls-track {
  display: flex;
  gap: 7px;
  flex-wrap: nowrap;
}

.group-pill {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 0 10px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(61, 115, 217, 0.16);
  background: #f5f8ff;
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.group-pill-rare {
  border-color: rgba(255, 119, 119, 0.18);
  background: #fff6f6;
  color: #d94d4d;
}

.ai-plan-panel {
  display: grid;
  gap: 16px;
  flex: 1;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.ai-plan-switches {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.ai-switch {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #ffffff;
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.ai-switch:hover,
.ai-switch:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 8px 16px rgba(47, 98, 203, 0.08);
  transform: translateY(-1px);
}

.ai-switch.is-active {
  border-color: rgba(47, 98, 203, 0.32);
  background: #f5f8ff;
}

.ai-current-panel {
  display: grid;
  gap: 12px;
}

.ai-current-line {
  color: var(--text-strong);
  font-size: 17px;
  font-weight: 600;
}

.ai-current-line.is-updating {
  color: #b42318;
}

.ai-history-panel {
  display: grid;
  gap: 8px;
  max-height: none;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
  align-content: start;
}

.ai-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 12px;
  align-items: center;
}

.ai-history-text {
  color: var(--text-strong);
  font-size: 16px;
  line-height: 1.45;
}

.ai-history-status {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
}

.ai-history-status.is-hit {
  color: var(--red);
}

.ai-history-status.is-miss {
  color: var(--green);
}

.ai-history-empty {
  color: var(--muted);
  font-size: 14px;
}

.empty-box {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fbfcfe;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 16px;
  display: grid;
  place-items: center;
  background: rgba(26, 37, 58, 0.38);
  backdrop-filter: blur(4px);
  z-index: 40;
}

.guide-modal,
.lottery-modal {
  width: min(640px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  padding: 16px;
}

.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.guide-body {
  margin-top: 14px;
  color: var(--text);
}

.lottery-body {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.lottery-options {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lottery-option {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff, #f5f8fd);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.lottery-option:hover,
.lottery-option:focus-visible {
  transform: translateY(-1px);
  border-color: var(--blue);
  box-shadow: 0 8px 16px rgba(47, 98, 203, 0.08);
  outline: none;
}

.lottery-option.is-active {
  border-color: rgba(47, 98, 203, 0.35);
  background: #edf4ff;
  color: var(--blue-strong);
}

.lottery-info {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
  color: var(--text);
}

.guide-list,
.guide-links {
  padding-left: 18px;
}

body.modal-open {
  overflow: hidden;
}

body.landing-picker {
  min-height: 100vh;
  background:
    linear-gradient(180deg, #fbfdff, #f1f5fb);
}

body.landing-picker .skip-link,
body.landing-picker .page-shell {
  display: none;
}

body.landing-picker.modal-open {
  overflow: auto;
}

body.landing-picker .modal-backdrop {
  position: static;
  min-height: 100vh;
  padding: 24px 12px;
  background: transparent;
  backdrop-filter: none;
}

body.landing-picker .lottery-modal {
  width: min(720px, 100%);
  box-shadow: 0 18px 48px rgba(39, 64, 111, 0.12);
}

body.landing-picker #closeLottery {
  visibility: hidden;
  pointer-events: none;
}

[data-lucide] {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
}

@media (max-width: 1320px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .status-hero {
    grid-template-columns: minmax(150px, 0.75fr) minmax(200px, 1fr) minmax(280px, 1fr);
    gap: 12px;
  }

  .status-brand-title {
    font-size: 28px;
  }

  .hero-balls .ball,
  .hero-balls .ball-placeholder {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100vw - 12px, 1480px);
  }

  .content-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .ai-surface {
    order: 1;
    height: min(58vh, 560px);
    max-height: none;
  }

  .history-surface {
    order: 2;
    height: min(58vh, 560px);
  }

  .site-header {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
    position: relative;
    width: 100%;
    min-height: 44px;
    padding-right: 148px;
  }

  .header-actions {
    position: absolute;
    top: 0;
    right: 6px;
    z-index: 5;
    justify-content: flex-end;
  }

  .status-hero {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "brand brand"
      "timer result";
  }

  .status-brand-title {
    grid-area: brand;
    text-align: center;
  }

  .status-hero-center {
    grid-area: timer;
  }

  .status-hero-result {
    grid-area: result;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 6px 0 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .surface,
  .guide-modal,
  .lottery-modal {
    padding: 10px;
  }

  .site-header {
    padding: 0 140px 0 6px;
  }

  .mini-brand-copy h1 {
    font-size: 18px;
  }

  .mini-brand {
    gap: 8px;
  }

  .mini-brand-mark {
    width: 50px;
    height: 50px;
    flex-basis: 50px;
  }

  .tool-button {
    min-height: 32px;
    padding: 0 9px;
    background: #ffffff;
    box-shadow: 0 6px 14px rgba(39, 64, 111, 0.08);
  }

  .status-hero {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "timer"
      "result";
    padding: 8px 10px 6px;
    gap: 10px;
  }

  .status-brand-title {
    font-size: 24px;
  }

  .status-hero-center .status-label,
  .status-hero-result .status-label {
    font-size: 13px;
  }

  .status-hero-result {
    justify-items: center;
    text-align: center;
  }

  .status-ball-stage {
    justify-content: center;
  }

  .hero-countdown {
    gap: 6px;
  }

  .hero-countdown strong {
    font-size: 34px;
  }

  .hero-countdown span {
    font-size: 20px;
  }

  .ball,
  .ball-placeholder {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .ball-row.compact .ball,
  .ball-row.compact .ball-placeholder,
  .result-balls .ball,
  .result-balls .ball-placeholder {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .hero-balls {
    gap: 8px;
  }

  .hero-balls .ball,
  .hero-balls .ball-placeholder {
    width: 42px;
    height: 42px;
    font-size: 23px;
    border-width: 2px;
  }

  .mini-time-box {
    min-width: 58px;
    min-height: 58px;
  }

  .mini-time-box strong {
    min-width: 40px;
    font-size: 21px;
  }

  .history-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .history-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .history-table th,
  .history-table td {
    padding: 8px 6px;
  }

  .history-table th:nth-child(1),
  .history-table td:nth-child(1) {
    width: 72px;
  }

  .history-table th:nth-child(3),
  .history-table td:nth-child(3) {
    width: 96px;
  }

  .history-table td:nth-child(3) {
    font-size: 12px;
    word-break: break-all;
  }

  .result-balls {
    justify-content: flex-start;
  }

  .result-balls-track {
    gap: 5px;
  }

  .group-pill {
    min-width: 44px;
    height: 24px;
    padding: 0 6px;
    font-size: 10px;
  }

  .ai-switch {
    min-height: 42px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 14px;
  }

  .ai-plan-panel {
    gap: 12px;
  }

  .ai-plan-switches {
    gap: 10px;
  }

  .ai-warning {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
    max-width: 142px;
    font-size: 12px;
    line-height: 1.25;
    text-align: right;
  }

  .ai-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    min-height: 34px;
    padding-right: 150px;
  }

  .ai-head > div {
    display: none;
  }

  .ai-current-line,
  .ai-history-text {
    font-size: 14px;
  }

  .ai-history-row {
    grid-template-columns: minmax(0, 1fr) 32px;
    gap: 8px;
  }

  .ai-history-status {
    font-size: 15px;
  }

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

  .lottery-option {
    min-height: 36px;
    padding: 0 8px;
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .site-header {
    position: static;
    padding-right: 128px;
  }

  .mini-brand {
    max-width: calc(100vw - 142px);
  }

  .mini-brand-copy h1 {
    font-size: 17px;
  }

  .mini-brand-copy p {
    font-size: 12px;
  }

  .header-actions {
    top: 6px;
    right: 6px;
  }

  .tool-button {
    gap: 4px;
    width: auto;
    min-width: 40px;
    padding: 0 8px;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
  }

  .tool-button [data-lucide] {
    display: none;
  }

  .tool-button::before {
    content: none;
    color: var(--text-strong);
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
  }

  #lotteryButton::before {
    content: "彩";
  }

  #lotteryButton::before {
    content: none;
  }

  .tool-button span {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: nowrap;
  }

  .lottery-options {
    grid-template-columns: 1fr;
  }

  .history-table th,
  .history-table td {
    padding-inline: 5px;
  }

  .history-table th:nth-child(1),
  .history-table td:nth-child(1) {
    width: 64px;
  }

  .history-table th:nth-child(3),
  .history-table td:nth-child(3) {
    width: 84px;
  }

  .result-balls-track {
    gap: 4px;
  }

  .result-balls .ball,
  .result-balls .ball-placeholder {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }
}
