/* Billiard Club Studios: one design system for every page. Plain CSS, no JavaScript, no external requests.
   Grid: 40 columns x 25 rows. One cell = --c wide, 1.25 --c high (cell aspect 0.8, dot 4:3). Font: our own bitmap font (advance 0.8 em, em = cell height).
   Sizes follow docs/LAYOUT_MOBILE.md: phones fill the width (whole-pixel steps where they fit, else the exact fit), desktop 24 px cells, large desktop 30 px. */
@font-face { font-family: "BCS Teletext"; src: url("bcs-teletext-v3.woff") format("woff"); font-display: block; }

:root {
  --green: #0a5a2e; --white: #ffffff; --yellow: #ffff00; --cyan: #00ffff; --magenta: #ff00ff; --red: #ff0000; --blue: #0000ff;
  --c: max(8px, calc((100vw - 12px) / 40));
  --row: calc(var(--c) * 1.25);
}
@media (min-width: 363px) and (max-width: 389px) and (max-resolution: 2.49dppx) { :root { --c: 9px; } }
@media (min-width: 412px) and (min-resolution: 2.5dppx) and (max-width: 971px) { :root { --c: 10px; } }
@media (min-width: 972px) { :root { --c: 24px; } }
@media (min-width: 1260px) and (min-height: 1050px) { :root { --c: 30px; } }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--green); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--green); color: var(--white); min-height: 100vh; min-height: 100dvh;
  font-family: "BCS Teletext", ui-monospace, Menlo, Consolas, monospace; font-size: var(--row); line-height: var(--row);
  font-kerning: none; font-synthesis: none; letter-spacing: 0; font-variant-ligatures: none;
  padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom));
}
body.legal { padding-top: 0; }

.screen { width: calc(var(--c) * 40); margin: 0 auto; padding-left: calc(var(--c) * 2); padding-right: calc(var(--c) * 2); }
.screen > * { max-width: calc(var(--c) * 36); }
.lead { display: none; height: calc(var(--row) * 2); }
@media (min-width: 972px) { .lead { display: block; } body { padding-top: 24px; } body.legal { padding-top: 0; } }
body.legal .screen { padding-top: var(--row); }
body.legal .lead { display: none !important; }

/* the red DRAFT bar: row 0, full width */
.bar { background: var(--red); color: var(--white); height: calc(var(--row) + max(0px, env(safe-area-inset-top))); padding-top: max(0px, env(safe-area-inset-top)); width: 100%; }
.bar span { display: block; width: calc(var(--c) * 40); margin: 0 auto; padding-left: var(--c); white-space: nowrap; }   /* col 1: the longest bar text is 39 characters and must fit the 40 columns */

/* title: double height (the same glyphs stretched 2x), yellow, always the one h1 */
h1 { font-size: inherit; height: calc(var(--row) * 2); font-weight: normal; color: var(--yellow); white-space: nowrap; }
h1 > span { display: block; transform: scaleY(2); transform-origin: top left; height: var(--row); }
h1 + * { margin-top: var(--row); }          /* one empty row under the title */
body.legal h1 + * { margin-top: var(--row); }

h2 { font-size: inherit; font-weight: normal; color: var(--yellow); }
p, .list { margin: 0; }
p.gap, ul.gap { margin-bottom: var(--row); }
.l { display: block; white-space: nowrap; }
.ph { font-weight: normal; color: var(--magenta); }

.list { list-style: none; }
.list li { white-space: nowrap; padding-left: calc(var(--c) * 2); position: relative; }
.list li::before { content: "\2192"; color: var(--cyan); position: absolute; left: 0; }

/* the art block: 36 x 14 cells = 72 x 42 sixels */
.artwrap { margin-top: var(--row); margin-bottom: var(--row); height: calc(var(--row) * 14); }
.art { display: block; width: calc(var(--c) * 36); height: calc(var(--row) * 14); }
.home h1 + .artwrap { margin-top: var(--row); }
.home .games { margin-bottom: calc(var(--row) * 3); }
/* home games list: the WHOLE row (arrow + name) is the link; the look stays exactly as the plain list: white name, cyan arrow, same columns */
.games li { padding-left: 0; }
.games li::before { content: none; }
.list.games a { display: inline-block; position: relative; padding-left: calc(var(--c) * 2); color: var(--white); text-decoration: none; }
.list.games a::before { content: "\2192"; position: absolute; left: 0; color: var(--cyan); }
.list.games a:hover, .list.games a:focus-visible { background: var(--cyan); color: var(--green); }
.list.games a:hover::before, .list.games a:focus-visible::before { color: var(--green); }

/* link row: cyan, closes every page. Visible box = one row; the hit area is enlarged without moving the grid */
.links { white-space: nowrap; }
.links a { position: relative; color: var(--cyan); text-decoration: none; }
.links a::after { content: ""; position: absolute; inset: -10px -6px; }
.links.g3 { word-spacing: calc(var(--c) * 2); }   /* 3 blank cells between links (one space + 2 cells) */
.links.g2 { word-spacing: var(--c); }             /* 2 blank cells */
.list a { color: var(--cyan); text-decoration: none; position: relative; }
.list a::after { content: ""; position: absolute; inset: -10px -6px; }
a:hover, a:focus-visible { background: var(--cyan); color: var(--green); outline: none; }
body.legal .links { margin-top: var(--row); }

@media print { html, body { background: #fff; } }

/* ===== Mobile R2 (game-uiux, docs/MOBILE_R2.md): phones and small windows only. Everything above is the approved desktop CSS, untouched; nothing below applies at >= 972 px. =====
   --lh: line pitch for reading (font size and glyph shapes stay = --row; only the space between lines grows). 44 px = minimum touch target. */
@media (max-width: 971px) {
  :root { --lh: calc(var(--c) * 1.6); --tap: 44px; --top: max(20px, calc(env(safe-area-inset-top) + 10px)); }
  body {
    display: flex; flex-direction: column; line-height: var(--lh);
    padding-top: var(--top); padding-bottom: 0;
    padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  }
  body.legal { padding-top: 0; }
  .bar { height: calc(var(--lh) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); margin-left: calc(env(safe-area-inset-left) * -1); margin-right: calc(env(safe-area-inset-right) * -1); width: auto; align-self: stretch; }
  .bar span { line-height: var(--lh); }
  .screen { flex: 1 0 auto; display: flex; flex-direction: column; }
  body.legal .screen { padding-top: calc(var(--lh) * 1.5); }
  .screen > * { max-width: calc(var(--c) * 36); }
  h1 { height: calc(var(--lh) * 2); }
  h1 > span { height: var(--lh); }
  h1 { margin-bottom: calc(var(--lh) * 1.5); }
  h1 + *, body.legal h1 + * { margin-top: 0; }
  p.gap, ul.gap { margin-bottom: calc(var(--lh) * 1); }
  .l { line-height: var(--lh); }

  /* touch rows: every list row is a 44 px tall flex row; arrow and label keep the same two-cell column */
  .list li { display: flex; align-items: center; min-height: var(--tap); padding-left: 0; }
  .list li::before { position: static; flex: 0 0 calc(var(--c) * 2); }
  .list li a { display: flex; align-items: center; flex: 1; min-height: var(--tap); }
  .list a::after { content: none; }
  .list.games a { display: flex; align-items: center; padding-left: 0; width: 100%; min-height: var(--tap); }
  .list.games a::before { position: static; flex: 0 0 calc(var(--c) * 2); }
  .home .games { margin-bottom: 0; }

  /* bottom app-style navigation: links spread edge to edge of the text column, 44 px touch targets, stays at the bottom of the screen (sticky while a long page scrolls), safe-area aware */
  .links, .links.g2, .links.g3 { word-spacing: 0; display: flex; justify-content: space-between; margin-top: auto; align-self: stretch; max-width: none; width: calc(var(--c) * 36);
    position: sticky; bottom: 0; background: var(--green); padding-top: calc(var(--lh) * 0.5); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  body.legal .links { margin-top: auto; }
  .links a { display: flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: var(--tap); }
  .links a::after { content: none; }
  @media (hover: none) { a:hover { background: none; } .links a:hover, .list a:hover { color: var(--cyan); } .list.games a:hover { color: var(--white); } .list.games a:hover::before { color: var(--cyan); } }

  /* short pages: intentional vertical distribution (free height is shared between the groups; they never overlap and never shrink below the tight layout) */
  .home .artwrap, .home h1 + .artwrap { margin-top: auto; margin-bottom: 0; }
  .home .games { margin-top: auto; margin-bottom: auto; }
  /* legal pages (all fit one phone screen except the longest ones): free height goes between the sections; on a page that overflows every auto margin is 0 */
  body.legal h1 + *, body.legal h2 { margin-top: auto; }
}

/* R3: home title in the three ball colours (9 yellow, 7 blue, 0 red); home only, same glyphs and positions */
h1 .t9 { color: var(--yellow); } h1 .t7 { color: var(--blue); } h1 .t0 { color: var(--red); }

/* k (Factive privacy draft page only): dash bullets and inline links in the 36-column text. Nothing above changes. */
.bl { list-style: none; margin: 0; }
.bl.gap { margin-bottom: var(--row); }
.bl li { position: relative; padding-left: calc(var(--c) * 2); }
.bl li::before { content: "-"; position: absolute; left: 0; color: var(--white); }
.l a { color: var(--cyan); text-decoration: none; }
@media (max-width: 971px) { .bl.gap { margin-bottom: calc(var(--lh) * 1); } }
