:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f3f3f3;
  color: #333;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #f3f3f3; }

body { overflow-x: hidden; }

.page {
  width: min(100%, 720px);
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 14px rgba(0, 0, 0, .12);
}

.lottery-sticky {
  position: sticky;
  top: 0;
  z-index: 999;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .12);
}

/*
 * 隐藏维护说明：以下选择器配合 ok.html 的 ?view=header 和 ?view=content 使用。
 * header 模式只保留 .lottery-sticky；content 模式隐藏它，吸顶定位由父页面负责。
 * 两种嵌入模式都必须 min-height: 0，否则 iframe 在桌面/手机宽度切换后可能无法缩短。
 */
html[data-view="header"],
html[data-view="header"] body,
html[data-view="content"],
html[data-view="content"] body {
  min-height: 0;
  background: #fff;
}

html[data-view="header"] .page,
html[data-view="content"] .page {
  width: 100%;
  box-shadow: none;
}

html[data-view="header"] .page > :not(.lottery-sticky) { display: none !important; }
html[data-view="header"] .lottery-sticky { position: static; box-shadow: none; }
html[data-view="content"] .lottery-sticky { display: none; }

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

.lottery-tab {
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 16px;
  background: #eee;
  color: #222;
  font: 700 18px/1 inherit;
  cursor: pointer;
  white-space: nowrap;
}

.lottery-tab img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex: 0 0 auto;
}

.lottery-tab.active { background: #efc42f; color: #fff; }

.quick-result {
  display: grid;
  grid-template-columns: 138px repeat(6, 1fr) 26px 1fr;
  min-height: 42px;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  background: #fff;
}

.quick-meta {
  display: grid;
  place-content: center;
  text-align: center;
  font-size: 15px;
  line-height: 18px;
}

.quick-meta b { color: #000; }
.quick-records {
  display: inline-block;
  padding: 0 3px;
  background: #ffeb3b;
  color: #f00;
  font-weight: 700;
}

.quick-ball {
  display: grid;
  grid-template-rows: 22px 20px;
  text-align: center;
  border-left: 1px solid #eee;
}

.quick-ball strong { color: #fff; font-size: 17px; line-height: 22px; }
.quick-ball span { color: #222; font-size: 15px; line-height: 20px; }
.quick-ball.red strong { background: #d62e24; }
.quick-ball.blue strong { background: #3187d8; }
.quick-ball.green strong { background: #41ae43; }
.quick-ball.gray strong { background: #8a8a8a; }

.quick-refresh {
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid #eee;
  padding: 0;
  background: #ffeb3b;
  color: #f00;
  font: 700 14px/16px inherit;
  cursor: pointer;
}

.video-frame {
  display: block;
  width: calc(100% - 10px);
  height: auto;
  aspect-ratio: 980 / 630;
  margin: 0 5px;
  border: 0;
  background: #30343c;
}

[hidden].video-frame { display: none !important; }

.video-placeholder {
  display: flex;
  aspect-ratio: 980 / 630;
  min-height: 0;
  height: auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #000;
  color: #fff;
  text-align: center;
}

.video-placeholder p {
  margin: 0;
  padding: 0 16px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.5;
}

.video-placeholder button {
  border: 1px solid #f00;
  border-radius: 4px;
  padding: 7px 18px;
  background: #ffeb3b;
  color: #f00;
  font: 700 18px/1.2 inherit;
  cursor: pointer;
}

.results { border-top: 1px solid #dfdfdf; background: #fff; }

.result-card {
  padding: 5px 5px 3px;
  border-bottom: 1px solid #dfdfdf;
}

.result-head, .result-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 27px;
  font-size: 20px;
  line-height: 1.25;
}

.result-head .name { flex: 1; }
.result-head .name, .result-foot > span { min-width: 0; white-space: nowrap; }
.result-head .period, .result-foot .next-period { color: #e33a2a; }
.result-head .countdown { min-width: 112px; text-align: center; }
.result-head a { color: #de4135; text-decoration: none; white-space: nowrap; }

.balls {
  display: grid;
  grid-template-columns: repeat(6, 1fr) 28px 1fr;
  gap: 6px;
  margin: 4px 0;
}

.ball {
  min-width: 0;
  height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #fff;
}

.ball.red { background: #d62f25; }
.ball.blue { background: #3589d9; }
.ball.green { background: #45af42; }
.ball.gray { background: #8a8a8a; }
.ball strong { font: 500 34px/38px Arial, sans-serif; }
.ball span { margin-top: 4px; padding: 1px 5px; border-radius: 2px; background: #fff; color: #333; font-size: 17px; white-space: nowrap; }
.plus { display: grid; place-items: center; font: 800 34px/82px Arial, sans-serif; }

.result-foot { justify-content: space-between; }
.refresh {
  border: 0;
  border-radius: 4px;
  padding: 1px 7px;
  background: #f3a22d;
  color: #fff;
  font: 17px/25px inherit;
  cursor: pointer;
}

.happy8-frame {
  display: block;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

@media (max-width: 560px) {
  .lottery-tab { height: 38px; border-radius: 13px; font-size: 16px; }
  .quick-result { grid-template-columns: 82px repeat(6, 1fr) 18px 1fr; min-height: 38px; }
  .quick-meta { font-size: 12px; line-height: 15px; }
  .quick-ball { grid-template-rows: 20px 18px; }
  .quick-ball strong { font-size: 14px; line-height: 20px; }
  .quick-ball span { font-size: 12px; line-height: 18px; }
  .video-placeholder { gap: 12px; }
  .video-placeholder p { font-size: 19px; }
  .video-placeholder button { font-size: 16px; }
  .result-head {
    display: grid;
    grid-template-columns: minmax(118px, 1fr) 76px 64px 64px;
    min-height: 24px;
    gap: 2px;
    font-size: 15px;
  }
  .result-head .countdown { min-width: 0; text-align: center; }
  .result-head a { text-align: center; }
  .result-foot { min-height: 24px; gap: 2px; font-size: 14px; }
  .balls { gap: 4px; grid-template-columns: repeat(6, 1fr) 20px 1fr; }
  .ball { height: 68px; }
  .ball strong { font-size: 25px; line-height: 29px; }
  .ball span { padding: 1px 2px; font-size: 12px; }
  .plus { font-size: 25px; line-height: 68px; }
  .refresh { flex: 0 0 auto; padding: 1px 4px; font-size: 13px; line-height: 21px; }
  .happy8-frame { min-height: 0; }
}

@media (max-width: 360px) {
  .lottery-tab { font-size: 14px; }
  .lottery-tab img { width: 18px; height: 18px; }
  .result-head a { font-size: 14px; }
  .ball span { font-size: 11px; }
}
