/* ==========================================================================
   ChibiGuessr — stylesheet
   Layout: a centred column, a scrollable results table, and a card layout
   below 900px. All colours live in custom properties so the colourblind
   palette is a single attribute flip.
   ========================================================================== */

@font-face {
  font-family: "ONE Mobile";
  src: url("../fonts/ONE Mobile OTF Regular.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "ONE Mobile Title";
  src: url("../fonts/ONE Mobile Title OTF.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #fbf7f2;
  --tint-pink: rgba(255, 208, 228, 0.6);
  --tint-violet: rgba(214, 205, 255, 0.55);
  --surface: #fffdfb;
  --surface-2: #f7f1f7;
  --surface-3: #f1eaf4;

  --ink: #201827;
  --ink-soft: #110f13;
  --ink-faint: #19171b;

  --line: #ece3f0;
  --line-strong: #dccfe4;

  --accent: #ff4f93;
  --accent-2: #7b5cff;
  --button: #c2185b;
  --button-hover: #ad1457;
  --focus: #7b5cff;
  --brand-color: #a51262;
  --brand-gradient: #a51262;
  --brand-filter: none;

  --exact: #278049;
  --exact-ink: #fff;
  --partial: #e3a112;
  --partial-ink: #3a2a05;
  --miss: #e97373;
  --miss-ink: #310707;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(51, 38, 63, 0.05), 0 3px 10px rgba(51, 38, 63, 0.04);
  --shadow-md: 0 14px 40px -18px rgba(51, 38, 63, 0.35);

  --page-overlay: linear-gradient(
    rgba(255, 255, 255, 0.60),
    rgba(255, 255, 255, 0.20)
  );
  --selection-bg: rgba(255, 79, 147, 0.22);

  --corner-bg: rgba(255, 255, 255, 0.72);
  --corner-hover-bg: #fff;
  --corner-pressed-bg: var(--ink);
  --corner-pressed-border: var(--ink);
  --corner-pressed-ink: #fff;
  --corner-mark-bg: var(--ink);
  --corner-mark-ink: #fff;
  --corner-pressed-mark-bg: #fff;
  --corner-pressed-mark-ink: var(--ink);

  --chip-bg: rgba(255, 255, 255, 0.6);
  --mode-bar-bg: rgba(255, 255, 255, 0.65);
  --mode-active-bg: var(--ink);
  --mode-active-ink: #fff;
  --mode-active-ring: none;

  --input-hover-border: #cbb9d6;
  --error-ink: #c42442;

  --suggestion-sat: 80%;
  --suggestion-l: 94%;
  --suggestion-hover-sat: 76%;
  --suggestion-hover-l: 88%;
  --suggestion-scrollbar: rgba(51, 38, 63, 0.35);
  --suggestion-thumb: rgba(51, 38, 63, 0.3);
  --dot-ring: rgba(51, 38, 63, 0.12);

  --cell-border: rgba(51, 38, 63, 0.045);
  --name-sat: 80%;
  --name-l: 94%;
  --name-border-sat: 45%;
  --name-border-l: 84%;

  --avatar-sat-1: 82%;
  --avatar-l-1: 84%;
  --avatar-sat-2: 78%;
  --avatar-l-2: 72%;
  --avatar-ring: rgba(51, 38, 63, 0.1);
  --avatar-shadow: rgba(51, 38, 63, 0.14);

  --correct-ring: rgba(39, 128, 73, 0.18);
  --empty-bg: rgba(255, 255, 255, 0.35);
  --primary-shadow: 0 10px 20px -14px rgba(194, 24, 91, 1);
  --guess-shadow: 0 6px 14px -8px rgba(194, 24, 91, 0.9);
  --guess-hover-shadow: 0 9px 18px -9px rgba(194, 24, 91, 1);

  --dialog-shadow: 0 40px 90px -30px rgba(51, 38, 63, 0.55);
  --dialog-backdrop: rgba(51, 38, 63, 0.42);
  --cta-bg: var(--ink);
  --cta-ink: #fff;
  --cta-hover-bg: #4a3859;

  --toast-bg: var(--ink);
  --toast-ink: #fff;
  --toast-border: transparent;

  --skip-bg: var(--ink);
  --skip-ink: #fff;
  --skip-border: transparent;

  /* Colourblind palette, selected per theme. */
  --cb-exact: #1f6feb;
  --cb-exact-ink: #fff;
  --cb-partial: #f08c2e;
  --cb-partial-ink: #2c1704;
  --cb-miss: #d8d2df;
  --cb-miss-ink: #3d3448;

  --font: "ONE Mobile", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "ONE Mobile", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-title: "ONE Mobile Title", "ONE Mobile", "Segoe UI", system-ui, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0912;
  --surface: #15111f;
  --surface-2: #1d1829;
  --surface-3: #282133;

  --ink: #f2ebf8;
  --ink-soft: #baabce;
  --ink-faint: rgb(209, 197, 228);

  --line: #2b2438;
  --line-strong: #413552;

  --accent: #ff5ca8;
  --accent-2: #a88cff;
  --button: #c2185b;
  --button-hover: #e02a78;
  --focus: #b9a7ff;
  --brand-color: #ff3d86;
  --brand-gradient: #ff3d86 0%;
  --brand-filter: drop-shadow(0 0 5px #a51262);

  --exact: #1d5c3d;
  --exact-ink: #d7ffe8;
  --partial: #7a4d0d;
  --partial-ink: #ffe3b0;
  --miss: #6f2b36;
  --miss-ink: #ffd7de;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45), 0 3px 10px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 18px 50px -22px rgba(0, 0, 0, 0.85);

  --page-overlay: linear-gradient(
    rgba(6, 5, 11, 0.9) 20%,
    rgba(6, 5, 11, 0.8) 50%,
    rgba(6, 5, 11, 0.95) 100%
  );
  --selection-bg: rgba(255, 92, 168, 0.28);

  --corner-bg: rgba(14, 11, 20, 0.82);
  --corner-hover-bg: var(--surface-2);
  --corner-pressed-bg: #2b1f3f;
  --corner-pressed-border: var(--accent-2);
  --corner-pressed-ink: var(--ink);
  --corner-mark-bg: var(--surface-3);
  --corner-mark-ink: var(--ink);
  --corner-pressed-mark-bg: var(--accent);
  --corner-pressed-mark-ink: #2a0b18;

  --chip-bg: rgba(255, 255, 255, 0.06);
  --mode-bar-bg: rgba(13, 10, 20, 0.78);
  --mode-active-bg: #342650;
  --mode-active-ink: var(--ink);
  --mode-active-ring: inset 0 0 0 1px rgba(168, 140, 255, 0.18);

  --input-hover-border: #5a4a6e;
  --error-ink: #ff9aa8;

  --suggestion-sat: 32%;
  --suggestion-l: 16%;
  --suggestion-hover-sat: 38%;
  --suggestion-hover-l: 23%;
  --suggestion-scrollbar: rgba(255, 255, 255, 0.28);
  --suggestion-thumb: rgba(255, 255, 255, 0.24);
  --dot-ring: rgba(255, 255, 255, 0.14);

  --cell-border: rgba(255, 255, 255, 0.06);
  --name-sat: 32%;
  --name-l: 17%;
  --name-border-sat: 35%;
  --name-border-l: 30%;

  --avatar-sat-1: 42%;
  --avatar-l-1: 32%;
  --avatar-sat-2: 48%;
  --avatar-l-2: 21%;
  --avatar-ring: rgba(255, 255, 255, 0.14);
  --avatar-shadow: rgba(0, 0, 0, 0.4);

  --correct-ring: rgba(74, 222, 128, 0.2);
  --empty-bg: rgba(18, 15, 26, 0.7);
  --primary-shadow: 0 10px 24px -14px rgba(255, 92, 168, 0.7);
  --guess-shadow: 0 6px 16px -8px rgba(255, 92, 168, 0.65);
  --guess-hover-shadow: 0 9px 20px -9px rgba(255, 92, 168, 0.8);

  --dialog-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.85);
  --dialog-backdrop: rgba(3, 2, 6, 0.72);
  --cta-bg: #3c2b5c;
  --cta-ink: var(--ink);
  --cta-hover-bg: #4a376f;

  --toast-bg: #241b32;
  --toast-ink: var(--ink);
  --toast-border: var(--line-strong);

  --skip-bg: var(--surface-3);
  --skip-ink: var(--ink);
  --skip-border: var(--line-strong);

  --cb-exact: #1d4f8f;
  --cb-exact-ink: #dceaff;
  --cb-partial: #7a4a12;
  --cb-partial-ink: #ffe1b2;
  --cb-miss: #3a3344;
  --cb-miss-ink: #e8e2ee;
}

/* Colourblind mode: swap green/amber for blue/orange and add a texture, so the
   result never depends on hue alone. */
html[data-cb="on"] {
  --exact: var(--cb-exact);
  --exact-ink: var(--cb-exact-ink);
  --partial: var(--cb-partial);
  --partial-ink: var(--cb-partial-ink);
  /* The wrong state is neutral in colourblind mode so exact/wrong never rely
     on a red/green distinction. */
  --miss: var(--cb-miss);
  --miss-ink: var(--cb-miss-ink);
}

html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar {
  display: none;
}

/* Theme switches are instantaneous. The class is applied around the theme
   attribute change in main.js so colour transitions cannot smear the old
   palette into the new one. Hover transitions resume on the next frame. */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}

html[data-cb="on"] .state-exact {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.14) 0 5px,
    transparent 5px 10px
  );
}

html[data-cb="on"] .state-partial {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(0, 0, 0, 0.09) 0 5px,
    transparent 5px 10px
  );
}

/* ------------------------------ base ------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 20px 40px;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    var(--page-overlay),
    url("../img/background/background_graphic_alt.webp");
  background-position: center, center;
  background-size: cover, cover;
  background-repeat: no-repeat;
  background-attachment: fixed, fixed;
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0;
}

p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

a {
  color: var(--accent-2);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: var(--selection-bg);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 16px;
  border: 1px solid var(--skip-border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--skip-bg);
  color: var(--skip-ink);
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

/* ------------------------------ masthead ------------------------------ */

/* Corner actions: Colourblind (left) and How to play (right). */
.corner-button {
  position: absolute;
  top: 16px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px 6px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--corner-bg);
  backdrop-filter: blur(8px);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.12s ease;
}

.corner-cluster {
  position: absolute;
  top: 16px;
  left: 20px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
}

.corner-cluster .corner-button {
  position: static;
}

.corner-button--right {
  right: 20px;
}

.corner-button:hover {
  background: var(--corner-hover-bg);
  border-color: var(--accent-2);
  color: var(--ink);
  transform: translateY(-1px);
}

.corner-button[aria-pressed="true"] {
  background: var(--corner-pressed-bg);
  border-color: var(--corner-pressed-border);
  color: var(--corner-pressed-ink);
}

.corner-button[aria-pressed="true"]:hover {
  background: var(--corner-pressed-bg);
  border-color: var(--corner-pressed-border);
}

.corner-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  background: var(--corner-mark-bg);
  color: var(--corner-mark-ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.corner-button[aria-pressed="true"] .corner-mark {
  background: var(--corner-pressed-mark-bg);
  border-color: transparent;
  color: var(--corner-pressed-mark-ink);
}

.masthead {
  max-width: 1080px;
  margin: 0 auto;
  padding: 44px 0 26px;
  text-align: center;
}

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

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-6deg);
  }
  50% {
    transform: translateY(-5px) rotate(6deg);
  }
}

.brand-name {
  font-family: var(--font-title);
  font-size: clamp(2.3rem, 6vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  background-color: var(--brand-color);
  background-image: var(--brand-gradient);
  --brand-filter: drop-shadow(0 0 5px #ff3d86);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: var(--brand-filter);
}

.brand-name span {
  color: transparent;
}

.tagline {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.tagline em {
  font-style: italic;
  color: var(--ink);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip--ghost {
  background: var(--chip-bg);
  border-color: var(--line);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ shell ------------------------------ */

.shell {
  max-width: 1080px;
  margin: 0 auto;
}

.mode-bar {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  width: fit-content;
  margin: 0 auto 14px;
  background: var(--mode-bar-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.mode-tab {
  border: none;
  background: transparent;
  padding: 7px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-faint);
  transition: color 0.15s ease, background 0.15s ease;
}

.mode-tab:hover {
  color: var(--ink);
}

.mode-tab.is-active {
  background: var(--mode-active-bg);
  color: var(--mode-active-ink);
  box-shadow: var(--mode-active-ring);
}

.lede {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-bottom: 16px;
  min-height: 1.4em;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .legend-arrows span {
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 1px;
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  display: inline-block;
  flex: none;
}

.swatch--exact {
  background: var(--exact);
}

.swatch--partial {
  background: var(--partial);
}

.swatch--miss {
  background: var(--miss);
  border: 1px solid var(--line-strong);
}

/* ------------------------------ search ------------------------------ */

.search {
  max-width: 560px;
  margin: 0 auto 26px;
  position: relative;
}

.search-form {
  margin: 0;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  font-size: 20px;
  color: var(--ink-faint);
  pointer-events: none;
  transform: translateY(-1px);
}

.search-input {
  width: 100%;
  height: 54px;
  padding: 0 108px 0 44px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  font: inherit;
  /* 16px minimum: iOS Safari zooms the page when a focused input is smaller. */
  font-size: 16px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

.search-input::placeholder {
  color: var(--ink-faint);
}

.search-input:hover:not(:disabled) {
  border-color: var(--input-hover-border);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.14), var(--shadow-sm);
}

.search-input:disabled {
  background: var(--surface-2);
  color: var(--ink-faint);
  cursor: not-allowed;
}

.guess-button {
  position: absolute;
  right: 6px;
  top: 6px;
  bottom: 6px;
  padding: 0 20px;
  border: none;
  border-radius: 12px;
  background-color: var(--button);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.06));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  box-shadow: var(--guess-shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease,
    background-color 0.12s ease;
}

.guess-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background-color: var(--button-hover);
  box-shadow: var(--guess-hover-shadow);
}

.guess-button:active:not(:disabled) {
  transform: translateY(0);
}

.guess-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.search-hint,
.search-error {
  margin-top: 8px;
  font-size: 12px;
  text-align: center;
  min-height: 1.2em;
}

.search-hint {
  color: var(--ink-faint);
}

.search-error {
  color: var(--error-ink);
  font-weight: 600;
}

.search-error:empty {
  display: none;
}

/* suggestions */

.suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(360px, 55vh);
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: dropIn 0.12s ease-out;
  scrollbar-width: thin;
  scrollbar-color: var(--suggestion-scrollbar) transparent;
}

.suggestions::-webkit-scrollbar {
  width: 8px;
}

.suggestions::-webkit-scrollbar-track {
  background: transparent;
}

.suggestions::-webkit-scrollbar-thumb {
  background: var(--suggestion-thumb);
  border-radius: 8px;
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 0;
  cursor: pointer;
  scroll-margin: 6px;
  /* Each row is tinted by the apostle's personality colour. */
  background-color: hsl(var(--hue, 270) var(--suggestion-sat) var(--suggestion-l));
}

.suggestion[aria-selected="true"],
.suggestion:hover {
  background-color: hsl(
    var(--hue, 270) var(--suggestion-hover-sat) var(--suggestion-hover-l)
  );
}

.suggestion.is-guessed {
  opacity: 0.42;
  cursor: default;
  filter: grayscale(0.7);
}

.suggestion.is-guessed:hover {
  background-color: hsl(var(--hue, 270) var(--suggestion-sat) var(--suggestion-l));
}

.suggestion-name {
  font-weight: 700;
  font-size: 14px;
}

.suggestion-dot {
  margin-left: auto;
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: hsl(var(--hue) 70% 62%);
  box-shadow: inset 0 0 0 1px var(--dot-ring);
}

.suggestion-empty {
  padding: 16px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ------------------------------ board ------------------------------ */

.board-region {
  position: relative;
}

.board-scroll {
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.board {
  width: 100%;
  min-width: 700px;
  border-collapse: separate;
  border-spacing: 6px;
  table-layout: fixed;
}

.board-head-cell {
  padding: 0 4px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: center;
  white-space: nowrap;
}

.board-head-cell:first-child {
  text-align: left;
  padding-left: 10px;
}

.board .col-name {
  width: 216px;
}

.cell {
  height: 58px;
  padding: 8px;
  border-radius: 14px;
  background: var(--miss);
  color: var(--miss-ink);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--cell-border);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.cell .cell-value {
  display: inline-block;
}

.cell .arrow {
  display: block;
  font-size: 9px;
  line-height: 1;
  margin-top: 3px;
  opacity: 0.9;
}

.cell.state-exact {
  background-color: var(--exact);
  color: var(--exact-ink);
  border-color: transparent;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.cell.state-partial {
  background-color: var(--partial);
  color: var(--partial-ink);
  border-color: transparent;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

.cell.state-miss {
  background-color: var(--miss);
  color: var(--miss-ink);
}

/* name column */

.cell--name {
  text-align: left;
  color: var(--ink);
  /* The name cell is tinted with the apostle's personality colour. */
  background-color: hsl(var(--hue, 270) var(--name-sat) var(--name-l));
  border: 1px solid hsl(var(--hue, 270) var(--name-border-sat) var(--name-border-l));
  padding: 7px 10px;
}

.cell--name .apostle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.apostle-name {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  --hue: 270;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink);
  background-image: linear-gradient(
    140deg,
    hsl(var(--hue) var(--avatar-sat-1) var(--avatar-l-1)),
    hsl(var(--hue) var(--avatar-sat-2) var(--avatar-l-2))
  );
  box-shadow: inset 0 0 0 1px var(--avatar-ring), 0 1px 3px var(--avatar-shadow);
}

.avatar.has-image {
  overflow: hidden;
  background-image: none;
  background-color: var(--surface-2);
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.board tbody tr.is-correct .cell--name {
  border-color: var(--exact);
  box-shadow: 0 0 0 2px var(--correct-ring);
}

.board tbody tr.is-new .cell {
  animation: cellIn 0.3s ease-out both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

@keyframes cellIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.board-empty {
  margin: 14px auto 0;
  padding: 26px 20px;
  max-width: 720px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--empty-bg);
}

.board-empty[hidden] {
  display: none;
}

/* ------------------------------ result ------------------------------ */

.result {
  max-width: 620px;
  margin: 0 auto 22px;
}

.result[hidden] {
  display: none;
}

.result-card {
  position: relative;
  overflow: hidden;
  padding: 26px 24px 22px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  animation: cardIn 0.35s ease-out both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.result-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.result-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 10px 0 4px;
}

.result-answer .avatar {
  width: 54px;
  height: 54px;
  font-size: 17px;
}

.result-name {
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.result-score {
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.result-community {
  max-width: 470px;
  margin: 16px auto 0;
}

.community-note {
  margin: 0;
  color: var(--ink-faint);
  font-size: 12px;
}

.community-headline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.community-headline strong {
  color: var(--ink);
  font-weight: 800;
}

.community-average {
  margin: 3px 0 0;
  color: var(--ink-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.community-average strong {
  color: var(--ink-soft);
}

.community-chart {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
  margin-top: 12px;
}

.community-bin {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.community-count {
  color: var(--ink-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.community-bar {
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 2px 2px;
  background: var(--surface-3);
  transition: height 0.25s ease;
}

.community-bar.level-0 {
  height: 3px;
  background: var(--line);
}

.community-bar.level-1 {
  height: 8px;
}

.community-bar.level-2 {
  height: 13px;
}

.community-bar.level-3 {
  height: 18px;
}

.community-bar.level-4 {
  height: 23px;
}

.community-bar.level-5 {
  height: 28px;
}

.community-bar.level-6 {
  height: 34px;
}

.community-bar.level-7 {
  height: 40px;
}

.community-bar.level-8 {
  height: 46px;
}

.community-bar.level-9 {
  height: 51px;
}

.community-bar.level-10 {
  height: 56px;
}

.community-label {
  color: var(--ink-faint);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.community-bin.is-you .community-bar {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}

.community-bin.is-you .community-count,
.community-bin.is-you .community-label {
  color: var(--ink);
  font-weight: 800;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.button {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background-color: var(--button);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.06));
  color: #fff;
  box-shadow: var(--primary-shadow);
}

.button--primary:hover {
  background-color: var(--button-hover);
}

.button--ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.button--ghost:hover {
  background: var(--surface-3);
}

.result-next {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.result-stats {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

.stats {
  margin: 16px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.stats[hidden] {
  display: none;
}

/* ------------------------------ footer ------------------------------ */

.footer {
  max-width: 760px;
  margin: 46px auto 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-faint);
}

.footer p + p {
  margin-top: 6px;
}

.footer-more {
  margin-top: 9px;
}

.more-info-link {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--accent-2);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.more-info-link:hover {
  color: var(--accent);
}

/* ------------------------------ dialog ------------------------------ */

.dialog {
  width: min(620px, calc(100% - 32px));
  max-height: 86vh;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--dialog-shadow);
}

.dialog::backdrop {
  background: var(--dialog-backdrop);
  backdrop-filter: blur(3px);
}

.dialog-body {
  padding: 28px 28px 26px;
  max-height: calc(86vh - 2px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dialog-body::-webkit-scrollbar {
  display: none;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dialog-head h2 {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.dialog-close {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1;
}

.dialog-close:hover {
  background: var(--surface-3);
}

.dialog p {
  color: var(--ink-soft);
  font-size: 0.925rem;
  margin-bottom: 14px;
}

.dialog h3 {
  margin: 20px 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.help-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.help-intro {
  margin-top: -4px;
}

.help-legend li {
  display: grid;
  grid-template-columns: 13px 3.8em minmax(0, 1fr);
  column-gap: 9px;
  align-items: start;
}

.help-legend .swatch {
  grid-column: 1;
  margin-top: 4px;
}

.help-legend .legend-icon {
  width: 13px;
  grid-column: 1;
}

.help-legend strong {
  grid-column: 2;
  color: var(--ink);
}

.help-legend .legend-copy {
  grid-column: 3;
  min-width: 0;
}

.help-columns {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 7px 16px;
  margin: 0;
  font-size: 0.9rem;
}

.help-columns dt {
  font-weight: 700;
  color: var(--ink);
}

.help-columns dd {
  margin: 0;
  color: var(--ink-soft);
}

.help-notes {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  display: grid;
  gap: 5px;
}

.dialog-cta {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  border: none;
  border-radius: 13px;
  background: var(--cta-bg);
  color: var(--cta-ink);
  font-weight: 700;
  font-size: 14px;
}

.dialog-cta:hover {
  background: var(--cta-hover-bg);
}

/* ------------------------------ toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  z-index: 60;
  padding: 11px 20px;
  border: 1px solid var(--toast-border);
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.announce {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 900px) {
  .board {
    min-width: 640px;
  }

  .cell {
    font-size: 12px;
  }

  .board .col-name {
    width: 180px;
  }
}

@media (max-width: 900px) {
  body {
    padding: 0 14px 32px;
  }

  .corner-cluster {
    top: 10px;
    left: 12px;
    gap: 6px;
  }

  .corner-cluster .corner-button {
    padding: 5px 10px 5px 5px;
    gap: 6px;
  }

  .corner-button--right {
    top: 10px;
    right: 12px;
    padding: 5px;
    gap: 0;
  }

  .corner-label {
    display: none;
  }

  /* The two left-hand modes keep their wording on phones; the help button
     stays a compact question mark. */
  .corner-cluster .corner-label {
    display: inline;
    font-size: 11px;
  }

  .corner-mark {
    width: 24px;
    height: 24px;
  }

  .masthead {
    padding-top: 56px;
  }

  .chips {
    gap: 6px;
  }

  .chip {
    font-size: 11px;
    padding: 5px 10px;
  }

  .board-scroll {
    overflow: visible;
    padding: 0;
  }

  .board {
    min-width: 0;
    border-spacing: 0;
    table-layout: auto;
  }

  .board thead {
    display: none;
  }

  .board,
  .board tbody,
  .board tr,
  .board td {
    display: block;
  }

  .board tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
    padding: 9px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .board tbody td {
    height: auto;
    min-height: 52px;
    padding: 8px 11px;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
  }

  .board tbody td::before {
    content: attr(data-label);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    opacity: 0.72;
    line-height: 1.2;
  }

  .board tbody td .arrow {
    display: inline;
    margin: 0 0 0 4px;
    font-size: 10px;
  }

  .board tbody .cell--name {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 6px 8px;
    min-height: 0;
    background-color: hsl(var(--hue, 270) var(--name-sat) var(--name-l));
    border: none;
    border-bottom: 1px solid hsl(var(--hue, 270) var(--name-border-sat) var(--name-border-l));
    border-radius: 10px;
    text-align: left;
  }

  .board tbody .cell--name::before {
    display: none;
  }

  .apostle-name {
    font-size: 15px;
  }

  .board tbody tr.is-correct .cell--name {
    box-shadow: none;
    border-color: hsl(var(--hue, 270) var(--name-border-sat) var(--name-border-l));
  }

  .suggestion-meta {
    display: none;
  }

  .result-card {
    padding: 22px 18px 18px;
  }

  .footer {
    margin-top: 34px;
  }

  .dialog-body {
    padding: 22px 20px 20px;
  }

  .help-columns {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .help-columns dd {
    margin-bottom: 8px;
  }
}

@media (max-width: 420px) {
  .search-input {
    padding-left: 40px;
    padding-right: 96px;
    font-size: 16px;
  }

  .guess-button {
    padding: 0 14px;
    font-size: 13px;
  }

  .board tbody td {
    padding: 7px 9px;
    min-height: 46px;
  }

  .cell--name {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
