:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --ink: #202d29;
  --muted: #4c6159;
  --line: #d6dcd3;
  --accent: #255b4a;
  --soft: #eaf0e5;
  --numbers: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 1rem; line-height: 1.55; }
h1, h2, h3, p { margin: 0; }
h2, h3 { line-height: 1.35; }
a { color: var(--accent); text-underline-offset: 0.22em; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid #137453; outline-offset: 4px; }
[id] { scroll-margin-block: 1rem; }
.container { width: min(100% - 2rem, 68rem); margin-inline: auto; }

.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus {
  position: fixed;
  inset: 0.5rem auto auto 0.5rem;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  z-index: 2;
}

.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner {
  min-height: 3.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}
.brand, .official-link { min-height: 2.75rem; display: inline-flex; align-items: center; gap: 0.5rem; }
.brand { color: var(--ink); font-size: 1.2rem; font-weight: 800; text-decoration: none; }
.brand-mark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: linear-gradient(135deg, var(--accent) 50%, #d7e6d5 50%);
}
.official-link, .footer a { font-size: 0.88rem; font-weight: 700; }

main.container { padding-block: clamp(1.1rem, 5vw, 3.35rem) 1.5rem; }
.dayboard {
  display: grid;
  gap: 1.1rem;
  align-items: end;
  padding: clamp(1.05rem, 3.4vw, 2.4rem);
  border: 1px solid #c8d5c7;
  border-radius: 0.85rem;
  background: var(--soft);
}
h1 { font-size: 1rem; font-weight: 750; color: var(--accent); }
.date-display {
  display: block;
  min-height: 1.35em;
  margin-top: 0.34rem;
  font-size: clamp(1.8rem, 4.3vw, 3.35rem);
  font-weight: 820;
  letter-spacing: -0.035em;
  line-height: 1.19;
  overflow-wrap: anywhere;
}
.date-weekday {
  display: block;
  margin-top: 0.37rem;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 730;
  letter-spacing: normal;
}
.date-weekday:empty { display: none; }
.date-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.46rem; }
.date-panel label { font-size: 0.91rem; font-weight: 740; }
.date-panel input {
  width: 100%;
  min-width: 0;
  min-height: 2.8rem;
  border: 1px solid #9daea0;
  border-radius: 0.45rem;
  padding: 0.42rem 0.66rem;
  color: var(--ink);
  background: var(--surface);
}
.date-shortcuts { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.4rem; }
.date-shortcuts button, .copy-button {
  min-height: 2.75rem;
  border: 1px solid #a5b7a8;
  border-radius: 0.45rem;
  padding: 0.4rem 0.68rem;
  color: var(--accent);
  background: var(--surface);
  font-size: 0.87rem;
  font-weight: 760;
  cursor: pointer;
}
.date-shortcuts button:hover, .copy-button:hover:not(:disabled) { background: #e4eee1; }
.date-shortcuts button:first-child { text-align: left; }
.date-shortcuts button:last-child { text-align: right; }
.date-error { color: #892e25; font-size: 0.88rem; font-weight: 700; }
.notice { margin-top: 1rem; padding: 0.8rem; border: 1px solid var(--line); }

.schedule { margin-top: 1.35rem; }
.schedule-heading, .section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-bottom: 0.68rem;
}
.schedule-heading h2 { font-size: 1rem; }
.schedule-heading p, .section-header p { font-size: 0.88rem; color: var(--muted); }
.schedule-slots {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
}
.schedule-slots li + li { border-top: 1px solid var(--line); }
.schedule-slots a {
  display: grid;
  grid-template-columns: 4.1rem minmax(0, 1fr);
  align-items: baseline;
  column-gap: 0.65rem;
  padding: 0.62rem 0.8rem;
  color: var(--ink);
  text-decoration: none;
}
.schedule-slots a:hover { background: var(--soft); }
.schedule-slots a:hover .slot-formula { text-decoration: underline; }
.draw-time { grid-row: span 2; font: 750 1.28rem/1.2 var(--numbers); color: var(--accent); }
.slot-formula { font-size: 0.94rem; font-weight: 760; }
.slot-release { font-size: 0.83rem; color: var(--muted); }
.slot-release time, .section-header time, .section-header h2 span, .b8-card time { font-family: var(--numbers); font-weight: 720; }

.round-block, .evidence { margin-top: clamp(1.6rem, 4.5vw, 2.8rem); }
.section-header h2 { font-size: clamp(1.22rem, 2.5vw, 1.55rem); }
p.source-status { display: inline-flex; align-items: center; gap: 0.46rem; font-weight: 740; }
.source-status::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  flex: none;
  border-radius: 50%;
  background: #7a8d84;
}
.source-status[data-state="ready"]::before, .source-status[data-state="historical"]::before { background: #287956; }
.source-status[data-state="waiting"]::before, .source-status[data-state="waiting_release"]::before { background: #966716; }
.source-status[data-state="error"]::before { background: #b34035; }

.results { display: grid; align-items: start; gap: 0.85rem; }
.pick-card {
  --card-ink: #27533f;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: clamp(0.85rem, 2.7vw, 1.3rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
}
.pick-card-67 { --card-ink: #344c66; }
.b8-card { --card-ink: #61472d; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.65rem; }
.card-header h3 { color: var(--card-ink); font-size: 1.3rem; font-weight: 820; }
.card-header h3 span { font: 750 1.45rem/1 var(--numbers); }
.card-header p { margin-top: 0.28rem; color: var(--muted); font-size: 0.89rem; }
.copy-button { flex: none; white-space: nowrap; color: var(--card-ink); }
.copy-button:disabled { color: #596860; background: #f1f2ec; cursor: default; }
.picks {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(0.22rem, 0.65vw, 0.42rem);
  margin: 0;
  padding: 0;
  list-style: none;
  user-select: text;
}
.picks li {
  padding: 0.47rem 0.04rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: #f1f3eb;
  color: var(--card-ink);
  text-align: center;
  font: 690 clamp(0.78rem, 1.5vw, 1.04rem)/1.1 var(--numbers);
}
.pick-card-67 li { background: #eef1f3; }
.b8-card li { background: #f5eee2; }
.card-count, .b8-source { font-size: 0.84rem; color: var(--muted); }
.card-count { margin-top: auto; font-weight: 720; }
.b8-source { margin-top: -0.5rem; }
.empty-message {
  padding: 0.68rem 0.72rem;
  border-inline-start: 2px solid #a2b4a3;
  background: #f2f3ed;
  color: var(--muted);
  font-size: 0.92rem;
}

.overlap {
  display: grid;
  gap: 0.28rem;
  margin-top: 0.75rem;
  padding: 0.78rem 0.92rem;
  background: var(--soft);
  border: 1px solid #cbd8c8;
  border-radius: 0.56rem;
}
.overlap-head { display: flex; align-items: baseline; gap: 0.28rem 0.72rem; flex-wrap: wrap; }
.overlap-head h3 { font-size: 0.99rem; }
.overlap-head p, .overlap-values { color: var(--muted); font-size: 0.88rem; }
.overlap-head strong { color: var(--accent); font: 750 1.02rem/1 var(--numbers); }
.overlap-values { overflow-wrap: anywhere; }
.overlap-values[data-ready="true"] { color: var(--ink); font: 620 0.92rem/1.7 var(--numbers); }

.evidence-grid { display: grid; gap: 0.7rem; }
.anchor-panel, .last-panel { min-width: 0; padding: 0.88rem 0.95rem; border-top: 1px solid var(--line); }
.anchor-panel h3, .last-panel h3 { font-size: 0.96rem; }
.anchor-panel p, .last-panel p { margin-top: 0.26rem; color: var(--muted); font-size: 0.88rem; }
.anchor-value { display: block; margin-top: 0.4rem; color: var(--accent); font: 760 2.05rem/1.16 var(--numbers); }
.last-five { display: grid; grid-template-columns: repeat(auto-fit, minmax(3.7rem, 1fr)); gap: 0.48rem; list-style: none; margin: 0.64rem 0 0; padding: 0; }
.last-five li { display: grid; gap: 0.34rem; border-inline-start: 2px solid #b2c5b2; padding-inline-start: 0.44rem; }
.last-five time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.last-five strong { font: 680 1.12rem/1 var(--numbers); }
.footer { margin-top: 1.65rem; padding-block: 0.8rem 0.2rem; border-top: 1px solid var(--line); }
.footer a { display: inline-flex; min-height: 2.75rem; align-items: center; }

@media (min-width: 40rem) {
  .dayboard { grid-template-columns: minmax(0, 1.5fr) minmax(15rem, 0.7fr); }
  .schedule-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .schedule-slots li + li { border-top: 0; border-inline-start: 1px solid var(--line); }
  .schedule-slots a { padding: 0.82rem 0.9rem; }
  .evidence-grid { grid-template-columns: minmax(11rem, 0.65fr) minmax(0, 1.35fr); }
}
@media (min-width: 52rem) {
  .results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .picks { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
@media (max-width: 21rem) {
  .container { width: calc(100% - 1.2rem); }
  .date-shortcuts button { padding-inline: 0.45rem; }
}

