/* Puzzle Together — shared styles for the play screen */

:root {
  --bg: #eef1f6;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --text: #1d2433;
  --sub: #61697c;
  --accent: #6366f1;
  --accent2: #0ea5e9;
  --ok: #16a34a;
  --border: rgba(25, 35, 65, 0.13);
  --shadow: 0 12px 36px rgba(30, 40, 70, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

body.play { position: fixed; inset: 0; width: 100%; }

.fatal {
  padding: 60px 20px;
  text-align: center;
  font-size: 18px;
}
.fatal a { color: var(--accent2); }

/* ------------------------------------------------------------ top bar */
#topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  /* NO backdrop-filter here: --panel is 92% opaque so the blur was invisible,
   * but it forced the compositor to read back and gaussian-blur the region
   * behind this always-on-screen bar on every composite. */
  flex-wrap: wrap;
}

.pz { min-width: 0; }
.pz h1 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.sub { font-size: 12px; color: var(--sub); }

#pzSub { font-variant-numeric: tabular-nums; white-space: nowrap; }

#players { display: flex; align-items: center; margin-left: auto; }
/* Invite lives in the header, NOT in #playTools — that whole nav collapses into
 * the hamburger on mobile, which is what used to bury it two taps deep. A light
 * tint marks it as the one "bring someone in" action among the tools. */
#btnShare { flex: none; background: rgba(99, 102, 241, 0.10); border-color: rgba(99, 102, 241, 0.30); }
#btnShare:hover { background: rgba(99, 102, 241, 0.18); }
.pdot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(30, 40, 70, 0.25);
  margin-left: -6px;
}
.pdot:first-child { margin-left: 0; }
.pdot.me { border-color: var(--text); cursor: pointer; }
.pdot.me:hover { transform: scale(1.12); }
.pdot.more { background: #8a93a8; }

#offline {
  font-size: 12px;
  color: #b45309;
  padding: 3px 8px;
  border: 1px solid rgba(180, 83, 9, 0.4);
  border-radius: 8px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

.tools { display: flex; align-items: center; gap: 2px; }
/* desktop: a tool sliding off the bar is lifted out of the row where it stood
 * (js sets left/top) so the others can close up under it */
#playTools { position: relative; }
#playTools .tbtn.leaving { position: absolute; margin: 0; pointer-events: none; }
.sep { width: 1px; height: 30px; background: var(--border); margin: 0 5px; }

/* ZOOM - Fit is the control, the steps are an affordance.
 *
 * They stay VISIBLE while the bar has room. Only when it would wrap onto a
 * second row do they fold behind Fit and drop down over the board on hover,
 * which is the point at which hiding them actually buys something. js sets
 * body.bar-tight by measuring whether the bar still fits on one line. */
.zoomgroup { display: inline-flex; align-items: center; position: relative; }
.zoomsteps { display: inline-flex; align-items: center; }

body.bar-tight .zoomsteps {
  position: absolute; top: 100%; right: -4px; margin-top: 6px; z-index: 60;
  padding: 6px; gap: 2px;
  background: var(--panel-solid);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease;
}
/* focus-within as well as hover, or tabbing to a zoom step would move focus
   into something invisible. On touch there is no hover, so it opens on focus
   from the tap instead. */
body.bar-tight .zoomgroup:hover .zoomsteps,
body.bar-tight .zoomgroup:focus-within .zoomsteps {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}

/* the player list behind the +N pill */
.pop-title { grid-column: 1 / -1; padding: 2px 4px 6px; color: var(--sub);
  font-size: 12px; font-weight: 750; letter-spacing: .2px; }
#playersPop { display: block; min-width: 190px; max-height: 60vh; overflow-y: auto; }
.prow { display: flex; align-items: center; gap: 9px; padding: 4px 4px; }
.prow .pdot { margin-left: 0; flex: none; }
.pname { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.pdot { cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; padding: 0; }

/* labeled toolbar button: icon on top, tiny caption underneath */
.tbtn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 52px;
  padding: 5px 7px 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.tbtn span {
  font-size: 10px;
  line-height: 1;
  color: var(--sub);
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.tbtn:hover { background: rgba(30, 40, 70, 0.07); border-color: var(--border); }
.tbtn:active { transform: scale(0.94); }
.tbtn.on { background: rgba(99, 102, 241, 0.16); border-color: var(--accent); color: #4338ca; }
.tbtn.on span { color: #4338ca; }
/* a tool that just moved up from More into the bar (desktop) glows once */
.tbtn.arrived { animation: tool-arrived 1.1s ease-out; }
@keyframes tool-arrived { from { background: rgba(99, 102, 241, 0.28); border-color: var(--accent); } }
.tbtn.accent {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.tbtn.accent span { color: #fff; }
.tbtn.accent:hover { filter: brightness(1.08); }
.tbtn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* -------------------------------------------------------------- canvas */
#game {
  position: fixed;
  left: 0;
  top: 48px;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#game:active { cursor: grabbing; }

/* ------------------------------------------------------------ popover */
.pop {
  position: fixed;
  z-index: 30;
  top: 52px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(3, 46px);
  gap: 8px;
  padding: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.swatch {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 2px solid rgba(25, 35, 65, 0.18);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.swatch:hover { transform: scale(1.08); border-color: var(--accent); }

#bgPop {
  z-index: 31;   /* over the More menu it is opened from, should both ever be up */
  width: min(430px, calc(100vw - 24px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  padding: 12px;
}
.bg-pop-title {
  grid-column: 1 / -1;
  padding: 1px 2px 2px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .2px;
}
/* 25 tiles in four groups: shorter chips keep the whole picker on a laptop
 * screen without scrolling */
#bgPop .bg-swatch-color { height: 26px; margin-bottom: 5px; }
/* Light / Medium / Deep / Your own */
.bg-pop-group {
  grid-column: 1 / -1;
  margin: 3px 2px -3px;
  color: var(--sub);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
/* the colour input fills the swatch, invisible, so the browser's picker opens
 * from (and anchors to) the tile itself */
.bg-custom { position: relative; display: block; text-align: center; }
.bg-color-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: 0; padding: 0;
}
.bg-swatch {
  min-width: 0;
  padding: 5px 5px 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: 600 10.5px/1.2 "Segoe UI", system-ui, sans-serif;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.bg-swatch:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 7px 16px rgba(30,40,70,.12);
}
.bg-swatch.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.14);
  color: #4338ca;
}
.bg-swatch-color {
  display: block;
  width: 100%;
  height: 38px;
  margin-bottom: 6px;
  border-radius: 8px;
  border: 1px solid rgba(25,35,65,.15);
}
.bg-swatch-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------ overlays */
.ov {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(235, 240, 248, 0.55);
  backdrop-filter: blur(5px);
  padding: 20px;
}
/* NO BACKDROP BLUR ON TOUCH. Same lesson as the top bar above: backdrop-filter
 * makes the compositor read back and gaussian-blur everything behind the
 * element on EVERY composite - and behind this one is a full-screen canvas
 * holding the finished puzzle. Scrolling the picture grid composites
 * continuously, so the whole viewport is re-blurred for every frame of the
 * scroll. A desktop GPU absorbs that; a phone judders, which is exactly the
 * report. Kept on pointer-fine screens, where it is cheap and looks nice. */
@media (hover: none), (pointer: coarse), (max-width: 900px) {
  .ov { backdrop-filter: none; background: rgba(235, 240, 248, 0.72); }
}
.card {
  width: min(400px, 92vw);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px;
  text-align: center;
}
.brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 14px;
}
.card h2 { font-size: 22px; margin-bottom: 6px; }
.card .sub { margin-bottom: 16px; }
.card label {
  display: block;
  text-align: left;
  font-size: 12px;
  color: var(--sub);
  margin: 14px 0 5px;
}
.card input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: #f4f6fa;
  color: var(--text);
  font-size: 15px;
}
.card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.loadbar {
  height: 6px;
  border-radius: 4px;
  background: rgba(30, 40, 70, 0.10);
  overflow: hidden;
  margin-top: 4px;
}
.loadbar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.2s;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 18px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f1f3f8;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, filter 0.15s;
}
.btn:hover { filter: brightness(0.96); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: default; filter: none; }

.row { display: flex; gap: 10px; }
.row .btn { margin-top: 18px; }

.donerow { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.donerow .btn { flex: 1; min-width: 150px; text-decoration: none; }

/* ---- solved a picture puzzle → three next-puzzle picks: one in the same
 * art style, two random pictures from other styles ---- */
/* The card now holds the whole library, so it scrolls inside itself rather
   than growing past the viewport — the rating bar and the first picks stay
   put while "More puzzles" pages in below. */
#doneOv .card {
  width: min(760px, 96vw);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 620px) { #doneOv .card { width: 96vw; max-height: 92vh; } }
/* ---- was this picture any good? (completion card) ----
 * Deliberately big: this is the one moment a player is asked anything, and a
 * pair of small emoji buttons in a tidy row read as decoration rather than a
 * question. */
/* RATING - a pill on the finish bar, beside Next puzzle.
 *
 * Sized and shaped to sit next to that button rather than to fill a card row:
 * same pill radius, same white outline so it reads on top of any artwork, and
 * a solid panel background because it floats over the finished picture.
 *
 * The buttons come FIRST and the label second on narrow screens (see below):
 * the two targets should be the part nearest the thumb. */
.ratebar {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 26px;
  background: var(--panel-solid);
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  /* keep clear of Next puzzle: #nextBtns' own 10px gap is not enough separation
     between a thing you tap once and a thing you tap to leave */
  margin-right: 8px;
}
/* the question doubles as the spacer - the wider it is, the harder it is to hit
   one thumb while aiming for the other */
.ratelab { padding: 0 6px; }
.ratebar[hidden] { display: none; }
.ratelab { font-size: 13.5px; font-weight: 700; color: var(--sub); white-space: nowrap; }
.ratebtn {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  font-size: 20px; line-height: 1; padding: 6px 12px; cursor: pointer;
  min-width: 48px; min-height: 40px;
  transition: transform .08s, border-color .12s, background .12s;
}
.ratebtn:hover { transform: translateY(-2px); border-color: var(--accent); }
.ratebtn.on { background: var(--accent); border-color: var(--accent); }
.ratebtn:disabled { cursor: default; transform: none; }
.ratethx { font-size: 13px; color: var(--accent); font-weight: 700; white-space: nowrap; }
.ratethx[hidden] { display: none; }
/* the retirement: thanks, then out of the way */
.ratebar { transition: opacity .3s ease, transform .3s ease; }
.ratebar.rate-gone { opacity: 0; transform: scale(.92); pointer-events: none; }

/* Two columns because there are exactly two tiles — Another, and Surprise.
 * Three columns left the pair sitting in two thirds of the card with a hole
 * where the old style picks used to be. Two also gives each tile roughly half
 * the width, so the one thumbnail on offer is bigger than any of the four
 * cramped ones it replaced. */
.nextpicks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 2px 0 6px; }
.nextpicks[hidden] { display: none; }
/* the mystery pick — random, no preview */
.npick.nsurprise {
  align-items: center; justify-content: center; text-align: center;
  border-style: dashed; border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.06); min-height: 100px;
}
.npick.nsurprise:hover { background: rgba(99, 102, 241, 0.11); }
.npick.nsurprise .nsl {
  font-size: 13px; font-weight: 750; color: var(--accent);
  padding: 8px; line-height: 1.35;
}
.npick {
  position: relative; padding: 0; overflow: hidden; cursor: pointer;
  border: 2.5px solid transparent; border-radius: 14px; background: #e9ecf5;
  box-shadow: 0 5px 14px rgba(30, 40, 70, 0.12);
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; font: inherit; color: inherit; text-align: left;
}
.npick:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 22px rgba(30, 40, 70, 0.18); }
.npick:disabled { opacity: 0.6; cursor: default; transform: none; }
.npick img { width: 100%; height: 132px; object-fit: cover; display: block; }
/* The art-style name was a full-width banner across every tile and crowded out
 * the picture, which is the only thing that actually sells the puzzle. It now
 * rides small in the corner, and only the "another like this" tile gets a
 * prominent one — that tile's whole reason for existing is the style. */
.npick .npk-tag {
  position: absolute; top: 6px; left: 6px; max-width: calc(100% - 12px);
  background: rgba(20, 26, 48, 0.6); color: #fff; border-radius: 8px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.2px; padding: 2px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.npick .npk-tag.same {
  background: var(--accent); font-size: 11px; padding: 4px 9px; border-radius: 9px;
}
/* "another Halloween puzzle" — the topic's own colour (--tc), not the accent */
.npick.ntopic { --tc: #ff8a1f; border-color: var(--tc); }
.npick.ntopic .npk-tag.same { background: var(--tc); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.npick .npk-name {
  padding: 7px 9px 8px; font-size: 12.5px; font-weight: 650; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- the rest of the library, scrolling on underneath ---- */
.morewrap { margin-top: 4px; }
.morewrap[hidden] { display: none; }
.morehead {
  font-size: 13px; font-weight: 750; color: var(--sub); text-transform: uppercase;
  letter-spacing: .5px; margin: 16px 0 8px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.moresent { height: 1px; }
.moreend { text-align: center; color: var(--sub); font-size: 13px; padding: 16px 0 4px; }
.moreend[hidden] { display: none; }

@media (max-width: 620px) {
  /* Two real tiles per row rather than one squashed strip. The old phone layout
     put a 118x64 thumbnail beside a line of text, which made every picture too
     small to judge — the exact thing you are being asked to choose between. */
  .nextpicks { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .npick img { height: 118px; }
  .npick .npk-name { font-size: 12px; padding: 6px 8px 7px; }
  /* Art-style names are long and a tile is narrow, so every one of them was
     ellipsised — half a style name tells you nothing and costs a strip of the
     picture. Hidden on phones; the picture and its title carry the tile. */
  .npick .npk-tag { display: none; }
  /* the exception: this tile's whole point is "like the one you just did",
     so it keeps its label and wraps rather than truncating */
  .npick .npk-tag.same {
    display: block; white-space: normal; font-size: 10.5px; line-height: 1.2;
    padding: 3px 7px; max-width: calc(100% - 12px);
  }
  .npick.nsurprise { min-height: 92px; }
  /* Phones KEEP the label. Two thumbs with no words could be about the puzzle,
     the app, or the person who shared it; naming the picture is the whole point
     of asking. The finish bar wraps, so the pill simply takes its own line.
     48px tall clears the 44px minimum - this is the one control here that is a
     favour to us rather than to the player, so it must never take two goes. */
  .ratebar { padding: 6px 8px 6px 12px; gap: 6px; }
  .ratelab { font-size: 13px; }
  .ratebtn { font-size: 22px; padding: 7px 14px; min-width: 56px; min-height: 48px; }
  .ratebtn { font-size: 28px; padding: 9px 15px; }
  .ratethx { width: 100%; margin-left: 0; text-align: center; }
}
@media (max-width: 380px) {
  .npick img { height: 100px; }
}

.linkline {
  display: inline-block;
  margin-top: 14px;
  color: var(--sub);
  font-size: 13px;
  text-decoration: none;
}
.linkline:hover { color: var(--accent2); }

/* -------------------------------------------------- invite dialog bits */
.card { position: relative; }
.xclose {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sub);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.xclose:hover { background: rgba(30, 40, 70, 0.08); color: var(--text); }

.card label .mini { font-weight: 400; text-transform: none; letter-spacing: 0; }
.linkrow { display: flex; gap: 8px; }
.linkrow input {
  flex: 1;
  font-size: 13px;
  color: var(--sub);
}
.copybtn {
  flex: none;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.copybtn:hover { filter: brightness(1.08); }
.copybtn:active { transform: scale(0.96); }

/* ------------------------------------------------- rotation hover popup */
#rotPop {
  position: fixed;
  z-index: 26;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 7px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: rp-in 0.15s ease;
}
@keyframes rp-in { from { opacity: 0; transform: translateY(4px); } }
.rp-arrows { display: flex; gap: 6px; }
.rp-btn {
  width: 34px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f1f3f8;
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.rp-btn:hover { background: rgba(99, 102, 241, 0.14); border-color: var(--accent); }
.rp-previews { display: flex; gap: 5px; }
.rp-prev {
  width: 58px;
  height: 58px;
  padding: 2px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f7f9fc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, transform 0.12s;
}
.rp-prev:hover:not(:disabled) { border-color: var(--accent); transform: scale(1.06); }
.rp-prev:disabled {
  opacity: 0.45;
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.10);
  cursor: default;
}
.rp-prev canvas { display: block; }
/* iPhone "how to go fullscreen" help card */
.fs-steps { text-align: left; margin: 6px 0 12px; padding-left: 24px; line-height: 1.55; font-size: 15px; }
.fs-steps li { margin: 9px 0; }
.fs-share { width: 18px; height: 18px; vertical-align: -4px; color: var(--accent); }
.fs-tip {
  text-align: left; font-size: 13px; color: var(--sub);
  background: rgba(99, 102, 241, 0.09); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.playprompt {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 94vw;
  padding: 11px 15px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  animation: rp-in 0.18s ease;
}
.playprompt .btn { padding: 8px 14px; font-size: 13px; }
.rp-note {
  max-width: 232px;
  margin-top: 1px;
  padding: 0 2px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--sub);
  text-align: center;
}

/* ------------------------------------------------ sections (chunk mode) */
#sectPop {
  display: block;
  width: 250px;
  padding: 12px;
}

/* overflow tools — keeps the top bar to one compact row so the banner above
 * it doesn't push the board down */
#morePop {
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  gap: 4px;
  width: auto;
  padding: 8px;
}
#morePop .tbtn { min-width: 64px; }
/* desktop: EVERY tool, under a heading per group (the bar shows copies of the
 * four used most recently). As many columns as the widest group (Help, five
 * with Sections), so no group wraps a lone tool onto a second row. */
#morePop.grouped { grid-template-columns: repeat(5, minmax(64px, 1fr)); row-gap: 2px; }
#morePop.grouped .pop-title { padding: 4px 4px 2px; }
#morePop.grouped .pop-title:not(:first-child) {
  margin-top: 5px; padding-top: 8px; border-top: 1px solid var(--border);
}

/* ---- next-puzzle setup: piece count + piece options, from the toolbar ---- */
#setupPop {
  display: block;
  width: min(330px, calc(100vw - 24px));
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  padding: 14px;
}
.su-pieces { margin-bottom: 12px; }
.su-count { display: flex; align-items: baseline; gap: 6px; }
.su-count b { font-size: 24px; color: var(--accent); line-height: 1; }
.su-count span { font-size: 12px; color: var(--sub); }
#suSlider {
  width: 100%; margin-top: 8px; appearance: none; -webkit-appearance: none;
  height: 7px; border-radius: 5px; cursor: pointer;
  background: linear-gradient(90deg, #079acb, var(--accent));
}
#suSlider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 7px rgba(30,40,70,.28);
}
#suSlider::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 7px rgba(30,40,70,.28);
}
.su-ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--sub); margin-top: 4px; }
.su-ticks span { cursor: pointer; }
.su-ticks span:hover { color: var(--accent); }
.su-opts { display: grid; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.su-opt {
  display: flex; align-items: flex-start; gap: 9px; cursor: pointer;
  padding: 7px 6px; border-radius: 9px; font-size: 13px;
}
.su-opt:hover { background: rgba(91,94,232,0.07); }
.su-opt input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin-top: 1px; }
.su-opt span { display: block; font-weight: 650; line-height: 1.25; }
.su-opt small { display: block; font-weight: 400; color: var(--sub); font-size: 11px; margin-top: 1px; }
.su-opt.su-sub { margin-left: 18px; }

/* ---- admin: "Next puzzles" peek (only rendered for a signed-in admin) ---- */
#nextPop {
  display: block;
  width: min(400px, calc(100vw - 24px));
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  padding: 14px;
}
.np-admin {
  font: 800 9px/1 "Segoe UI", system-ui, sans-serif; letter-spacing: .8px;
  text-transform: uppercase; vertical-align: 2px; margin-left: 6px;
  background: var(--accent); color: #fff; padding: 3px 6px; border-radius: 5px;
}
.np-setup { font-size: 12px; color: var(--sub); margin-bottom: 8px; line-height: 1.45; }
.np-setup b { color: var(--text); }
.np-tiers { display: grid; gap: 3px; margin-bottom: 10px; }
.np-tier { display: flex; gap: 8px; align-items: baseline; font-size: 11px; color: var(--sub); }
.np-tier .n { font-weight: 800; color: var(--text); flex: none; min-width: 52px; }
.np-tier .r { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; }
.np-tier.live .n { color: #16a34a; }
.np-tier.empty { opacity: .5; }
.np-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.np-pic { position: relative; border-radius: 9px; overflow: hidden; background: #e9ecf5; }
.np-pic img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.np-pic span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 5px 3px;
  font: 700 9.5px/1.25 "Segoe UI", system-ui, sans-serif; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.78));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.np-note { font-size: 11px; color: var(--sub); line-height: 1.45; margin-top: 10px; }
.su-note {
  margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--sub); line-height: 1.35;
}
/* appears once the settings differ from the puzzle on screen — one tap to
 * actually play with them instead of hunting for Skip */
#suNext {
  display: block; width: 100%; margin-top: 10px; padding: 11px 10px;
  border: none; border-radius: 11px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #4f46e5); color: #fff;
  font: 700 13.5px "Segoe UI", system-ui, sans-serif;
  box-shadow: 0 5px 16px rgba(99,102,241,0.32);
}
#suNext[hidden] { display: none; }
#suNext:hover { filter: brightness(1.07); }
#suNext:active { transform: scale(0.98); }
#suNext:disabled { opacity: 0.7; cursor: default; }
.sp-title { font-weight: 700; font-size: 13px; color: var(--sub); margin-bottom: 9px; }
#sectGrid { display: grid; gap: 7px; }
.sp-cell {
  border: 2px solid var(--border);
  border-radius: 10px;
  background: rgba(30, 40, 70, 0.03);
  color: var(--text);
  font: inherit;
  padding: 7px 4px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}
.sp-cell:hover { border-color: var(--accent); }
.sp-cell.sel { border-color: var(--accent); background: rgba(99, 102, 241, 0.10); }
.sp-cell.done { opacity: 0.55; }
.sp-cell:disabled { cursor: not-allowed; opacity: 0.7; }
.sp-cell b { display: block; font-size: 15px; }
.sp-cell small {
  display: block; color: var(--sub); font-size: 10.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-cell.all { padding: 8px; font-weight: 650; font-size: 13.5px; }
.sp-claim {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 11px; font-size: 12px; color: var(--sub); cursor: pointer;
}
.sp-claim input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin-top: 1px; }

/* ------------------------------------------------- completion results */
#doneBar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 0.3s ease;
  max-width: 92vw;
  flex-wrap: wrap;
  justify-content: center;
}
.db-title { font-weight: 700; color: var(--sub); font-size: 13px; }
.db-entry { display: inline-flex; align-items: center; gap: 6px; }
.db-entry i { width: 11px; height: 11px; border-radius: 50%; }
.db-entry b { font-variant-numeric: tabular-nums; }

/* one-tap follow-up floating over the finished picture; with company it
 * becomes a pair: together (accent) / alone (muted) in the same pill style */
#nextBtns {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 94vw;
}
#nextBtn, #nextBtnSolo {
  padding: 13px 28px;
  border-radius: 26px;
  border: 2.5px solid rgba(255, 255, 255, 0.95);  /* visible even on purple art */
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}
#nextBtnSolo { background: #475069; }             /* the quieter choice */
#nextBtn:active, #nextBtnSolo:active { transform: scale(0.96); }
#nextBtn:disabled, #nextBtnSolo:disabled { opacity: 0.7; cursor: default; }
/* the three next-puzzle picks are ready — a soft heartbeat on the pills */
@keyframes pickpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
  60% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
}
#nextBtn.pickready, #btnNextTop.pickready { animation: pickpulse 1.7s ease-out infinite; }
body.donebar #nextBtns { bottom: 78px; }   /* clear the standings strip */

/* finished on mobile: the dead menu swaps for Home, chunk pill retires */
body.mobile.done #btnMenu { display: none; }
body.mobile.done .homebtn { display: inline-flex; }
body.done #msect { display: none; }
body.mobile.done #mzoom { display: none; }   /* finished: no zoom controls over the montage */

/* --------------------------------------------------- race standings strip */
#raceBar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 44;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12.5px;
  max-width: 92vw;
  flex-wrap: wrap;
  justify-content: center;
}
.rb-title { font-weight: 700; color: var(--sub); font-size: 12px; }
.rb-entry { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rb-entry.fin { color: #16a34a; font-weight: 650; }
body.mobile #raceBar { bottom: 168px; }   /* sit above the piece tray */

/* ------------------------------------------- invite mode: team up / race */
.invmodes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.invmode {
  border: 2px solid var(--border);
  border-radius: 12px;
  background: rgba(30, 40, 70, 0.03);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.invmode:hover { border-color: var(--accent); }
.invmode.sel { border-color: var(--accent); background: rgba(99, 102, 241, 0.08); }
.invmode b { display: block; font-size: 14px; }
.invmode small { display: block; color: var(--sub); font-size: 11.5px; margin-top: 2px; }
.invmode:disabled { opacity: 0.6; cursor: wait; }
.joinrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.joinrow .btn.slim { padding: 8px 14px; font-size: 13.5px; width: auto; margin: 0; }

/* ------------------------------------------------------ invite QR code */
.qrwrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.qrwrap canvas {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}
.qrwrap .mini { color: var(--sub); font-size: 12px; }

/* -------------------------------------------------------------- toasts */
#toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 16px;
  font-size: 14px;
  animation: toast-in 0.25s ease;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* -------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  #topbar { gap: 4px; padding: 5px 6px; }
  .pz h1 { max-width: 110px; font-size: 13px; }
  .tbtn { min-width: 40px; padding: 4px 4px 3px; }
  .tbtn span { font-size: 9px; }
  .sep { display: none; }
}

/* mobile mode: hamburger menu + board/tray split + zoom overlay */
.menu-only { display: none; }

#mzoom {
  position: fixed;
  right: 10px;
  top: 110px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#mzoom button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}
#mzoom button:active { transform: scale(0.92); }
/* 'Fit' is a word, not a glyph: at the 19px bold the + uses it measures 45px
 * inside a 46px circle -- one pixel of slack, which clips on another font.
 * Needs #mzoom in the selector: `#mzoom button` is (1,0,1) and would beat a
 * bare `#mzReset` at (1,0,0). */
#mzoom button#mzReset { font-size: 14px; letter-spacing: .2px; }

/* ---- mobile zoom pill: SWITCHED OFF FOR TESTING ----------------------------
 * Pinch-to-zoom and double-tap still work; this only removes the floating
 * +/1x shortcut. Nothing else was touched — the markup in play.php, the
 * button wiring and the resize() positioning in js/main.js are all still
 * there, so deleting THIS ONE RULE brings the control straight back.
 * (Specificity 0,1,2 beats the #mzoom display:flex above.) */
/* The + stays off; the RESET does not. The rule above used to hide the whole
 * cluster, which also hid #mzReset -- the only way back from a view that is
 * zoomed or shoved off-centre, hidden on the one platform where pinch can
 * strand you. A player hit exactly that. It shows itself only when the view
 * differs from Fit (see atFittedView), so it costs nothing when untouched. */
body.mobile #mzIn { display: none; }

/* mobile: quick access to chunk mode, top-left of the board view */
#msect {
  position: fixed;
  left: 10px;
  top: 110px;
  z-index: 15; /* below #topbar (20) so the open hamburger menu covers the pill */
}
#msect button {
  height: 40px;
  padding: 0 15px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
#msect button.on { border-color: var(--accent); color: var(--accent); }
#msect button:active { transform: scale(0.94); }
body.mobile #sectPop { left: 10px; right: auto; }

body.mobile .homebtn,
body.mobile #btnZoomIn,
body.mobile #btnZoomOut,
body.mobile #btnFit,
body.mobile #btnArrange,
body.mobile #btnColor { display: none; }
body.mobile .menu-only { display: inline-flex; }
body.mobile #playTools { display: none; }
body.mobile.menu-open #playTools {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: fixed;
  top: 52px;
  left: 8px;
  z-index: 70;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  gap: 2px;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}
body.mobile.menu-open #playTools .tbtn {
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  min-width: 190px;
  padding: 11px 12px;
}
body.mobile.menu-open #playTools .tbtn span { font-size: 14px; color: var(--text); }
body.mobile.menu-open #playTools .sep { display: block; width: auto; height: 1px; margin: 5px 0; }
/* In the hamburger the tools are a vertical stack, so the zoom wrapper must not
   introduce a row of its own. display:contents removes it from layout entirely
   and the three buttons become children of the column, like every other tool. */
body.mobile.menu-open #playTools .zoomgroup { display: contents; }
body.mobile #doneTools { margin-left: auto; }

/* ------------------------------------------------------------------ ads
 * Slots only exist in the DOM when they're switched on (see ads.php), so an
 * ad-free build is byte-identical to before. Sizes are fixed here so turning
 * ads on doesn't reflow anything, and nothing ever sits over the canvas. */
.adslot {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex: none;
  border-radius: 12px;
}
/* Only a PLACEHOLDER draws itself.
 *
 * The stripes exist so that, while previewing placement, you can tell "the
 * slot is here and empty" from "the slot did not render" — that ambiguity is
 * the whole problem when you are positioning one. But fill is never 100%,
 * and once ads are LIVE the same striped box on every unfilled impression
 * reads as a broken game rather than as an ad that did not arrive. So a live
 * slot is invisible until Ramp puts something in it, while still holding its
 * space so nothing reflows when one lands. */
.adslot-ph {
  border: 1px solid var(--border);
  background: repeating-linear-gradient(135deg,
    rgba(47, 124, 246, .10) 0 14px, rgba(47, 124, 246, .02) 14px 28px);
}
.adslot-tag {                      /* players can always tell it's an ad */
  position: absolute; top: 3px; left: 6px; z-index: 2;
  font: 600 9px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: .6px; text-transform: uppercase; color: var(--sub); opacity: .75;
}
.adslot-test {
  font: 700 12px "Segoe UI", system-ui, sans-serif; color: var(--sub);
  border: 1px dashed var(--border); border-radius: 8px; padding: 6px 12px;
  text-align: center;
}
/* ads.php writes "<b>AD SPACE</b>place<br>size" and relies on the b being a
 * block to break the first line. The landing page had that rule inline and
 * this file did not, so the same markup read "AD SPACEtop" here. */
.adslot-test b { display: block; letter-spacing: .6px; }
/* INLINE, between the title and the tools, at 320x50 on every screen size.
 * Home and the title stay on the left where they belong; the slot rides in the
 * room the condensed toolbar freed, so it costs the board no width and no extra
 * height on desktop, and it gives ground when the bar gets tight — the tools
 * always win.
 *
 * WHY NOT A 728x90 LEADERBOARD, which is where desktop demand actually is:
 * measured at 1280, the most common width by a wide margin, only about 440px is
 * free inline — the toolbar alone is 454 and home/title/players/invite another
 * 312. So 728 fits only on its OWN ROW above the title, and that layout was
 * built and then rejected: a band running across the top before you reach the
 * puzzle's own name reads as the page being about the ad. Phones do get that
 * row treatment (below), because there is nothing to share the line with there.
 *
 * flex 0 1 <basis> with NO max-width: the slot asks for its ideal width and
 * yields when the bar is tight, which is what keeps everything on one line. A
 * max-width here is what made the title wrap up beside it — the cap freed the
 * remainder and the siblings took it. */
.adslot-top {
  flex: 0 1 320px; min-width: 300px; height: 50px; margin: 0 auto;
}
/* the auto margins centre it AND shove the tools to the far right */
#topbar .adslot-top ~ #players { margin-left: 0; }

/* phones: nothing to share — the slot takes its own full-width line, at the
 * standard 320×50 mobile banner height */
@media (max-width: 820px) {
  /* Its own full-width row ABOVE everything, at the standard 320×50 mobile
   * banner height. order:-1 beats every sibling's default 0, so the ad is the
   * first thing on the screen and the title, avatars and tools close ranks
   * underneath it — one band to skim past and then ignore for the rest of the
   * puzzle, rather than a strip wedged between the title and the board where
   * it sits in the way of the game. Still the top of the screen and never the
   * bottom, because the bottom of a phone is the piece tray. */
  .adslot-top { flex: 1 1 100%; min-width: 0; height: 50px; margin: 0 0 4px; order: -1; }
  #topbar .adslot-top ~ #players { margin-left: auto; }
}
