/* Puzzle games: Sudoku, 2048, Logic, Jigsaw, Groovy Gems. Colors come from the theme. */

.puzzles .pop {
  z-index: 200000;
}

.btn svg {
  vertical-align: -3px;
  margin-right: 6px;
}

/* ---- Sudoku ---------------------------------------------------------------- */

.sudoku {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px;
}

.sudoku.wide {
  flex-direction: row;
  gap: 36px;
}

.sboard {
  width: var(--board);
  height: var(--board);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: calc(var(--board) * 0.009);
  padding: calc(var(--board) * 0.009);
  border-radius: calc(var(--board) * 0.03);
  background: var(--ink);
  box-shadow: 0 8px 0 var(--ink), 0 18px 30px rgba(74, 44, 26, 0.3);
}

.sboard.deal .sbox {
  animation: box-in 0.5s var(--ease) both;
}

.sboard.deal .sbox:nth-child(3n + 2) {
  animation-delay: 0.06s;
}

.sboard.deal .sbox:nth-child(3n) {
  animation-delay: 0.12s;
}

.sbox {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 2px;
  background: #b98a5e;
  border-radius: calc(var(--board) * 0.016);
  overflow: hidden;
}

.sc {
  position: relative;
  border: 0;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  font: 900 calc(var(--board) * 0.06) var(--font-body);
  cursor: pointer;
  transition: background 0.12s;
}

.sc.user {
  color: #1f6f66;
}

.sc.peer {
  background: #fde4c2;
}

.sc.same {
  background: #f7c27f;
}

.sc.sel {
  background: var(--accent-2);
  box-shadow: inset 0 0 0 3px var(--accent-3);
}

.sc.err {
  color: var(--accent-3);
  background: #f8d0c4;
}

.sc.err::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 14%;
  height: 3px;
  border-radius: 2px;
  background: var(--accent-3);
}

.sc.flash {
  animation: cell-flash 0.7s ease-out;
}

.sc:focus-visible {
  outline: 3px solid var(--accent-3);
  outline-offset: -3px;
}

.notes {
  position: absolute;
  inset: 6%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  font: 800 calc(var(--board) * 0.021) var(--font-body);
  color: #8a5a3a;
  line-height: 1;
  align-items: center;
  justify-items: center;
}

.spanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, var(--board));
}

.sudoku.wide .spanel {
  width: 300px;
}

.mode {
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--bar-bg);
}

.mode button {
  flex: 1;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--bar-ink);
  font: 800 15px var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}

.mode button[aria-pressed='true'] {
  background: var(--accent-2);
  color: var(--ink);
}

.pad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
}

.sudoku.wide .pad {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.key {
  position: relative;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  font: 400 26px var(--font-display);
  box-shadow: 0 4px 0 var(--ink), 0 0 0 2px var(--ink);
  cursor: pointer;
}

.sudoku.wide .key {
  height: 80px;
  border-radius: 20px;
  font-size: 38px;
}

.key small {
  position: absolute;
  right: 6px;
  bottom: 3px;
  font: 900 11px var(--font-body);
  color: #8a5a3a;
}

.key.done {
  opacity: 0.4;
}

.key:active {
  transform: translateY(2px);
}

.erase {
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--bar-bg);
  color: var(--bar-ink);
  font: 800 15px var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

@keyframes cell-flash {
  0% {
    background: var(--accent-2);
  }
}

@keyframes box-in {
  from {
    opacity: 0;
    transform: scale(0.85) rotate(-3deg);
  }
}

/* ---- 2048 -------------------------------------------------------------------- */

.g2048 {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.gboard {
  position: relative;
  border-radius: 22px;
  background: var(--ink);
  box-shadow: 0 8px 0 #2b1a10, 0 18px 30px rgba(74, 44, 26, 0.3);
}

.gboard.bump {
  animation: shake 0.3s ease-in-out;
}

.gcells {
  position: absolute;
  inset: var(--gap);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.gcells i {
  border-radius: 14px;
  background: var(--bar-raised);
}

.gt {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease-out;
  user-select: none;
}

.gboard.no-anim .gt {
  transition: none;
}

.gt.new {
  animation: grow 0.24s var(--ease);
}

.gt.merge {
  animation: merge 0.22s ease-out;
}

.gt[data-v='2'] { background: #fff6e5; color: #4a2c1a; }
.gt[data-v='4'] { background: #fbe0b4; color: #4a2c1a; }
.gt[data-v='8'] { background: #f7c27f; color: #4a2c1a; }
.gt[data-v='16'] { background: #f1c40f; color: #4a2c1a; }
.gt[data-v='32'] { background: #e67e22; color: #2b1407; }
.gt[data-v='64'] { background: #c0392b; color: #fff1d6; }
.gt[data-v='128'] { background: #e76f9a; color: #2b1407; }
.gt[data-v='256'] { background: #7b4fa0; color: #fff1d6; }
.gt[data-v='512'] { background: #2a9d8f; color: #fff1d6; }
.gt[data-v='1024'] { background: #6f8f2f; color: #fff1d6; }
.gt[data-v='2048'] { background: #4a2c1a; color: #f1c40f; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.3), 0 0 0 4px #f1c40f, 0 0 26px rgba(241, 196, 15, 0.8); }
.gt[data-v='big'] { background: #2b1a10; color: #f1c40f; box-shadow: 0 0 0 4px #e76f9a; }

.arrow {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 50;
  font: 400 140px var(--font-display);
  color: var(--panel);
  text-shadow: 4px 4px 0 var(--accent-3), 8px 8px 0 var(--ink);
  pointer-events: none;
  animation: bob 0.8s ease-in-out infinite;
}

@keyframes grow {
  from {
    scale: 0;
  }
}

@keyframes merge {
  50% {
    scale: 1.18;
  }
}

/* ---- Groovy Gems -------------------------------------------------------------- */

.gems {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.mboard {
  position: relative;
  border-radius: 24px;
  background: var(--ink);
  box-shadow: 0 8px 0 #2b1a10, 0 18px 30px rgba(74, 44, 26, 0.3);
}

.mboard.shake-all .gm {
  animation: wobble 0.4s ease-in-out;
}

.mboard.deal .gm {
  animation: grow 0.4s var(--ease) both;
}

.mbg {
  position: absolute;
  inset: 6px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border-radius: 18px;
  overflow: hidden;
}

.mbg i.a {
  background: #fff3dc;
}

.mbg i.b {
  background: #f9dfb2;
}

.gm {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cs);
  height: var(--cs);
  display: grid;
  place-items: center;
  transition: transform 0.24s cubic-bezier(0.3, 0.1, 0.4, 1.3), opacity 0.2s, scale 0.2s;
  cursor: pointer;
  touch-action: none;
}

.mboard.no-anim .gm {
  transition: none;
}

.gm svg {
  width: 84%;
  height: 84%;
  pointer-events: none;
}

.gm.sel {
  scale: 1.12;
  filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 3px var(--accent-3));
}

.gm.hint svg {
  animation: wobble 0.9s ease-in-out infinite;
}

.gm.pop-out {
  opacity: 0;
  scale: 1.6;
  transition: opacity 0.24s ease-in, scale 0.24s ease-out;
}

.gm.born {
  animation: merge 0.4s ease-out;
}

.gm.sp-h::after,
.gm.sp-v::after {
  content: '';
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
}

.gm.sp-h::after {
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.85) 0 3px, transparent 3px 7px);
}

.gm.sp-v::after {
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.85) 0 3px, transparent 3px 7px);
}

.gm.sp-disco svg {
  animation: spin 3s linear infinite;
}

.boosts {
  display: flex;
  gap: 12px;
}

.bt {
  position: relative;
  min-width: 96px;
  height: 64px;
  padding: 0 14px;
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  font: 800 13px var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
}

.bt.on {
  background: var(--accent-2);
  box-shadow: 0 5px 0 var(--ink), 0 0 0 3px var(--accent-3);
}

.bt:disabled {
  opacity: 0.45;
  cursor: default;
}

.bt .dz svg {
  width: 26px;
  height: 26px;
}

.bt .n {
  position: absolute;
  top: -8px;
  right: -6px;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--accent-3);
  color: var(--pop-ink);
  font: 900 12px var(--font-body);
  font-style: normal;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 3px var(--page-bg);
}

.gi svg {
  width: 22px;
  height: 22px;
  vertical-align: -6px;
}

.stars {
  margin-left: 6px;
  color: var(--accent-2);
  letter-spacing: 1px;
}

@keyframes wobble {
  25% {
    rotate: -8deg;
  }
  75% {
    rotate: 8deg;
  }
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

/* ---- Jigsaw ------------------------------------------------------------------- */

.jframe {
  position: absolute;
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 0 0 6px var(--ink), 0 0 0 12px var(--accent), 0 0 0 16px var(--ink), 0 22px 34px rgba(74, 44, 26, 0.35);
}

.jframe.done {
  animation: merge 0.6s ease-out;
}

.jghost,
.jpeek {
  position: absolute;
  inset: 0;
  background-size: 100% 100%;
  border-radius: 6px;
}

.jghost {
  opacity: 0.2;
}

.jpeek {
  z-index: 60000;
  box-shadow: 0 0 0 4px var(--accent-2);
}

.jslot {
  position: absolute;
  border: 3px dashed var(--accent-3);
  border-radius: 6px;
  background: rgba(241, 196, 15, 0.45);
  animation: pulse 1s ease-in-out infinite;
}

.jbar {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.jbar .btn {
  pointer-events: auto;
  height: 42px;
  padding: 0 16px;
  font-size: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}

.jbar .btn[aria-pressed='true'] {
  background: var(--accent-2);
}

.jp {
  position: absolute;
  left: 0;
  top: 0;
  filter: drop-shadow(2px 4px 3px rgba(74, 44, 26, 0.45));
  transition: transform 0.25s var(--ease);
  touch-action: none;
  cursor: grab;
}

.jp.placed {
  filter: none;
  cursor: default;
}

.jp.dragging {
  transition: none;
  cursor: grabbing;
  filter: drop-shadow(8px 14px 8px rgba(74, 44, 26, 0.5));
}

.jp.no-anim {
  transition: none;
}

.jp.snap {
  animation: snap 0.35s ease-out;
}

.jp.hint {
  animation: wobble 0.5s ease-in-out 4;
  filter: drop-shadow(0 0 6px var(--accent-2)) drop-shadow(0 0 2px var(--accent-3));
}

@keyframes snap {
  40% {
    scale: 1.06;
  }
}

@keyframes pulse {
  50% {
    background: rgba(241, 196, 15, 0.75);
  }
}

/* ---- Logic puzzles ------------------------------------------------------------ */

.logic {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.logic.wide {
  flex-direction: row;
  gap: 20px;
  padding: 16px 20px;
}

.lpanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 0 0 4px var(--ink), 0 6px 0 4px var(--ink);
}

.logic.wide .lpanel {
  flex: 0 0 400px;
  overflow: auto;
}

.lpanel h2 {
  margin: 0;
  font: 400 26px/1.1 var(--font-display);
  color: var(--accent-3);
}

.story {
  margin: 0;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.45;
}

.lclues {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lclues button {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: 700 15px/1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
}

.lclues button:hover {
  background: #fde4c2;
}

.lclues .n {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bar-ink);
  font: 900 13px var(--font-body);
  display: grid;
  place-items: center;
}

.lclues button.done {
  color: #9b7a60;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.lclues button.done .n {
  background: #c9b49a;
}

.lclues button.focus {
  background: #fde4c2;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.note {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #8a5a3a;
}

.lacts {
  display: flex;
  gap: 8px;
}

.lgridwrap {
  flex: 1;
  min-width: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 0 0 4px var(--ink), 0 6px 0 4px var(--ink);
}

.lstair,
.lone {
  --c: 40px;
}

.lhead,
.lhead2 {
  display: flex;
}

.lgrp {
  height: 26px;
  border-radius: 8px;
  background: var(--bar-raised);
  color: var(--bar-ink);
  font: 900 12px var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  white-space: nowrap;
  overflow: hidden;
}

.lgrp.v {
  width: 28px;
  height: auto;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.lch {
  height: 92px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}

.lch span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}

.lch.flat {
  height: 34px;
}

.lch.flat span {
  writing-mode: horizontal-tb;
  transform: none;
  font-size: 13px;
  text-align: center;
  white-space: normal;
  line-height: 1.1;
}

.lband {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.lrow {
  display: flex;
  gap: 6px;
}

.lrh {
  height: var(--c);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lseg {
  display: flex;
}

.lstair .lhead {
  gap: 6px;
}

.lstair .lhead2 {
  margin-top: 4px;
  gap: 6px;
}

.lc {
  width: var(--c);
  height: var(--c);
  padding: 0;
  border: 1px solid #c9a97f;
  background: #fffaf0;
  color: var(--ink);
  font: 900 calc(var(--c) * 0.55) var(--font-body);
  cursor: pointer;
}

.lc:hover {
  background: #fde4c2;
}

.lc.x {
  color: var(--accent-3);
}

.lc.y {
  background: #2a9d8f;
  color: #fff6e5;
}

.lc.tip {
  box-shadow: inset 0 0 0 4px var(--accent);
  animation: cell-flash 0.9s ease-in-out infinite alternate;
}

.lc.bad {
  box-shadow: inset 0 0 0 4px var(--accent-3);
  background: #f8d0c4;
  color: var(--accent-3);
}

.ltabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
}

.ltab {
  flex: none;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: 800 13px var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}

.ltab.ok {
  background: #2a9d8f;
  border-color: #2a9d8f;
  color: #fff6e5;
}

.ltab.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bar-ink);
}

.lone {
  align-self: center;
  padding: 12px 12px 12px 0;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--ink), 0 5px 0 3px var(--ink);
}

.lone .lrow {
  gap: 0;
}

.lans {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-weight: 800;
}

.lans th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a5a3a;
  padding: 0 6px 4px;
}

.lans td {
  padding: 5px 6px;
  border-top: 1px solid #e8cfa8;
}

.lans td.q {
  color: #b99b80;
}

@media (prefers-reduced-motion: reduce) {
  .gt,
  .gm,
  .jp {
    transition-duration: 0.01s !important;
  }
  .arrow,
  .gm.sp-disco svg,
  .jslot,
  .lc.tip {
    animation: none;
  }
}

/* ---- lobby art ---------------------------------------------------------------- */

.game-art .mp {
  position: absolute;
  left: 0;
  top: 0;
  transition: transform 0.35s var(--ease);
}

.mp-grid {
  width: 96px;
  height: 96px;
  display: grid;
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
  background: var(--ink);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.22);
}

.mp-sudoku {
  grid-template-columns: repeat(3, 1fr);
}

.mp-logic {
  grid-template-columns: repeat(4, 1fr);
}

.mp-grid i {
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: #fff6e5;
  color: var(--ink);
  font: 900 20px/1 var(--font-body);
  font-style: normal;
}

.mp-logic i {
  font-size: 14px;
}

.mp-logic i.y { color: #2a9d8f; }
.mp-logic i.x { color: #c0392b; opacity: 0.7; }

.game-art .mp-2048 {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  font-size: 19px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18), 0 4px 0 rgba(0, 0, 0, 0.2);
}

.game-art .mp-2048[data-v='256'] {
  font-size: 15px;
}

.game-art .mp-2048[data-v='2048'] {
  font-size: 12px;
  box-shadow: 0 0 0 3px #f1c40f, 0 0 14px rgba(241, 196, 15, 0.7);
}

.mp-gem {
  width: 52px;
  height: 52px;
}

.mp-jig {
  width: 66px;
  height: 66px;
}

.mp-gem svg,
.mp-jig svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.22));
}

.puzzles .tool[hidden] {
  display: none;
}

/* ---- Word Search ------------------------------------------------------------------ */

.ws {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  box-sizing: border-box;
}

.ws.wide {
  flex-direction: row;
  gap: 40px;
}

.wsboard {
  padding: 12px;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 0 0 5px var(--ink), 0 9px 0 5px var(--ink), 0 22px 36px rgba(74, 44, 26, 0.3);
  flex: none;
}

.wsboard.deal {
  animation: box-in 0.5s var(--ease) both;
}

.wsgrid {
  position: relative;
  width: calc(var(--cs) * var(--n));
  height: calc(var(--cs) * var(--n));
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.wscells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cs));
  grid-template-rows: repeat(var(--n), var(--cs));
  z-index: 2;
  pointer-events: none;
}

.wc {
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 calc(var(--cs) * 0.56) / 1 var(--font-body);
  color: var(--ink);
  border-radius: 50%;
}

.wc.hint {
  animation: ws-hint 0.9s ease-in-out infinite;
}

.wc.start {
  background: var(--accent-3);
  color: #fff1d6;
}

.wspills,
.wslive {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.wp,
.wslive {
  position: absolute;
  opacity: 0.82;
}

.wp.fresh {
  animation: ws-pop 0.4s var(--ease);
}

.wp.bonus {
  background: repeating-linear-gradient(90deg, #f1c40f 0 10px, #e76f9a 10px 20px, #2a9d8f 20px 30px) !important;
  opacity: 0.75;
}

.wslive {
  inset: auto;
  opacity: 1;
  background: rgba(192, 57, 43, 0.22);
  box-shadow: inset 0 0 0 3px var(--accent-3);
}

.wslive.miss {
  animation: ws-shake 0.26s ease-in-out;
}

.wslive[hidden],
.wsbubble[hidden] {
  display: none;
}

.wsbubble {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -100%);
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--accent-2);
  font: 400 20px var(--font-display);
  letter-spacing: 0.08em;
  white-space: nowrap;
  box-shadow: 0 0 0 3px var(--accent-2);
  pointer-events: none;
}

/* On a phone the list may be wider than a small board, so it gets three columns. */
.wspanel {
  width: min(100%, max(calc(var(--cs) * var(--n) + 24px), 340px));
  box-sizing: border-box;
  color: var(--ink);
}

.ws.wide .wspanel {
  width: var(--panel-w);
  padding: 22px 24px;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 0 0 5px var(--ink), 0 9px 0 5px var(--ink);
}

.wshead {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wshead h2 {
  margin: 0;
  font: 400 30px/1.05 var(--font-display);
  color: var(--accent-3);
}

.ws:not(.wide) .wshead h2 {
  font-size: 22px;
}

.wspick {
  margin-left: auto;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bar-ink);
  font: 800 13px var(--font-body);
  cursor: pointer;
  flex: none;
}

.wsmeta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.wsmeta span {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bar-ink);
  font: 800 12px var(--font-body);
}

.ws:not(.wide) .wsmeta {
  display: none;
}

.wswords {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ws:not(.wide) .wswords {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 2px 10px;
  margin-top: 6px;
}

/* Set by fitWords() for a word too long for its column. */
.wswords {
  grid-auto-flow: dense;
}

.ww.span2 {
  grid-column: span 2;
}

.ww span {
  white-space: nowrap;
}

@media (min-width: 600px) {
  .ws:not(.wide) .wspanel .wswords {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .ws:not(.wide) .wswords .ww {
    font-size: 16px;
    min-height: 28px;
  }

  .ws:not(.wide) .wspanel .wshead h2 {
    font-size: 28px;
  }
}

@media (max-width: 370px) {
  .ws:not(.wide) .wsbonus small {
    display: none;
  }
}

.ww {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  font: 800 16px/1.15 var(--font-body);
  letter-spacing: 0.04em;
}

.ws:not(.wide) .ww {
  font-size: 13px;
  min-height: 22px;
  gap: 6px;
}

.ww i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ink);
  flex: none;
}

.ww.found {
  color: #a07a58;
  text-decoration: line-through;
  text-decoration-thickness: 3px;
}

.wsbonus {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--bar-ink);
}

.wsbonus > div {
  display: flex;
  flex-direction: column;
}

.wsbonus b {
  font: 400 17px var(--font-display);
  color: var(--accent-2);
  white-space: nowrap;
}

.wsbonus small {
  font: 700 12px var(--font-body);
}

.wsbonus .slots {
  display: flex;
  gap: 3px;
  margin-left: auto;
}

.wsbonus .slots i {
  width: 18px;
  height: 24px;
  border-radius: 5px;
  background: #6b3f23;
  color: var(--accent-2);
  font: 900 13px/24px var(--font-body);
  font-style: normal;
  text-align: center;
}

.wsbonus .bword {
  margin-left: auto;
  font-size: 20px;
  letter-spacing: 0.06em;
}

.wsbonus.got {
  box-shadow: 0 0 0 3px var(--accent-2);
}

.ws:not(.wide) .wsbonus {
  margin-top: 10px;
  padding: 6px 12px;
}

.wsprog {
  height: 14px;
  margin-top: 14px;
  border-radius: 7px;
  background: #e9cfa3;
  overflow: hidden;
}

.wsprog i {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(90deg, #c0392b 0 18px, #e67e22 18px 36px, #f1c40f 36px 54px);
  transition: width 0.4s var(--ease);
}

.ws:not(.wide) .wsprog {
  display: none;
}

/* Set by render() when the side panel is taller than the screen (tablets, hard puzzles). */
.ws.wide.tight .wspanel {
  padding: 14px 20px;
}

.ws.tight .wsmeta {
  margin: 6px 0 8px;
}

.ws.tight .ww {
  min-height: 22px;
  font-size: 14px;
}

.ws.tight .wsbonus {
  margin-top: 10px;
  padding: 8px 12px;
}

.ws.tight .wsbonus small,
.ws.tight .wsprog {
  display: none;
}

/* The category picker. */
.wspicker {
  width: min(94vw, 900px);
  max-height: calc(100dvh - 30px);
}

.wspicker .modal-body {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 30px);
  box-sizing: border-box;
}

.wspicker .lede {
  margin-bottom: 12px;
}

.pscroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 4px;
}

.pscroll h3 {
  margin: 12px 0 6px;
}

.pcats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

.pcat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 9px 12px;
  border: 0;
  border-radius: 14px;
  background: #fbe0b4;
  color: var(--ink);
  font: 900 15px var(--font-body);
  text-align: left;
  cursor: pointer;
}

.pcat small {
  font: 700 12px var(--font-body);
  opacity: 0.8;
}

.pcat.on {
  background: var(--ink);
  color: var(--bar-ink);
  box-shadow: 0 0 0 3px var(--accent-2);
}

.pcat.surprise {
  width: 100%;
  background: repeating-linear-gradient(135deg, #c0392b 0 14px, #e67e22 14px 28px, #f1c40f 28px 42px);
  color: #2b1407;
}

.pcat.surprise.on {
  box-shadow: 0 0 0 3px var(--ink);
}

.psizes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.psize {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  border: 0;
  border-radius: 14px;
  background: #fbe0b4;
  color: var(--ink);
  cursor: pointer;
}

.psize b {
  font: 400 20px var(--font-display);
}

.psize small {
  font: 800 12px var(--font-body);
}

.psize.on {
  background: var(--accent-2);
  box-shadow: 0 0 0 3px var(--ink);
}

.wspicker .actions {
  margin-top: 14px;
}

@keyframes ws-hint {
  50% {
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-3), 0 0 16px 4px rgba(192, 57, 43, 0.6);
  }
}

@keyframes ws-pop {
  from {
    opacity: 0;
    filter: brightness(1.6);
  }
}

@keyframes ws-shake {
  25% {
    translate: -4px 0;
  }
  75% {
    translate: 4px 0;
  }
}

.game-art .mp-letter {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: #fff1d6;
  box-shadow: 0 0 0 3px var(--ink), 0 4px 0 3px var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 900 22px var(--font-body);
  color: var(--ink);
}

.game-art .mp-swoosh {
  width: 168px;
  height: 36px;
  border-radius: 18px;
  background: var(--accent-2);
  opacity: 0.8;
}

/* Six puzzle tabs: drop the brand name before the header runs out of room. */
@media (max-width: 1600px) {
  .puzzles .bar .brand-name {
    display: none;
  }
}

/* Word Search: messages go below the board so they never cover letters. */
body[data-game='wordsearch'] .toast {
  top: auto;
  bottom: 12px;
}

/* Once the tabs have their own row there's room for the name again. */
@media (min-width: 481px) and (max-width: 1240px) {
  .puzzles .bar .brand-name {
    display: inline;
  }
}
