/* ==========================================================================
   RandomChat design system
   Theme is driven by [data-theme="light|dark"] on <html>.
   Layout uses logical properties so RTL (Arabic) mirrors automatically.
   ========================================================================== */

:root {
  --hf-radius-sm: 8px;
  --hf-radius: 14px;
  --hf-radius-lg: 22px;
  --hf-radius-pill: 999px;

  --hf-accent: #5b5bd6;
  --hf-accent-strong: #4646c4;
  --hf-accent-soft: rgba(91, 91, 214, 0.12);
  --hf-danger: #d64545;
  --hf-danger-soft: rgba(214, 69, 69, 0.12);
  --hf-warn: #b7791f;
  --hf-warn-soft: rgba(183, 121, 31, 0.14);
  --hf-success: #2f9e6a;

  --hf-font: "Pretendard", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans KR", "Noto Sans JP", "Noto Sans SC", "Noto Sans Arabic",
    "Noto Sans Devanagari", Roboto, "Helvetica Neue", sans-serif;
  --hf-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --hf-header-height: 58px;
  --hf-shadow-sm: 0 1px 2px rgba(15, 18, 34, 0.06);
  --hf-shadow: 0 6px 24px rgba(15, 18, 34, 0.08);
  --hf-shadow-lg: 0 18px 48px rgba(15, 18, 34, 0.16);
}

html[data-theme="light"] {
  --hf-bg: #f4f5f9;
  --hf-bg-elevated: #ffffff;
  --hf-bg-sunken: #eceef4;
  --hf-border: #dfe2ec;
  --hf-border-strong: #c6cad9;
  --hf-text: #16182a;
  --hf-text-muted: #666a80;
  --hf-text-faint: #8c90a6;
  --hf-bubble-me: linear-gradient(135deg, #5b5bd6, #7a5bf0);
  --hf-bubble-me-text: #ffffff;
  --hf-bubble-partner: #ffffff;
  --hf-bubble-partner-text: #16182a;
  color-scheme: light;
}

html[data-theme="dark"] {
  --hf-bg: #0e1117;
  --hf-bg-elevated: #171b24;
  --hf-bg-sunken: #0a0d13;
  --hf-border: #262b37;
  --hf-border-strong: #363c4b;
  --hf-text: #e9ecf5;
  --hf-text-muted: #a3a9bd;
  --hf-text-faint: #767c91;
  --hf-accent: #8b8bff;
  --hf-accent-strong: #a0a0ff;
  --hf-accent-soft: rgba(139, 139, 255, 0.16);
  --hf-bubble-me: linear-gradient(135deg, #4b4bd0, #6d4be0);
  --hf-bubble-me-text: #ffffff;
  --hf-bubble-partner: #1e2331;
  --hf-bubble-partner-text: #e9ecf5;
  --hf-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --hf-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --hf-shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--hf-font);
  background: var(--hf-bg);
  color: var(--hf-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--hf-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5em;
  line-height: 1.25;
  font-weight: 700;
}

p {
  margin: 0 0 0.85em;
}

.hf-hidden {
  display: none !important;
}

.hf-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- header -- */

.hf-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--hf-header-height);
  padding-inline: 16px;
  padding-top: env(safe-area-inset-top, 0);
  background: color-mix(in srgb, var(--hf-bg-elevated) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hf-border);
}

.hf-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 17px;
  color: var(--hf-text);
  white-space: nowrap;
}

.hf-brand:hover {
  text-decoration: none;
}

.hf-brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--hf-accent), #9a5bf0);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  flex: none;
}

.hf-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.hf-nav::-webkit-scrollbar {
  display: none;
}

.hf-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--hf-radius-pill);
  color: var(--hf-text-muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

/*
 * Count badge on a navigation item (chat / community / my page). It is a sibling
 * of the label, so re-translating the label never wipes it.
 */
.hf-nav__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--hf-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex: none;
}

.hf-nav__link:hover {
  background: var(--hf-bg-sunken);
  color: var(--hf-text);
  text-decoration: none;
}

.hf-nav__link[aria-current="page"] {
  background: var(--hf-accent-soft);
  color: var(--hf-accent);
}

.hf-header__spacer {
  flex: 1;
}

.hf-header__tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --------------------------------------------------------------- controls -- */

.hf-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--hf-radius);
  background: var(--hf-accent);
  color: #fff;
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.hf-btn:hover:not(:disabled) {
  filter: brightness(1.07);
}

.hf-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.hf-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hf-btn--ghost {
  background: transparent;
  border-color: var(--hf-border-strong);
  color: var(--hf-text);
}

.hf-btn--ghost:hover:not(:disabled) {
  background: var(--hf-bg-sunken);
  filter: none;
}

.hf-btn--subtle {
  background: var(--hf-bg-sunken);
  color: var(--hf-text);
}

.hf-btn--danger {
  background: var(--hf-danger);
}

.hf-btn--danger-ghost {
  background: transparent;
  border-color: var(--hf-danger);
  color: var(--hf-danger);
}

.hf-btn--block {
  width: 100%;
}

.hf-btn--lg {
  padding: 14px 26px;
  font-size: 16px;
  border-radius: var(--hf-radius-lg);
}

.hf-btn--icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: var(--hf-radius-sm);
  background: transparent;
  color: var(--hf-text-muted);
}

.hf-btn--icon:hover:not(:disabled) {
  background: var(--hf-bg-sunken);
  color: var(--hf-text);
  filter: none;
}

.hf-badge-dot {
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--hf-radius-pill);
  background: var(--hf-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ icons ------ */

.hf-icon {
  display: block;
  width: 19px;
  height: 19px;
  flex: none;
}

/*
 * Game shortcut in the header bar. Phones only - on desktop the same link is a
 * normal item in the inline navigation.
 */
.hf-header__game {
  display: none;
  width: auto;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--hf-radius-pill);
  background: var(--hf-accent-soft);
  color: var(--hf-accent);
}

.hf-header__game:hover:not(:disabled) {
  background: var(--hf-accent-soft);
  color: var(--hf-accent-strong, var(--hf-accent));
}

.hf-header__game-label {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* Small tag next to a partner name (their MBTI, when it was shared). */
.hf-persona-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--hf-radius-pill);
  background: var(--hf-accent-soft);
  color: var(--hf-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  flex: none;
}

/*
 * Nicknames can be long ("Marshmallow", "स्पाइडरमैन"), so anything showing one
 * has to shrink instead of pushing the layout around.
 */
.hf-truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Gender / age / MBTI chips next to a partner name. */
.hf-persona-tags {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

/* -------------------------------------------------------- nav drawer ------ */

/* Hidden on desktop; the header bar shows the links inline there. */
.hf-menu-toggle {
  display: none;
}

.hf-drawer {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.hf-drawer--open {
  visibility: visible;
  opacity: 1;
}

.hf-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 18, 0.55);
  backdrop-filter: blur(2px);
}

.hf-drawer__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(84vw, 320px);
  height: 100%;
  padding: 14px;
  padding-top: calc(14px + env(safe-area-inset-top, 0));
  background: var(--hf-bg-elevated);
  border-inline-end: 1px solid var(--hf-border);
  box-shadow: var(--hf-shadow-lg);
  overflow-y: auto;
}

.hf-drawer__head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hf-border);
}

.hf-drawer__title {
  flex: 1;
  font-weight: 800;
  font-size: 16px;
}

.hf-drawer__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hf-drawer__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 14px;
  border-radius: var(--hf-radius);
  color: var(--hf-text);
  font-size: 15px;
  font-weight: 600;
}

/* The count sits at the end of the row, like a mail inbox list. */
.hf-drawer__link .hf-nav__label {
  flex: 1;
}

.hf-drawer__link:hover {
  background: var(--hf-bg-sunken);
  text-decoration: none;
}

.hf-drawer__link[aria-current="page"] {
  background: var(--hf-accent-soft);
  color: var(--hf-accent);
}

/* Tool entries only shown on phones, where the header bar hides them. */
.hf-drawer__tools {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--hf-border);
}

.hf-drawer__tool {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--hf-radius);
  background: transparent;
  color: var(--hf-text-muted);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}

.hf-drawer__tool:hover {
  background: var(--hf-bg-sunken);
  color: var(--hf-text);
}

.hf-drawer__tool .hf-badge-dot {
  position: static;
  margin-inline-start: auto;
}

body.hf-scroll-lock {
  overflow: hidden;
}

.hf-input,
.hf-select,
.hf-textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--hf-text);
  background: var(--hf-bg-elevated);
  border: 1px solid var(--hf-border-strong);
  border-radius: var(--hf-radius);
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hf-textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.6;
}

.hf-input:focus,
.hf-select:focus,
.hf-textarea:focus {
  border-color: var(--hf-accent);
  box-shadow: 0 0 0 3px var(--hf-accent-soft);
}

.hf-field {
  margin-bottom: 14px;
}

.hf-label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--hf-text-muted);
  margin-bottom: 6px;
}

.hf-hint {
  font-size: 12px;
  color: var(--hf-text-faint);
  margin-top: 5px;
}

.hf-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 10px;
}

.hf-check input {
  margin-top: 3px;
  accent-color: var(--hf-accent);
  width: 17px;
  height: 17px;
  flex: none;
}

.hf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.hf-chip {
  border: 1px solid var(--hf-border-strong);
  background: var(--hf-bg-elevated);
  color: var(--hf-text-muted);
  border-radius: var(--hf-radius-pill);
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hf-chip[aria-pressed="true"] {
  background: var(--hf-accent-soft);
  border-color: var(--hf-accent);
  color: var(--hf-accent);
}

.hf-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.hf-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.hf-switch__track {
  width: 50px;
  height: 29px;
  border-radius: var(--hf-radius-pill);
  background: var(--hf-border-strong);
  position: relative;
  transition: background 0.18s ease;
  flex: none;
}

.hf-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--hf-shadow-sm);
  transition: transform 0.18s ease;
}

.hf-switch input:checked + .hf-switch__track {
  background: var(--hf-accent);
}

.hf-switch input:checked + .hf-switch__track::after {
  transform: translateX(21px);
}

[dir="rtl"] .hf-switch input:checked + .hf-switch__track::after {
  transform: translateX(-21px);
}

/* ---------------------------------------------------------------- layout -- */

.hf-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}

.hf-main--wide {
  max-width: 1320px;
}

.hf-main--flush {
  padding: 0;
  max-width: 100%;
}

.hf-card {
  background: var(--hf-bg-elevated);
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius-lg);
  padding: 20px;
  box-shadow: var(--hf-shadow-sm);
}

.hf-card + .hf-card {
  margin-top: 16px;
}

/*
 * The header and the footer are built by the client, so their space has to be
 * reserved here. Without this the whole page jumps down when they appear, and
 * that jump is what Cumulative Layout Shift measures - it was up to 0.097 on the
 * community page before this rule existed.
 */
#hf-header {
  min-height: var(--hf-header-height);
}

/* The daily tally and the footer are filled in after load: reserve their boxes. */
#stat-daily {
  min-height: 1.4em;
}

#hf-footer {
  /* Measured footer height, so its appearance at the end of a short page does
     not push the layout around. Phones wrap the links onto two lines. */
  min-height: 81px;
}

@media (max-width: 640px) {
  #hf-footer {
    min-height: 108px;
  }
}

.hf-card__title {
  font-size: 15px;
  font-weight: 750;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/*
 * Search-engine copy. Real headings (h2) instead of divs, so the page has a
 * heading outline for crawlers and screen readers, styled to match the cards.
 */
.hf-seo__title {
  font-size: 15px;
  font-weight: 750;
  margin: 18px 0 8px;
}

.hf-seo__title:first-child {
  margin-top: 0;
}

.hf-seo__text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
}

/* The "more to do here" links under the games page. */
.hf-seo__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding-left: 1.1em;
  font-size: 14px;
}

.hf-seo__links a {
  color: var(--hf-accent-strong);
  text-decoration: none;
}

.hf-seo__links a:hover {
  text-decoration: underline;
}

.hf-seo__faq {  margin: 0;
}

.hf-seo__faq dt {
  font-weight: 650;
  font-size: 13.5px;
  margin-top: 12px;
}

.hf-seo__faq dd {
  margin: 4px 0 0;
  font-size: 13.5px;
  line-height: 1.7;
}

.hf-seo__list {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.7;
}

.hf-seo__list li + li {
  margin-top: 6px;
}

.hf-grid {
  display: grid;
  gap: 16px;
}

.hf-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hf-row--between {
  justify-content: space-between;
}

.hf-stack > * + * {
  margin-top: 12px;
}

.hf-empty {
  text-align: center;
  color: var(--hf-text-faint);
  font-size: 14px;
  padding: 28px 12px;
}

.hf-muted {
  color: var(--hf-text-muted);
}

.hf-faint {
  color: var(--hf-text-faint);
}

.hf-small {
  font-size: 12.5px;
}

.hf-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--hf-radius-pill);
  background: var(--hf-accent-soft);
  color: var(--hf-accent);
}

.hf-badge--partner {
  background: linear-gradient(135deg, var(--hf-accent), #9a5bf0);
  color: #fff;
}

.hf-badge--warn {
  background: var(--hf-warn-soft);
  color: var(--hf-warn);
}

.hf-badge--danger {
  background: var(--hf-danger-soft);
  color: var(--hf-danger);
}

.hf-divider {
  height: 1px;
  background: var(--hf-border);
  margin: 16px 0;
}

/* ------------------------------------------------------------------ home -- */

.hf-hero {
  text-align: center;
  padding: 46px 16px 34px;
}

.hf-hero h1 {
  font-size: clamp(28px, 6vw, 46px);
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.hf-hero__sub {
  font-size: clamp(15px, 2.4vw, 18px);
  color: var(--hf-text-muted);
  max-width: 620px;
  margin: 0 auto 26px;
}

.hf-hero__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hf-livebar {
  display: flex;
  justify-content: center;
  gap: 26px;
  flex-wrap: wrap;
  margin-top: 28px;
  font-size: 13px;
  color: var(--hf-text-muted);
}

.hf-livebar b {
  display: block;
  font-size: 21px;
  color: var(--hf-text);
  font-variant-numeric: tabular-nums;
}

.hf-livebar__value {
  display: flex !important;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

/* --- rolling digit counter ------------------------------------------------ */

.hf-counter {
  display: inline-flex;
  align-items: baseline;
  line-height: 1;
  /* The digits arrive from the live counter, so reserve their line box: an empty
     counter is 0px tall and the whole hero moves when the numbers land. */
  min-height: 1.15em;
  font-variant-numeric: tabular-nums;
  /*
   * Digits must read left-to-right even inside an RTL page. Without this the
   * per-digit spans are laid out right-to-left and "3,018" renders as "810,3".
   */
  direction: ltr;
  unicode-bidi: isolate;
}

.hf-counter__digit {
  display: inline-block;
  height: 1em;
  overflow: hidden;
}

.hf-counter__strip {
  display: block;
  transition: transform 0.75s cubic-bezier(0.22, 0.9, 0.3, 1);
  will-change: transform;
}

.hf-counter__strip > span {
  display: block;
  height: 1em;
  line-height: 1;
}

.hf-counter__sep {
  display: inline-block;
  height: 1em;
  line-height: 1;
}

/* --- change badge --------------------------------------------------------- */

.hf-delta {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: start;
  /* Keep "+12" / "-7" reading the same way in RTL layouts. */
  direction: ltr;
  unicode-bidi: isolate;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.hf-delta--up {
  color: #2f9e6a;
}

.hf-delta--down {
  color: #d64545;
}

@media (prefers-reduced-motion: reduce) {
  .hf-counter__strip {
    transition: none;
  }
}

.hf-featuregrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.hf-feature {
  background: var(--hf-bg-elevated);
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius);
  padding: 18px;
  font-size: 14px;
}

.hf-feature__icon {
  margin-bottom: 10px;
  color: var(--hf-accent);
}

.hf-icon--feature {
  width: 24px;
  height: 24px;
}

.hf-steps {
  counter-reset: step;
  display: grid;
  gap: 12px;
}

.hf-step {
  counter-increment: step;
  position: relative;
  padding-inline-start: 46px;
  font-size: 14.5px;
}

.hf-step::before {
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--hf-accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
}

.hf-notice {
  border-radius: var(--hf-radius);
  padding: 11px 14px;
  font-size: 13.5px;
  background: var(--hf-accent-soft);
  color: var(--hf-text);
  margin-bottom: 16px;
}

.hf-notice--warn {
  background: var(--hf-warn-soft);
}

.hf-notice--danger {
  background: var(--hf-danger-soft);
}

.hf-ads {
  margin: 20px auto;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--hf-radius);
}

.hf-ads:empty {
  display: none;
}

/* ------------------------------------------------------------------ chat -- */

.hf-chat {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--hf-header-height));
  max-width: 840px;
  margin: 0 auto;
  background: var(--hf-bg-elevated);
  position: relative;
}

@media (min-width: 861px) {
  .hf-chat {
    height: calc(100dvh - var(--hf-header-height) - 32px);
    margin: 16px auto;
    border: 1px solid var(--hf-border);
    border-radius: var(--hf-radius-lg);
    overflow: hidden;
    box-shadow: var(--hf-shadow);
  }
}

.hf-chat__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hf-border);
  background: var(--hf-bg-elevated);
  flex: none;
  z-index: 5;
}

.hf-chat__who {
  flex: 1;
  min-width: 0;
}

/*
 * The nickname keeps its ellipsis (.hf-truncate) and the persona pills keep their
 * size (.hf-persona-tags has `flex: none`), so on a phone the pills drop to a second
 * line instead of being squeezed and clipped mid-chip.
 */
.hf-chat__name {
  font-weight: 700;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  row-gap: 4px;
  min-width: 0;
}

.hf-chat__status {
  font-size: 12px;
  color: var(--hf-text-faint);
  min-height: 17px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hf-chat__status--typing {
  color: var(--hf-accent);
}

@media (max-width: 560px) {
  /*
   * On a phone the bar holds the back button, the name, three persona pills, this
   * badge and two icon buttons. Dropping the points badge is what gives the pills
   * their room; the same number is on My page.
   */
  .hf-chat__bar #chat-points {
    display: none;
  }
}

.hf-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overscroll-behavior: contain;
}

.hf-msg {
  max-width: min(78%, 560px);
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  animation: hf-pop 0.16s ease-out;
}

@keyframes hf-pop {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.hf-msg--me {
  align-self: flex-end;
  background: var(--hf-bubble-me);
  color: var(--hf-bubble-me-text);
  border-end-end-radius: 6px;
}

.hf-msg--partner {
  align-self: flex-start;
  background: var(--hf-bubble-partner);
  color: var(--hf-bubble-partner-text);
  border: 1px solid var(--hf-border);
  border-end-start-radius: 6px;
}

.hf-msg--system {
  align-self: center;
  max-width: 92%;
  background: var(--hf-bg-sunken);
  color: var(--hf-text-muted);
  font-size: 12.5px;
  text-align: center;
  border-radius: var(--hf-radius-pill);
  padding: 6px 14px;
  animation: none;
}

.hf-msg--warn {
  background: var(--hf-warn-soft);
  color: var(--hf-warn);
}

.hf-msg__meta {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 3px;
}

.hf-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 11px 14px;
  background: var(--hf-bubble-partner);
  border: 1px solid var(--hf-border);
  border-radius: 18px;
  border-end-start-radius: 6px;
}

.hf-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hf-text-faint);
  animation: hf-blink 1.2s infinite;
}

.hf-typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.hf-typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes hf-blink {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.hf-composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--hf-border);
  background: var(--hf-bg-elevated);
}

.hf-composer__input {
  flex: 1;
  min-height: 42px;
  max-height: 128px;
  resize: none;
  border-radius: var(--hf-radius-lg);
  padding: 11px 15px;
}

.hf-composer__count {
  font-size: 11px;
  color: var(--hf-text-faint);
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.hf-emojis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
  max-height: 190px;
  overflow-y: auto;
}

.hf-emojis button {
  font-size: 21px;
  border: 0;
  background: transparent;
  border-radius: var(--hf-radius-sm);
  padding: 6px;
  cursor: pointer;
  line-height: 1;
}

.hf-emojis button:hover {
  background: var(--hf-bg-sunken);
}

/* -------------------------------------------------------------- overlays -- */

.hf-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--hf-bg-elevated);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px 20px;
}

.hf-overlay__inner {
  max-width: 420px;
  width: 100%;
}

.hf-spinner {
  width: 58px;
  height: 58px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 4px solid var(--hf-accent-soft);
  border-top-color: var(--hf-accent);
  animation: hf-spin 0.9s linear infinite;
}

@keyframes hf-spin {
  to {
    transform: rotate(360deg);
  }
}

.hf-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 18, 0.55);
  backdrop-filter: blur(3px);
  animation: hf-fade 0.14s ease-out;
}

@keyframes hf-fade {
  from {
    opacity: 0;
  }
}

.hf-modal__panel {
  background: var(--hf-bg-elevated);
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius-lg);
  width: 100%;
  max-width: 440px;
  max-height: min(86dvh, 720px);
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--hf-shadow-lg);
  animation: hf-rise 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.hf-modal__panel--wide {
  max-width: 680px;
}

@keyframes hf-rise {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
}

.hf-modal__title {
  font-size: 18px;
  font-weight: 750;
  margin-bottom: 8px;
}

.hf-modal__body {
  font-size: 14px;
  color: var(--hf-text-muted);
  margin-bottom: 18px;
}

.hf-modal__actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 6px;
}

.hf-toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding-inline: 16px;
}

.hf-toast {
  pointer-events: auto;
  background: var(--hf-text);
  color: var(--hf-bg);
  border-radius: var(--hf-radius-pill);
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--hf-shadow-lg);
  animation: hf-rise 0.2s ease-out;
  max-width: 100%;
}

.hf-toast--warn {
  background: var(--hf-warn);
  color: #fff;
}

.hf-toast--danger {
  background: var(--hf-danger);
  color: #fff;
}

/* ---------------------------------------------------------------- notes -- */

.hf-notes {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  min-height: 380px;
}

.hf-notes__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 560px;
  overflow-y: auto;
  border-inline-end: 1px solid var(--hf-border);
  padding-inline-end: 10px;
}

.hf-notes__item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--hf-text);
  font: inherit;
  text-align: start;
  border-radius: var(--hf-radius);
  padding: 10px 12px;
  cursor: pointer;
  display: block;
  width: 100%;
}

.hf-notes__item:hover {
  background: var(--hf-bg-sunken);
}

.hf-notes__item[aria-selected="true"] {
  background: var(--hf-accent-soft);
  border-color: var(--hf-accent);
}

.hf-notes__item b {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
}

.hf-notes__item span {
  display: block;
  font-size: 12px;
  color: var(--hf-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hf-notes__panel {
  display: flex;
  flex-direction: column;
  min-height: 340px;
}

.hf-notes__log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 2px 12px;
  max-height: 420px;
}

.hf-notes__back {
  display: none;
}

@media (max-width: 760px) {
  .hf-notes {
    grid-template-columns: 1fr;
  }
  .hf-notes__list {
    border-inline-end: 0;
    max-height: none;
  }
  .hf-notes--open .hf-notes__list {
    display: none;
  }
  .hf-notes:not(.hf-notes--open) .hf-notes__panel {
    display: none;
  }
  .hf-notes__back {
    display: inline-flex;
  }
}

/* -------------------------------------------------------------- community -- */

.hf-post {
  border-bottom: 1px solid var(--hf-border);
  padding: 16px 4px;
}

.hf-post:last-child {
  border-bottom: 0;
}

.hf-post__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--hf-text-faint);
  margin-bottom: 6px;
}

.hf-post__author {
  font-weight: 700;
  color: var(--hf-text-muted);
}

.hf-post__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--hf-text);
}

.hf-post__body {
  font-size: 14.5px;
  color: var(--hf-text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.hf-post__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--hf-text-faint);
}

.hf-like {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--hf-text-faint);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--hf-radius-pill);
}

.hf-like:hover {
  background: var(--hf-bg-sunken);
}

.hf-like[aria-pressed="true"] {
  color: var(--hf-danger);
  font-weight: 700;
}

.hf-comment {
  padding: 9px 0;
  border-top: 1px solid var(--hf-border);
  font-size: 14px;
}

/* --------------------------------------------------------------- my page -- */

.hf-statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.hf-stat {
  background: var(--hf-bg-sunken);
  border-radius: var(--hf-radius);
  padding: 13px;
  text-align: center;
}

.hf-stat b {
  display: block;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.hf-stat span {
  font-size: 12px;
  color: var(--hf-text-muted);
}

.hf-langlist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
}

.hf-langlist button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hf-border);
  background: var(--hf-bg-elevated);
  color: var(--hf-text);
  border-radius: var(--hf-radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: start;
}

.hf-langlist button[aria-pressed="true"] {
  border-color: var(--hf-accent);
  background: var(--hf-accent-soft);
  color: var(--hf-accent);
  font-weight: 700;
}

/* ----------------------------------------------------------------- admin -- */

.hf-admin {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 20px;
  align-items: start;
}

.hf-admin__tabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: calc(var(--hf-header-height) + 22px);
}

.hf-admin__tab {
  border: 0;
  background: transparent;
  color: var(--hf-text-muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: start;
  padding: 9px 13px;
  border-radius: var(--hf-radius-sm);
  cursor: pointer;
}

.hf-admin__tab:hover {
  background: var(--hf-bg-sunken);
}

.hf-admin__tab[aria-selected="true"] {
  background: var(--hf-accent-soft);
  color: var(--hf-accent);
}

.hf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.hf-table th,
.hf-table td {
  text-align: start;
  padding: 9px 8px;
  border-bottom: 1px solid var(--hf-border);
  vertical-align: top;
}

.hf-table th {
  color: var(--hf-text-faint);
  font-weight: 650;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hf-table code {
  font-family: var(--hf-mono);
  font-size: 11.5px;
  background: var(--hf-bg-sunken);
  padding: 1px 5px;
  border-radius: 5px;
}

.hf-transcript {
  font-family: var(--hf-mono);
  font-size: 12px;
  background: var(--hf-bg-sunken);
  border-radius: var(--hf-radius-sm);
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 820px) {
  .hf-admin {
    grid-template-columns: 1fr;
  }
  .hf-admin__tabs {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .hf-admin__tabs::-webkit-scrollbar {
    display: none;
  }
}

/* ---------------------------------------------------------------- footer -- */

.hf-footer {
  border-top: 1px solid var(--hf-border);
  padding: 22px 16px calc(22px + env(safe-area-inset-bottom, 0));
  font-size: 12.5px;
  color: var(--hf-text-faint);
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.hf-footer a {
  color: var(--hf-text-faint);
}

.hf-footer a:hover {
  color: var(--hf-accent);
}

@media (max-width: 720px) {
  /* Page links, tool icons and the install entry all move into the drawer. */
  .hf-menu-toggle {
    display: inline-flex;
  }
  .hf-nav {
    display: none;
  }
  .hf-header__tools {
    display: none;
  }
  .hf-header__game {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  /* Keep the logo mark, drop only the wordmark so the header stays compact. */
  .hf-brand__name {
    display: none;
  }
  .hf-main {
    padding: 16px 12px 30px;
  }
}

@media (max-width: 330px) {
  /* Safety net for very small phones: keep the icon, drop the word. */
  .hf-header {
    padding-inline: 10px;
    gap: 6px;
  }
  .hf-header__game {
    padding: 8px 10px;
  }
  .hf-header__game-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------------------------
   Trio Tiles — the puzzle on the random-games page.

   The board is a fixed rectangle that sizes itself from the card width
   (aspect-ratio 504 / 677 - taller than it is wide), and every tile is placed as a
   percentage of that rectangle, so nothing depends on
   JavaScript measurements and the layout cannot shift when the game mounts.
   Tiles are deliberately larger than their cell box at 100%: the placement math
   in game-trio.js gives them `span = grid + 0.5`, which is exactly one tile plus
   the half-cell the shifted layers need.
   --------------------------------------------------------------------------- */

.hf-trio {
  display: grid;
  gap: 12px;
  /* A 560px column, and the page gutters are trimmed on this page only (see
     `[data-page="game"]` below), so the board fills a phone screen instead of
     sitting in a narrow column with the tiles shrunk to match. */
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

/*
 * The heading and the dogs share one line: the dogs sit immediately after the
 * heading text and come down far enough to rest on the top edge of the game
 * table, so they read as perched on it.
 *
 * Flex rather than absolute on purpose - the row is exactly as tall as the
 * heading's box, so the height is right from the first paint and nothing moves
 * when the image file lands.
 */
/* Random games list: one card per row, full width, so a phone shows them stacked. */
.hf-games__title {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
}

.hf-games {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}


.hf-games__item {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--hf-radius-lg);
  background: var(--hf-bg-elevated);
  box-shadow: var(--hf-shadow);
  color: inherit;
  text-decoration: none;
}

.hf-games__art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2048 / 1071;
  object-fit: cover;
  background: var(--hf-bg-subtle, #f4f4f8);
}

/* One game = one card. The row is the tappable part; the sentence below is its own. */
.hf-games__card {
  padding: 0;
  overflow: hidden;
}

/* The card is the frame now, so the row inside it must not draw a second one. */
.hf-games__card .hf-games__item {
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

/*
 * The name line: the game's name on the left, its description toggle on the right.
 * They share one row, so a long description never pushes the name around.
 */
.hf-games__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
}

.hf-games__name {
  display: block;
  min-width: 0;
  padding: 10px 0 12px;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hf-games__toggle {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 0 8px 12px;
  border: 0;
  background: none;
  color: var(--hf-accent, #4a5cf0);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* The arrow is what says "there is more under here" without spelling it out. */
.hf-games__toggle::after {
  content: "▾";
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  transition: transform 200ms ease;
}

.hf-games__toggle[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

/*
 * The description, folded away. `grid-template-rows: 0fr -> 1fr` is what makes the
 * open/close smooth without anyone measuring the text: the row has a real height in
 * both states, so the browser can interpolate it. The inner box owns the overflow, and
 * the padding lives one level deeper on `.hf-games__text` - padding on the clipped box
 * would keep a sliver of empty card on screen even when the row collapsed to nothing.
 */
.hf-games__desc {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms ease;
}

.hf-games__desc[data-open="true"] {
  grid-template-rows: 1fr;
}

.hf-games__desc-inner {
  min-height: 0;
  overflow: hidden;
}

.hf-games__text {
  margin: 0;
  padding: 4px 16px 16px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--hf-text-muted, #54545f);
}

/* Sits in the middle of the picture, so the card reads as a game and not a poster. */
.hf-games__cta {
  position: absolute;
  inset: 0;
  width: max-content;
  height: max-content;
  margin: auto;
  padding: 13px 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
  color: #1c1c1e;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  pointer-events: none;
}

.hf-game-head {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  /* Same column as the board, so the heading and the dogs stay lined up with the
     table as it grows. */
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

/*
 * The game page keeps the header: it is how a visitor gets anywhere else, and the
 * in-game back arrow alone was not enough. Only the footer is dropped, since the game
 * page has no copy of its own to link to.
 */
body[data-page="game"] #hf-footer {
  display: none;
}

/*
 * The game fills the screen **below the header**, not the whole viewport.
 *
 * `min-height: 100dvh` on `.hf-main` asked for a full screen *after* the header had
 * already taken its share, so the page was always taller than the screen and the top
 * of the game - the clock - sat above the fold. Dragging up was the only way to see
 * it. Making the body a column and letting main take what is left removes the
 * guesswork: the height is whatever the header did not use, whatever that header is.
 *
 * The gutters are trimmed here too. The board is a fixed ratio, so its width *is* the
 * tiles' scale and the extra 15% of width is 15% bigger pieces.
 */
body[data-page="game"] {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

body[data-page="game"] .hf-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* A flex child refuses to shrink below its content without this, which is the other
     half of "the content is taller than the box". */
  min-height: 0;
  overflow: hidden;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}

/* The game card is a frame around the board, so it needs less padding than a card
   full of text. */
.hf-card--game {
  padding: 8px;
}

.hf-game-head h1 {
  margin: 0;
}

.hf-game-pets {
  flex: 0 0 auto;
  display: block;
  /*
   * Exactly the heading's own box, so the dogs read as one line of text: the h1
   * is 2em with a 1.25 line-height, so its box is 2.5em and the artwork matches
   * it. Width follows from the 621:254 ratio.
   */
  height: calc(2em * 1.25);
  width: auto;
  aspect-ratio: 621 / 254;
  /*
   * Pulled down so the paws actually meet the table. -3px is the value the
   * operator confirmed in the browser: it covers the transparent margin under the
   * paws in A.png (8px of a 254-tall image, so about 1.3px at this size) and the
   * rest clears the gap. The dogs sit on the left now, right after the heading,
   * so the card's rounded top corner no longer matters here.
   */
  margin-bottom: -3px;
  pointer-events: none;
  user-select: none;
}

/* The tile layer is its own box so repainting the board cannot disturb it. */
.hf-trio__tiles {
  position: absolute;
  inset: 0;
  display: block;
}

/*
 * The board is as tall as the pitch needs: seven grid steps plus the widest and
 * tallest piece, so a piece in the last cell is never clipped. The ratio is fixed
 * here (not measured) so the skeleton in game.html reserves exactly this box.
 */
.hf-trio__board {
  position: relative;
  aspect-ratio: 504 / 677;
  background: var(--hf-bg-sunken);
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius);
  touch-action: manipulation;
}

/*
 * A tile button is exactly the piece: its width and height come from JavaScript,
 * which knows the sheet boxes and the current scale. Nothing is sized here, which
 * is what keeps a big piece's button big and a small piece's button small.
 */
.hf-trio__tile {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.12s ease;
}

/* The card face is the piece plus a hair of gutter, so it grows with the piece. */
.hf-trio__tile::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 8px;
  background: var(--hf-bg-elevated);
  border: 1px solid var(--hf-border);
  box-shadow: var(--hf-shadow-sm);
}

.hf-trio__tile.is-buried {
  cursor: default;
  filter: brightness(0.88) saturate(0.65);
}

.hf-trio__tile:not(.is-buried):hover::before {
  border-color: var(--hf-accent);
}

.hf-trio__tile:not(.is-buried):active {
  filter: brightness(0.94);
}

.hf-trio__tile:focus-visible {
  outline: 2px solid var(--hf-accent);
  outline-offset: 2px;
}

/*
 * One tile icon, cut out of /game/B.png. Its size, its offset into the sheet and
 * the sheet's own scale all arrive as inline px from game-trio.js, because the
 * same numbers decide which tiles are buried - keeping them in one place stops
 * the art and the rules from disagreeing.
 */
.hf-trio__icon {
  position: relative;
  display: block;
  background-image: url("/game/B.png");
  background-repeat: no-repeat;
  pointer-events: none;
}

.hf-trio__slots {
  display: grid;
  grid-template-columns: repeat(var(--trio-slot-cap, 7), minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  min-height: 48px;
  background: var(--hf-bg-sunken);
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius);
}

.hf-trio__cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed var(--hf-border-strong);
  border-radius: 6px;
}

.hf-trio__cell.is-filled {
  border-style: solid;
  border-color: var(--hf-border);
  background: var(--hf-bg-elevated);
  box-shadow: var(--hf-shadow-sm);
}

/*
 * The trio pops out after sitting in the slots for a beat - the timing lives in
 * game-trio.js (TRIO_SETTLE_MS / TRIO_POP_MS) because the cells are only marked
 * once the third tile has landed. `forwards` holds the shrunken state until the
 * module repaints without these cells. The site-wide reduced-motion rule further
 * up collapses this for anyone who asks for that.
 */
@keyframes hf-trio-pop {
  to {
    transform: scale(0.25);
    opacity: 0;
  }
}

.hf-trio__cell.is-matched {
  animation: hf-trio-pop 240ms ease-in forwards;
}

.hf-trio__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  /* Reserved so the static skeleton in game.html is exactly as tall as the
     mounted game; a mismatch there is a layout shift for everything below. */
  min-height: 40px;
}

.hf-trio__hint {
  margin: 0;
  flex: 1 1 180px;
  min-height: 1.4em;
  font-size: 13px;
  color: var(--hf-text-muted);
}

.hf-trio__actions {
  display: flex;
  gap: 8px;
}

.hf-trio__revive,
.hf-trio__share {
  white-space: nowrap;
}

/*
 * The ad slot. The wrapper holds the height, not the ad itself, so an ad that
 * loads late, fails, or is blocked cannot move anything below it - the box stays
 * and simply stays empty. It sits under the game so it can never cover the board.
 */
.hf-trio__adslot {
  display: block;
  min-height: 100px;
  margin-top: 16px;
}

/* The uploaded ad: full screen, with nothing of the page behind it. */
.hf-advideo {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #000;
}

/*
 * Absolute, not `height: 100%`. A percentage height on a grid child resolves against an
 * auto-sized row, which came out as zero - the video then rendered 0px tall and only its
 * audio played.
 */
.hf-advideo__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.hf-advideo__player {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/*
 * "Ad" and the mute control share the top-left row. The row is what is positioned, not the
 * label, so the button sits beside the word at whatever width the language gives it.
 */
.hf-advideo__bar {
  position: absolute;
  inset-block-start: calc(10px + env(safe-area-inset-top));
  inset-inline-start: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hf-advideo__title {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/*
 * Mute toggle. A dark disc rather than a bare glyph, because the ad's own first frame can
 * be any colour and a white icon alone disappears on a bright one.
 */
.hf-advideo__mute {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.hf-advideo__mute:hover,
.hf-advideo__mute:focus-visible {
  background: rgba(0, 0, 0, 0.68);
}

/* The operator's link button: on screen from the first frame, over the video. */
.hf-advideo__cta {
  position: absolute;
  inset-block-end: 86px;
  inset-inline: 0;
  margin-inline: auto;
  width: max-content;
  /* The operator types this label by hand, so it can be long: keep it on one line inside
     the viewport instead of letting it run off the edges of a phone. */
  max-width: calc(100vw - 40px);
  overflow: hidden;
  padding: 13px 30px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color: #1c1c1e;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.hf-advideo__left {
  position: absolute;
  inset-block-end: 46px;
  inset-inline: 0;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  text-align: center;
}

/* Only revealed once the time has been served. */
.hf-advideo__close {
  position: absolute;
  inset-block-end: calc(14px + env(safe-area-inset-bottom));
  inset-inline-end: 14px;
}

/* Admin — the ad-video card reuses the form look, with two small helpers. */
.hf-admin__hint {
  margin: 0 0 10px;
  color: var(--hf-text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.hf-field__label {
  display: block;
  margin: 0 0 4px;
  color: var(--hf-text-muted);
  font-size: 12px;
  font-weight: 500;
}

.hf-admin__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* Each share destination gets a logo tile; picking one is the completed attempt. */
/*
 * One uploaded ad video in the console: its size, then the link and label that belong to
 * that video. A rule between rows is what tells the operator these are separate ads and
 * not one form with repeated fields.
 */
.hf-admin__adrow {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--hf-border, #e6e6ee);
}

/* Blog — rendered on the server, styled with the same cards as the rest of the site. */
.hf-blog__title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.35;
  word-break: keep-all;
}

.hf-blog__intro {
  margin: 0 0 20px;
  color: var(--hf-text-muted);
  font-size: 14px;
  line-height: 1.7;
}

.hf-blog__list {
  display: grid;
  gap: 10px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.hf-blog__link {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius);
  color: inherit;
  text-decoration: none;
}

.hf-blog__link:hover,
.hf-blog__link:focus-visible {
  background: var(--hf-bg-sunken);
}

.hf-blog__card-title {
  font-size: 15px;
  font-weight: 600;
  word-break: keep-all;
}

.hf-blog__excerpt {
  color: var(--hf-text-muted);
  font-size: 13px;
  line-height: 1.6;
  word-break: keep-all;
}

.hf-blog__minutes {
  color: var(--hf-text-muted);
  font-size: 12px;
}

.hf-blog h2 {
  margin: 22px 0 8px;
  font-size: 17px;
  line-height: 1.4;
  word-break: keep-all;
}

/* The h3 sits inside an h2 section, so it has to read as a level below it: smaller,
   tighter, and with less air above than the h2 that introduced the section. */
.hf-blog h3 {
  margin: 16px 0 6px;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 600;
  opacity: 0.9;
  word-break: keep-all;
}

.hf-blog p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.8;
  word-break: keep-all;
}

.hf-blog__cta {
  margin: 24px 0 12px;
}

.hf-blog__back {
  margin: 0;
  font-size: 13px;
}

.hf-trio__sharelist {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

/*
 * A logo tile rather than a stack of text buttons, so a dozen services fit without
 * taking over the dialog. The mark carries the brand colour; the tile stays neutral so
 * the grid does not turn into a rainbow. The name under it keeps the row readable.
 */
.hf-trio__sharebtn {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 2px 7px;
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius-sm, 8px);
  background: var(--hf-bg-elevated);
  color: var(--hf-text);
  font-size: 10px;
  line-height: 1.1;
  cursor: pointer;
}

.hf-trio__sharebtn:hover,
.hf-trio__sharebtn:focus-visible {
  background: var(--hf-bg-sunken);
}

.hf-trio__sharemark {
  width: 26px;
  height: 26px;
}

.hf-trio__sharename {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hf-trio__overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 18, 34, 0.5);
}

.hf-trio__panel {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 20px;
  text-align: center;
  background: var(--hf-bg-elevated);
  border-radius: var(--hf-radius-lg);
  box-shadow: var(--hf-shadow-lg);
}

/*
 * The X in the top-right of the panel. Declining both second chances has to be
 * possible, and the operator asked for a glyph rather than a third button - the
 * accessible name lives in aria-label. The pseudo-element draws the cross so the
 * button element stays empty, and ::after widens the tap target to 44px without
 * shifting the glyph out of the corner.
 */
.hf-trio__close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--hf-radius-sm, 8px);
  background: none;
  color: var(--hf-text-muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.hf-trio__close::before {
  content: '✓';
}

.hf-trio__close::after {
  content: '';
  position: absolute;
  inset: -6px;
}

.hf-trio__close:hover,
.hf-trio__close:focus-visible {
  color: var(--hf-text);
  background: var(--hf-bg-sunken);
}

.hf-trio__panel-title {
  margin: 0 0 6px;
  font-size: 17px;
}

.hf-trio__panel-body {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--hf-text-muted);
}

.hf-trio__panel-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 640px) {
  .hf-trio__slots {
    gap: 4px;
    padding: 4px;
    min-height: 42px;
  }

  .hf-trio__hint {
    font-size: 12px;
  }
}

html[data-theme="dark"] .hf-trio__tile.is-buried {
  filter: brightness(0.62) saturate(0.7);
}

/* ---------------------------------------------------------------------------
   Reaction game (/react)
   ---------------------------------------------------------------------------
   Same full-screen body as the tile game, so the trimmed gutters and the
   header-only chrome are inherited rather than repeated.

   The board is a 3x3 of 9:16 cards, which makes the whole grid 27:48. That ratio
   on the container is what keeps every cell 9:16 while still being responsive -
   the cards themselves just fill their cell, so no fixed pixel size appears
   anywhere and the board scales with the phone.
   --------------------------------------------------------------------------- */

.hf-react {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  /* Take whatever height the main area has left, so the board can size itself from a
     real number rather than from a guess at how tall the header is. */
  flex: 1 1 auto;
  min-height: 0;
}

/*
 * Top line: the clock is the middle column, so it is centred on the card regardless
 * of how long the level label is. The two 1fr side columns are what keep the middle
 * one at the true centre rather than merely centred between the label and nothing.
 */
.hf-react__hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.hf-react__level {
  grid-column: 1;
  justify-self: start;
  font-size: 15px;
  color: var(--hf-text-muted, #54545f);
}

.hf-react__timer {
  grid-column: 2;
  justify-self: center;
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--hf-text);
}

/* The board now has the row to itself, so it only has to be centred. */
.hf-react__board {
  display: flex;
  /* Stretch, not centre: centring left the stage at its content height, which made the
     grid's height:100% unresolvable and collapsed the whole board to zero. The grid
     centres itself, so nothing needs centring here. */
  align-items: stretch;
  justify-content: center;
  min-height: 0;
  flex: 1 1 auto;
  /* Holds the restart button that appears once a loss panel is dismissed. */
  position: relative;
}

/*
 * The board's mount point. It sits in the page's full-height column, so it has to pass
 * that height down to the board - without it the column hands the child nothing and the
 * board falls back to the height of its own text, which is how a card ended up a few
 * pixels tall. Keyed on a class set by game-react.js because Trio Tiles mounts in the
 * same element and lays itself out differently.
 */
.hf-react-root {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/*
 * Holds the grid (which decides the height) and the preview overlay on top of it.
 * Same footprint for both, so swapping one for the other moves nothing.
 */
.hf-react__stage {
  position: relative;
  display: flex;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.hf-react__grid {
  display: grid;
  /* 2x2: four pictures, four cells. */
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 8px;
  /* Two columns of 9:16 cards make the board 18:32, which is the same 9:16 - every
     cell keeps the portrait ratio the art is cut to.

     Height-driven on purpose: the board takes the height the page has and the width
     follows from the ratio. Sizing it from a width formula meant guessing the header
     height, and a wrong guess pushed the clock above the fold. */
  aspect-ratio: 9 / 16;
  height: 100%;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

/*
 * The countdown screen: the target picture in the middle of the board area with the
 * counter directly beneath it. It is laid over the grid, which is already dealt and
 * laid out underneath, so the cards cost no reflow when they appear.
 */
.hf-react__intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 4;
  pointer-events: none;
}

.hf-react__intro.hf-hidden {
  display: none;
}

.hf-react__target-label {
  font-size: 14px;
  color: var(--hf-text-muted, #54545f);
  text-align: center;
}

/* Big enough to actually memorise, which is the whole point of the preview. */
.hf-react__target-card {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(76px, 19vh, 128px);
  aspect-ratio: 9 / 16;
  /* Never shrink: a flex child that gets squashed loses the ratio the art is cut to. */
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 12px;
  background: var(--hf-bg-subtle, #f4f4f8);
  box-shadow: var(--hf-shadow);
}

.hf-react__card {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--hf-bg-elevated, #fff);
  box-shadow: var(--hf-shadow);
  color: var(--hf-text);
  cursor: pointer;
  /* A tap must not also scroll or zoom the page underneath. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hf-react__card.is-pressed {
  transform: scale(0.96);
}

/* Cards are dealt and laid out before the countdown ends; they simply are not
   visible yet. Painting them at the last moment would cost the player a frame. */
.hf-react__grid.is-waiting .hf-react__card {
  opacity: 0;
  pointer-events: none;
}

/*
 * The card's picture. It is cut out of the shared tile sheet with background-position,
 * so the cut-out scales with the card instead of being pinned to one pixel size.
 *
 * Positioned out of flow on purpose: as a grid item its aspect-ratio took part in the
 * row sizing, and the board's 1fr rows collapsed to nothing. Absolutely placed, the
 * picture cannot influence the card's size - only sit in it.
 */
.hf-react__pic {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  transform: translateY(-50%);
  background-repeat: no-repeat;
  /* Let the browser smooth the scaled sheet - the source is a small bitmap. */
  image-rendering: auto;
}

/* A per-card file the operator drops in wins over the built-in cut-out. */
.hf-react__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* No file at that path: the built-in art underneath is the card. */
.hf-react__img.is-missing {
  display: none;
}

.hf-react__countdown {
  /* Same reason as the picture above: the number keeps its size. */
  flex: 0 0 auto;
  font-size: clamp(128px, 40vh, 264px);
  font-weight: 800;
  line-height: 1;
  color: var(--hf-text);
  text-shadow: 0 2px 18px rgb(0 0 0 / 22%);
}

.hf-react__overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(12 12 18 / 46%);
}

.hf-react__overlay.hf-hidden {
  display: none;
}

.hf-react__panel {
  position: relative;
  width: min(100%, 380px);
  padding: 20px;
  border-radius: var(--hf-radius-lg);
  background: var(--hf-bg-elevated, #fff);
  box-shadow: var(--hf-shadow);
  text-align: center;
}

/*
 * The X in the top-right of the outcome card, as asked for: white glyph, no text, so
 * it never reads as a third labelled button (the accessible name is in aria-label).
 * It sits on a translucent dark disc because the card is white in the light theme -
 * a bare white glyph on a white panel would be invisible, and the point of this
 * button is that it is easy to find. ::after widens the tap target to 44px without
 * moving the glyph out of the corner.
 */
.hf-react__close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(16 18 30 / 42%);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.hf-react__close::before {
  content: '✓';
}

.hf-react__close::after {
  content: '';
  position: absolute;
  inset: -6px;
}

.hf-react__close:hover,
.hf-react__close:focus-visible {
  background: rgb(16 18 30 / 66%);
}

/*
 * The way on once the panel is dismissed. Absolutely placed inside the board so it
 * takes no height from it - the board sizes itself from the viewport, and a real
 * sibling would shrink every card on a phone.
 */
.hf-react__restart {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 5;
  transform: translateX(-50%);
  /* It sits on top of the cards, so it needs its own surface to stay readable. */
  background: var(--hf-bg-elevated, #fff);
  box-shadow: 0 4px 14px rgb(0 0 0 / 20%);
}

.hf-react__panel-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
}

.hf-react__panel-body {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--hf-text-muted, #54545f);
}

.hf-react__panel-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------------------------------------------------------------------------
   Outcome buttons arrive one at a time
   ---------------------------------------------------------------------------
   Both games show the headline first and grow the buttons a beat later (the guard
   in each module). They used to land as one block; sliding in one after another
   makes that beat read as part of the panel rather than as a missing render, and
   the button a stray finger is most likely to hit is the one that arrives last.

   `both` is what makes the stagger real: each button holds the from-state during
   its own delay, so nothing is fully on screen before its turn. The operator asked
   for a slow arrival - one second per button, 110ms apart - so the panel fills as a
   wave rather than a pop. The prefers-reduced-motion rules below collapse the whole
   thing for anyone who asked for that.
   --------------------------------------------------------------------------- */

@keyframes hf-action-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.hf-trio__panel-actions > *,
.hf-react__panel-actions > * {
  animation: hf-action-in 1000ms cubic-bezier(0.22, 0.68, 0.3, 1) both;
}

.hf-trio__panel-actions > *:nth-child(2),
.hf-react__panel-actions > *:nth-child(2) {
  animation-delay: 110ms;
}

.hf-trio__panel-actions > *:nth-child(3),
.hf-react__panel-actions > *:nth-child(3) {
  animation-delay: 220ms;
}

.hf-trio__panel-actions > *:nth-child(4),
.hf-react__panel-actions > *:nth-child(4) {
  animation-delay: 330ms;
}

@media (prefers-reduced-motion: reduce) {
  .hf-trio__panel-actions > *,
  .hf-react__panel-actions > * {
    animation-delay: 0ms;
  }
}

/* Game statistics table in the admin console. */
.hf-stats {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hf-stats th,
.hf-stats td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--hf-border, #e6e6ee);
  text-align: right;
}

.hf-stats thead th {
  font-weight: 700;
  text-align: center;
}

.hf-stats tbody th {
  text-align: left;
  font-weight: 600;
}

@media (max-width: 640px) {
  /* A phone has less height to give, so the board's cap and the preview scale down
     a step while the clock stays legible on the top line. */
  .hf-react__timer {
    font-size: 22px;
  }

  .hf-react__target-card {
    width: clamp(70px, 17vh, 110px);
  }

  .hf-react__countdown {
    font-size: clamp(116px, 34vh, 220px);
  }
}
