:root {
  --board-bg: #f6f6f6;
}
@media (prefers-color-scheme: dark) {
  :root { --board-bg: #1c1c1c; }
}
html[data-theme="dark"] { --board-bg: #1c1c1c; }
html[data-theme="light"] { --board-bg: #f6f6f6; }

/* Opened from the Home Screen (no address bar) the page runs edge to edge
   (viewport-fit=cover): keep its own bars and buttons clear of the notch, the
   Dynamic Island and the home indicator, while the board runs under them. */
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px); }
/* The banners along the bottom are centred on the screen rather than on the
   board area, which a side camera pushes off-centre (a folded iPhone Duo): the
   camera is up top, clear of them. Used inside .stage, where 100% is its width. */
:root { --screen-mid: calc(50% + (var(--safe-right) - var(--safe-left)) / 2); --screen-width: calc(100% + var(--safe-left) + var(--safe-right)); }
/* Pinned to the viewport's edges rather than height: 100dvh, which iOS gets
   wrong from the Home Screen (the page stopped short of the bottom); the board's
   colour behind it hides any sliver iOS still leaves. */
.play-body { display: flex; flex-direction: column; position: fixed; inset: 0; overflow: hidden; padding: var(--safe-top) var(--safe-right) 0 var(--safe-left); }
/* The top of the screen from the Home Screen. Since iOS 26 the system lays a
   blurred "glass" edge over the status bar, whatever the page asks for, and
   uses a page colour there only when a fixed or sticky box with a solid
   background covers the top edge: the top bar is that box (sticky, the
   theme's own background). Where iOS still runs the page under the status bar
   (black-translucent, index.html), a fixed strip fills that space with the same
   colour; the clock is white there, so on light themes the strip is shaded. */
.play-nav { position: sticky; top: 0; background: var(--bg); }
@media (display-mode: standalone) {
  .play-body::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; height: var(--safe-top); z-index: 100; pointer-events: none;
    background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.38)), var(--bg);
  }
  html[data-theme="dark"] .play-body::before, html[data-theme="matrix"] .play-body::before { background: var(--bg); }
}
@media (display-mode: standalone) and (prefers-color-scheme: dark) {
  html:not([data-theme]) .play-body::before { background: var(--bg); } /* Auto on a phone in dark mode */
}
html:has(.play-body) { background: var(--board-bg); overflow: hidden; } /* (nothing scrolls: see game.js unscroll) */

.play-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.play-title { margin: 0; color: var(--subtext); font-size: 0.9rem; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  touch-action: none;
}

/* The board runs under a side camera (a folded iPhone Duo on its side, or a
   notch in landscape) while the bars and buttons keep clear of it: the page is
   padded by the side insets and the canvas alone reaches back out over them. */
#board { display: block; position: absolute; top: 0; left: calc(-1 * var(--safe-left)); width: calc(100% + var(--safe-left) + var(--safe-right)); height: 100%; cursor: crosshair; }
.play-nav { margin-inline: calc(-1 * var(--safe-left)) calc(-1 * var(--safe-right)); padding-inline: calc(20px + var(--safe-left)) calc(20px + var(--safe-right)); }

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: none;
}
.tally {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.tally b { font-variant-numeric: tabular-nums; }
.tally .pts { font-style: normal; font-size: 0.75em; color: var(--subtext); font-variant-numeric: tabular-nums; white-space: nowrap; }
.points-pop {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--active, #2f80ed);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  white-space: pre-line;
  text-align: center;
  width: max-content;
  max-width: calc(100% - 32px);
  opacity: 0;
  z-index: 20;
}
.points-pop.note { font-size: 1.05rem; color: var(--text, #1a1a1a); background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; text-shadow: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); }
.points-pop.go { animation: points-pop 1.1s ease-out; }
@keyframes points-pop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -40px) scale(1); }
}
/* Messages ("Already found by ...") stay up long enough to read: in, hold, out. */
.points-pop.note.go { animation: note-pop 3.2s ease-out; }
@keyframes note-pop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.9); }
  6% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  10% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  85% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(1); }
}
/* Reclaiming a lost first word: gold, and held long enough to read like a message. */
.points-pop.gold { color: #e0a800; text-shadow: 0 0 12px rgba(255, 196, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.25); }
.points-pop.gold.go { animation: note-pop 3.2s ease-out; }
/* A points pop with more to read ("GLOBAL FIRST!", "First for you · …") holds like a message. */
.points-pop.hold.go { animation: note-pop 3.2s ease-out; }
@keyframes note-fade { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
/* A find with more to say (game.js showPoints): a solid card, so it reads over the board. */
.points-pop.card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text, #1a1a1a); background: var(--surface, #fff); border: 2px solid var(--text, #1a1a1a);
  border-radius: 18px; padding: 10px 18px 12px; text-shadow: none; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
  white-space: normal; max-width: min(calc(100% - 32px), 360px);
}
.points-pop.card.gold { border-color: #e0a800; text-shadow: none; }
.pop-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.pop-badge { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; background: #1f5fd1; color: #fff; }
.pop-badge.special { background: #8e44ad; }
.pop-badge.gold { background: #ffc857; color: #000; }
.pop-main { display: flex; align-items: baseline; gap: 10px; }
.pop-word { font-size: 1.7rem; letter-spacing: 0.08em; }
.pop-points { font-size: 1.35rem; color: #1a8a3a; }
.points-pop.card.gold .pop-points { color: #9a6b00; }
.pop-detail { font-size: 0.85rem; font-weight: 600; color: var(--subtext); line-height: 1.3; }
html[data-theme="matrix"] .points-pop.card { background: #000; border-color: #3dff72; box-shadow: 0 0 18px rgba(61, 255, 114, 0.35); }
html[data-theme="matrix"] .pop-badge { background: #3dff72; color: #000; }
html[data-theme="matrix"] .pop-points { color: #3dff72; }
@media (prefers-reduced-motion: reduce) {
  .points-pop.go { animation-duration: 0.01s; }
  .points-pop.note.go, .points-pop.gold.go, .points-pop.hold.go { animation: note-fade 3.2s linear; } /* no movement, but still readable */
}
.tally-you { color: var(--subtext); margin-left: 2px; }

.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.swatch-pjom { background: #ffc857; border: 1px solid #00000030; }
.swatch-chat { background: #8e7cff; }
.swatch-players { background: #66bb6a; }
.swatch-friends { background: #4fc3f7; } /* as their markers (game.js FRIEND_COLOR) */
.swatch-crew { background: #ff8a65; }

.status {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--subtext);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}
.status:empty { display: none; }

.bubble {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translate(-50%, -8px);
  background: #fff;
  color: #000;
  border: 2px solid #000;
  border-radius: 16px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: min(80vw, 360px);
  text-align: center;
  z-index: 30; /* over the pill rows, which wrap down onto it on a phone */
}
.bubble.visible { opacity: 1; transform: translate(-50%, 0); }
/* While a revelio is on, Pjom keeps its word on screen just above the hint bar. */
.revelio-hint {
  position: absolute; bottom: calc(58px + var(--safe-bottom)); left: var(--screen-mid); transform: translateX(-50%); z-index: 25;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 6px; row-gap: 0;
  width: max-content; max-width: min(90vw, 380px);
  padding: 6px 16px 6px 46px; border-radius: 16px; border: 2px solid #b8860b;
  background: #fff8e1; color: #000; font-weight: 600; font-size: 0.92rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); cursor: pointer; /* tap for the word's meaning */
}
.revelio-hint[hidden] { display: none; }
.revelio-hint::before {
  content: ""; position: absolute; left: 6px; bottom: 4px; width: 32px; height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-30 -44 60 76'%3E%3Cg stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cellipse cx='0' cy='4' rx='26' ry='22.4' fill='%23ffc857'/%3E%3Cpath d='M0 -20.4V-35.1'/%3E%3Ccircle cx='0' cy='-36.4' r='5' fill='%23ff6b6b'/%3E%3Ccircle cx='-11' cy='-2' r='10' fill='%23fff'/%3E%3Ccircle cx='11' cy='-2' r='10' fill='%23fff'/%3E%3Ccircle cx='-11' cy='-2' r='3.4' fill='%23000' stroke='none'/%3E%3Ccircle cx='11' cy='-2' r='3.4' fill='%23000' stroke='none'/%3E%3Cpath d='M-6 16H6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}
.revelio-hint b { letter-spacing: 0.08em; font-size: 1.05rem; }
.revelio-hint small { color: #6b5a00; font-weight: 500; font-variant-numeric: tabular-nums; }
html[data-theme="matrix"] .revelio-hint { background: #000; color: #3dff72; border-color: #3dff72; }
html[data-theme="matrix"] .revelio-hint small { color: #1fae4a; }
/* A little Pjom perched on the top-left corner, so it reads as his speech bubble. */
.bubble::before {
  content: "";
  position: absolute;
  top: -32px;
  left: -26px;
  width: 38px;
  height: 48px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-30 -44 60 76'%3E%3Cg stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cellipse cx='0' cy='4' rx='26' ry='22.4' fill='%23ffc857'/%3E%3Cpath d='M0 -20.4V-35.1'/%3E%3Ccircle cx='0' cy='-36.4' r='5' fill='%23ff6b6b'/%3E%3Ccircle cx='-11' cy='-2' r='10' fill='%23fff'/%3E%3Ccircle cx='11' cy='-2' r='10' fill='%23fff'/%3E%3Ccircle cx='-11' cy='-2' r='3.4' fill='%23000' stroke='none'/%3E%3Ccircle cx='11' cy='-2' r='3.4' fill='%23000' stroke='none'/%3E%3Cpath d='M-6 16H6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

/* Chat with Pjom (pjomChat.js): a panel over the board, so he stays in view. */
.chat-panel {
  position: absolute; right: 16px; bottom: calc(16px + var(--safe-bottom)); z-index: 30; width: min(360px, calc(100% - 32px)); max-height: min(70vh, 560px);
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 18px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface, #fff); color: var(--text, #111); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-head h2 { margin: 0; font-size: 1rem; }
.chat-feed { list-style: none; margin: 0; padding: 0 2px; overflow-y: auto; flex: 1 1 auto; min-height: 90px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.chat-msg { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; border-radius: 12px; background: color-mix(in srgb, var(--border) 45%, transparent); max-width: 88%; align-self: flex-start; overflow-wrap: anywhere; }
.chat-msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--active, #2f80ed) 22%, var(--surface, #fff)); }
.chat-msg.sending { opacity: 0.6; }
.chat-msg.pjom { background: #fff3c4; color: #000; border: 1px solid #e0a800; }
.chat-who { font-size: 0.72rem; font-weight: 700; color: var(--subtext); }
.chat-msg.pjom .chat-who { color: #7a5b00; }
.chat-who time { font-weight: 500; }
.chat-text { font-size: 0.9rem; line-height: 1.3; }
.chat-empty { color: var(--subtext); font-size: 0.85rem; text-align: center; padding: 16px 0; }
.chat-form { display: flex; gap: 6px; }
.chat-form[hidden] { display: none; }
.chat-form .text-input { flex: 1 1 auto; min-width: 0; margin: 0 !important; }
.chat-form .btn { margin: 0; padding-inline: 14px; width: auto; }
.chat-login { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-login[hidden] { display: none; }
.chat-login .hint-text { margin: 0; }
.chat-login .btn { width: auto; margin: 0; white-space: nowrap; }
.chat-note { margin: 0; font-size: 0.78rem; min-height: 1em; }
.chat-warn { color: #c75a00 !important; font-weight: 600; }
html[data-theme="matrix"] .chat-warn { color: #ffb74d !important; }
.chat-help { font-size: 0.8rem; color: var(--subtext); }
.chat-help summary { cursor: pointer; }
.chat-help ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; }
@media (max-width: 600px) {
  .chat-panel { left: 8px; right: 8px; bottom: calc(8px + var(--safe-bottom)); width: auto; max-height: 58vh; }
}
html[data-theme="matrix"] .chat-panel { background: #000; border-color: #3dff72; box-shadow: 0 0 18px rgba(61, 255, 114, 0.3); }
html[data-theme="matrix"] .chat-msg.pjom { background: #031a0a; color: #3dff72; border-color: #3dff72; }

/* Mini games chooser (🎮 Games). */
.games-btn.fresh::after { content: ""; width: 7px; height: 7px; margin-left: 2px; border-radius: 50%; background: #e53935; display: inline-block; }
.game-card { display: grid; gap: 4px; width: 100%; text-align: left; margin: 10px 0 0; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.game-card b { font-size: 1.05rem; }
.game-card span { font-size: 0.85rem; color: var(--subtext); }
@media (hover: hover) { .game-card:hover { border-color: var(--subtext); } }
#games-dialog .btn { margin-top: 14px; }

/* Stardoom (stardoom.js): full screen on a phone, a big square otherwise. */
.stardoom { padding: 0; border: 0; border-radius: 18px; overflow: hidden; background: #05060f; color: #fff; width: min(96vw, 760px); height: min(90dvh, 760px); max-width: none; max-height: none; }
.stardoom::backdrop { background: rgba(0, 0, 0, 0.7); }
@media (max-width: 600px) { .stardoom { width: 100vw; height: 100dvh; border-radius: 0; } }
#sd-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.sd-hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: calc(12px + var(--safe-top)) 14px 12px; pointer-events: none; }
.sd-score { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sd-lives { font-size: 1.2rem; color: #ffd54f; letter-spacing: 2px; }
.sd-x { margin-left: auto; pointer-events: auto; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.08); color: #fff; font-size: 1rem; cursor: pointer; }
.sd-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; background: rgba(5, 6, 15, 0.72); text-align: center; }
.sd-overlay[hidden] { display: none; }
.sd-overlay .btn { width: min(80vw, 280px); margin: 0; }
.sd-overlay .btn-primary { background: #ffd54f; border-color: #ffd54f; color: #000; }
.sd-overlay .btn:not(.btn-primary) { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.sd-title { margin: 0; font-size: 1.8rem; color: #fff; }
.sd-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.98rem; color: #dfe3ff; }
.sd-why { margin: 0; color: #ffb4a8; font-weight: 600; }
.sd-final { margin: 0; font-size: 2.6rem; font-weight: 800; color: #ffd54f; }
.sd-best { margin: 0; color: #dfe3ff; min-height: 1.2em; }
.sd-best .btn { width: auto; }

/* Wordit, the daily word game (wordit.js). */
.wordit-btn.fresh::after { content: ""; width: 7px; height: 7px; margin-left: 2px; border-radius: 50%; background: #e53935; display: inline-block; }
.wordit h2 small.wd-day { font-size: 0.7rem; font-weight: 600; color: var(--subtext); letter-spacing: 0; margin-left: 6px; }
.wd-legend { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; font-size: 0.9rem; }
.wd-legend li { display: flex; align-items: center; gap: 10px; }
.wd-legend .wd-tile { width: 30px; height: 30px; font-size: 1rem; }
.wd-timer { margin: 4px 0 0; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 1.2em; color: var(--text); }
.wd-grid { display: grid; gap: 6px; justify-content: center; margin: 8px 0 4px; }
.wd-grid[hidden] { display: none; }
.wd-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wd-tile {
  display: grid; place-items: center; width: min(13vw, 52px); height: min(13vw, 52px); border-radius: 10px;
  border: 2px solid var(--border); font-weight: 800; font-size: 1.5rem; color: var(--text); background: var(--surface);
  text-transform: uppercase;
}
.wd-tile.typed { border-color: var(--subtext); }
.wd-tile.hit, .wd-key.hit { background: #2e9d4a; border-color: #2e9d4a; color: #fff; }
.wd-tile.near, .wd-key.near { background: #e0a800; border-color: #e0a800; color: #000; }
.wd-tile.miss, .wd-key.miss { background: #7a7a7a; border-color: #7a7a7a; color: #fff; }
.wd-msg { margin: 4px 0; min-height: 1.3em; text-align: center; font-size: 0.9rem; font-weight: 600; color: var(--text) !important; }
.wd-msg.bad { color: #c62828 !important; }
.wd-keys { display: grid; gap: 6px; margin-top: 6px; }
.wd-keys[hidden] { display: none; }
.wd-keyrow { display: flex; justify-content: center; gap: 4px; }
.wd-key { flex: 1 1 0; max-width: 40px; min-width: 0; height: 46px; border: 0; border-radius: 8px; font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; background: color-mix(in srgb, var(--border) 70%, var(--surface)); color: var(--text); padding: 0; }
.wd-key.wide { flex: 1.6 1 0; max-width: 64px; font-size: 0.8rem; }
.wd-done { text-align: center; }
.wd-done[hidden] { display: none; }
.wd-result { font-weight: 700; color: var(--text) !important; margin: 6px 0 2px; }
.wd-answer { font: inherit; font-size: 1.6rem; font-weight: 800; letter-spacing: 0.12em; background: none; border: 0; color: var(--text); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 5px; }
.lb-mini[hidden] { display: none; }
.lb-mini .lb-mini-day { font-weight: 500; color: var(--subtext); }
.lb-mini .btn { margin: 8px 0 12px; }
html[data-theme="matrix"] .wd-tile.hit, html[data-theme="matrix"] .wd-key.hit { background: #3dff72; border-color: #3dff72; color: #000; }

/* A word's meaning (define.js), opened by tapping a pop-up about a word. */
.define h2 { letter-spacing: 0.08em; }
.def-block { margin: 10px 0 0; }
.define .def-pos { margin: 0 0 2px; font-style: italic; color: var(--subtext); font-size: 0.85rem; }
.def-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; color: var(--text); font-size: 0.95rem; line-height: 1.35; }
.define .define-credit { margin: 14px 0 8px; font-size: 0.75rem; }
.def-base { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.define .def-base-word { margin: 0; font-weight: 800; letter-spacing: 0.08em; color: var(--text); }
.def-base-word a { color: inherit; text-decoration: none; }
.define-credit a { color: inherit; }
/* Pop-ups about a word can be tapped for its meaning while they're showing. */
.points-pop.has-word { pointer-events: auto; cursor: pointer; }
.revelio-hint .def-i, .pop-detail.def-i { opacity: 0.7; }

/* Picking a word to suggest (game.js suggest mode). */
.suggest-banner {
  position: absolute; left: var(--screen-mid); bottom: calc(58px + var(--safe-bottom)); transform: translateX(-50%); z-index: 26;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(var(--screen-width) - 24px);
  padding: 8px 10px 8px 16px; border-radius: 999px; border: 2px dashed #8e44ad; background: #f6ecff; color: #000;
  font-weight: 600; font-size: 0.92rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.suggest-banner[hidden] { display: none; }
.suggest-banner button { font: inherit; font-size: 0.85rem; border: 0; border-radius: 999px; padding: 4px 12px; background: #8e44ad; color: #fff; cursor: pointer; }
html[data-hint="done"] .suggest-banner { bottom: calc(14px + var(--safe-bottom)); }
html[data-theme="matrix"] .suggest-banner { background: #000; color: #3dff72; border-color: #3dff72; }
.sg-go { font: inherit; font-weight: 700; background: none; border: 0; padding: 0; color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }

/* Pjom's quiz, shown while you're near him (pjomChat.js). Tap it to answer. */
.pjom-quiz {
  position: absolute; left: var(--screen-mid); bottom: calc(106px + var(--safe-bottom)); transform: translateX(-50%); z-index: 24;
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: max-content; max-width: min(90vw, 420px);
  padding: 8px 16px; border-radius: 16px; border: 2px solid #8e44ad; background: #f6ecff; color: #000;
  font: inherit; text-align: center; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.pjom-quiz[hidden] { display: none; }
.pjom-quiz.done { border-color: #1a8a3a; background: #e8f7ec; }
.pjom-quiz .pq-title { font-size: 0.78rem; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
.pjom-quiz .pq-q { font-size: 0.98rem; font-weight: 700; }
.pjom-quiz .pq-detail { font-size: 0.74rem; color: #4a3a5a; }
.pjom-quiz.in-panel { position: static; transform: none; width: auto; max-width: none; cursor: default; box-shadow: none; }
.pjom-quiz.in-panel.done { cursor: pointer; }
html[data-hint="done"] .pjom-quiz:not(.in-panel) { bottom: calc(62px + var(--safe-bottom)); }
html[data-theme="matrix"] .pjom-quiz { background: #000; color: #3dff72; border-color: #3dff72; }
html[data-theme="matrix"] .pjom-quiz .pq-detail { color: #1fae4a; }

/* Pjom's stats while he's on screen (game.js renderPjomCard). */
.pjom-card {
  position: absolute; left: 10px; z-index: 18; pointer-events: none; width: 168px;
  display: grid; gap: 3px; padding: 8px 10px; border-radius: 14px;
  background: color-mix(in srgb, var(--surface, #fff) 92%, transparent); color: var(--text, #111);
  border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14); font-size: 0.78rem;
}
.pjom-card[hidden] { display: none; }
.pc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.pc-head b { font-size: 0.95rem; }
.pc-level { font-weight: 700; color: var(--subtext); }
.pc-health { display: flex; align-items: center; gap: 6px; }
.pc-health > span:first-child { color: #e53935; }
.pc-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.pc-bar i { display: block; height: 100%; border-radius: 3px; }
.pc-num { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 2.6em; text-align: right; }
.pc-line { color: var(--subtext); }
.pc-stats { display: grid; gap: 3px; }
/* The chat with Pjom lives on his card (pjomChat.js opens it). */
.pc-chat {
  pointer-events: auto; margin-top: 4px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 0.8rem; font-weight: 600; color: inherit; cursor: pointer;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface, #fff);
}
.pc-chat:hover { border-color: var(--text, #111); }
html[data-theme="matrix"] .pc-chat { background: #000; border-color: #1fae4a; color: #3dff72; }
html[data-hud="hidden"] .pjom-card { display: none; }
html[data-theme="matrix"] .pjom-card { background: #000; border-color: #1fae4a; color: #3dff72; }

/* The letters being spelled, at the top while you drag (game.js renderSpelling). */
.spelling {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 40; pointer-events: none;
  padding: 6px 18px; border-radius: 999px; border: 2px solid var(--border); background: var(--surface, #fff); color: var(--text, #111);
  font-weight: 800; font-size: 1.5rem; letter-spacing: 0.14em; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.spelling[hidden] { display: none; }
.spelling.found { border-color: #9e9e9e; color: #8a8a8a; }
.spelling small { font-size: 0.7rem; letter-spacing: 0.02em; font-weight: 700; margin-left: 8px; vertical-align: middle; }
html[data-theme="matrix"] .spelling { background: #000; border-color: #1fae4a; color: #3dff72; }

/* Gone once the player has marked a word and panned (game.js learnt). */
html[data-hint="done"] .hint { opacity: 0; visibility: hidden; transition: opacity 0.6s, visibility 0s 0.6s; }
html[data-hint="done"] .revelio-hint { bottom: calc(14px + var(--safe-bottom)); }
.hint {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  left: var(--screen-mid);
  transform: translateX(-50%);
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--subtext);
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(var(--screen-width) - 28px);
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .play-title { display: none; }
  .play-nav { gap: 10px; padding: 10px calc(14px + var(--safe-right)) 10px calc(14px + var(--safe-left)); }
  .auth .btn-small { padding: 8px 12px; font-size: 0.8rem; white-space: nowrap; }
  .auth { gap: 8px; }
  .hud { top: 10px; left: 10px; right: 10px; }
  .tally { padding: 5px 10px; font-size: 0.78rem; }
  .status { top: 52px; right: 10px; padding: 5px 10px; font-size: 0.78rem; }
  .hint { font-size: 0.72rem; padding: 6px 12px; }
}
/* The smallest phones: the logo alone keeps the title-bar buttons on one line. */
@media (max-width: 380px) {
  .play-nav .brand span { display: none; }
}

/* Layer toggles: the tally pills for chat, other players and cursors double
   as buttons. The HUD itself ignores the pointer so the board underneath
   stays draggable; only the buttons opt back in. */
.toggle {
  font: inherit;
  color: inherit;
  cursor: pointer;
  pointer-events: auto;
}
@media (hover: hover) { .toggle:hover { border-color: var(--subtext); } }
.toggle[aria-pressed="false"] { opacity: 0.55; }
.toggle[aria-pressed="false"] .swatch { background: transparent; border: 1.5px solid currentColor; }
.swatch-cursor { background: #fff; border: 1.5px solid #00000055; }
.toggle:focus-visible { outline: 3px solid var(--active); outline-offset: 2px; }

/* Sign-in */
.auth { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--subtext); }
.auth .join-in { white-space: nowrap; }
.auth { min-width: 0; }
.auth-name { max-width: 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth .linklike { flex: none; white-space: nowrap; }
.auth .linklike { background: none; border: none; padding: 0; font: inherit; color: var(--text); text-decoration: underline; cursor: pointer; }

.signin {
  width: min(92vw, 380px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.signin::backdrop { background: rgba(0, 0, 0, 0.5); }
/* Dialogs only ever scroll up and down: on a phone a pixel or two of extra width
   (Safari measures text a little wider) must never turn into a sideways scroll.
   Rows that are meant to slide sideways (the theme chips) scroll inside themselves. */
.signin { overflow-x: hidden; overscroll-behavior-x: none; }
.signin h2 { font-size: 1.5rem; margin-bottom: 10px; }
.signin p { color: var(--subtext); margin-bottom: 18px; }
.signin .btn { width: 100%; margin-top: 10px; }
.auth-error { color: #ef5350 !important; font-weight: 600; }
.signin-reason { color: var(--text) !important; font-weight: 600; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.account-danger { margin-top: 24px; padding-top: 4px; border-top: 1px solid var(--border); }
.btn-danger { background: #d32f2f; color: #fff; border-color: #d32f2f; }
.btn-danger:hover { background: #b71c1c; border-color: #b71c1c; }
.btn-danger:disabled { opacity: 0.6; cursor: default; }

/* Author display rules (like .btn's inline-flex) beat the browser's own
   [hidden] style, so restore it. */
[hidden] { display: none !important; }

/* The player's own button: their name and count, plus a small edit button. */
.tally-group { display: flex; gap: 4px; pointer-events: none; }
.swatch-mine { background: var(--mine, #2f80ed); border: 2px solid color-mix(in srgb, var(--mine, #2f80ed) 55%, #000); box-sizing: border-box; }
.me-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally.edit { padding: 6px 10px; cursor: pointer; pointer-events: auto; font: inherit; color: inherit; }
@media (hover: hover) { .tally.edit:hover { border-color: var(--subtext); } }

.text-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.id-line { font-size: 0.8rem; margin: 12px 0 0 !important; }
.id-line code { word-break: break-all; color: var(--text); }

/* "N on the board" — a live presence count, not a button. */
.online .dot { width: 8px; height: 8px; border-radius: 50%; background: #43a047; box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.6); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(67, 160, 71, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0); }
}
@media (prefers-reduced-motion: reduce) { .online .dot { animation: none; } }

/* Marker colour choices in the name dialog. */
.field-label { margin: 16px 0 8px !important; color: var(--text) !important; font-weight: 600; font-size: 0.9rem; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; font-size: 0.9rem; color: var(--text); cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--text); cursor: pointer; }
.hint-text { font-size: 0.8rem; margin: 8px 0 0 !important; }
.color-choices { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.color-choices button, .color-choices label {
  width: 30px; height: 30px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid transparent; box-shadow: 0 0 0 1px var(--border);
}
.color-choices button[aria-pressed="true"], .color-choices label.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.color-choices label { position: relative; overflow: hidden; background: conic-gradient(#ef5350, #ffd54f, #66bb6a, #26c6da, #2f80ed, #ec407a, #ef5350); }
.color-choices label input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }

/* A plain action pill (not a toggle): jump somewhere random. */
.tally.action { font: inherit; color: inherit; cursor: pointer; pointer-events: auto; }
@media (hover: hover) { .tally.action:hover { border-color: var(--subtext); } }
.tally.action:focus-visible { outline: 3px solid var(--active); outline-offset: 2px; }

/* Star round banner: shown while a player has to catch Pjom's shooting stars. */
.star-banner {
  position: absolute;
  left: var(--screen-mid);
  bottom: calc(58px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(var(--screen-width) - 28px);
  background: #fff3b0;
  color: #3b2f00;
  border: 2px solid #ffc857;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}
.star-banner-sub { display: none; font-weight: 500; }
@media (min-width: 760px) { .star-banner { font-size: 0.9rem; padding: 8px 18px; } .star-banner-sub { display: inline; } }
.star-banner b { font-variant-numeric: tabular-nums; }

/* Leaderboard and achievements */
.lb { width: min(94vw, 460px); padding: 20px; max-height: 88dvh; }
.lb > * { min-width: 0; max-width: 100%; }
.lb > :is(.lb-tabs, .lb-cats) { max-width: none; } /* (they reach both edges: see .lb-tabs) */
.lb-head { display: flex; align-items: center; justify-content: space-between; }
.lb-head h2 { margin: 0; }
.lb-x { border: 0; background: none; font-size: 1.1rem; color: var(--subtext); cursor: pointer; padding: 6px 8px; border-radius: 8px; }
@media (hover: hover) { .lb-x:hover { color: var(--text); } }
/* A row of tabs that scrolls sideways when it doesn't fit (the leaderboard's four
   on a phone), edge to edge like the category chips; when there's room they fill it. */
.lb-tabs { display: flex; gap: 6px; margin: 14px -20px 10px; padding: 2px 20px 4px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.lb-tabs > *, .lb-cats > * { scroll-snap-align: center; }
.lb-tabs::-webkit-scrollbar { display: none; }
.lb-tab, .lb-chip {
  font: inherit; font-size: 0.85rem; white-space: nowrap; font-weight: 600; cursor: pointer; color: var(--subtext);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
}
/* The three tabs share the row, each as wide as its label. */
.lb-tab { flex: 1 0 auto; padding: 7px 12px; font-size: 0.8rem; white-space: nowrap; }
.lb-tab[aria-pressed="true"], .lb-chip[aria-pressed="true"] { color: var(--button-text); background: var(--button-bg); border-color: var(--button-bg); }
.lb-cats { display: flex; gap: 6px; margin: 0 -20px 12px; padding: 2px 20px 4px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.lb-cats::-webkit-scrollbar { display: none; }
.lb-chip { flex: none; }
.lb-chip { padding: 4px 10px; font-size: 0.75rem; }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; font-size: 0.92rem; }
.lb-row:nth-child(odd) { background: var(--surface); }
.lb-row.me { outline: 2px solid var(--mine, #2f80ed); outline-offset: -2px; font-weight: 600; }
.lb-row.apart { margin-top: 10px; }
.lb-rank { width: 26px; text-align: center; font-variant-numeric: tabular-nums; color: var(--subtext); }
.lb-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1px solid #00000030; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.lb-value { font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.lb-name small { display: block; color: var(--subtext); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em; }
.lb-ach { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.lb-ach-card { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); opacity: 0.6; }
.lb-ach-card.done { opacity: 1; border-color: #ffc857; background: color-mix(in srgb, #ffc857 16%, var(--surface)); }
.lb-ach-icon { font-size: 1.6rem; width: 34px; text-align: center; filter: grayscale(1); }
.lb-ach-card.done .lb-ach-icon { filter: none; }
.lb-ach-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; color: var(--subtext); }
.lb-ach-body strong { color: var(--text); font-size: 0.92rem; }
.lb-ach-body small { color: var(--subtext); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.lb-bar { height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 4px; }
.lb-bar i { display: block; height: 100%; background: #66bb6a; }
.lb-ach-card.done .lb-bar i { background: #ffc857; }

/* "A new version is here" notice */
.update-banner {
  position: absolute;
  left: var(--screen-mid);
  bottom: calc(106px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(var(--screen-width) - 28px);
  background: var(--button-bg);
  color: var(--button-text);
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.update-btn {
  font: inherit; font-weight: 700; cursor: pointer;
  background: #ffc857; color: #000; border: 0; border-radius: 999px; padding: 6px 14px;
}
.update-x { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; opacity: 0.7; padding: 4px 8px; }
@media (hover: hover) { .update-x:hover { opacity: 1; } }
.version-name { font-weight: 600; }

/* Theme picker (in the name & colour dialog) */
/* A single row of chips: centred when they fit, and a sideways scroll (with a soft
   fade at whichever edge has more) when they don't, so more themes can be added.
   It bleeds to the dialog's edges so chips slide under them rather than hitting them. */
.theme-choices {
  display: flex;
  gap: 8px;
  justify-content: safe center;
  overflow-x: auto;
  margin-inline: -28px;
  padding: 2px 28px 6px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.theme-choices::-webkit-scrollbar { display: none; }
.theme-choices > * { flex: none; white-space: nowrap; scroll-snap-align: center; }
/* The soft fade at whichever edge has more (scrollRow.js sets the classes): the
   theme and zoom chips here, and the leaderboard's tabs and categories. */
:is(.theme-choices, .lb-tabs, .lb-cats).more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
:is(.theme-choices, .lb-tabs, .lb-cats).more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); }
:is(.theme-choices, .lb-tabs, .lb-cats).more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); }
.theme-chip {
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: var(--subtext);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 16px;
}
.theme-chip[aria-pressed="true"] { color: var(--button-text); background: var(--button-bg); border-color: var(--button-bg); }

/* The Matrix theme: the page's colours and type follow <html data-theme="matrix">.
   (The board itself is drawn on the canvas; see THEMES in game.js.) */
html[data-theme="matrix"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #03140a;
  --text: #3dff72;
  --subtext: #1fae4a;
  --border: #0d4d20;
  --button-bg: #3dff72;
  --button-text: #000000;
  --active: #3dff72;
  --board-bg: #000000;
  --serif: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
html[data-theme="matrix"] .tally,
html[data-theme="matrix"] .hint,
html[data-theme="matrix"] .signin,
html[data-theme="matrix"] .lb-row,
html[data-theme="matrix"] .lb-ach-card { box-shadow: 0 0 0 1px #0d4d20, 0 0 14px rgba(61, 255, 114, 0.12); }
html[data-theme="matrix"] .bubble { background: #000; color: #3dff72; border-color: #3dff72; box-shadow: 0 0 16px rgba(61, 255, 114, 0.35); }
html[data-theme="matrix"] .bubble::before { filter: hue-rotate(0deg) saturate(0.9); }
html[data-theme="matrix"] .signin::backdrop { background: rgba(0, 12, 4, 0.75); }
html[data-theme="matrix"] .btn-primary { background: #3dff72; color: #000; }
html[data-theme="matrix"] .lb-ach-card.done { background: color-mix(in srgb, #3dff72 12%, #000); border-color: #3dff72; }
html[data-theme="matrix"] .lb-bar i { background: #1fae4a; }
html[data-theme="matrix"] .lb-ach-card.done .lb-bar i { background: #3dff72; }
html[data-theme="matrix"] .update-banner { background: #000; color: #3dff72; border: 1px solid #3dff72; }

/* Friends, crew and power-ups */
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px; border-radius: 999px; background: #e53935; color: #fff; font-size: 0.7rem; }
.revelio-btn { opacity: 0.75; }
.revelio-btn.charged { opacity: 1; background: linear-gradient(135deg, #ffe066, #e0a800); color: #000; border-color: #b8860b; }
.fr-code { display: flex; align-items: center; gap: 10px; }
.fr-code code { flex: 1; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.25em; padding: 6px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-align: center; }
.fr-code .btn { width: auto !important; margin: 0 !important; }
.fr-add { display: flex; gap: 8px; }
.fr-add .text-input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.15em; }
.fr-add .btn { width: auto !important; margin: 0 !important; }
.fr-section { margin-top: 6px; }
.fr-list { list-style: none; margin: 6px 0 0; padding: 0; }
.fr-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; font-size: 0.9rem; }
.fr-row:nth-child(odd) { background: var(--surface); }
.fr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.fr-name small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--subtext); }
.fr-actions { display: flex; gap: 6px; flex: none; }
.fr-btn { font: inherit; font-size: 0.75rem; font-weight: 600; padding: 5px 10px; border-radius: 999px; cursor: pointer; color: var(--text); background: var(--bg); border: 1px solid var(--border); }
.fr-btn.primary { background: var(--button-bg); color: var(--button-text); border-color: var(--button-bg); }
@media (hover: hover) { .fr-btn:hover { border-color: var(--subtext); } }
.streak-line { color: var(--text) !important; font-weight: 600; margin: 4px 0 0 !important; }
.pu-slots { display: flex; gap: 8px; margin-top: 6px; }
.pu-slot { flex: 1; aspect-ratio: 1; max-width: 52px; display: grid; place-items: center; font-size: 1.3rem; border-radius: 14px; border: 2px dashed var(--border); }
.pu-slot.on { border: 2px solid #b8860b; background: linear-gradient(135deg, #ffe066, #e0a800); }
.pu-bar { margin-top: 10px; height: 8px; }
.pu-bar i { background: linear-gradient(90deg, #ffe066, #e0a800); }
html[data-theme="matrix"] .pu-slot.on, html[data-theme="matrix"] .revelio-btn.charged { background: #3dff72; border-color: #3dff72; color: #000; }


/* Location pins */
.pins-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.pin-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.pin-slot .fr-actions { margin-left: auto; }
.pin-slot.empty { background: none; border-style: dashed; }
.pin-badge { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #ec407a; color: #fff; font-weight: 700; font-size: 0.8rem; }
.pin-slot.empty .pin-badge { background: var(--border); color: var(--subtext); }
.pin-badge b { transform: rotate(45deg); line-height: 1; }
.pin-body { flex: 1 1 150px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pin-body small { font-size: 0.72rem; color: var(--subtext); }
.pin-name { padding: 4px 8px !important; font-size: 0.9rem !important; margin: 0 !important; }
.pin-empty { color: var(--subtext); font-size: 0.9rem; }
.pins-sub { margin: 16px 0 0; font-size: 0.95rem; }
.pin-slot.revelio .pin-badge { background: #ffc857; color: #000; }
.pin-revelio-word { font-size: 0.9rem; }
.pin-revelio-word b { letter-spacing: 0.06em; }
.pins-count { margin-left: 4px; font-size: 0.8em; font-weight: 700; color: #b8860b; }
html[data-theme="matrix"] .pins-count { color: #3dff72; }

/* The Mine / Friends / Global first-finds switch (pip and leaderboard) */
.scope-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); pointer-events: auto; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.scope-switch[hidden] { display: none; }
.scope-label { font-size: 0.72rem; color: var(--subtext); padding: 0 6px 0 8px; white-space: nowrap; }
.scope-switch button { font: inherit; font-size: 0.75rem; font-weight: 600; padding: 4px 10px; border: 0; border-radius: 999px; background: none; color: var(--subtext); cursor: pointer; }
.scope-switch button[aria-pressed="true"] { background: var(--button-bg); color: var(--button-text); }
.scope-switch button:disabled { opacity: 0.4; cursor: default; }
.lb .scope-switch { margin: 0 0 10px; box-shadow: none; }
.lb-scope-empty { text-align: center; }

/* Stats tab */
.fw { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 6px; }
.fw-search { margin: 0 !important; }
.fw-help { font-size: 0.78rem; color: var(--subtext); }
.fw-help summary { cursor: pointer; width: max-content; }
.fw-help dl { margin: 8px 0 4px; }
.fw-help dt { color: var(--text); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.74rem; overflow-wrap: anywhere; }
.fw-help dd { margin: 0 0 6px; }
.fw-help p { margin: 0 !important; }
.fw-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; overflow-x: hidden; border-radius: 12px; }
.fw-row { display: flex; width: 100%; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 0; border-radius: 10px; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--text); }
.fw-list li:nth-child(odd) .fw-row { background: var(--surface); }
@media (hover: hover) { .fw-row:hover { outline: 1px solid var(--subtext); } }
.fw-row:focus-visible { outline: 3px solid var(--active); }
.fw-word { flex: 0 0 auto; max-width: 55%; font-weight: 700; letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fw-tags { font-weight: 400; margin-left: 6px; letter-spacing: 0; }
.fw-meta { flex: 0 1 auto; min-width: 0; font-size: 0.75rem; color: var(--subtext); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* One column that's never wider than the dialog: Safari sizes an automatic grid
   column to the widest line that can't wrap, which pushed rows past the edge. */
.st { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.st > *, .fw > *, .lb-ach > * { min-width: 0; }
.st-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.st-tile { padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-tile strong { font-family: var(--serif); font-size: 1.5rem; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.st-tile span { font-size: 0.75rem; color: var(--subtext); overflow-wrap: anywhere; }
.st-h { font-size: 1rem; margin: 14px 0 4px; }
.st-list { list-style: none; margin: 0; padding: 0; }
.st-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: 0.9rem; }
.st-list li:nth-child(odd) { background: var(--surface); }
.st-main { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; letter-spacing: 0.02em; }
.st-main small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--subtext); letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }
.st-value { flex: 0 0 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--subtext); font-size: 0.85rem; }
.st-hours { display: flex; align-items: flex-end; gap: 2px; height: 70px; padding: 6px 4px 0; border-bottom: 1px solid var(--border); }
.st-hours i { flex: 1; background: #66bb6a; border-radius: 3px 3px 0 0; opacity: 0.75; }
.st-hours i.peak { background: #ffc857; opacity: 1; }
.st-axis { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--subtext); padding: 3px 0 0; font-variant-numeric: tabular-nums; }
.st-note { font-size: 0.75rem; color: var(--subtext); margin-top: 4px !important; }
html[data-theme="matrix"] .st-tile { box-shadow: 0 0 0 1px #0d4d20, 0 0 14px rgba(61, 255, 114, 0.12); }
html[data-theme="matrix"] .st-hours i { background: #1fae4a; }
html[data-theme="matrix"] .st-hours i.peak { background: #3dff72; }
html[data-theme="matrix"] .update-btn { background: #3dff72; }

.update-link { font: inherit; font-weight: 600; cursor: pointer; background: none; border: 0; color: inherit; text-decoration: underline; padding: 4px 4px; }
/* On a phone the same banner shows, wrapping onto two lines if it must. */
@media (max-width: 640px) {
  .update-banner { border-radius: 20px; flex-wrap: wrap; justify-content: center; row-gap: 6px; padding: 10px 12px; font-size: 0.8rem; }
  .update-banner #update-text { flex: 1 1 200px; text-align: left; }
}
.update-changes { margin: 0 0 8px; max-height: 40vh; overflow-y: auto; font-size: 0.9rem; color: var(--text); }
.update-changes h3 { font-family: var(--serif); font-size: 1rem; margin: 12px 0 4px; }
.update-changes h3:first-child { margin-top: 0; }
.update-changes ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.update-more { color: var(--subtext); font-size: 0.8rem; margin: 10px 0 0; }
html[data-theme="matrix"] .btn:not(.btn-primary):not(.btn-small) { background: #03140a; color: #3dff72; border-color: #0d4d20; }

/* Dictionary suggestions */
.sg-list { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 6px; }
.sg-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-radius: 12px; font-size: 0.9rem; }
.sg-word { letter-spacing: 0.05em; color: var(--text); }
.sg-note { flex: 1; color: var(--subtext); font-size: 0.8rem; text-align: right; }
.sg-agree { font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; background: var(--button-bg); color: var(--button-text); border: 0; border-radius: 999px; padding: 5px 12px; }
.sg-agree:disabled { opacity: 0.45; cursor: default; }
#suggest-message.bad { color: #ef5350; font-weight: 600; }
#suggest-dialog code { background: var(--surface); padding: 1px 6px; border-radius: 6px; }

/* The "on the board" pip is a button that folds Pjom, Chat, Players and Cursors in and out. */
.tally.online { font: inherit; color: inherit; cursor: pointer; pointer-events: auto; }
@media (hover: hover) { .tally.online:hover { border-color: var(--subtext); } }
.tally.online:focus-visible { outline: 3px solid var(--active); outline-offset: 2px; }
.online .chev { display: inline-block; color: var(--subtext); font-size: 0.8em; transition: transform 0.15s; }
.online[aria-expanded="true"] .chev { transform: rotate(90deg); }

/* The light/dark button in the title bar */
.theme-toggle {
  margin-left: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 50%;
}
@media (hover: hover) { .theme-toggle:hover { border-color: var(--subtext); } }
.theme-toggle:focus-visible { outline: 3px solid var(--active); outline-offset: 2px; }
.theme-toggle + .auth { margin-left: 0; }
.theme-toggle svg { display: block; }

/* Hide every button over the board (Preferences, or the eye button in the title bar). */
/* The eye off: only your name and Preferences (and a ghost's 👻 pill) stay. */
html[data-hud="hidden"] .hud > :not(.tally-group):not(.ghost-pill) { display: none; }
.hud-toggle {
  margin-left: auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 50%;
}
@media (hover: hover) { .hud-toggle:hover { border-color: var(--subtext); } }
.hud-toggle:focus-visible { outline: 3px solid var(--active); outline-offset: 2px; }
.hud-toggle svg { display: block; transform-origin: center; }
/* Three quick blinks as the buttons hide or show (authUi.js blinkEye). */
.hud-toggle.blink svg { animation: eye-blink 0.9s ease-in-out; }
@keyframes eye-blink {
  0%, 30%, 60%, 100% { transform: scaleY(1); }
  15%, 45%, 80% { transform: scaleY(0.08); }
}
@media (prefers-reduced-motion: reduce) { .hud-toggle.blink svg { animation: none; } }

/* Touch: no double-tap-to-zoom delay on buttons, no leftover text selection or
   callout after dragging the board, and the title-bar buttons keep their size. */
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.play-body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.play-body input, .play-body textarea { -webkit-user-select: text; user-select: text; }
.hud-toggle, .theme-toggle { flex: none; }

/* Welcome screen: log in, continue as guest, or watch */
.welcome { width: min(92vw, 420px); text-align: center; }
.welcome-pjom { display: block; margin: 0 auto 6px; }
.welcome h2 { margin-bottom: 8px; }
.welcome p { margin-bottom: 14px; }
.welcome-choice {
  display: block; width: 100%; margin-top: 10px; padding: 12px 16px; cursor: pointer; text-align: left;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
.welcome-choice strong { display: block; font-size: 1rem; }
.welcome-choice span { display: block; margin-top: 2px; font-size: 0.82rem; color: var(--subtext); }
.welcome-choice.primary { background: var(--button-bg); color: var(--button-text); border-color: var(--button-bg); }
.welcome-choice.primary span { color: inherit; opacity: 0.8; }
@media (hover: hover) { .welcome-choice:hover { border-color: var(--subtext); } }
.welcome-choice:focus-visible { outline: 3px solid var(--active); outline-offset: 2px; }
.legal-note { margin-top: 14px !important; font-size: 0.75rem; color: var(--subtext); }
.legal-note a { color: inherit; }
.welcome::backdrop { background: rgba(0, 0, 0, 0.6); }
html[data-theme="matrix"] .welcome-choice.primary { background: #3dff72; color: #000; }

/* Ghosts (ghost.js): the 👻 pill while you're helping someone, and its dialogs. */
.ghost-pill { pointer-events: auto; border-color: #9aa3ad; background: color-mix(in srgb, #9aa3ad 16%, var(--surface, #fff)); }
.ghost-pill[hidden] { display: none; }
.ghost-pill-btn { font: inherit; font-size: 0.8rem; font-weight: 600; border: 0; border-radius: 999px; padding: 3px 10px; margin-left: 2px; background: #6b7580; color: #fff; cursor: pointer; }
.ghost-pill-btn[hidden] { display: none; }
.ghost-dialog h2 { margin-bottom: 6px; }
#ghost-thanks-join[hidden] { display: none; }
html[data-theme="matrix"] .ghost-pill { background: #000; border-color: #1fae4a; }

/* An observer, or someone who hasn't chosen how to join yet, has no score (authUi.js renderName). */
html[data-no-score] #tally-you, html[data-no-score] #pts-you { display: none; }
.text-input:disabled { opacity: 0.6; cursor: not-allowed; }
