:root {
  color-scheme: light;
  --page: #eef4f6;
  --surface: #fdfefe;
  --surface-muted: #f3f5f5;
  --text: #171b1c;
  --muted: #687577;
  --line: #d8dfe0;
  --accent: #078f88;
  --accent-strong: #006b66;
  --accent-soft: #d8f1ef;
  --danger: #e23a43;
  --danger-soft: #ffd8e9;
  --focus: #f3a712;
  --radius: 7px;
  --shadow: 0 10px 28px rgba(20, 65, 67, 0.1);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--text);
  background: var(--page);
  font-size: 14px;
  line-height: 1.5;
}

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

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 9px 13px;
  border-radius: 6px;
  color: #172022;
  background: #f7d36d;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-shell {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 8px 8px 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.macau-banner {
  position: relative;
  min-height: 178px;
  overflow: hidden;
  border: 4px solid var(--danger);
  border-radius: var(--radius);
  background: #22383d url("/assets/macau-banner.webp") center 55% / cover no-repeat;
}

.macau-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(13, 27, 31, 0.78), rgba(13, 27, 31, 0.24) 58%, rgba(13, 27, 31, 0.16));
}

.banner-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 170px;
  flex-direction: column;
  justify-content: center;
  width: min(70%, 430px);
  padding: 18px 28px;
  color: #fff9e7;
  text-shadow: 0 2px 8px rgba(13, 20, 22, 0.64);
}

.banner-kicker {
  color: #f5d16f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.banner-overlay h1 {
  margin: 5px 0 0;
  color: #ffd85f;
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei", sans-serif;
  font-size: clamp(32px, 7vw, 54px);
  line-height: 1;
  letter-spacing: 0.08em;
}

.banner-overlay p {
  margin: 7px 0 2px;
  font-weight: 700;
}

.banner-overlay strong {
  font-size: 13px;
  letter-spacing: 0.12em;
}

.primary-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 0 7px;
}

.nav-link {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 5px 7px;
  border: 1px solid #01736e;
  border-radius: 999px;
  color: #f8ffff;
  background: var(--accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--accent-strong);
}

.ticker {
  display: flex;
  height: 34px;
  align-items: center;
  overflow: hidden;
  border-radius: 4px;
  color: #f9fbfb;
  background: #133c3d;
}

.ticker > strong {
  display: grid;
  align-self: stretch;
  min-width: 76px;
  place-items: center;
  color: #fff4c3;
  background: var(--accent);
}

.ticker-window {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-window span {
  display: inline-block;
  padding-left: 100%;
  animation: ticker 18s linear infinite;
}

.draw-panel {
  margin-top: 7px;
  overflow: hidden;
  border: 5px solid #078b87;
  border-radius: 0;
  background: #fff;
}

.draw-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px 10px 0;
  background: #fff;
}

.draw-tabs button {
  min-width: 0;
  padding: 2px 5px;
  border: 0;
  border-radius: 5px;
  color: #262626;
  background: #e9e9e9;
  font-family: inherit;
  font-size: clamp(16px, 2.4vw, 23px);
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.draw-tabs button:hover {
  background: #d9eeee;
}

.draw-tabs button:active {
  transform: scale(0.98);
}

.draw-tabs button:focus-visible {
  outline: 3px solid rgba(7, 139, 135, 0.28);
  outline-offset: 2px;
}

.draw-tabs [aria-selected="true"] {
  color: #fff;
  background: #f32626;
}

.draw-tabs [aria-selected="true"]:hover {
  background: #d91f1f;
}

.draw-heading {
  display: grid;
  grid-template-columns: auto auto minmax(70px, 1fr) auto;
  min-height: 40px;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: clamp(14px, 2vw, 20px);
}

.draw-heading strong {
  color: #282828;
  font-size: inherit;
  font-weight: 400;
}

.draw-heading > span {
  color: #f21c23;
}

.draw-heading time {
  color: #222;
  font-size: clamp(16px, 2.4vw, 23px);
  font-weight: 800;
  text-align: center;
}

.draw-heading time.is-expired {
  color: #d91f1f;
}

.draw-heading a {
  color: #00ad70;
  font-weight: 400;
  text-decoration: none;
}

.draw-numbers {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) 34px minmax(0, 1fr);
  align-items: stretch;
  gap: 7px;
  padding: 0 10px 7px;
}

.draw-ball-wrap {
  display: grid;
  min-width: 0;
  min-height: 79px;
  align-content: center;
  justify-items: center;
  gap: 5px;
  padding: 5px 4px;
  border-radius: 5px;
  background: #f5231c;
}

.draw-ball-wrap.blue {
  background: #2f7fdc;
}

.draw-ball-wrap.green {
  background: #00b947;
}

.draw-ball {
  color: #fff;
  background: transparent;
  font-size: clamp(25px, 3.8vw, 38px);
  font-weight: 900;
  line-height: 1;
}

.draw-zodiac {
  max-width: 100%;
  padding: 0 7px;
  overflow: hidden;
  color: #202020;
  background: #fff;
  font-size: clamp(10px, 1.55vw, 16px);
  line-height: 1.4;
  white-space: nowrap;
}

.draw-plus {
  display: grid;
  place-items: center;
  color: #1a1a1a;
  font-size: 38px;
  font-weight: 900;
}

.next-draw {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 5px;
  background: #fff;
  font-size: clamp(13px, 2vw, 19px);
}

.next-draw span:first-child {
  color: var(--danger);
  font-weight: 800;
}

.next-draw button {
  min-height: 27px;
  margin-left: auto;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  color: #fefafa;
  background: #ff9d2d;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.date-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  margin-top: 7px;
  padding: 8px 10px;
  border-radius: 4px;
  color: #fafefe;
  background: var(--accent);
  font-size: 12px;
  text-align: center;
}

.gallery-banner {
  display: block;
  margin-top: 7px;
  padding: 8px 10px;
  color: #f7f8ff;
  background: linear-gradient(90deg, #0471c0, #5252c9);
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.address-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 7px;
  border: 1px solid var(--line);
  background: #fffdfd;
}

.address-grid h2 {
  grid-column: 1 / -1;
  margin: 0;
  padding: 7px;
  color: var(--danger);
  background: #f1f2f2;
  font-size: 15px;
  text-align: center;
}

.address-grid a {
  min-height: 36px;
  padding: 8px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  color: var(--danger);
  font-weight: 800;
  text-align: center;
}

.address-grid a:nth-of-type(even) {
  border-right: 0;
}

.site-slogan {
  margin: 7px 0;
  padding: 8px 10px;
  color: #f7ffff;
  background: var(--accent);
  font-weight: 800;
  text-align: center;
}

.content-sections {
  display: grid;
  gap: 8px;
}

.content-section {
  scroll-margin-top: 8px;
  overflow: hidden;
  border: 2px solid var(--accent);
  background: #fffefe;
}

.content-section.theme-red {
  border-color: #ff5d91;
}

.section-title {
  margin: 0;
  padding: 8px 10px;
  color: #006c66;
  background: #c9f2ee;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
}

.theme-red .section-title {
  color: #263ec3;
  background: #ffc8e3;
}

.section-body {
  padding: 0;
}

.data-row {
  display: grid;
  grid-template-columns: minmax(105px, 0.34fr) minmax(0, 1fr);
  min-height: 35px;
  border-bottom: 1px solid var(--line);
}

.data-row:last-child {
  border-bottom: 0;
}

.data-label,
.data-value {
  padding: 7px 9px;
}

.data-label {
  border-right: 1px solid var(--line);
  color: #0b4ab7;
  font-weight: 800;
}

.data-value {
  color: var(--danger);
  font-weight: 800;
}

.text-content {
  padding: 12px;
  white-space: pre-wrap;
}

.link-list {
  display: grid;
}

.content-link {
  min-height: 38px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: #074fc4;
  background: #fffefe;
  font-weight: 800;
}

.content-link:last-child {
  border-bottom: 0;
}

.number-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 9px;
  border-bottom: 1px solid var(--line);
}

.number-row:last-child {
  border-bottom: 0;
}

.number-label {
  font-weight: 800;
}

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

.number-ball {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #fdfefe;
  background: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.number-row[data-color="red"] .number-ball { background: #df3d45; }
.number-row[data-color="blue"] .number-ball { background: #425ad0; }
.number-row[data-color="green"] .number-ball { background: #15914f; }

.loading-state,
.error-state {
  padding: 24px 12px;
  border: 1px solid var(--line);
  background: #f5f7f7;
  text-align: center;
}

.error-state button {
  min-height: 36px;
  margin-left: 10px;
  border: 0;
  border-radius: 4px;
  color: #fffafa;
  background: var(--danger);
}

.site-footer {
  padding: 20px 10px 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer p {
  margin: 3px 0;
}

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@media (max-width: 600px) {
  .site-shell {
    padding: 5px 5px 18px;
    box-shadow: none;
  }

  .macau-banner {
    min-height: 132px;
  }

  .banner-overlay {
    min-height: 124px;
    width: 82%;
    padding: 14px 17px;
  }

  .banner-overlay h1 {
    font-size: 34px;
  }

  .banner-overlay p {
    font-size: 12px;
  }

  .primary-nav {
    gap: 4px;
    padding-block: 5px;
  }

  .nav-link {
    min-height: 34px;
    padding-inline: 2px;
    font-size: 12px;
  }

  .draw-heading {
    grid-template-columns: auto auto minmax(55px, 1fr) auto;
    min-height: 30px;
    gap: 2px;
    padding-inline: 4px;
    font-size: 11px;
  }

  .draw-heading strong {
    font-size: inherit;
  }

  .draw-heading time {
    font-size: 13px;
  }

  .draw-tabs {
    gap: 4px;
    padding: 5px 4px 0;
  }

  .draw-tabs button {
    padding-inline: 2px;
    font-size: 12px;
  }

  .draw-numbers {
    grid-template-columns: repeat(6, minmax(0, 1fr)) 16px minmax(0, 1fr);
    gap: 3px;
    padding: 0 4px 4px;
  }

  .draw-ball-wrap {
    min-height: 57px;
    gap: 3px;
    padding: 4px 1px;
  }

  .draw-ball {
    font-size: 22px;
  }

  .draw-zodiac {
    padding-inline: 2px;
    font-size: 8px;
  }

  .draw-plus {
    font-size: 23px;
  }

  .next-draw {
    min-height: 29px;
    gap: 3px;
    padding: 1px 4px 3px;
    font-size: 11px;
  }

  .next-draw button {
    min-height: 24px;
    padding-inline: 5px;
    font-size: 12px;
  }

  .date-strip {
    display: grid;
    gap: 2px;
  }

  .data-row {
    grid-template-columns: minmax(80px, 0.34fr) minmax(0, 1fr);
  }

  .data-label,
  .data-value {
    padding: 7px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ticker-window span { animation: none; padding-left: 10px; }
}
