/* Fonts are served from this site (no requests to Google). */
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/inter-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: Fraunces; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fraunces-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Fraunces; font-style: normal; font-weight: 800; font-display: swap; src: url(fonts/fraunces-latin-800-normal.woff2) format("woff2"); }

:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --tile-bg: #eee7da;
  --sky: #6a9fd4;              /* result highlights */
  --sky-ink: #ffffff;
  --star: #f3d661;
  --warn: #b45309;          /* empty tiles: a step darker than the page, like dark mode is a step lighter */
  --ink: #1b2230;
  --muted: #6b7280;
  --line: #ded6c6;
  --brand: #1f4e9c;          /* azulejo blue */
  --brand-ink: #f6f1e7;
  --g: #2f8f5b;              /* right place */
  --y: #ffb858;              /* elsewhere */
  --b: #7d8793;              /* absent */
  --tile-ink: #ffffff;        /* letters on coloured tiles */
  --y-ink: #ffffff;
  --key: #e7dfcf;
  --key-ink: #1b2230;
  --shadow: 0 10px 40px rgba(27, 34, 48, .18);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181f;
    --surface: #1d232c;
    --tile-bg: #1d232c;
    --sky: #7aa5ef;
    --sky-ink: #10141a;
    --warn: #f5b04a;
    --ink: #eef0f3;
    --muted: #9aa3b0;
    --line: #333b47;
    --brand: #7aa5ef;
    --brand-ink: #10141a;
    --g: #3a9e68;
    --y: #ffb858;
    --b: #7d8793;
    --tile-ink: #ffffff;
    --y-ink: #ffffff;
    --key: #5a6270;
    --key-ink: #eef0f3;
    --shadow: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #14181f;
    --surface: #1d232c;
    --tile-bg: #1d232c;
    --sky: #7aa5ef;
    --sky-ink: #10141a;
    --warn: #f5b04a;
    --ink: #eef0f3;
    --muted: #9aa3b0;
    --line: #333b47;
    --brand: #7aa5ef;
    --brand-ink: #10141a;
    --g: #3a9e68;
    --y: #ffb858;
    --b: #7d8793;
    --tile-ink: #ffffff;
    --y-ink: #ffffff;
    --key: #5a6270;
    --key-ink: #eef0f3;
    --shadow: 0 10px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}


* { box-sizing: border-box; }
[hidden] { display: none !important; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* Header */
.top {
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.top-left, .top-right { display: flex; gap: 4px; }
.top-right { justify-content: flex-end; }
/* Theme toggle shows the mode you'd switch to. */
.i-sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .i-sun { display: block; } :root:not([data-theme="light"]) .i-moon { display: none; } }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
.brand { text-align: center; line-height: 1.1; }
.brand h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -.5px;
  color: var(--brand);
}
.puzzle-no { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; background: none; border-radius: 10px;
}
.icon-btn:hover { background: var(--key); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .fill { fill: var(--ink); stroke: none; }

/* Game */
/* The board fills whatever height is left after the header and keyboard. */
main#game {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 8px calc(10px + env(safe-area-inset-bottom, 0px));
  gap: 12px;
}
.board-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center;
  container-type: size;
}
.board {
  --gap: 6px;
  display: grid;
  grid-template-rows: repeat(6, auto);
  gap: var(--gap);
  /* 5 tiles + 4 gaps wide, 6 tiles + 5 gaps tall: fit both directions. */
  width: min(100cqw, (100cqh - 5 * var(--gap)) * 5 / 6 + 4 * var(--gap), 480px);
  container-type: inline-size;
}
.row-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap); }
.row-tiles.active .tile { cursor: pointer; }
.row-tiles.shake { animation: shake .4s; }
.tile {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
  font-size: calc((100cqw - 4 * var(--gap)) / 5 * .55);
  text-transform: uppercase;
  background: var(--tile-bg);
  user-select: none;
}
.tile.filled { border-color: var(--muted); animation: pop .1s; }
.tile.sel { border-color: var(--brand); box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--brand) 55%, transparent); }
.tile.g, .tile.y, .tile.b { color: var(--tile-ink); border-color: transparent; }
.tile.g { background: var(--g); }
.tile.y { background: var(--y); color: var(--y-ink); }
.tile.b { background: var(--b); }
.tile.flip { animation: flip .5s ease forwards; }
.tile.win { animation: bounce .5s ease; }

@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes bounce { 40% { transform: translateY(-14px); } 70% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .tile, .row-tiles { animation: none !important; } }

.keyboard { flex: none; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.kb-row { display: flex; justify-content: center; gap: 5px; }
.key {
  flex: 1;
  max-width: 60px;
  height: clamp(44px, 7.4dvh, 66px);
  border: 0;
  border-radius: 8px;
  background: var(--key);
  color: var(--key-ink);
  font-weight: 700;
  font-size: clamp(15px, 2.4dvh, 20px);
  text-transform: uppercase;
  touch-action: manipulation;
}
.key.wide { max-width: 92px; flex: 1.5; font-size: clamp(12px, 1.8dvh, 15px); }
.key svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.key.g, .key.y, .key.b { color: var(--tile-ink); }
.key.g { background: var(--g); }
.key.y { background: var(--y); color: var(--y-ink); }
.key.b { background: var(--b); }
.key:active { filter: brightness(.9); }

/* Toasts */
.toasts { position: fixed; inset: 72px auto auto 50%; margin: 0; padding: 0; border: 0; background: none; overflow: visible; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); text-align: center; animation: fade 2.2s forwards; }
@keyframes fade { 0% { opacity: 0; transform: translateY(-6px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* Dialogs */
dialog.sheet {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  overflow: auto;
}
dialog.sheet.narrow { width: min(400px, calc(100vw - 32px)); }
dialog.sheet.tall { width: min(560px, calc(100vw - 32px)); min-height: min(640px, calc(100dvh - 48px)); }
dialog::backdrop { background: rgba(10, 14, 20, .55); backdrop-filter: blur(2px); }
dialog[open] { animation: rise .22s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); border-radius: 8px; }
.close:hover { background: var(--key); }
dialog h2 { font-family: Fraunces, Georgia, serif; font-weight: 800; font-size: 26px; margin: 0 0 8px; letter-spacing: -.3px; }
dialog h3 { font-size: 15px; margin: 18px 0 8px; }
dialog p { margin: 0 0 12px; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface); border: 1.5px solid var(--brand); color: var(--brand); }
.btn.ghost:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 4px 0; text-decoration: underline; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row .btn { flex: 1 1 140px; }

/* Result */
.res-word { font-family: Fraunces, Georgia, serif; font-size: 22px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: var(--brand); }
.score-card { display: flex; gap: 20px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }
.score-total { display: grid; justify-items: center; min-width: 88px; }
.score-total span { font-family: Fraunces, Georgia, serif; font-weight: 800; font-size: 44px; line-height: 1; color: var(--brand); }
.score-total small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.score-lines { margin: 0; flex: 1; display: grid; gap: 6px; }
.score-lines div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.score-lines dt { color: var(--muted); }
.score-lines dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-lines dd.off { color: var(--muted); font-weight: 500; }
.nudge { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: var(--radius); padding: 16px; margin: 4px 0 8px; }
.nudge h3 { margin: 0 0 4px; font-size: 16px; }
.nudge p { font-size: 14px; color: var(--ink); margin: 0; }
.next { text-align: center; color: var(--muted); font-size: 14px; margin: 16px 0 0; }
.next strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Forms */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--key); border-radius: 12px; margin: 4px 36px 16px 0; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.auth-context { font-size: 14px; background: color-mix(in srgb, var(--g) 14%, var(--surface)); border-radius: 10px; padding: 10px 12px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.form input, .inline-form input {
  font: inherit; font-weight: 400;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}
.form input:focus, .inline-form input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.hint.bad { color: #c2410c; }
.hint.good { color: var(--g); }
.form-msg { font-size: 14px; margin: 0; min-height: 1em; }
.form-msg.bad { color: #c2410c; }
.form-msg.good { color: var(--g); }

/* Scoreboard */
.locked { padding: 8px 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 4px 0 10px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.chips button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.segmented { display: flex; gap: 2px; padding: 3px; background: var(--key); border-radius: 10px; margin-bottom: 12px; }
.segmented button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--ink); }
.group-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; margin-bottom: 10px; color: var(--muted); }
.group-bar strong { color: var(--ink); letter-spacing: .12em; }
.group-bar span { margin-right: auto; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lb td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lb tr:last-child td { border-bottom: 0; }
.lb .num { text-align: right; font-variant-numeric: tabular-nums; }
.lb td.rank { width: 36px; color: var(--muted); font-weight: 700; }
.lb td.pts { font-weight: 800; }
.lb tr.me td { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.lb tr.me td.name::after { content: " (tu)"; color: var(--muted); font-weight: 500; }
.lb tr.top1 td.rank { color: #c08a00; }
.empty { padding: 20px; text-align: center; color: var(--muted); margin: 0; }
.groups-manage { margin-top: 16px; }
.groups-manage summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: 6px 0; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { padding: 8px 10px; }

/* Account */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 8px; text-align: center; }
.stats strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 28px; font-weight: 800; }
.stats span { font-size: 12px; color: var(--muted); }
.total-pts { text-align: center; color: var(--muted); font-size: 14px; }
.total-pts strong { color: var(--ink); }
.dist { display: grid; gap: 4px; margin-bottom: 16px; }
.dist-row { display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; }
.dist-bar { background: var(--b); color: #fff; padding: 2px 8px; border-radius: 4px; text-align: right; min-width: 26px; width: var(--w); transition: width .4s; }
.dist-bar.cur { background: var(--g); }

/* Help */
.example { display: grid; grid-template-columns: repeat(5, 44px); gap: 5px; margin: 12px 0; }
.example .tile { font-size: 22px; border-radius: 6px; }
.legend, .rules { padding-left: 0; list-style: none; margin: 0; display: grid; gap: 8px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.sw.g { background: var(--g); } .sw.y { background: var(--y); } .sw.b { background: var(--b); }
table.pts { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 12px; }
.pts th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; }
.pts td { text-align: center; padding: 6px 4px; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pts tr + tr td { font-weight: 800; }
.rules { margin-bottom: 8px; }

@media (max-width: 360px) { .board { --gap: 4px; } .kb-row { gap: 4px; } }
@media (max-width: 480px) {
  .lb th, .lb td { padding: 10px 8px; }
  .lb th:nth-child(4), .lb td:nth-child(4) { display: none; }
}
@media (max-width: 380px) {
  .top { padding: 8px 12px; }
  .stats strong { font-size: 22px; }
  .lb th:nth-child(4), .lb td:nth-child(4) { display: none; }
}

/* Result: centred celebration card */
dialog.result { text-align: center; padding: 26px 22px 20px; }
.res-icon { display: grid; place-items: center; margin-bottom: 8px; }
.res-icon svg { width: 52px; height: 52px; fill: none; stroke: var(--star); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.res-icon.lose svg { stroke: var(--muted); }
dialog.result h2 { font-family: Inter, system-ui, sans-serif; font-weight: 800; font-size: 28px; letter-spacing: -.6px; margin: 0 0 2px; }
.res-sub { font-size: 16px; margin: 0 0 12px; }
.res-answer { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 8px; font-size: 20px; font-weight: 800; margin: 0 0 14px; }
.res-answer strong { color: var(--sky); text-transform: uppercase; letter-spacing: .02em; }
.res-info { display: inline-grid; color: var(--muted); border-radius: 50%; }
.res-info:hover { color: var(--ink); }
.res-info svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.res-info svg .fill { fill: currentColor; stroke: none; }
.res-score { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; margin: 0 0 12px; display: grid; gap: 10px; }
.res-total { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.res-total strong { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -1px; color: var(--sky); font-variant-numeric: tabular-nums; }
.res-total span { font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.res-lines { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; padding-top: 10px; border-top: 1px solid var(--line); }
.res-lines div { display: grid; gap: 2px; }
.res-lines div + div { border-left: 1px solid var(--line); }
.res-lines dt { font-size: 12px; color: var(--muted); }
.res-lines dd { margin: 0; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.res-lines dd.off { font-size: 12px; font-weight: 500; color: var(--muted); padding-top: 3px; }
dialog.result .nudge { text-align: left; margin: 0; padding: 14px; }
dialog.result .nudge .row { margin-top: 10px; }
.btn.share { display: flex; align-items: center; justify-content: center; gap: 10px; width: min(100%, 340px); margin: 14px auto 0; padding: 13px 20px; border-radius: 10px; border-color: var(--sky); background: var(--sky); color: var(--sky-ink); font-size: 18px; font-weight: 700; }
.btn.share:hover { filter: brightness(1.06); border-color: var(--sky); }
.btn.share svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
dialog.result .link { margin-top: 10px; }
dialog.result .next { display: grid; gap: 0; margin: 16px 0 0; color: var(--ink); font-size: 16px; }
dialog.result .next strong { font-size: 38px; font-weight: 800; line-height: 1.1; letter-spacing: -1px; color: var(--sky); }
#res-title:focus { outline: none; }

/* Share sheet */
.share-sheet { text-align: center; }
.share-badge { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--sky) 16%, var(--surface)); }
.share-badge svg { width: 30px; height: 30px; fill: none; stroke: var(--sky); stroke-width: 2.2; stroke-linecap: round; }
.share-sheet h2 { font-family: Inter, system-ui, sans-serif; font-weight: 800; font-size: 24px; margin: 0 0 4px; }
.share-sub { color: var(--muted); margin: 0 0 18px; }
.share-label { text-align: left; font-weight: 700; font-size: 14px; margin: 0 0 8px; }
.share-copy { display: flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--tile-bg) 55%, var(--surface)); border-radius: 12px; padding: 8px 8px 8px 16px; margin-bottom: 22px; text-align: left; }
.share-copy span { flex: 1; min-width: 0; font-size: 14px; color: var(--ink); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-copy .icon-btn svg { stroke: var(--muted); }
.share-copy .icon-btn { flex: none; width: 36px; height: 36px; }
.share-copy .icon-btn svg { width: 20px; height: 20px; }
.share-via { display: flex; justify-content: space-between; gap: 4px; }
.share-via a, .share-via button { flex: 1; min-width: 0; display: grid; justify-items: center; gap: 6px; font-size: 11px; color: var(--muted); text-decoration: none; border: 0; background: none; padding: 0; }
.share-via .dot { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: var(--c); background: transparent; border: 1.5px solid color-mix(in srgb, var(--c) 40%, transparent); transition: background .15s, color .15s; }
.share-via .dot svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.share-via .logo { width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.share-via a:hover .dot, .share-via a:focus-visible .dot { background: var(--c); color: var(--surface); }
.res-lines dd.warn { display: flex; align-items: center; justify-content: center; gap: 4px; text-align: center; line-height: 1.25; font-size: 12px; font-weight: 600; color: var(--warn); padding-top: 3px; }
.res-lines dd.warn svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.res-lines dd.warn svg circle { fill: currentColor; stroke: none; }
.back { position: absolute; top: 10px; left: 12px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 8px; }
.back:hover { background: var(--key); color: var(--ink); }
.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Ko-fi button in the header: full label on wide screens, icon-only on phones */
.top { grid-template-columns: 1fr auto 1fr; }
.top-left { align-items: center; min-width: 0; }
.kofi { display: flex; align-items: center; margin-left: 4px; min-width: 0; }
.kofi .btn-container { display: flex; }
.kofi-demo { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 10px; background: #7aa5ef; color: #fff; font-size: 14px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.kofi-demo .kofitext { display: inline-flex; align-items: center; gap: 6px; }
.kofi-demo svg { width: 18px; height: 18px; fill: #fff; flex: none; }
@media (max-width: 640px) {
  .top .kofitext { font-size: 0 !important; gap: 0; }
  .top .kofi-button { padding: 0 9px !important; min-width: 0 !important; }
  .top .kofiimg { margin: 0 !important; }
}
@media (max-width: 360px) {
  .top-left, .top-right { gap: 0; }
  .top .icon-btn { width: 34px; height: 34px; }
  .kofi { margin-left: 2px; }
  .top .kofi-button { padding: 0 7px !important; height: 32px; }
  .brand h1 { font-size: 26px; }
}

/* Scoreboard: larger title, more room between sections */
#dlg-board h2 { font-size: 34px; margin-bottom: 20px; }
#board-content { display: grid; gap: 20px; }
#board-content > * { margin: 0; }
#dlg-board .chips { padding-bottom: 2px; }
#dlg-board .groups-manage { border-top: 1px solid var(--line); padding-top: 20px; }
#dlg-board .chips button { padding: 8px 16px; font-size: 15.5px; }
.board-label { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
#dlg-board .chips { margin: 0; }
#dlg-board .board-label { font-size: 16px; margin-bottom: 12px; }

/* Private groups page */
#dlg-groups { padding-top: 56px; }
#dlg-groups .groups-title { font-family: Inter, system-ui, sans-serif; font-weight: 800; font-size: 26px; margin: 0 0 6px; }
#dlg-groups .groups-sub { color: var(--muted); margin: 0 0 24px; }
#dlg-groups .board-label { font-size: 16px; margin: 0 0 10px; }
#dlg-groups .inline-form { margin: 0 0 24px; }
#dlg-groups .inline-form:last-child { margin-bottom: 4px; }
#dlg-groups .inline-form input { padding: 11px 12px; }
#dlg-groups .inline-form .btn { padding: 0 18px; }
#dlg-board .groups-manage .btn { margin-top: 0; }

/* Avatars */
.avatar { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--av); font-size: 18px; line-height: 1; }
.avatar.sm { width: 26px; height: 26px; font-size: 15px; margin-right: 8px; vertical-align: middle; }
.avatar.md { width: 40px; height: 40px; font-size: 22px; }
.avatar.xl { width: 64px; height: 64px; font-size: 36px; }
.avatar.xxl { width: 88px; height: 88px; font-size: 50px; }
.lb td.name { white-space: nowrap; }
.res-total { align-items: center; }
#res-avatar:empty { display: none; }
.acc-head { display: flex; align-items: center; gap: 14px; }
.acc-head h2 { margin: 0; }
#btn-avatar { margin: 14px 0 4px; }
#dlg-avatar { padding-top: 56px; }
#dlg-avatar .groups-title { font-family: Inter, system-ui, sans-serif; font-weight: 800; font-size: 26px; margin: 0 0 12px; }
#dlg-avatar .board-label { font-size: 15px; margin: 0 0 10px; }
.board-hint { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 6px; }
.av-preview { display: grid; place-items: center; margin: 0 0 18px; }
.av-colors { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.av-colors button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); padding: 0; }
.av-colors button.on { box-shadow: 0 0 0 2px var(--ink); }
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; margin-bottom: 20px; }
.av-grid button { position: relative; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--tile-bg); font-size: 24px; padding: 0; }
.av-grid button.on { border-color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.av-grid.special { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.av-grid.special button { height: auto; padding: 8px 4px 6px; display: grid; justify-items: center; gap: 3px; }
.av-grid.special small { font-size: 10.5px; line-height: 1.15; color: var(--muted); }
.av-grid button.locked .em { filter: grayscale(1); opacity: .35; }
.av-grid .lock { position: absolute; top: 5px; right: 5px; width: 12px; height: 12px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linejoin: round; }
/* Compact avatar picker on phones, save button always visible */
.av-colors { gap: 8px; flex-wrap: nowrap; }
.av-colors button { width: 30px; height: 30px; flex: none; }
#av-free { grid-template-columns: repeat(6, 1fr); }
#av-free button { height: 44px; font-size: 22px; }
.av-preview .avatar.xxl { width: 72px; height: 72px; font-size: 40px; }
#btn-av-save { position: sticky; bottom: 0; margin-top: 4px; box-shadow: 0 -12px 16px var(--surface); }
#dlg-board:not(.tall) h2 { margin-bottom: 4px; }
#dlg-board .locked { padding-top: 0; }
#board-locked .row, #acc-guest .row { margin-top: 24px; }
#board-locked p, #acc-guest p { margin-bottom: 0; }
#acc-guest h2 { margin-bottom: 4px; }
#dlg-board:not(.tall) h2, #acc-guest h2 { margin-bottom: 8px; }

/* Account actions and edit page */
.acc-actions { margin: 14px 0 4px; }
.acc-actions .btn { flex: 1 1 120px; }
#btn-avatar { margin: 0; }
#dlg-edit { padding-top: 56px; }
#dlg-edit .groups-title { font-family: Inter, system-ui, sans-serif; font-weight: 800; font-size: 26px; margin: 0 0 18px; }
#dlg-edit .edit-block { gap: 10px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
#dlg-edit .edit-block:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 4px; }
#dlg-edit .board-label { font-size: 16px; margin: 0; }
#dlg-edit .inline-form { margin: 0; }
#dlg-edit .inline-form .btn { padding: 0 18px; }
#dlg-edit .btn.wide { margin-top: 2px; }
#dlg-edit .form-msg:empty { display: none; }
/* Scoreboard: your position next to the title, scrolling top-50 list */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-right: 36px; margin-bottom: 20px; }
#dlg-board .board-head h2 { margin: 0; }
#dlg-board:not(.tall) .board-head { margin-bottom: 8px; }
.my-rank { display: grid; justify-items: end; line-height: 1.1; padding: 6px 12px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.my-rank span { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.my-rank strong { font-size: 26px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
#dlg-board .table-wrap { max-height: min(420px, 46dvh); overflow-y: auto; overscroll-behavior: contain; }
#dlg-board .lb thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.lb tr.gap td { text-align: center; color: var(--muted); padding: 4px; }
.my-rank span { white-space: nowrap; }
.board-head h2 { min-width: 0; }
.board-head { justify-content: flex-start; gap: 12px; }
.my-rank { justify-items: center; gap: 4px; padding: 6px 12px 5px; }
.my-rank { gap: 6px; padding: 7px 14px 6px; }
.my-rank strong { line-height: 1; }
.my-rank { padding: 6px 14px; }
#dlg-board .chips { align-items: center; }
.chips .chip-add { flex: none; width: 38px; height: 38px; padding: 0; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed var(--muted); background: transparent; color: var(--muted); transition: background .15s, color .15s, border-color .15s; }
.chips .chip-add svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.chips .chip-add:hover, .chips .chip-add:focus-visible { border-style: solid; border-color: var(--brand); background: var(--brand); color: var(--surface); }
#dlg-board .chips { gap: 10px; }
#dlg-board .chips button { height: 40px; display: inline-flex; align-items: center; }
#dlg-board .chips .chip-add { width: 40px; height: 40px; padding: 0; justify-content: center; font-size: 0; }
/* Period tabs: softer track in light mode (dark mode keeps --key) */
:root:not([data-theme="dark"]) #dlg-board .segmented { background: var(--tile-bg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #dlg-board .segmented { background: var(--key); } }
:root:not([data-theme="dark"]) #dlg-board .segmented { background: color-mix(in srgb, var(--sky) 18%, var(--surface)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #dlg-board .segmented { background: var(--key); } }
:root:not([data-theme="dark"]) .lb tr.me td { background: #e7dfcf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lb tr.me td { background: color-mix(in srgb, var(--brand) 10%, transparent); } }
:root:not([data-theme="dark"]) #dlg-board .segmented { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #dlg-board .segmented { background: var(--key); } }
:root:not([data-theme="dark"]) .lb tr.me td { background: color-mix(in srgb, var(--g) 14%, var(--surface)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lb tr.me td { background: color-mix(in srgb, var(--brand) 10%, transparent); } }
/* Rank numbers in the title colour; active group chip in primary blue */
.lb td.rank { color: var(--ink); }
.chips button.active { background: var(--brand); border-color: var(--brand); color: #ffffff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chips button.active { color: var(--brand-ink); } }
:root[data-theme="dark"] .chips button.active { color: var(--brand-ink); }
.board-head h2 { flex: none; white-space: nowrap; }
@media (max-width: 440px) { #dlg-board .board-head h2 { font-size: 29px; } .my-rank strong { font-size: 22px; } .my-rank { padding: 5px 11px; } }
/* Your row: one solid highlight, no grey lines above or below */
:root { --me-row: color-mix(in srgb, var(--g) 14%, var(--surface)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --me-row: color-mix(in srgb, var(--brand) 10%, var(--surface)); } }
:root[data-theme="dark"] { --me-row: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.lb tbody tr.me td { background: var(--me-row) !important; border-bottom-color: var(--me-row); }
.lb tbody tr:has(+ tr.me) td { border-bottom-color: var(--me-row); }
/* Unlock conditions under special avatars: small uppercase labels */
.av-grid.special small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; line-height: 1.25; color: var(--ink); opacity: .7; text-wrap: balance; }
.av-grid.special button.locked small { color: var(--muted); opacity: 1; }
/* White text on primary buttons and the selected group chip, in both modes */
.btn.primary, #btn-av-save { color: #ffffff; }
.chips button.active,
:root[data-theme="dark"] .chips button.active { color: #ffffff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chips button.active { color: #ffffff; } }
/* Your row is green in dark mode too */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --me-row: color-mix(in srgb, var(--g) 22%, var(--surface)); } }
:root[data-theme="dark"] { --me-row: color-mix(in srgb, var(--g) 22%, var(--surface)); }
.unavailable { display: grid; gap: 4px; text-align: center; padding: 14px 18px; border-radius: var(--radius); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); width: min(100%, 420px); }
.unavailable strong { font-size: 16px; }
.unavailable span { font-size: 14px; color: var(--muted); }
.keyboard[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* Consent banner and privacy notice */
.consent { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: min(520px, calc(100vw - 24px)); display: grid; gap: 12px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.consent p { margin: 0; font-size: 14px; line-height: 1.45; }
.consent p strong { display: block; font-size: 15px; margin-bottom: 2px; }
.consent .link { font-size: 14px; padding: 0; margin-left: 2px; }
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* Accept and decline look the same on purpose (GDPR: refusing must be as easy as accepting). */
.consent-actions .btn, .privacy .row .btn { background: var(--surface); border: 1.5px solid var(--brand); color: var(--brand); font-weight: 700; }
.privacy { text-align: left; }
.privacy h3 { margin: 18px 0 6px; font-size: 15px; }
.privacy p, .privacy li { font-size: 14px; line-height: 1.5; }
.privacy ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.privacy .groups-title { font-family: Inter, system-ui, sans-serif; font-weight: 800; font-size: 26px; margin: 0 0 10px; }
.consent-state { font-weight: 600; }
.privacy-link { display: block; margin: 14px auto 0; font-size: 13px; color: var(--muted); }
.guest-only { display: none; }
#acc-guest:not([hidden]) ~ .guest-only { display: block; }

/* Ko-fi: coffee cup with a little wiggle, like Ko-fi's own button */
.kofi-demo svg.cup { width: 20px; height: 20px; fill: none; overflow: visible; transform-origin: 50% 75%; animation: cup-wiggle 3s ease-in-out infinite; }
.kofi-demo svg.cup .mug { fill: #ffffff; }
.kofi-demo svg.cup .handle, .kofi-demo svg.cup .steam { fill: none; stroke: #ffffff; stroke-width: 1.8; stroke-linecap: round; }
@keyframes cup-wiggle {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(-12deg); }
  80% { transform: rotate(10deg); }
  85% { transform: rotate(-8deg); }
  90% { transform: rotate(5deg); }
  95% { transform: rotate(-2deg); }
}
@media (prefers-reduced-motion: reduce) { .kofi-demo svg.cup { animation: none; } }
/* Phones: a little more room between the coffee button and the +Cinco name */
@media (max-width: 640px) { .top .brand { padding-left: 14px; } }
@media (max-width: 360px) { .top .brand { padding-left: 8px; } }
