/* [FONTS] The site's four fonts, served from our own fonts/ folder (was
   Google Fonts until 2026-11-24: on a slow connection the page showed a
   stand-in font first, then switched). Here because every page loads
   rules.css. Latin letters only; ✓ ✗ ▸ ✎ come from the device's fonts.
   font-display: block = a moment of invisible text rather than the wrong
   font (the browser falls back after ~3 s if a file never arrives).
   Each page also "preloads" the ones it shows first (<link rel="preload">
   in its <head>). The start screen's title and buttons don't wait at all:
   index.html has their letters built in. Nunito and Rubik are "variable"
   fonts: one file holds every weight. All four: SIL Open Font License. */
@font-face {
  font-family: 'Geo';
  src: url('fonts/geo.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Lilita One';
  src: url('fonts/lilita-one.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Nunito';
  src: url('fonts/nunito.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: block;
}
@font-face {
  font-family: 'Rubik';
  src: url('fonts/rubik.woff2') format('woff2');
  font-weight: 300 900;
  font-display: block;
}
/* ═══════════════════════════════════════════════════════════════════
   RULES POPUP + RULES BUTTON
   Shared by index.html (splash) and play.html (game). The popup's text
   and pictures are built in rules.js; everything about how it looks is
   here. Search for [FONTS] [COLORS] [POSITIONING].
═══════════════════════════════════════════════════════════════════ */
:root {
  /* [FONTS] Geo for headings and buttons; Nunito for the text you read */
  --rules-font:          'Geo', 'Segoe UI', sans-serif;
  --rules-text-font:     'Nunito', 'Segoe UI', sans-serif;
  /* the popup's title: Lilita One, the start screen's title font, a little
     bigger than the Geo it was (user, 2026-11-05) */
  --rules-title-font:    'Lilita One', 'Segoe UI', sans-serif;
  --rules-title-size:    2.3rem;
  --rules-heading-size:  1.5rem;     /* "Goals" / "Rules" */
  --rules-text-size:     1rem;
  --rules-caption-size:  0.9rem;     /* labels under pictures */
  /* every counting number: the row/column counts and the numbers on blocks
     and squares (Rubik: the user's pick, 2026-11-23; was Nunito for the
     counts and Geo for the numbers, whose 1 looked like a 7) */
  --rules-count-font:    'Rubik', 'Nunito', system-ui, sans-serif;
  --rules-count-size:    21px;      /* (was 19: bigger numbers, mock-up B) */

  /* [COLORS] Woodblock, light mode (default); dark mode is the html.dark
     block below. Same colors as game.css. */
  --rules-panel:         #FBFBF8;    /* popup background */
  --rules-panel-border:  #DCDDD6;
  --rules-overlay:       rgba(31, 35, 48, 0.45);
  --rules-title:         #1F2330;    /* headings */
  --rules-text:          #1F2330;
  --rules-text-dim:      #5E6270;    /* hint line, picture captions */
  /* (brighter since 2026-11-16, user picked counting mock-up B; the same as
     game.css --color-count-even / -odd) */
  --rules-even:          #3E9B3A;    /* green highlighter: even row/column */
  --rules-odd:           #E2483D;    /* red highlighter: odd row/column, "not allowed" mark */
  --rules-highlight-opacity: 0.4;    /* red highlighter strength */
  --rules-highlight-even-opacity: 0.4;   /* green highlighter strength */
  --rules-board:         #DCDFE6;    /* frame behind picture boards (as on the board) */
  --rules-cell:          #FFFFFF;    /* an empty square in pictures */
  --rules-dotted:        #E2483D;    /* dotted lines: vermilion */
  --rules-arrow:         #1F2330;    /* reflect / rotate arrows */
  --rules-empty:         #2B4C7E;    /* ring marking an empty open square (analyzer) */
  --rules-button:        #1F2330;    /* "Got it" button (filled ink) */
  --rules-button-text:   #F5F5F2;
  --rules-btn-bg:        #FBFBF8;    /* the small plain buttons: Rules, Large text, Dark mode */
  --rules-btn-hover:     #ECECE6;
  --rules-btn-line:      #1F2330;    /* their fine ink border */
  /* The official terms (grid, square, empty square, block, piece,
     pentomino, Tiling, Solving for Parity) in their own color, in the
     rules and the tutorial (user, 2026-11-14; markTerms in shapes.js) */
  --color-term:          #1E7B86;    /* deep teal */
  --rules-hl:            #F6DC74;    /* an empty square highlighted (the highlighter's yellow) */
  --rules-accent:        #2B4C7E;    /* indigo: the goals' numbers */
  --rules-tool-on:       #C9D4E6;    /* a game button pressed in (game.css --color-tool-on) */

  /* [POSITIONING] */
  --rules-width:         600px;      /* popup max width */
  --rules-item-gap:      22px;       /* space between each goal/rule */
}
/* [COLORS] Dark mode (theme.js) */
html.dark {
  --rules-panel:         #181C26;
  --rules-panel-border:  #2C3240;
  --rules-overlay:       rgba(0, 0, 0, 0.6);
  --rules-title:         #EDEAE3;
  --rules-text:          #EDEAE3;
  --rules-text-dim:      #A3A6B0;
  --rules-even:          #A8E07E;
  --rules-odd:           #FF6B5E;
  --rules-board:         #0B0E15;
  --rules-cell:          #1F2533;
  --rules-dotted:        #F06A5E;
  --rules-arrow:         #EDEAE3;
  --rules-empty:         #8FA9D6;
  --rules-button:        #EDEAE3;
  --rules-button-text:   #12151D;
  --rules-btn-bg:        #1F2533;
  --rules-btn-hover:     #2A3142;
  --rules-btn-line:      #EDEAE3;
  --color-term:          #6CC7D1;
  --rules-hl:            #F2D35A;
  --rules-accent:        #8FA9D6;
  --rules-tool-on:       #3A4A66;
}
/* an official term (wrapped by markTerms, shapes.js) */
/* (always normal weight, even inside bold text, so every teal word looks the
   same: teal means "a game word", bold means emphasis: user, 2026-11-15) */
.term { color: var(--color-term); font-weight: 400; }
/* a term can be tapped for its definition (shapes.js TERM_DEFS, 2026-11-23):
   a faint dotted underline says so */
.term[data-term] { cursor: help; text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, var(--color-term) 55%, transparent);
                   text-underline-offset: 3px; -webkit-tap-highlight-color: transparent; }
.term[data-term]:focus-visible { outline: 2px solid var(--color-term); outline-offset: 2px; border-radius: 3px; }
.term-def { position: fixed; z-index: 1000; max-width: min(300px, calc(100vw - 16px)); box-sizing: border-box;
            display: flex; flex-direction: column; gap: 3px; padding: 10px 14px; border-radius: 10px;
            background: var(--rules-panel); color: var(--rules-text); border: 1.5px solid var(--color-term);
            box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18); font-family: var(--rules-text-font); font-size: 0.98rem; line-height: 1.4;
            text-align: left; animation: termDefIn 0.15s ease-out; }
.term-def b { color: var(--color-term); font-weight: 800; }
@keyframes termDefIn { from { opacity: 0; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .term-def { animation: none; } }
u:has(> .term) { text-decoration-color: var(--color-term); }   /* (an underlined term: the line in teal too) */
/* termPictures (shapes.js): a block, a piece, the empty squares on a grid */
/* (2026-11-14: the "counted" look the user picked: numbers on the
   squares, the empty squares highlighted yellow; no rings or arrows) */
.term-pics { display: flex; flex-direction: column; align-items: center; }
.term-row { display: flex; justify-content: center; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.term-fig { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0; }
.term-fig figcaption { font-size: 0.95rem; line-height: 1.35; text-align: center; color: var(--rules-text); max-width: 10em; }
.term-pics.compact .term-row { gap: 12px; }
.term-pics.compact figcaption { font-size: 0.85rem; max-width: 8em; }
.term-svg { overflow: visible; }
.term-hl { fill: var(--rules-hl); }
.term-num { font-family: var(--rules-count-font); font-weight: 600; fill: #1F2330; }   /* (on yellow: dark ink in both modes) */
.term-num.on-piece { fill: #FFFFFF; }
.term-num.on-empty { fill: var(--rules-text); }   /* (on a bare empty square: ink, or light in dark mode) */
.rules-terms { margin: 0 0 var(--rules-item-gap); }
.rules-popup u { text-underline-offset: 3px; text-decoration-skip-ink: none; }

/* ── The "Rules" button (top-right of each page) ── */
.rules-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 4px;
  border: 1.5px solid var(--rules-btn-line);
  background: var(--rules-btn-bg);
  color: var(--rules-text);
  font-family: var(--rules-font);
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.rules-btn:hover { background: var(--rules-btn-hover); }
.rules-btn:active { transform: translateY(1px); }
.rules-btn:focus-visible { outline: 3px solid #2443d6; outline-offset: 3px; }

/* ── The moon / sun button (theme.js): dark mode on or off, any time ──
   Top left of the start screen and the puzzle page. */
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%; padding: 0;
  border: 1.5px solid var(--rules-btn-line);
  background: var(--rules-btn-bg); color: var(--rules-text);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
}
.theme-toggle:hover { background: var(--rules-btn-hover); }
.theme-toggle:active { transform: translateY(1px); }
.theme-toggle:focus-visible { outline: 3px solid #2B4C7E; outline-offset: 3px; }

/* ── "There's more below" (scroll-hint.js; phones only) ──
   A small round ▾ at the bottom of the tutorial / the rules while they go
   on below the screen. Bobs gently; fades in and out. */
.scroll-hint {
  position: fixed; z-index: 1001; transform: translateX(-50%);
  width: 38px; height: 38px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--rules-btn-line); background: var(--rules-btn-bg); color: var(--rules-text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.scroll-hint.shown { opacity: 0.92; visibility: visible; animation: scrollBob 1.6s ease-in-out infinite; }
@keyframes scrollBob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 5px); } }
@media (prefers-reduced-motion: reduce) { .scroll-hint.shown { animation: none; } }

/* ── Popup ── */
.rules-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--rules-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.rules-backdrop[hidden] { display: none; }

.rules-popup {
  position: relative;
  width: 100%;
  max-width: var(--rules-width);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--rules-panel);
  border: 1px solid var(--rules-panel-border);
  border-radius: 18px;
  padding: 16px 20px 20px;
  display: flex; flex-direction: column; gap: 14px;   /* [POSITIONING] space between the parts */
  color: var(--rules-text);
  font-family: var(--rules-text-font);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: left;
  user-select: none;
  outline: none;
}
@media (min-width: 601px) { .rules-popup { padding: 16px 30px 20px; } }

/* (2026-11-24 redesign, user's pick "B, style 1"; rules.js has the plan)
   The top row: dark mode and Larger text / Smaller text at the left, ×
   at the right; the title under it */
.rules-bar { display: flex; align-items: center; gap: 8px; }
.rules-popup h2 {
  font-family: var(--rules-title-font);
  letter-spacing: 0.01em;
  font-size: var(--rules-title-size);
  font-weight: 400;
  line-height: 1.05;
  color: var(--rules-title);
  margin: 0;
  white-space: nowrap;
}
.rules-bar .theme-toggle { width: 36px; height: 36px; flex: none; }
.rules-bar .text-size-btn { flex: none; height: 36px; padding: 0 14px; }
.rules-close {
  flex: none; margin-left: auto;
  width: 34px;
  height: 36px;
  margin-right: -6px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--rules-text-dim);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}
.rules-close:hover { color: var(--rules-text); background: rgba(128, 128, 128, 0.12); }
@media (max-width: 360px) { .rules-popup { --rules-title-size: 1.75rem; } }

/* ── "Large text" / "Standard text" and "Dark mode" / "Light mode" ──
   Side by side at the top-left of the rules popup and the tutorial
   (.view-btns). Large text puts the class "large-text" on the page
   (<html>) and remembers it in localStorage ('pb_largeText'); Dark mode
   is theme.js ('pb_theme'). The rules and tutorial share both. */
.view-btns {
  position: absolute; top: 12px; left: 14px; z-index: 5;
  display: flex; align-items: center; gap: 8px;
}
/* the moon / sun there, as tall as the Large text button beside it */
.view-btns .theme-toggle { width: 38px; height: 38px; flex: 0 0 auto; }
@media (max-width: 600px) { .tut-head .view-btns .theme-toggle { width: 32px; height: 32px; } }
.text-size-btn {
  height: 38px; padding: 0 16px; border-radius: 4px;
  border: 1.5px solid var(--rules-btn-line);
  background: var(--rules-btn-bg); color: var(--rules-text);
  font-family: var(--rules-text-font); font-size: 1rem; font-weight: 400;
  cursor: pointer; white-space: nowrap;
}
.text-size-btn:hover { background: var(--rules-btn-hover); }
.text-size-btn.is-large-label { font-weight: 800; font-size: 1.05rem; }   /* "Large text" in bold */
.text-size-btn:focus-visible { outline: 3px solid #2443d6; outline-offset: 2px; }

/* Large text in the rules popup */
html.large-text .rules-popup { --rules-text-size: 1.8rem; --rules-caption-size: 1.45rem; max-width: 820px; }
html.large-text .rules-popup .rules-ok { font-size: 1.8rem; height: 60px; }
html.large-text .rules-goals { flex-direction: column; align-items: center; }   /* (the goals one above the other) */
html.large-text .rules-half { max-width: 30em; }

/* (the tutorial's counting: an outline round a counted row / column, and
   the numbers on its blocks) */
.rb-band { fill: none; stroke-width: 2.5; }
.rb-band.even { stroke: var(--rules-even); }
.rb-band.odd { stroke: var(--rules-odd); }
.term-num.cnt-num { paint-order: stroke; stroke: rgba(0, 0, 0, 0.45); stroke-width: 2px; }

/* [POSITIONING] The two goals, side by side: name, picture, one line each.
   The pictures shrink to fit narrow phones. */
.rules-goals { display: flex; gap: 16px; align-items: flex-start; }
.rules-half { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rules-popup .rules-goal-name { margin: 0; font-family: var(--rules-title-font); font-weight: 400; font-size: 1.4rem; line-height: 1.1; color: var(--color-term); }
.rules-half-pic svg { display: block; max-width: 100%; height: auto; }
.rules-popup p { margin: 0; font-size: var(--rules-text-size); line-height: 1.42; }

/* The piece to try (rules.js tryPiece), on its own line */
.rules-try { display: flex; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--rules-panel-border); }
.rules-try-piece {
  flex: none; width: 56px; height: 56px; padding: 0; border-radius: 12px; cursor: pointer;
  border: 1.5px dashed var(--rules-text-dim); background: transparent; color: inherit;
  display: grid; place-items: center; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.rules-try-spin { display: grid; place-items: center; transition: transform 0.32s cubic-bezier(.3, 1.4, .5, 1); }
.rules-try-spin svg { display: block; }
.rules-popup .rules-try-text { font-size: var(--rules-caption-size); }

/* The game's buttons (look: game.css .hl-pencil / .shuffle-btn / .reset-btn) */
.rules-tools { position: relative; display: flex; flex-direction: column; gap: 8px; }
.rules-popup .rules-tools-prompt { font-size: var(--rules-caption-size); font-weight: 700; color: var(--rules-text-dim); }
.rules-tool-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rules-tool {
  height: 40px; min-width: 40px; box-sizing: border-box; padding: 0; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--rules-btn-line); background: var(--rules-btn-bg); color: var(--rules-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--rules-font); font-size: 1.2rem; letter-spacing: 0.04em;
  transition: background 0.15s, box-shadow 0.15s; -webkit-tap-highlight-color: transparent;
}
.rules-tool.clear { border-radius: 4px; padding: 0 14px 0 11px; }
.rules-tool.on { background: var(--rules-tool-on); box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.18); }
/* a button's line: a card floating just above the buttons (over the piece
   to try and the pictures), its pointer at the button, so nothing moves */
.rules-tool-card {
  position: absolute; z-index: 4; left: -6px; right: -6px; bottom: calc(100% + 6px);
  padding: 11px 14px; border-radius: 12px; font-size: var(--rules-caption-size); line-height: 1.45;
  background: var(--rules-panel); color: var(--rules-text); border: 1.5px solid var(--rules-btn-line);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22); animation: termDefIn 0.15s ease-out;
  pointer-events: none;   /* (only to read: a tap goes through to what's under it, and closes it) */
}
.rules-tool-card::after {
  content: ""; position: absolute; left: var(--point, 30px); bottom: -8px; width: 14px; height: 14px;
  background: var(--rules-panel); border-right: 1.5px solid var(--rules-btn-line); border-bottom: 1.5px solid var(--rules-btn-line);
  transform: translateX(-50%) rotate(45deg);
}
.rules-tool-card b { font-weight: 800; }
.rules-tool:focus-visible, .rules-try-piece:focus-visible, .rules-bar .text-size-btn:focus-visible { outline: 3px solid #2443d6; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .rules-try-spin { transition: none; } .rules-tool-card { animation: none; } }

/* The tutorial and Got it, side by side, under one short line */
.rules-foot { display: flex; flex-direction: column; gap: 8px; }
.rules-foot-btns { display: flex; gap: 10px; }
.rules-foot-btns .rules-ok { flex: 1 1 0; min-width: 0; padding: 0 8px; font-size: 1.2rem; white-space: nowrap; }
html.large-text .rules-foot-btns { flex-direction: column; }

/* [POSITIONING] Short phones (iPhone mini / SE in Safari): a little tighter,
   so the rules still fit on one screen */
@media (max-width: 600px) and (max-height: 700px) {
  .rules-popup { gap: 9px; padding-top: 12px; padding-bottom: 14px; --rules-title-size: 1.9rem; }
  .rules-half { gap: 5px; }
  .rules-half-pic svg { max-height: 96px; width: auto; }
  .rules-try { padding-top: 9px; }
  .rules-try-piece { width: 48px; height: 48px; }
  .rules-foot { gap: 6px; }
  .rules-foot-btns .rules-ok { height: 44px; }
}
/* the shortest (iPhone SE in Safari): tighter still */
@media (max-width: 600px) and (max-height: 600px) {
  .rules-popup { gap: 7px; padding-top: 10px; --rules-title-size: 1.7rem; }
  .rules-half { gap: 4px; }
  .rules-half-pic svg { max-height: 80px; }
  .rules-try { padding-top: 7px; }
  .rules-try-piece { width: 44px; height: 44px; }
  .rules-tools { gap: 6px; }
  .rules-foot-btns .rules-ok { height: 40px; }
}

.rules-ok {
  display: block;
  width: 100%;
  height: 48px;
  background: var(--rules-button);
  color: var(--rules-button-text);
  font-family: var(--rules-font);
  font-size: 1.35rem;
  cursor: pointer;
  border-radius: 4px;
  border: 2px solid var(--rules-btn-line);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.14);
}
.rules-ok:hover { filter: brightness(1.15); }
.rules-ok:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.14); }
/* "Play the tutorial" button: plain */
.rules-tutorial { background: var(--rules-btn-bg); color: var(--rules-text); border-width: 1.5px; box-shadow: none; }
/* the line above it ("Watch the tutorial to learn strategies.") */
.rules-popup .rules-tutorial-tip { font-size: var(--rules-caption-size); color: var(--rules-text-dim); }
.rules-ok:focus-visible, .rules-close:focus-visible { outline: 3px solid #2443d6; outline-offset: 2px; }

/* ── Picture parts (SVG classes used by rules.js) ── */
.rb-frame    { fill: var(--rules-board); }
.rb-cell     { fill: var(--rules-cell); }
.rb-hl       { opacity: var(--rules-highlight-opacity); }   /* highlighter strokes */
.rb-hl.rb-even { opacity: var(--rules-highlight-even-opacity); }
.rb-even     { fill: var(--rules-even); }
.rb-odd      { fill: var(--rules-odd); }
.rb-count    { font-family: var(--rules-count-font); font-size: var(--rules-count-size); font-weight: 700; opacity: 1; }
.rb-no       { fill: none; stroke: var(--rules-odd); stroke-width: 3.5; }
.rb-no-x     { stroke: var(--rules-odd); stroke-width: 3.5; stroke-linecap: round; }
.rb-empty    { fill: none; stroke: var(--rules-empty); stroke-width: 2.5; }   /* analyzer: open square left empty */
.rb-arrow    { fill: none; stroke: var(--rules-arrow); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }