/* Self-hosted font: no requests to Google or any third party. */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --line: #eef1ef;
  --line-strong: #d9dfdb;
  --text: #0c120e;
  --text-soft: #3b443e;
  --muted: #5f6b63;
  --faint: #8a958e;
  --accent: #22c55e;       /* bright green: buttons, logo, caret, lines */
  --accent-ink: #15803d;   /* darker green for text links (readable on white) */
  --accent-dim: rgba(34, 197, 94, 0.12);
  --danger: #dc2626;
  --edge: clamp(16px, 2.5vw, 36px);
  --font: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  color-scheme: light;
}

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

/* Elements marked hidden stay hidden, even if a class gives them a display. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Background grid ---------- */

/* Faint grid behind the whole page, fading out toward the edges. */
.grid-bg {
  --cell: 48px;
  position: fixed;
  inset: 0;
  z-index: -1;
  display: grid;
  grid-auto-rows: var(--cell);
  pointer-events: none;
}

/* Plain drawn grid, used on touch screens and when motion is turned off. */
.grid-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 78%);
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 78%);
}

/* With a mouse, site.js replaces that with real tiles. Each tile draws its own
   lines (top and left edge; the neighbours draw the rest), so when a tile
   rises its lines rise with it and the spot underneath is left empty.
   --fade (set per tile) fades the lines toward the screen edges.
   --lift (0 to 1, set while the mouse is near) says how high a tile rises. */
.grid-bg.interactive::before { display: none; }

.cell {
  --lift: 0;
  box-shadow:
    inset 1px 1px 0 0 rgba(12, 18, 14, calc(0.07 * var(--fade, 1))),
    0 0 0 -6px rgba(12, 18, 14, 0);
  /* Slow settle back down, so the mouse leaves a gentle wake. */
  transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1), box-shadow 0.7s ease, background-color 0.7s ease;
}
.cell.up {
  position: relative;
  z-index: var(--z, 1);
  background-color: color-mix(in srgb, var(--accent) calc(var(--lift) * 16%), #fff);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) calc(var(--lift) * 75%), #eceeed),
    0 calc(var(--lift) * 14px) calc(var(--lift) * 22px) -6px rgba(12, 18, 14, calc(var(--lift) * 0.32));
  transform: translateY(calc(var(--lift) * -10px)) scale(calc(1 + var(--lift) * 0.04));
  transition-duration: 0.2s; /* rise quickly */
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

/* ---------- Header: logo top-left, account links top-right ---------- */

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 var(--edge);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
}

.site-header::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
  opacity: 0.8;
}

.brand { display: flex; align-items: center; }
.brand img { display: block; border-radius: 7px; transition: transform 0.2s ease; }
.brand:hover img { transform: scale(1.06); }

.site-nav { display: flex; align-items: center; gap: 22px; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease;
}
.nav-link:hover { color: var(--text); text-decoration: none; }

/* ---------- Main ---------- */

.site-main {
  display: grid;
  place-items: center;
  padding: 48px var(--edge);
}

.hero { text-align: center; }

.hero-title {
  margin: 0;
  font-size: clamp(44px, 9vw, 92px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.22em;
  /* letter-spacing adds trailing space; nudge so the word stays centered */
  margin-right: -0.22em;
  position: relative;
  display: inline-block;
}
.hero-title-sm { font-size: clamp(40px, 7vw, 72px); }

/* A text-input style caret, positioned outside the word so it doesn't throw
   off the centering. The offset cancels the letter-spacing after the last
   letter so the caret sits right against it. */
.cursor {
  position: absolute;
  left: calc(100% - 0.16em);
  top: 0.04em;
  width: 0.06em;
  min-width: 3px;
  height: 0.92em;
  background: var(--accent);
  animation: blink 1.06s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero-note { margin: 28px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- Forms & panels ---------- */

.panel {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.panel-title {
  margin: 0 0 24px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-form { display: grid; }

.auth-form label {
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-form label:first-of-type { margin-top: 0; }

.auth-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.check, .auth-form .check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 20px 0 0;
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.5;
  cursor: pointer;
}
.check input, .auth-form .check input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.text-button {
  display: block;
  margin: 16px auto 0;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.text-button:hover { color: var(--danger); }

.field-hint { margin: 6px 0 0; color: var(--faint); font-size: 11px; }

.form-error { min-height: 1.6em; margin: 14px 0 6px; color: var(--danger); font-size: 12px; }

.form-note { margin: 20px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.button {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #052e14;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.button:hover { filter: brightness(0.95); }
.button:disabled { opacity: 0.5; cursor: wait; }

.button-ghost { background: transparent; color: var(--accent-ink); }
.button-ghost:hover { background: var(--accent-dim); filter: none; }

.details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 20px;
  margin: 0 0 28px;
}
.details dt { color: var(--muted); font-size: 12px; }
.details dd { margin: 0; text-align: right; }

/* ---------- Account, recovery, 2FA ---------- */

.panel-wide { max-width: 520px; }

.panel-text { margin: 0 0 16px; color: var(--text-soft); font-size: 13px; }

.button { display: block; text-align: center; text-decoration: none; }
.button:hover { text-decoration: none; }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-spaced { margin-top: 12px; }
.button-row { display: flex; gap: 10px; margin: 0 0 16px; }
.button-row .button { flex: 1; }

.form-error:empty, .form-success:empty { min-height: 0; margin: 8px 0 4px; }
.form-success { margin: 14px 0 6px; color: var(--accent-ink); font-size: 12px; }

.optional { color: var(--faint); text-transform: none; letter-spacing: 0; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.badge-warn { background: #fef3c7; color: #92400e; }

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-dim);
  font-size: 12px;
}
.notice p { margin: 0; }
.notice .text-button { margin: 6px 0 0; padding: 0; }
.notice-warn { border-color: #f59e0b; background: #fffbeb; color: #92400e; }

details.setting {
  border-top: 1px solid var(--line-strong);
}
details.setting:last-of-type { border-bottom: 1px solid var(--line-strong); margin-bottom: 24px; }

details > summary {
  padding: 14px 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '+'; display: inline-block; width: 18px; color: var(--accent-ink); }
details[open] > summary::before { content: '−'; }
details > :not(summary) { margin-bottom: 18px; }
.setting-danger > summary { color: var(--danger); }
.setting-danger > summary::before { color: var(--danger); }

.qr { display: block; margin: 0 auto 12px; border: 1px solid var(--line-strong); border-radius: 4px; }
.secret {
  display: block;
  margin: 0 0 16px;
  padding: 8px 10px;
  border-radius: 4px;
  background: #f4f6f5;
  font-size: 12px;
  word-break: break-all;
  user-select: all;
}

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 28px;
  white-space: nowrap;
  margin: 0 0 20px;
  padding: 16px 16px 16px 36px;
  border-radius: 4px;
  background: #f4f6f5;
  font-size: 13px;
  font-weight: 600;
}

.account-actions { display: grid; gap: 4px; }

/* ---------- Admin ---------- */

.site-main:has(.admin) { place-items: start center; grid-template-columns: minmax(0, 1fr); }
/* min-width: 0 lets wide tables scroll sideways instead of stretching the page. */
.admin { width: 100%; max-width: 1000px; min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat, .admin-card {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}
.stat { display: grid; gap: 2px; padding: 16px 20px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.admin-card { margin-bottom: 16px; padding: 20px 24px; }
.admin-heading { margin: 0 0 16px; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

.invite-form { grid-template-columns: 110px 150px 1fr auto; align-items: end; gap: 0 14px; }
.invite-form .field { display: grid; }
.invite-form input, .invite-form select { height: 44px; }
.invite-form .button { width: auto; padding-inline: 28px; }
.invite-form .form-error { grid-column: 1 / -1; }
.auth-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.auth-form select:focus { outline: none; border-color: var(--accent); }

.invite-code-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.invite-code {
  flex: 1;
  padding: 10px 14px;
  border-radius: 4px;
  background: #f4f6f5;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  user-select: all;
}
.invite-code-row .button { width: auto; padding-inline: 24px; }
.invite-result .text-button { display: inline-block; margin: 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th {
  padding: 0 12px 10px 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table td { padding: 10px 12px 10px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.table td .text-button { margin: 0; padding: 0; }
.table td .form-error:empty { margin: 0; }
.table .empty { color: var(--faint); text-align: center; padding: 20px 0; }
.muted-dash { color: var(--faint); }

.status { font-weight: 600; font-size: 11px; }
.status-active { color: var(--accent-ink); }
.status-used-up, .status-expired { color: var(--faint); }
.status-revoked { color: var(--danger); }

@media (max-width: 700px) {
  .invite-form { grid-template-columns: 1fr 1fr; gap: 12px 14px; }
  .invite-form .field-grow, .invite-form .button { grid-column: 1 / -1; }
}

/* ---------- Avatars ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  color: #fff;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}
.avatar-xs { width: 22px; height: 22px; font-size: 10px; }
.avatar-sm { width: 34px; height: 34px; font-size: 14px; }
.avatar-lg { width: 72px; height: 72px; font-size: 28px; }
.avatar-logo { border-radius: 8px; }
.avatar-c0 { background: #16a34a; }
.avatar-c1 { background: #0d9488; }
.avatar-c2 { background: #2563eb; }
.avatar-c3 { background: #7c3aed; }
.avatar-c4 { background: #db2777; }
.avatar-c5 { background: #ea580c; }
.avatar-c6 { background: #ca8a04; }
.avatar-c7 { background: #0891b2; }

.nav-user .avatar { margin-right: 2px; }

.avatar-editor { display: flex; align-items: center; gap: 18px; margin: 0 0 24px; }
.avatar-actions { display: grid; justify-items: start; gap: 6px; }
.avatar-actions .text-button { margin: 0; padding: 0; }
.avatar-actions .form-error:empty { margin: 0; }
.button-small { display: inline-block; width: auto; padding: 8px 14px; font-size: 11px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Dashboard ---------- */

.site-main:has(.home), .site-main:has(.word-game) { place-items: start center; grid-template-columns: minmax(0, 1fr); }

.home { display: grid; gap: 22px; width: 100%; max-width: 860px; }

.avatar-md { width: 48px; height: 48px; font-size: 20px; }

/* Greeting */
.hello { display: flex; align-items: center; gap: 16px; }
.hello .avatar { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.hello-title { margin: 0; font-size: clamp(18px, 3.2vw, 24px); font-weight: 800; letter-spacing: -0.01em; }
.hello-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface);
  color: var(--muted); font-size: 11px;
}

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: live 2s ease-out infinite;
}
@keyframes live { 70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }

/* Game tiles */
.game-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.game-tile {
  position: relative;
  display: flex; align-items: center; gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: linear-gradient(135deg, #fff 55%, rgba(34, 197, 94, 0.08));
  color: var(--text);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.game-tile-alt { background: linear-gradient(135deg, #fff 55%, rgba(209, 159, 14, 0.1)); }
.game-tile:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 14px 28px -14px rgba(12, 18, 14, 0.35);
  text-decoration: none;
}
.game-tile-alt:hover { border-color: var(--w-present); }
.game-tile-text { display: grid; gap: 2px; min-width: 0; }
.eyebrow { color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.game-tile-title { font-size: 17px; font-weight: 800; }
.game-tile-status { color: var(--text-soft); font-size: 12px; }
.game-tile-cta { margin-top: 6px; color: var(--accent-ink); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.game-tile-alt .game-tile-cta { color: #9a7406; }
.game-tile-cta span { display: inline-block; transition: transform 0.18s ease; }
.game-tile:hover .game-tile-cta span { transform: translateX(4px); }

.mini-grid { display: grid; gap: 3px; flex: none; }
.mg-row { display: flex; gap: 3px; }
.mg { width: 11px; height: 11px; border-radius: 2px; background: #e8ece9; }
.mg-correct { background: var(--w-correct); }
.mg-present { background: var(--w-present); }
.mg-absent { background: var(--w-absent); }

/* Chat */
.chat {
  display: grid;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(12, 18, 14, 0.04);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; }
.chat-title { margin: 0; font-size: 14px; font-weight: 800; }
.avatar-stack { display: flex; padding-left: 8px; }
.avatar-stack .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); width: 28px; height: 28px; font-size: 12px; }
.avatar-more { background: #e8ece9; color: var(--muted); font-size: 10px !important; }

.chat-log {
  height: 420px;
  margin: 0;
  padding: 4px 0 12px;
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
}
.chat-empty { padding: 40px 20px; color: var(--faint); font-size: 12px; text-align: center; }

.chat-day {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 20px 6px;
  color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
}
.chat-day::before, .chat-day::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.msg { position: relative; display: flex; gap: 12px; padding: 6px 20px 2px; }
.msg-cont { padding-top: 1px; }
.msg:hover { background: #f7f9f8; }
.msg.is-new { animation: msg-in 0.3s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg-gutter {
  flex: none; width: 34px; padding-top: 4px;
  color: var(--faint); font-size: 9px; text-align: right;
  opacity: 0;
}
.msg-cont:hover .msg-gutter { opacity: 1; }
.msg-main { min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.msg-name { font-weight: 800; }
.msg-meta .badge { margin: 0; align-self: center; }
.msg-time { color: var(--faint); font-size: 10px; }
.msg-body { margin: 1px 0 0; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.msg-jumbo { font-size: 34px; line-height: 1.2; }
.msg-gif { display: block; max-width: min(280px, 100%); height: auto; margin: 6px 0 4px; border-radius: 10px; background: #eef1ef; }
.mention { padding: 0 3px; border-radius: 4px; background: var(--accent-dim); color: var(--accent-ink); font-weight: 700; }

.msg-delete {
  position: absolute; top: 4px; right: 14px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--muted);
  font: inherit; font-size: 10px;
  cursor: pointer; opacity: 0;
}
.msg:hover .msg-delete, .chat-system:hover .msg-delete, .msg-delete:focus-visible { opacity: 1; }
.msg-delete:hover { color: var(--danger); border-color: var(--danger); }

.chat-system { position: relative; display: flex; justify-content: center; padding: 6px 20px; }
.chat-system.is-new { animation: msg-in 0.3s ease-out; }
.system-pill {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin: 0; padding: 6px 14px;
  border: 1px dashed var(--line-strong); border-radius: 14px;
  color: var(--text-soft); font-size: 12px; text-align: center; justify-content: center;
}
.system-icon { color: var(--w-correct); }
.system-link { margin-left: 4px; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

/* Composer */
.composer {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  margin: 0 14px 14px;
  padding: 6px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: #f7f9f8;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.composer:focus-within { border-color: var(--accent); background: var(--surface); }
.composer-input {
  flex: 1; min-width: 0;
  padding: 8px 6px;
  border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 13px;
}
.composer-input:focus { outline: none; }
.composer-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.composer-btn:hover { background: #e8ece9; color: var(--text); }
.composer-btn:active { transform: scale(0.92); }
.composer-gif { font: inherit; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; }
.composer-send {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border: 0; border-radius: 10px;
  background: var(--accent); color: #052e14;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.composer-send:hover { filter: brightness(0.95); }
.composer-send:active { transform: scale(0.92); }
.composer-send:disabled { opacity: 0.5; }
.chat-error:empty { display: none; }
.chat-error { margin: -6px 20px 12px; }

/* Popovers above the composer */
.picker, .command-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  z-index: 20;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 40px -12px rgba(12, 18, 14, 0.3);
  animation: pop-up 0.16s ease-out;
}
@keyframes pop-up { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

.command-menu { right: 0; padding: 6px; }
.command-heading { padding: 6px 10px 4px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.command { display: flex; justify-content: space-between; gap: 16px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.command.active, .command:hover { background: var(--accent-dim); }
.command-name { font-weight: 800; }
.command-args { color: var(--faint); font-weight: 400; }
.command-hint { color: var(--muted); text-align: right; }

.picker { width: min(340px, calc(100vw - 48px)); padding: 10px; }
.picker-search {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: #f7f9f8; color: var(--text); font: inherit; font-size: 12px;
}
.picker-search:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.picker-tabs { display: flex; gap: 2px; margin: 8px 0 4px; }
.picker-tab {
  flex: 1; padding: 5px 0;
  border: 0; border-radius: 6px;
  background: none; font-size: 16px;
  cursor: pointer; filter: grayscale(1); opacity: 0.6;
  transition: filter 0.15s, opacity 0.15s, background-color 0.15s;
}
.picker-tab:hover, .picker-tab.active { filter: none; opacity: 1; background: #eef1ef; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); height: 220px; overflow-y: auto; align-content: start; }
.emoji {
  aspect-ratio: 1; padding: 0;
  border: 0; border-radius: 8px;
  background: none; font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.emoji:hover { background: #eef1ef; transform: scale(1.18); }
.picker-empty { grid-column: 1 / -1; margin: 30px 0; color: var(--faint); font-size: 12px; text-align: center; }

.picker-gif { width: min(380px, calc(100vw - 48px)); }
.gif-grid { columns: 2; column-gap: 6px; height: 300px; margin-top: 8px; overflow-y: auto; }
.gif-item {
  display: block; width: 100%; margin: 0 0 6px; padding: 0;
  border: 0; border-radius: 8px; overflow: hidden;
  background: #eef1ef; cursor: pointer;
  break-inside: avoid;
}
.gif-item img { display: block; width: 100%; height: auto; transition: transform 0.2s ease; }
.gif-item:hover img { transform: scale(1.04); }
.gif-more { margin: 6px auto 0; }
.picker-credit { margin: 6px 0 0; color: var(--faint); font-size: 9px; letter-spacing: 0.08em; text-align: right; text-transform: uppercase; }

@media (max-width: 600px) {
  .chat-log { height: 360px; }
  .msg, .chat-head { padding-left: 14px; padding-right: 14px; }
  .command-hint { display: none; }
}

/* Profile picture editor */
.cropper {
  width: min(380px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 60px rgba(12, 18, 14, 0.25);
}
.cropper[open] { animation: results-in 0.25s cubic-bezier(0.2, 0.8, 0.3, 1); }
.cropper::backdrop { background: rgba(12, 18, 14, 0.45); backdrop-filter: blur(2px); }
.cropper-title { margin: 0 0 16px; font-size: 15px; font-weight: 800; text-align: center; }
.crop-stage {
  position: relative;
  width: min(300px, 100%); aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 12px;
  background: #1a1f1c;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.crop-image { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
/* Everything outside the circle is dimmed. */
.crop-ring {
  position: absolute; inset: 7%;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(12, 18, 14, 0.55), inset 0 0 0 2px rgba(255, 255, 255, 0.9);
  pointer-events: none;
}
.crop-zoom { display: flex; align-items: center; gap: 12px; margin: 18px 6px 4px; color: var(--muted); }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.cropper-hint { margin: 4px 0 0; color: var(--faint); font-size: 11px; text-align: center; }
.cropper-actions { display: flex; gap: 10px; margin-top: 16px; }
.cropper .form-error:empty { display: none; }

/* ---------- Word game ---------- */

:root {
  --w-correct: #16a34a;
  --w-present: #d19f0e;
  --w-absent: #7b8480;
  --w-empty: #d9dfdb;
  --w-filled: #7b8480;
}

.word-game {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 22px;
  width: 100%;
  max-width: 500px;
}
.word-head { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.word-heading { display: grid; justify-items: center; gap: 8px; }
.word-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.mode-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 999px; background: #f4f6f5; }
.mode-switch a {
  padding: 4px 14px; border-radius: 999px;
  color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  transition: background-color 0.15s, color 0.15s;
}
.mode-switch a:hover { color: var(--text); text-decoration: none; }
.mode-switch a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(12, 18, 14, 0.12); }
.mode-switch span { color: var(--faint); }
.word-icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--text);
  cursor: pointer;
}
.word-icon-btn:hover { border-color: var(--accent); text-decoration: none; }
.word-icon-btn.invisible { visibility: hidden; } /* keeps its space so the title stays centered */

.board { display: grid; gap: 6px; }
.row { display: grid; grid-template-columns: repeat(5, var(--tile)); gap: 6px; --tile: clamp(48px, 15vw, 62px); }
.tile {
  display: grid;
  place-items: center;
  width: var(--tile);
  height: var(--tile);
  border: 2px solid var(--w-empty);
  background: var(--surface);
  font-size: calc(var(--tile) * 0.5);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}
.tile[data-state='tbd'] { border-color: var(--w-filled); }
.tile[data-state='correct'], .tile[data-state='present'], .tile[data-state='absent'] { color: #fff; }
.tile[data-state='correct'] { background: var(--w-correct); border-color: var(--w-correct); }
.tile[data-state='present'] { background: var(--w-present); border-color: var(--w-present); }
.tile[data-state='absent'] { background: var(--w-absent); border-color: var(--w-absent); }

.tile.pop { animation: pop 0.12s ease-out; }
@keyframes pop { 50% { transform: scale(1.12); } }

.tile.flip { animation: flip 0.5s ease-in-out; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(-90deg); } 100% { transform: rotateX(0); } }

.row.shake { animation: shake 0.6s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.tile.bounce { animation: bounce 1s; }
@keyframes bounce {
  0%, 20% { transform: translateY(0); }
  40% { transform: translateY(-30px); }
  50% { transform: translateY(5px); }
  60% { transform: translateY(-15px); }
  80% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

.toasts {
  position: absolute;
  top: 60px;
  left: 50%;
  z-index: 10;
  display: grid;
  gap: 8px;
  justify-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  animation: toast-in 0.2s ease-out;
}
.toast-out { opacity: 0; transition: opacity 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

.keyboard { display: grid; gap: 8px; width: 100%; user-select: none; }
.key-row { display: flex; justify-content: center; gap: 6px; }
.key {
  flex: 1;
  max-width: 44px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #e4e8e5;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.key:hover { filter: brightness(0.96); }
.key:active { transform: scale(0.95); }
.key-wide { flex: 1.5; max-width: 68px; font-size: 11px; display: grid; place-items: center; }
.key[data-state] { color: #fff; }
.key[data-state='correct'] { background: var(--w-correct); }
.key[data-state='present'] { background: var(--w-present); }
.key[data-state='absent'] { background: var(--w-absent); }

.results {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(12, 18, 14, 0.25);
}
.results[open] { animation: results-in 0.3s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes results-in { from { opacity: 0; transform: translateY(24px) scale(0.97); } }
.results::backdrop { background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(2px); }
.results-close {
  position: absolute; top: 12px; right: 14px;
  border: 0; background: none; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer;
}
.results-title { margin: 0 0 4px; font-size: 18px; font-weight: 800; text-align: center; }
.results-answer { margin: 0 0 18px; color: var(--text-soft); font-size: 12px; text-align: center; }
.results-answer strong { color: var(--accent-ink); letter-spacing: 0.1em; }
.results-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 20px; text-align: center; }
.result-stat { display: grid; }
.result-stat-value { font-size: 26px; font-weight: 800; }
.result-stat-label { color: var(--muted); font-size: 9px; letter-spacing: 0.04em; text-transform: uppercase; }
.results-heading { margin: 0 0 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.distribution { display: grid; gap: 4px; margin-bottom: 20px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dist-label { width: 10px; }
.dist-bar {
  width: var(--w);
  padding: 2px 8px;
  background: var(--w-absent);
  color: #fff;
  font-weight: 700;
  text-align: right;
  animation: grow 0.6s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.dist-today { background: var(--w-correct); }
@keyframes grow { from { width: 8%; } }
.leaderboard { display: grid; gap: 2px; margin: 0 0 18px; padding: 0; list-style: none; font-size: 12px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; }
.lb-you { background: var(--accent-dim); font-weight: 700; }
.lb-rank { width: 26px; color: var(--muted); }
.lb-name { flex: 1; }
.lb-score { font-weight: 700; }
.lb-empty { color: var(--faint); }
.results-actions { display: flex; gap: 10px; }
.results-next { margin: 0 0 16px; color: var(--muted); font-size: 12px; text-align: center; }
.results-next strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* Small screens: header links become icon-only (text stays for screen readers). */
@media (max-width: 640px) {
  .site-nav { gap: 16px; }
  .nav-link span:not(.avatar) {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .nav-link svg { width: 18px; height: 18px; }
}

@media (max-width: 420px) {
  .key { height: 52px; font-size: 12px; }
  .key-row { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile.flip, .tile.pop, .tile.bounce, .row.shake, .msg.is-new, .chat-system.is-new, .results[open], .cropper[open], .dist-bar, .live-dot, .picker, .command-menu { animation: none; }
  .game-tile, .emoji, .gif-item img { transition: none; }
}

/* ---------- Info pages ---------- */

.prose { width: 100%; max-width: 640px; }
.prose h1 {
  margin: 0 0 24px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.prose h2 { margin: 32px 0 10px; font-size: 13px; font-weight: 700; }
.prose p, .prose li { color: var(--text-soft); }
.prose p { margin: 0 0 16px; }
.prose ul { margin: 0 0 16px; padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose .muted { color: var(--faint); font-size: 12px; }

/* ---------- Footer: links bottom-left, copyright bottom-right ---------- */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  min-height: 52px;
  padding: 12px var(--edge);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-weight: 600;
}

.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); text-decoration: none; }

.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  color: var(--muted);
}
.footer-meta a { color: var(--muted); }
.footer-meta a:hover { color: var(--text); }
.footer-meta .dot { color: var(--faint); }

/* ---------- Small screens ---------- */

@media (max-width: 560px) {
  .site-footer { justify-content: center; text-align: center; }
  .panel { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  * { transition: none !important; }
}
