body[data-page="home"] .draw-stage {
  grid-template-columns: minmax(0, 1.42fr) minmax(330px, 0.72fr);
  align-items: stretch;
}

body[data-page="home"] .qa-fixture-banner {
  margin: 0 0 10px;
  padding: 9px 12px;
  border: 1px solid #c27a00;
  border-radius: 9px;
  background: var(--warning-soft);
  color: #6d4700;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

body[data-theme="dark"][data-page="home"] .qa-fixture-banner { color: #ffe88a; }

body[data-page="home"] .live-strip,
body[data-page="home"] .inline-scratch {
  min-height: 286px;
}

body[data-page="home"] .inline-scratch,
body[data-page="home"] .history-panel,
body[data-page="home"] .shape-summary,
body[data-page="home"] .tic-game {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

body[data-page="home"] .inline-scratch {
  min-width: 0;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 8px;
  border-top: 7px solid var(--magenta);
}

body[data-page="home"] .inline-scratch > header,
body[data-page="home"] .tic-game > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

body[data-page="home"] .inline-scratch h2,
body[data-page="home"] .history-heading h2,
body[data-page="home"] .shape-summary h2,
body[data-page="home"] .tic-game h2 {
  margin: 2px 0 0;
  font-family: "AceBrush", "STKaiti", cursive;
  font-size: 1.42rem;
  font-weight: 400;
}

body[data-page="home"] .inline-scratch > header > span {
  color: var(--muted);
  font-size: 0.72rem;
}

body[data-page="home"] .inline-scratch-ticket {
  position: relative;
  min-height: 132px;
  overflow: hidden;
  padding: 14px 8px;
  display: grid;
  place-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: url("/assets/ace28-scratch-study-v1.png") center / cover;
}

body[data-page="home"] .inline-scratch-ticket .question-digits {
  margin: 0;
  gap: 4px;
}

body[data-page="home"] .inline-scratch-ticket .question-digits span {
  width: 35px;
  height: 35px;
  border-width: 2px;
  font-size: 1rem;
  box-shadow: 0 3px 0 rgb(52 8 117 / 0.16);
}

body[data-page="home"] .inline-scratch-ticket .question-digits strong {
  min-width: 42px;
  height: 37px;
  padding: 0 6px;
  font-size: 1.08rem;
}

body[data-page="home"] .inline-scratch-ticket p {
  max-width: 32ch;
  margin: 0 auto;
  color: #321064;
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
}

body[data-page="home"] .inline-scratch-ticket canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

body[data-page="home"] .inline-scratch-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  text-align: center;
}

body[data-page="home"] .inline-scratch > footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

body[data-page="home"] .inline-scratch > footer .button {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 0.72rem;
}

body[data-page="home"] .inline-scratch > footer a {
  color: var(--purple);
  font-size: 0.7rem;
  font-weight: 800;
}

body[data-page="home"] .history-panel {
  margin-top: 12px;
  overflow: hidden;
  border-top: 7px solid var(--purple);
}

body[data-page="home"] .history-heading {
  padding: 16px 18px 12px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

body[data-page="home"] .history-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

body[data-page="home"] [data-history-status][data-state="complete"] { color: var(--green); }
body[data-page="home"] [data-history-status][data-state="partial"] { color: #8a5b00; }
body[data-theme="dark"][data-page="home"] [data-history-status][data-state="partial"] { color: #ffe08b; }

body[data-page="home"] .history-heading label {
  min-width: 210px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

body[data-page="home"] .history-heading input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--ink);
}

body[data-page="home"] .history-summary {
  padding: 9px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-block: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.74rem;
}

body[data-page="home"] .history-summary strong {
  color: var(--purple);
  font-family: "AceDigits", monospace;
}

body[data-page="home"] .history-table-wrap {
  max-width: 100%;
  overflow: auto;
}

body[data-page="home"] .history-table {
  width: 100%;
  min-width: 1010px;
  border-collapse: collapse;
  font-size: 0.75rem;
}

body[data-page="home"] .history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 8px;
  background: var(--purple-dark);
  color: #ffffff;
  text-align: left;
  white-space: nowrap;
}

body[data-page="home"] .history-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  white-space: nowrap;
}

body[data-page="home"] .history-table tbody tr:nth-child(even) { background: var(--surface-soft); }
body[data-page="home"] .history-table tbody tr:hover { background: var(--surface-blue); }
body[data-page="home"] .history-issue { font-family: "AceDigits", monospace; font-weight: 700; }
body[data-page="home"] .history-issue small { margin-top: 2px; display: block; color: var(--muted); font-family: inherit; font-weight: 400; }
body[data-page="home"] .history-result { color: var(--magenta-dark); font-family: "AceDigits", monospace; font-size: 0.86rem; font-weight: 800; }
body[data-theme="dark"][data-page="home"] .history-result { color: #ff9fd0; }

body[data-page="home"] .history-pagination {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--line);
}

body[data-page="home"] .history-pagination button {
  min-width: 36px;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

body[data-page="home"] .history-pagination button.active {
  border-color: var(--purple);
  background: var(--purple);
  color: #ffffff;
}

body[data-page="home"] .history-pagination button:disabled { opacity: 0.42; cursor: not-allowed; }
body[data-page="home"] .page-buttons { display: contents; }
body[data-page="home"] .page-gap { padding: 0 2px; color: var(--muted); }
body[data-page="home"] [data-page-info] { width: 100%; color: var(--muted); font-size: 0.72rem; text-align: center; }

body[data-page="home"] .home-modules {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  align-items: start;
  gap: 12px;
}

body[data-page="home"] .practice-panel { min-width: 0; }
body[data-page="home"] .module-stack { min-width: 0; display: grid; gap: 12px; }
body[data-page="home"] .shape-summary,
body[data-page="home"] .tic-game { padding: 16px; }
body[data-page="home"] .shape-summary { border-top: 7px solid var(--blue); }
body[data-page="home"] .shape-summary header p { margin: 5px 0 0; color: var(--muted); font-size: 0.74rem; line-height: 1.45; }
body[data-page="home"] .shape-sample { margin: 11px 0 7px; color: var(--muted); font-size: 0.76rem; }
body[data-page="home"] .shape-sample b { color: var(--magenta-dark); font-family: "AceDigits", monospace; }
body[data-page="home"] .shape-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
body[data-page="home"] .shape-grid article { min-width: 0; padding: 8px 4px; display: grid; justify-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
body[data-page="home"] .shape-grid span { font-size: 0.68rem; font-weight: 800; }
body[data-page="home"] .shape-grid b { color: var(--purple); font-family: "AceDigits", monospace; font-size: 1.05rem; }
body[data-page="home"] .shape-grid small { color: var(--muted); font-size: 0.6rem; }
body[data-page="home"] .shape-summary[data-state="waiting"] .shape-grid { opacity: 0.48; }

body[data-page="home"] .tic-game { border-top: 7px solid var(--magenta); }
body[data-page="home"] .tic-game > header > span { max-width: 15ch; color: var(--muted); font-size: 0.7rem; text-align: right; }
body[data-page="home"] .tic-board { width: min(100%, 238px); margin: 14px auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
body[data-page="home"] .tic-cell { aspect-ratio: 1; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-soft); color: var(--purple); font-family: "AceDigits", monospace; font-size: 1.7rem; font-weight: 700; }
body[data-page="home"] .tic-cell[data-mark="O"] { color: var(--magenta-dark); }
body[data-page="home"] .tic-cell:disabled { cursor: default; opacity: 1; }
body[data-page="home"] .tic-game footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body[data-page="home"] .tic-game footer small { color: var(--muted); font-size: 0.65rem; text-align: right; }

@media (max-width: 820px) {
  body[data-page="home"] .draw-stage,
  body[data-page="home"] .home-modules { grid-template-columns: 1fr; }
  body[data-page="home"] .inline-scratch { min-height: 250px; }
  body[data-page="home"] .history-heading { align-items: stretch; }
}

@media (max-width: 560px) {
  body[data-page="home"] .live-strip { min-height: 250px; }
  body[data-page="home"] .inline-scratch { min-height: 236px; padding: 11px; }
  body[data-page="home"] .inline-scratch-ticket { min-height: 116px; }
  body[data-page="home"] .history-heading { padding: 13px; display: grid; gap: 10px; }
  body[data-page="home"] .history-heading label { min-width: 0; }
  body[data-page="home"] .history-summary { padding: 8px 13px; display: grid; gap: 3px; }
  body[data-page="home"] .history-table { min-width: 930px; font-size: 0.71rem; }
  body[data-page="home"] .history-table th,
  body[data-page="home"] .history-table td { padding: 7px 6px; }
  body[data-page="home"] .history-pagination { padding: 10px 8px; gap: 4px; }
  body[data-page="home"] .history-pagination button { min-width: 33px; min-height: 34px; padding: 5px 7px; font-size: 0.72rem; }
  body[data-page="home"] .shape-summary,
  body[data-page="home"] .tic-game { padding: 14px; }
  body[data-page="home"] .shape-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 350px) {
  body[data-page="home"] .inline-scratch-ticket .question-digits { gap: 2px; }
  body[data-page="home"] .inline-scratch-ticket .question-digits span { width: 31px; height: 31px; }
  body[data-page="home"] .inline-scratch-ticket .question-digits strong { min-width: 37px; height: 34px; }
  body[data-page="home"] .history-pagination [data-page-first],
  body[data-page="home"] .history-pagination [data-page-last] { display: none; }
}

/* Keep below-table controls outside the loading viewport until records arrive. */
body[data-page="home"] [data-history-loading] .history-table-wrap { min-height: 600px; }
