:root {
  --bg: #fbfbfa;
  --fg: #24231f;
  --muted: #8d8b84;
  --line: #e2e0da;
  --accent: #1f6f6b;
  --loose: #c08a2e;
  --miss: #b5504a;
  --miss-line: #e6c3c0;
  --hit: #2f6fb0;          /* a landed entry: blue, distinct from the teal accent */
  --spent: #6b6a66;        /* a retry that cost an entry but no points */
  --panel: #ffffff;
  --radius: 6px;
  --font: "Inter", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --fg: #e8e6e1;
    --muted: #8f8d87;
    --line: #2e3033;
    --accent: #5fc0b8;
    --loose: #d8a44a;
    --miss: #e07a72;
    --miss-line: #5a3a38;
    --hit: #6aa6e0;
    --spent: #74736e;
    --panel: #1f2124;
  }
}

* { box-sizing: border-box; }

/* The hidden attribute only hides because the browser's default stylesheet
   says display:none — and ANY author display rule outranks that default.
   Two elements here set display:flex, so hiding them silently did nothing:
   the sign-in sheet stayed on screen no matter what the script did. Make
   the attribute mean what it says, everywhere. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }

.link {
  background: none;
  border: 0;
  padding: 2px 4px;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.link:hover { color: var(--fg); }
.link.active { color: var(--fg); border-bottom: 1px solid var(--fg); }
/* the nav carries both buttons and links; make them look identical */
a.link { text-decoration: none; }

/* ---- top bar ---- */
.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: lowercase; color: var(--muted); }
.modes { display: flex; gap: 6px; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.tiers { display: inline-flex; gap: 4px; }
.chip {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 0.78rem;
  color: var(--muted);
}
.chip.active { border-color: var(--accent); color: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 26px 22px 60px; }

/* ---- stage ---- */
.stage {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.seed-label { font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.seed { margin: 2px 0 0; font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 500; letter-spacing: -0.02em; }

.scoreboard { display: flex; gap: 26px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat-value { font-size: 1.7rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-key { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* ---- entry ---- */
.entry { margin-bottom: 22px; }
#guess-form { display: flex; gap: 8px; max-width: 460px; }
#guess {
  flex: 1;
  padding: 11px 13px;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#guess:focus { outline: none; border-color: var(--accent); }
#submit {
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
}
#submit[disabled] { opacity: 0.5; cursor: default; }

.message { min-height: 1.4em; margin: 10px 0 0; font-size: 0.88rem; color: var(--muted); }
.message.ok { color: var(--accent); }
.message.no { color: var(--miss); }
.message.neutral { color: var(--muted); }

/* ---- the entry track ---- */
.track-block { margin: 0 0 18px; }

.track {
  display: flex;
  gap: 3px;
  /* thin bars rather than boxes: a strip you read at a glance */
  height: 12px;
}

.pip {
  flex: 1 1 0;
  min-width: 6px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: transparent;      /* an unspent entry: outline only */
  transition: background-color 140ms ease, border-color 140ms ease;
}
.pip.hit   { background: var(--hit);   border-color: var(--hit); }
.pip.miss  { background: var(--miss);  border-color: var(--miss); }
.pip.spent { background: var(--spent); border-color: var(--spent); }

.track-key {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 7px 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
/* the key reuses .pip, so it needs a fixed size rather than flex */
.track-key .pip {
  flex: none;
  width: 16px;
  height: 10px;
  margin-left: 10px;
}
.track-key .pip:first-child { margin-left: 0; }

/* ---- board table ---- */
.board { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th {
  text-align: left;
  vertical-align: bottom;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  /* Columns size to their content rather than splitting evenly, so a word
     with several routes in stays on one line. The board scrolls sideways
     if the total outgrows the page. */
  width: auto;
  white-space: nowrap;
}
th + th { border-left: 1px solid var(--line); }
.col-name { display: block; font-size: 0.9rem; font-weight: 500; }
.col-meta { display: block; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.col-meta b { color: var(--fg); font-weight: 500; }

td { padding: 3px 14px; vertical-align: top; width: auto; white-space: nowrap; }
td + td { border-left: 1px solid var(--line); }
tbody tr:first-child td { padding-top: 12px; }
tbody tr:last-child td { padding-bottom: 14px; }

.cell { display: flex; align-items: baseline; gap: 7px; flex-wrap: nowrap; }
.word { font-size: 1rem; }
.word.new { animation: pop 0.5s ease; }
@keyframes pop { from { background: rgba(31,111,107,0.18); } to { background: transparent; } }
.from { font-size: 0.74rem; color: var(--muted); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; transform: translateY(-2px); }
.dot.loose { background: var(--loose); }

.empty { color: var(--muted); font-size: 0.85rem; padding: 16px 14px; }

/* ---- tries (the red list) ---- */
.stat-value.miss { color: var(--miss); }

.tries-block { margin-top: 18px; }
.tries-head {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.tries-cost { color: var(--miss); letter-spacing: 0.04em; }
.tries { display: flex; flex-wrap: wrap; gap: 6px 8px; list-style: none; margin: 0; padding: 0; }
.tries li {
  padding: 2px 9px;
  font-size: 0.85rem;
  color: var(--miss);
  border: 1px solid var(--miss-line);
  border-radius: 999px;
  text-decoration: line-through;
  text-decoration-color: var(--miss-line);
}

.tries li.resolved {
  color: var(--muted);
  border-color: var(--line);
  text-decoration-color: var(--line);
}
.tries-note { margin: 9px 0 0; font-size: 0.78rem; color: var(--muted); }

/* ---- same root (neutral bucket) ---- */
.roots-block { margin-top: 18px; }
.roots-cost { color: var(--muted); letter-spacing: 0.04em; }
.roots { display: flex; flex-wrap: wrap; gap: 6px 8px; list-style: none; margin: 0; padding: 0; }
.roots li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 9px;
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 999px;
}

/* ---- metrics ---- */
.metric-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px 30px;
}
.metric-head {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.metric-group dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0; font-size: 0.86rem; }
.metric-group dt { color: var(--muted); }
.metric-group dt[title] { cursor: help; border-bottom: 1px dotted var(--line); align-self: start; }
.metric-group dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.hist-block { margin-top: 22px; max-width: 340px; }
.hist-row { display: flex; align-items: center; gap: 8px; height: 16px; }
.hist-label { width: 1.5em; text-align: right; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-track { flex: 1; height: 7px; background: var(--line); border-radius: 3px; overflow: hidden; }
.hist-bar { display: block; height: 100%; background: var(--accent); }
.hist-value { width: 1.5em; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- footer bits ---- */
.finish { display: flex; gap: 14px; margin-top: 16px; }

.panel {
  margin-top: 22px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; font-weight: 500; }
.panel ul { margin: 0; padding-left: 20px; font-size: 0.92rem; }
.panel li { margin-bottom: 7px; }
.panel-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.panel-actions button:not(.link) {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: none;
}

/* ==================================================================
   Celebration: toasts and confetti, blitz mode by default
   ================================================================== */
.toast-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;   /* never steals a keystroke */
}

.toast {
  position: absolute;
  left: 50%;
  /* Up beside the seed word rather than over the board, so it never
     covers the thing the player is reading or the box they are typing in. */
  top: 13%;
  font-size: 3rem;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  animation: toast-rise 1100ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.toast .toast-label {
  display: block;
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  color: var(--accent);
  text-shadow: none;
}

@keyframes toast-rise {
  0%   { opacity: 0; transform: translate(-50%, 14px) scale(0.6); }
  18%  { opacity: 1; transform: translate(-50%, 0) scale(1.12); }
  30%  { transform: translate(-50%, 0) scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

.confetti {
  position: absolute;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  animation: confetti-fly 1200ms cubic-bezier(0.15, 0.7, 0.35, 1) forwards;
}

@keyframes confetti-fly {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); }
}

/* Confetti is exactly the sort of thing that makes some people ill, and a
   convention is exactly where you meet them. Honour the system setting:
   the emoji still appears, it just holds still. */
@media (prefers-reduced-motion: reduce) {
  .toast { animation: toast-hold 900ms linear forwards; }
  @keyframes toast-hold { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
  .confetti { display: none; }
}

/* ---- account + sign-in ---- */
.account { display: inline-flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
#btn-who { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-who.guest { font-style: italic; }

.signin-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 20, 18, 0.45);
}
.signin-card {
  width: min(420px, 100%);
  padding: 26px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.signin-card h2 { margin: 0 0 8px; font-size: 1.15rem; font-weight: 500; }
.signin-card p { margin: 0 0 18px; font-size: 0.9rem; color: var(--muted); }
.signin-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
#btn-google {
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
}
.signin-note { min-height: 1.2em; margin: 14px 0 0 !important; font-size: 0.85rem; }
.signin-rule { margin: 18px 0 14px; border: 0; border-top: 1px solid var(--line); }
.signin-small { margin: 6px 0 0 !important; font-size: 0.78rem; color: var(--muted); }

/* ---- scoreboard page ---- */
.board-page { max-width: 1080px; margin: 0 auto; padding: 30px 22px 60px; }
.board-intro { max-width: 620px; margin-bottom: 6px; }
.board-intro h1 { margin: 0 0 6px; font-size: clamp(1.8rem, 5vw, 2.3rem); font-weight: 500; letter-spacing: -0.02em; }
.board-intro p { margin: 0; font-size: 0.92rem; color: var(--muted); }
.board-page .panel { margin-top: 18px; }
.disclosure { padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); }
.disclosure h2 { margin-bottom: 10px; }
.disclosure p { margin: 0; font-size: 0.92rem; }

/* ---- scoreboard ---- */
.board-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.board-head h2 { margin: 0 0 12px; }
.board-where { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.board-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.board-scroll { overflow-x: auto; }
.board-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.board-table th {
  width: auto;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  border-left: 0;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.board-table td {
  width: auto;
  padding: 6px 10px;
  border-left: 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.board-table td.num { font-variant-numeric: tabular-nums; }
.board-table td.strong { font-size: 1rem; }
.board-table tr.mine td { background: rgba(31, 111, 107, 0.08); }
.board-note { margin: 12px 0 0; font-size: 0.82rem; color: var(--muted); }
.board-note em { font-style: normal; color: var(--fg); }
/* Today's daily board, on the game page: the same table as the scoreboard,
   sitting under the round summary once the round is over. Narrower minimum
   than the tier boards — it carries fewer columns and often shares a phone
   screen with the summary above it. */
.daily-board { margin-top: 16px; }
.daily-board .board-table { min-width: 460px; }

.board-table tr.clickable { cursor: pointer; }
.board-table tr.clickable:hover td { background: rgba(31, 111, 107, 0.06); }

.link.danger { color: var(--miss); }
.link.danger:hover { color: var(--miss); text-decoration: underline; }
.account-note { margin: 12px 0 0; font-size: 0.82rem; color: var(--muted); }

/* ---- one round, expanded ---- */
.run-detail {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 2px solid var(--accent);
}
.run-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.run-head h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 500; }
.run-words { margin: 0 0 18px; font-size: 0.85rem; color: var(--muted); line-height: 1.7; }
.run-missed { color: var(--miss); }

/* ---- round over ---- */
.panel.over {
  border: 1px solid var(--accent);
  border-top: 3px solid var(--accent);
  padding-top: 18px;
}
.over-flag {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 10px;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.panel.over h2 { font-size: 1.5rem; margin-bottom: 4px; }
.over-reason { margin: 0 0 16px; font-size: 0.88rem; color: var(--muted); }

.summary-grid { display: flex; flex-wrap: wrap; gap: 22px; font-variant-numeric: tabular-nums; }
.summary-grid div span { display: block; }
.summary-grid .k { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.summary-grid .v { font-size: 1.4rem; }
.missed { font-size: 0.88rem; color: var(--muted); margin: 16px 0 0; }
.missed b { color: var(--fg); font-weight: 500; }

.foot { padding: 0 22px 30px; text-align: center; font-size: 0.78rem; color: var(--muted); }
.foot a { color: inherit; }

/* ==================================================================
   about.html
   ================================================================== */
.prose { max-width: 760px; margin: 0 auto; padding: 34px 22px 60px; }
.prose section { margin-bottom: 46px; }
.prose h1 { margin: 0 0 4px; font-size: clamp(1.9rem, 5vw, 2.5rem); font-weight: 500; letter-spacing: -0.02em; }
.prose h2 {
  margin: 0 0 18px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.prose h3 { margin: 0 0 2px; font-size: 1.05rem; font-weight: 500; }
.prose p { margin: 0 0 14px; }
.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.author { display: flex; align-items: flex-start; gap: 28px; flex-wrap: wrap; }
.author-text { flex: 1 1 320px; }
.portrait {
  width: 148px;
  height: 148px;
  flex: none;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
}
.tagline { color: var(--muted); font-size: 0.95rem; margin-bottom: 18px !important; }

.books { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 26px; }
.book { display: flex; flex-direction: column; align-items: flex-start; }
.book img {
  width: 100%;
  max-width: 190px;
  height: auto;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
}
.book-meta { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px !important; }
.book p { font-size: 0.92rem; }

.links { list-style: none; margin: 0; padding: 0; }
.links li { margin-bottom: 9px; font-size: 0.95rem; color: var(--muted); }
.links li a { color: var(--fg); }

.button {
  display: inline-block;
  margin-top: auto;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg) !important;
  font-size: 0.88rem;
  text-decoration: none;
}
.button:hover { border-color: var(--accent); color: var(--accent) !important; }
.button.coffee { border-color: var(--accent); background: var(--accent); color: #fff !important; }
.button.coffee:hover { opacity: 0.9; color: #fff !important; }

.support { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.support p { font-size: 0.95rem; }
.back { font-size: 0.9rem; }

@media (max-width: 620px) {
  .scoreboard { gap: 18px; }
  .stat-value { font-size: 1.35rem; }
}
