/* ═══════════════════════════════════════════════════════════════════════
   PARITY BLOCKS: GAME LOOK
   Shared by play.html (the game) and sandbox.html (the puzzle builder),
   so the two always look the same.
   EDIT GUIDE: search for [FONTS] [COLORS] [POSITIONING] [CONTENT]
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  /* [FONTS] Two fonts: Geo for buttons, titles and headings (short, bold
     labels); Nunito for everything you read (messages, notes, popups).
     To try another reading font, e.g. Roboto, change --font-text here and
     add the font to the Google Fonts <link> in each page's <head>. */
  --font-display: 'Geo', 'Segoe UI', sans-serif;
  --font-text:    'Nunito', 'Segoe UI', sans-serif;
  --button-size:  1.5rem;

  /* [COLORS] "Woodblock" (user's pick, 2026-11-02): colors from Japanese
     woodblock prints on a soft paper page, ink-colored text, buttons with
     a fine ink border. Piece colors: INKS in shapes.js. Dark mode is the
     html.dark block just below. (Same palette as the splash screen.) */
  --color-bg:           #E3EFED;   /* page background: celadon, a pale teal-green (2026-11-03) */
  --color-text:         #1F2330;   /* ink */
  --color-text-dim:     #5E6270;
  --color-accent:       #2B4C7E;   /* indigo: headings, notes, hint glow */
  /* The board, made easy on the eyes (user: the Woodblock mock-up's grid
     was "very hard on the eyes"): a light board in light mode, with no
     black and no stark white. A soft indigo-grey frame, warm off-white
     squares, gentle gaps; the only strong color is the vermilion dotted
     line. Dark mode has the same layout in dark tones. */
  --color-board-bg:     #DCDFE6;   /* the frame round the squares (and the gaps between them) */
  --color-cell:         #FBFBF8;   /* an open grid square */
  --color-cell-line:    #FBFBF8;   /* its edge (none: the same as the square) */
  --color-dotted:       #E2483D;   /* dotted lines: vermilion */
  --color-valid-bg:     #E4EDD9;   /* drop preview on the board: fits */
  --color-valid-line:   #7BA05B;
  --color-invalid-bg:   #F8DCD8;   /*   doesn't fit */
  --color-invalid-line: #E2483D;
  --color-board-shadow: 0 1px 2px rgba(31, 35, 48, 0.08), 0 8px 24px rgba(31, 35, 48, 0.08);
  --color-cell-border:  #DCDDD6;   /* soft lines: popup edges */
  --color-valid:        #5E8A3E;   /* "Solved!" (deep moss) */
  /* Counting rows and columns (tutorial): brighter, so even / odd stands
     out (user picked mock-up B, 2026-11-16) */
  --color-count-even:   #3E9B3A;
  --color-count-odd:    #E2483D;
  --color-invalid:      #D23A2F;   /* odd row/column */
  --color-select:       #2B4C7E;   /* ring on an empty square (sandbox) */
  --color-highlight:    #E2483D;   /* highlighter over an uneven row/column */
  --color-status:       #C0392B;   /* "Uneven rows" message above the board */
  --color-button:       #1F2330;   /* main buttons: fill */
  --color-button-ink:   #F5F5F2;   /*   and text */
  --color-soft:         #FBFBF8;   /* plain buttons (Menu, Close): fill */
  --color-soft-ink:     #1F2330;   /*   and text */
  --color-btn-line:     #1F2330;   /* the fine ink border on buttons */
  --color-key-edge:     rgba(0, 0, 0, 0.14);   /* the soft shade along a button's bottom */
  --color-panel:        #FBFBF8;   /* popups */
  --color-overlay:      rgba(31, 35, 48, 0.45);
  --color-shadow:       rgba(31, 35, 48, 0.2);   /* under a lifted piece */
  /* the three levels (start screen buttons, stars, "Play Medium →"):
     asagi teal, gold, vermilion ("Warm and friendly", user's pick,
     2026-11-02), so a shared result shows 🟦 🟨 🟥 */
  --color-easy:         #3E8E9E;
  --color-medium:       #E8B33B;
  --color-hard:         #E2483D;
  --color-easy-ink:     #FFFFFF;   /* text on them */
  --color-medium-ink:   #1F2330;
  --color-hard-ink:     #FFFFFF;
  --color-level-ink:    #1F2330;
  --color-rotate:       #2B4C7E;   /* (the sandbox's main buttons) */
  /* the highlighter's four colors (game.js HIGHLIGHTER); the first is the
     one it starts with: soft yellow, green, pink, blue */
  --hl-0:               #F6DC74;
  --hl-1:               #A9DA9B;
  --hl-2:               #F4B5C9;
  --hl-3:               #A8CDEE;
  --color-tool-on:      #C9D4E6;   /* the pencil button's background while it's on */

  /* [POSITIONING] Sizes and spacing */
  --page-gap:        14px;   /* space between pieces, board and buttons */
  --tray-cell:       20px;   /* square size of the pieces at the top */
  --tray-gap:        10px;   /* space between pieces at the top */
  --board-max-cell:  84px;   /* largest a board square gets on big screens */
  --board-gap:       4px;    /* gap between board squares (the dotted lines run down it) */
  --board-pad:       10px;   /* frame thickness around the board */
  --button-width:    170px;  /* each of Reflect / Rotate */
  --button-height:   56px;
  --button-radius:   14px;

  /* Highlighter marks on uneven rows/columns */
  --highlight-opacity:   0.55;  /* 0 = invisible, 1 = solid */
  --highlight-thickness: 0.7;   /* stroke width, as a fraction of one square */
  --highlight-overhang:  18px;  /* how far it runs past the grid's edge */
}
/* [COLORS] Dark mode (theme.js; the "Dark mode" button next to "Large
   text"): Woodblock at night, a deep ink-blue page, never brown. The
   level and piece colors stay the same. */
html.dark {
  --color-bg:           #0E1C1F;   /* dark celadon */
  --color-text:         #EDEAE3;
  --color-text-dim:     #A3A6B0;
  --color-accent:       #8FA9D6;
  --color-board-bg:     #0B0E15;
  --color-cell:         #1F2533;
  --color-cell-line:    #1F2533;
  --color-dotted:       #F06A5E;
  --color-valid-bg:     #2B3A26;
  --color-valid-line:   #7BA05B;
  --color-invalid-bg:   #47231F;
  --color-invalid-line: #F06A5E;
  --color-board-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --color-cell-border:  #2C3240;
  --color-valid:        #9CC57A;
  --color-count-even:   #A8E07E;
  --color-count-odd:    #FF6B5E;
  --color-invalid:      #F06A5E;
  --color-select:       #8FA9D6;
  --color-status:       #F08A80;
  --color-button:       #EDEAE3;
  --color-button-ink:   #12151D;
  --color-soft:         #1F2533;
  --color-soft-ink:     #EDEAE3;
  --color-btn-line:     #EDEAE3;
  --color-key-edge:     rgba(0, 0, 0, 0.3);
  --color-panel:        #181C26;
  --color-overlay:      rgba(0, 0, 0, 0.6);
  --color-shadow:       rgba(0, 0, 0, 0.55);
  --color-rotate:       #8FA9D6;
  /* (bright, at least as bright as the pieces: user, 2026-11-05; the dim
     ones before were hard to see) */
  --hl-0:               #F2D35A;
  --hl-1:               #95D083;
  --hl-2:               #F0A2BD;
  --hl-3:               #8FC0EC;
  --color-tool-on:      #3A4A66;
}

@media (max-width: 480px) {
  :root { --tray-cell: 13px; --tray-gap: 6px; --button-width: 140px; }
  .status { font-size: 1rem; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* Phones: no double-tap zoom (double-tap reflects a piece). Pinch zoom still
   works. The pieces and board override this with touch-action: none. */
* { touch-action: manipulation; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-text);
  overflow: hidden;              /* whole game fits on screen; no scrolling */
  user-select: none;
  -webkit-user-select: none;
}

/* [POSITIONING] Main column: pieces, board, buttons, all centered. */
.game {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--page-gap);
  padding: 16px 16px 24px;
}

/* [POSITIONING] Top row: back button on the left, Rules on the right */
.top-row {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--color-btn-line);
  background: var(--color-soft);
  color: var(--color-soft-ink);
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* ── Available pieces (top) ── */
.tray {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--tray-gap);
  max-width: 640px;
}
.tray-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
  transition: background 0.15s;
}
.tray-slot:hover { background: rgba(128, 128, 128, 0.08); }
/* Puzzle page: the pieces' space */
.tray-area { flex: 0 0 auto; position: relative; width: 100%; display: flex; justify-content: center; }
.tray-area > .tray { flex: 0 1 auto; min-width: 0; }   /* (may shrink, so the pieces still wrap on phones) */
.tray-area.has-hl { padding-top: 44px; }               /* room above the pieces for the highlighter (and 10px under it; 44 = Safari's 40px button + 10 − a piece space's 6px padding; was 40: 6px gap on an iPhone mini with the I in the top row, 2026-11-19) */

/* ── The highlighter (game.js HIGHLIGHTER) ──
   [POSITIONING] game.js puts it above and to the right of the rightmost
   piece in the top row. A pencil button (shaded while on); beside it, while
   it's on, a dot in the current color with a ▾ that opens the colors. */
.hl-tool { position: absolute; z-index: 60; display: flex; align-items: flex-start; gap: 4px; }
.hl-tool[hidden] { display: none; }
.hl-tool.dot-left { flex-direction: row-reverse; }   /* (play.html: the pencil sits at the board's right edge) */
.hl-tool button { -webkit-tap-highlight-color: transparent; }   /* (no grey / blue flash on phones; the button shows its own "on" look) */
.hl-pencil {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--color-btn-line); background: var(--color-soft); color: var(--color-soft-ink);
  transition: background 0.15s, box-shadow 0.15s;
}
/* Shuffle (play.html; game.js placeShuffleButton): the pencil's twin,
   above the pieces. (The pieces' slide is in game.js shuffleTray.) */
.shuffle-btn {
  position: absolute; z-index: 60;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--color-btn-line); background: var(--color-soft); color: var(--color-soft-ink);
  -webkit-tap-highlight-color: transparent;
}
.shuffle-btn:active { background: var(--color-tool-on); box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.18); }
/* "Tap once = rotate · Double tap = reflect" (play.html, first puzzle
   only, user 2026-11-22): a card just under the pieces, pointing up at
   them. play.html places it (placeTurnTip). */
.turn-tip {
  position: absolute; z-index: 55; box-sizing: border-box; max-width: calc(100% - 8px);
  display: flex; align-items: center; gap: 12px; padding: 9px 10px 9px 16px; border-radius: 10px;
  background: var(--color-panel); color: var(--color-text); border: 1.5px solid var(--color-btn-line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15); font-size: 0.95rem; font-weight: 600; line-height: 1.3;
}
.turn-tip[hidden] { display: none; }
.turn-tip.below { position: static; flex: 0 0 auto; }   /* (under the board, in the page's column) */
.turn-tip.below::before { display: none; }
.turn-tip b { font-weight: 800; }
.turn-tip span span { white-space: nowrap; }   /* (wraps only at the "·") */
@media (max-width: 420px) { .turn-tip { font-size: 0.9rem; padding-left: 14px; gap: 10px; } }
.turn-tip::before {     /* the pointer */
  content: ""; position: absolute; left: var(--tip-arrow, 50%); top: -8px; width: 14px; height: 14px;
  background: var(--color-panel); border-left: 1.5px solid var(--color-btn-line); border-top: 1.5px solid var(--color-btn-line);
  transform: translateX(-50%) rotate(45deg);
}
.turn-tip button {
  flex: 0 0 auto; font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer;
  padding: 4px 11px; border-radius: 4px; border: 1.5px solid var(--color-btn-line);
  background: var(--color-soft); color: var(--color-soft-ink);
}
.hl-pencil.on { background: var(--color-tool-on); box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.18); }
.hl-color {
  width: 24px; height: 40px; padding: 4px 0 0; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--color-text);
  visibility: hidden;
}
.hl-color.shown { visibility: visible; }
.hl-dot { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--color-btn-line); }
.hl-menu {
  position: absolute; top: 46px; right: 0; display: flex; gap: 8px; padding: 7px 10px;
  background: var(--color-panel); border: 1.5px solid var(--color-btn-line); border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.hl-menu[hidden] { display: none; }
.hl-swatch { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--color-btn-line); cursor: pointer; }
.hl-swatch[aria-checked="true"] { outline: 2.5px solid var(--color-text); outline-offset: 2px; }

/* ── Solved badge (celebrate.js): every success message ──
   A green check in a circle, then a title and text, in one box. With
   .animate it plays along with the jingle (assets/solved.mp3): the circle
   pops in on the first note (0.11 s), the check draws until the note at
   1.08 s, it's "pressed" (shrinks) and pops back out on the big last note
   (1.46 s), and the text slides in with it. */
.win-badge {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px 12px 12px; border-radius: 14px; text-align: left;
  background: rgba(111, 174, 90, 0.12); border: 2px solid rgba(111, 174, 90, 0.55);   /* [COLORS] */
}
.win-badge.plain { background: none; border: none; padding: 0; }
.win-badge.stack { flex-direction: column; gap: 10px; text-align: center; background: none; border: none; padding: 0; }
.win-icon { flex: 0 0 auto; width: 46px; height: 46px; overflow: visible; }
.win-badge.stack .win-icon { width: 72px; height: 72px; }
.win-circle { fill: var(--color-valid); transform-box: fill-box; transform-origin: center; }
.win-check { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 34; }
.win-text strong {
  display: block; font-family: var(--font-display); font-weight: 400; letter-spacing: 0.03em;
  font-size: 1.45rem; line-height: 1.1; color: var(--color-valid);
}
.win-badge.stack .win-text strong { font-size: 2rem; }
/* (">": only the text line itself, not the colored terms inside it, which
   were each put on a line of their own: user, 2026-11-15) */
.win-text > span { display: block; margin-top: 3px; font-size: 1rem; line-height: 1.4; color: var(--color-text); }
.win-badge.stack .win-text > span { font-size: 1.05rem; }
.win-badge.animate { animation: winFade 0.25s ease both; }
.win-badge.animate .win-circle { animation: winCircle 0.3s 0.11s cubic-bezier(.3,1.5,.5,1) both; }
.win-badge.animate .win-check  { animation: winDraw 0.93s 0.15s ease-in-out both; }
.win-badge.animate .win-icon   { animation: winPress 0.5s 1.16s both; }   /* (smallest at 1.41 s, popped out at 1.49 s) */
.win-badge.animate .win-text   { animation: winText 0.45s 1.44s ease-out both; }
@keyframes winFade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes winCircle { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes winDraw   { from { stroke-dashoffset: 34; } to { stroke-dashoffset: 0; } }
@keyframes winPress  { 0% { transform: scale(1); } 50% { transform: scale(0.8); animation-timing-function: cubic-bezier(.2,.9,.3,1.4); }
                       66% { transform: scale(1.16); } 100% { transform: scale(1); } }
@keyframes winText   { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
/* No sound (the tutorial): the same animation, a little quicker */
.win-badge.animate.quick .win-circle { animation-delay: 0.05s; }
.win-badge.animate.quick .win-check  { animation-duration: 0.5s; animation-delay: 0.1s; }
.win-badge.animate.quick .win-icon   { animation-delay: 0.75s; }
.win-badge.animate.quick .win-text   { animation-delay: 1.03s; }
.win-badge.stack.animate .win-text { animation-name: winTextUp; }
@keyframes winTextUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .win-badge.animate, .win-badge.animate * { animation: none !important; } }

/* ── The win animation (celebrate.js solvedCelebration; the Solved popup) ──
   A small picture of the solved board; its rows and columns are counted
   with a green highlighter, then it turns green with a white check mark
   (hiding the solution), then "Solved!" and the time. */
.win-show { display: flex; flex-direction: column; align-items: center; }
.win-stage { position: relative; margin: 6px 0 16px; }
.win-board { display: block; overflow: visible; transform-origin: center; }
.win-board.glow { animation: boardGlow 1.4s var(--glow-delay, 0s) ease-out both; }
@keyframes boardGlow {
  0%   { filter: drop-shadow(0 0 0 rgba(123, 160, 91, 0)); }
  25%  { filter: drop-shadow(0 0 14px rgba(123, 160, 91, 0.85)); }
  100% { filter: drop-shadow(0 0 6px rgba(123, 160, 91, 0.4)); }
}
.win-cover { fill: var(--color-valid); color: var(--color-valid); }      /* (color: the frame of a board with cut squares is a stroke) */
.win-check-big { fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
/* the green bands that count each row and column (exactly the grid's size) */
.win-band { fill: var(--color-valid); opacity: 0.42; }
/* "Easy" / "Medium" / "Hard" above "Solved!", in that level's color
   (the start screen's buttons) */
.win-level { font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; letter-spacing: 0.03em; color: var(--color-text); }
.win-level.easy   { color: var(--color-easy); }
.win-level.medium { color: var(--color-medium); }
.win-level.hard   { color: var(--color-hard); }
.win-title { font-family: var(--font-display); font-weight: 400; font-size: 2.2rem; line-height: 1.1; color: var(--color-valid); letter-spacing: 0.03em; }
.win-time { margin: 4px 0 0 !important; font-size: 1.1rem; color: var(--color-text); }
.win-time b { font-variant-numeric: tabular-nums; }
/* the popup itself comes up with a little spring (play.html) */
@keyframes popupIn { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: none; } }
/* the real board behind it is blurred, so a screenshot of the popup
   doesn't show the solution (user, 2026-11-03) */
#solved-popup { -webkit-backdrop-filter: blur(36px); backdrop-filter: blur(36px); }
#solved-popup:not([hidden]) .popup { animation: popupIn 0.32s cubic-bezier(.2,.9,.3,1.15) both; }
@media (prefers-reduced-motion: reduce) { #solved-popup .popup, .win-board.glow { animation: none; } }

.tray-slot.used { visibility: hidden; }  /* keeps its space so nothing shifts */

/* ── Board ── */
.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* The board: separate rounded squares on a soft frame (the original layout;
   colors at the top: a light board in light mode, a dark one in dark mode) */
#board-outer {
  position: relative;
  background: var(--color-board-bg);
  border-radius: 12px;
  padding: var(--board-pad);
  box-shadow: var(--color-board-shadow);
  touch-action: none;
  transition: box-shadow 0.3s;
}
/* [COLORS] A finished board whose rows/columns aren't all even glows red */
#board-outer.uneven { box-shadow: 0 0 0 3px rgba(214, 40, 40, 0.85), 0 0 22px rgba(214, 40, 40, 0.45); }
#board { display: grid; }
/* Live counts beside the board (sandbox's Counts button; game.js LIVE COUNTS) */
#live-counts { position: absolute; left: 0; top: 0; pointer-events: none; }
.live-count {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 700; line-height: 1; white-space: nowrap;
}
.live-count.even { color: var(--color-valid); }
.live-count.odd  { color: var(--color-status); }
.live-count.zero { color: var(--color-text-dim); opacity: 0.6; }
.board-cell {
  background: var(--color-cell);
  border: 1px solid var(--color-cell-line);
  border-radius: 4px;
  transition: background 0.12s;
}
/* a square colored with the highlighter (its color: --mark, set by game.js) */
.board-cell.marked { background: var(--mark); border-color: var(--mark); }
/* While the highlighter is on, the mouse is a little pencil over the squares
   (user, 2026-11-05; was a cross). Dark ink with a white edge so it shows on
   light and dark squares; its tip (3, 21) is the point that's clicked. */
body.highlighting #board .board-cell:not(.removed) {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M3 21 L4.3 15.6 L15.2 4.7 a1.9 1.9 0 0 1 2.7 0 L19.3 6.1 a1.9 1.9 0 0 1 0 2.7 L8.4 19.7 Z' stroke='%23fff' stroke-width='4.2'/%3E%3Cpath d='M3 21 L4.3 15.6 L15.2 4.7 a1.9 1.9 0 0 1 2.7 0 L19.3 6.1 a1.9 1.9 0 0 1 0 2.7 L8.4 19.7 Z' fill='%23fff' stroke='%231F2330' stroke-width='1.8'/%3E%3Cpath d='M13.4 6.5 L17.5 10.6 M4.3 15.6 L8.4 19.7' stroke='%231F2330' stroke-width='1.8'/%3E%3C/g%3E%3C/svg%3E") 3 21, crosshair;
}
.board-cell.hl-valid   { background: var(--color-valid-bg);   border-color: var(--color-valid-line); }
.board-cell.hl-invalid { background: var(--color-invalid-bg); border-color: var(--color-invalid-line); }
#pieces-layer, #hint-overlay, #mark-overlay {
  position: absolute;
  inset: var(--board-pad);
  pointer-events: none;
}
#hint-overlay { z-index: 5; }

/* Highlighter marks over uneven rows/columns once every piece is placed.
   Drawn above the pieces, running a little past the edge of the grid. */
#mark-overlay { z-index: 6; overflow: visible; }
.highlight { fill: var(--color-highlight); opacity: var(--highlight-opacity); }

/* [CONTENT] Message above the board ("Uneven rows" etc.).
   The board must NEVER move when a message appears, so:
   • its space is a fixed height (2 lines), whether or not there's a message;
   • long messages wrap onto more lines instead of widening anything;
   • if a message needs a 3rd line, the extra line grows UPWARD into the
     space above (flex column + justify-content: flex-end), never down
     over the board. */
.status {
  flex: 0 0 auto;
  height: calc(2 * var(--status-line));
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: var(--status-line);
  color: var(--color-status);
  text-align: center;
  --status-line: 1.6rem;   /* [POSITIONING] height of one line of the message */
}

.placed-piece { position: absolute; }
.placed-piece .blk { pointer-events: auto; cursor: grab; touch-action: none; }
.piece-svg { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
/* A piece in a wrong spot (user, 2026-11-23, mock-up "G1", glow a little
   larger): a red outline plus a soft red glow. The old glow alone vanished
   on the red, orange and pink pieces; a thicker outline + pale ring + big
   glow was "too intense". */
.placed-piece.invalid .piece-svg {
  filter: drop-shadow(0 0 3px rgba(214, 40, 40, 0.75)) drop-shadow(0 0 5px rgba(214, 40, 40, 0.45));
}
.placed-piece.invalid .piece-outline { stroke: #C81E16; stroke-width: 2.25; }
/* ── Feel (game.js, FEEL) ── */
/* pressed: squeezes a little under the finger / mouse */
.piece-box { transition: transform 0.09s ease-out; }
.piece-box.pressed { transform: scale(0.95); }
/* the piece being dragged: lifted (bigger, a soft shadow below it), a little
   see-through so the green / red squares under it still show */
/* (will-change: the held piece gets its own layer, so the browser moves it
   without repainting what's behind it: no marks left where it's been) */
.ghost { position: absolute; pointer-events: none; opacity: 0.88; z-index: 50; will-change: transform, left, top; }
.piece-box.lifted { transform: scale(1.06); }
.piece-box.lifted .piece-svg { filter: drop-shadow(0 10px 9px var(--color-shadow)); }
.piece-box.lift-in { animation: liftIn 0.14s ease-out both; }
@keyframes liftIn { from { transform: scale(1); } to { transform: scale(1.06); } }
/* its place at the top while it's held */
.tray-slot.lifting .piece-box { opacity: 0.25; }
.tray-slot:hover .piece-box:not(.pressed) { transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) {
  .piece-box, .piece-box.lift-in { transition: none; animation: none; }
  .tray-slot:hover .piece-box:not(.pressed) { transform: none; }
}

/* [CONTENT] Puzzle hint caption (only some puzzles have one) */
.hint-caption {
  flex: 0 0 auto;
  max-width: 520px;
  text-align: center;
  color: var(--color-accent);
  font-size: 1rem;
}

/* ── Popups ── */
.popup-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.popup-backdrop[hidden] { display: none; }
.status[hidden] { display: none; }     /* the puzzle page hides the message area */
.popup {
  width: 100%;
  max-width: 340px;
  background: var(--color-panel);
  color: var(--color-text);
  border: 1px solid var(--color-cell-border);
  border-radius: 16px;
  padding: 26px 24px 22px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
.popup h2 { font-family: var(--font-display); color: var(--color-text); font-size: 2rem; font-weight: 400; margin-bottom: 8px; }
.popup p  { font-size: 1.05rem; line-height: 1.45; margin-bottom: 18px; }
.popup-buttons { display: flex; gap: 10px; }
/* [COLORS] Buttons (Woodblock): a fine ink border, small corners, a soft
   shade along the bottom; they press down a little when tapped. The main
   one (e.g. Reset) is ink; plain ones (.secondary) are paper. */
.popup-buttons a, .popup-buttons button {
  flex: 1;
  height: 46px;
  border: 2px solid var(--color-btn-line);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--color-button-ink);
  background: var(--color-button);
  box-shadow: inset 0 -3px 0 var(--color-key-edge);
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.popup-buttons a:active, .popup-buttons button:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 var(--color-key-edge); }
.popup-buttons .secondary { background: var(--color-soft); color: var(--color-soft-ink); }
/* The Solved popup (play.html): room between the celebration and the
   buttons. Menu and Close always look the same, plain; the only colorful
   button is "Play Medium →" / "Play Hard →" (after Easy / Medium), above
   them in that level's color */
.solved-win { margin-bottom: 22px; }
#solved-popup .popup-buttons a, #solved-popup .popup-buttons button { background: var(--color-soft); color: var(--color-soft-ink); }
.next-level-btn {
  display: flex; align-items: center; justify-content: center; height: 50px; margin-bottom: 12px;
  border: none; border-radius: 999px; text-decoration: none; font-family: var(--font-display); font-size: 1.45rem;
  color: var(--color-easy-ink); background: var(--color-easy); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.16);   /* (rounded, like the start screen's level buttons) */
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.next-level-btn[hidden] { display: none; }
/* Share (the Solved popup): the main dark key */
.share-btn {
  display: block; width: 100%; height: 48px; margin-bottom: 12px; border: 2px solid var(--color-btn-line); border-radius: 4px;
  font-family: var(--font-display); font-size: 1.4rem; cursor: pointer;
  background: var(--color-button); color: var(--color-button-ink); box-shadow: inset 0 -3px 0 var(--color-key-edge);
  transition: transform 0.08s, box-shadow 0.08s, background 0.2s;
}
.share-btn:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 var(--color-key-edge); }
.share-btn.done { background: var(--color-valid); border-color: var(--color-valid); color: #fff; }
/* [COLORS] the same as the start screen's Medium / Hard buttons
   (--color-medium / --color-hard at the top) */
.next-level-btn.medium { background: var(--color-medium); color: var(--color-medium-ink); }
.next-level-btn.hard   { background: var(--color-hard); color: var(--color-hard-ink); }
.next-level-btn:hover { filter: brightness(1.05); }
.next-level-btn:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.16); }
/* ── Sandbox modes (only the puzzle builder uses these) ── */
/* Edit mode: pieces fade and ignore clicks, so clicks reach the squares */
body.editing .placed-piece { opacity: 0.45; }
body.editing .placed-piece .blk { pointer-events: none; }
body.editing .board-cell { cursor: pointer; }
body.editing .board-cell:hover { filter: brightness(1.25); }
/* View mode: a solver tiling is shown; nothing can be dragged */
body.viewing .placed-piece .blk { pointer-events: none; cursor: default; }
/* View mode (sandbox only): ring on an open square no piece covers */
.empty-ring { fill: none; stroke: var(--color-select); stroke-width: 3; }
/* Two pulses of glowing light on a ring (the tutorial uses this) */
@keyframes ringPulse {
  0%, 100% { filter: none; }
  50%      { filter: drop-shadow(0 0 4px #ffd9a0) drop-shadow(0 0 9px #f2c48a); stroke: #fff2dc; }
}
.empty-ring.pulse, .rb-empty.pulse { animation: ringPulse 0.8s ease-in-out 2; }

/* View mode: the message above the board when a tiling passes parity */
.status.good { color: var(--color-valid); }

/* ── Clear button (game page, top-right, next to Rules; the tutorial's last
   slide has the same one) ──
   (2026-11-18, user: more pronounced, easier to spot) the same size and
   weight as Rules, full-strength text, with a "start again" arrow. Safe to
   press: Clear has Undo. */
.top-right, .top-left { display: flex; align-items: center; gap: 10px; }
.reset-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px;
  padding: 0 14px 0 11px;
  border-radius: 4px;
  border: 1.5px solid var(--color-text);
  background: var(--color-panel);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.reset-btn svg { flex: none; }
.reset-btn:hover { background: var(--color-cell-border); }
.reset-btn:active { transform: translateY(1px); }
.reset-btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
@media (max-width: 400px) { .reset-btn { padding: 0 10px 0 8px; font-size: 1.1rem; } }
/* "Board cleared · Undo" after Clear (play.html, 2026-11-17): a dark pill
   low on the screen, above the phone's bottom bar */
.undo-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; padding: 8px 10px 8px 18px; border-radius: 999px;
  background: var(--color-text); color: var(--color-bg); font-family: var(--font-text); font-size: 1rem; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2); animation: undoIn 0.2s ease both;
}
.undo-bar[hidden] { display: none; }     /* (display:flex above would otherwise keep it showing) */
@keyframes undoIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .undo-bar { animation: none; } }
.undo-bar button {
  border: none; border-radius: 999px; padding: 6px 14px; cursor: pointer;
  background: var(--color-bg); color: var(--color-text); font-family: var(--font-display); font-size: 1rem;
}
.undo-bar button:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* ── Irregular boards (puzzle.removed) ── */
/* A removed square keeps its place in the grid but isn't drawn */
.board-cell.removed { visibility: hidden; }
/* The frame follows the board's shape instead of being a rectangle */
#board-outer.irregular { background: transparent; box-shadow: none; }
#board-frame {
  position: absolute;
  left: var(--board-pad);
  top: var(--board-pad);
  overflow: visible;
  pointer-events: none;
}
#board-outer.irregular #board { position: relative; }
.frame-shape { fill: var(--color-board-bg); stroke: var(--color-board-bg); }
/* Sandbox "Shape" mode: removed squares show as dashed ghosts you can click to restore */
body.shaping .board-cell.removed {
  visibility: visible;
  background: transparent;
  border: 2px dashed var(--color-cell-border);
  opacity: 0.7;
}
/* A piece that starts on the board and can't be moved (tutorial), and every
   piece once the puzzle page's puzzle is solved */
.placed-piece.locked .blk, #board-outer.locked .placed-piece .blk { cursor: default; }

/* ── Tutorial popup (play.html) ── */
/* (2026-11-18, user: full screen again. In a 1000 × 860 window, slide 4's
   pieces wrapped and the grid jumped mid-animation; full screen the tutorial
   has the same room as tutorial.html on its own, which the tests check.
   Its × goes back to the puzzle underneath.) */
.tutorial-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--color-panel);
}
.tutorial-overlay[hidden] { display: none; }
.tutorial-overlay iframe {
  display: block; width: 100%; height: 100%;
  border: none; border-radius: 0;
  background: var(--color-panel);
}
