:root {
  --bg: #0e1013;
  --panel: #171a1f;
  --line: #262b33;
  --text: #dfe3ea;
  --dim: #7d8694;
  --hit: #ffb347;
  /* Second, third, ... word in the same DID. The longest keeps --hit. */
  --w1: #5ecbff;
  --w2: #ff7eb6;
  --w3: #8be28b;
  --w4: #b79cff;
  --w5: #ff6b5e;
  color-scheme: dark;
}

.w0 { color: var(--hit); }
.w1 { color: var(--w1); }
.w2 { color: var(--w2); }
.w3 { color: var(--w3); }
.w4 { color: var(--w4); }
.w5 { color: var(--w5); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, sans-serif;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 80px;
}

h1 {
  margin: 0 0 8px;
  font: 700 28px/1.1 ui-monospace, Consolas, monospace;
}

.lede { margin: 0 0 20px; color: var(--dim); }

form { display: flex; gap: 8px; }

input[type="text"],
button {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.handle-field { position: relative; flex: 1; min-width: 0; }
input[type="text"] { width: 100%; }
button { cursor: pointer; font-weight: 600; }

.typeahead {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.typeahead-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.typeahead-item:hover,
.typeahead-item.active { background: var(--line); }

.typeahead-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--line);
}

.typeahead-text { min-width: 0; }

.typeahead-name,
.typeahead-handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typeahead-name { font-weight: 600; line-height: 1.3; }
.typeahead-handle { color: var(--dim); font-size: 13px; line-height: 1.3; }

.options { margin-top: 10px; }

.option {
  display: block;
  margin-top: 4px;
  color: var(--dim);
  font-size: 13px;
}

.back,
.row-scan {
  padding: 3px 9px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 500;
}

.back:hover,
.row-scan:hover { color: var(--text); border-color: var(--dim); }

.back { margin-top: 18px; }

#status { min-height: 1.5em; margin: 18px 0 0; color: var(--dim); }
.back:not([hidden]) + #status { margin-top: 8px; }

/* The "you" card: sized and padded to survive being cropped into a screenshot. */
.me-card {
  margin-top: 14px;
  padding: clamp(20px, 5vw, 32px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(160deg, #1c2028, #121419);
}

.me-card.hit { border-color: var(--hit); }

.card-who { display: flex; align-items: center; gap: 14px; }

.card-avatar {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--line);
}

.card-names { min-width: 0; }
.card-name { font-size: 20px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.card-handle { color: var(--dim); overflow-wrap: anywhere; }

/* Two classes deep so it outranks the generic .did rule further down. */
.me-card .card-did {
  margin-top: 22px;
  color: var(--text);
  font-size: clamp(13px, 3.6vw, 18px);
}

.card-verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin: 10px 0 0;
}

.card-word {
  color: var(--hit);
  font: 700 clamp(34px, 10vw, 56px)/1.1 ui-monospace, Consolas, monospace;
  overflow-wrap: anywhere;
}

.card-word.none { color: var(--dim); }
.card-len { color: var(--dim); font-size: 18px; }

.card-also {
  margin: 6px 0 0;
  color: var(--dim);
  font: 600 15px/1.4 ui-monospace, Consolas, monospace;
  overflow-wrap: anywhere;
}

.card-standing { min-height: 1.5em; margin: 8px 0 0; color: var(--dim); }

.card-foot {
  display: flex;
  /* If the two don't fit on one line, the URL takes the bottom one so it
     stays in the card's bottom-left corner. */
  flex-wrap: wrap-reverse;
  justify-content: space-between;
  gap: 2px 12px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
}

.card-brand { color: var(--text); font: 700 13px/1.5 ui-monospace, Consolas, monospace; }

#leaderboard { margin-top: 32px; }

h2 {
  margin: 0;
  font: 700 16px/1.2 ui-monospace, Consolas, monospace;
}

#tally { margin: 4px 0 12px; color: var(--dim); font-size: 13px; }

#board { margin: 0; padding: 0; list-style: none; }

.row {
  display: grid;
  grid-template-columns: 34px 32px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 6px;
  border-top: 1px solid var(--line);
}

.row.me { background: var(--panel); }

.rank { color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--line);
}

.who { min-width: 0; }
.name { color: var(--text); font-weight: 600; text-decoration: none; }
.name:hover { text-decoration: underline; }
.handle { color: var(--dim); font-size: 13px; }

.did {
  display: block;
  color: var(--dim);
  font: 13px/1.4 ui-monospace, Consolas, monospace;
  overflow-wrap: anywhere;
}

/* Color comes from the mark's .w0-.w5 class, one per word. */
.did mark {
  padding: 0 1px;
  border-radius: 2px;
  background: none;
  font-weight: 700;
  text-decoration: underline;
  white-space: nowrap; /* when the DID wraps, the word moves as one piece */
}

.row-side { display: flex; align-items: center; gap: 12px; }

.word {
  color: var(--hit);
  font: 600 14px/1.2 ui-monospace, Consolas, monospace;
  white-space: nowrap;
}

/* Phones: stack the word over its scan button so the DID keeps its width. */
@media (max-width: 520px) {
  .row { grid-template-columns: 22px 32px 1fr auto; gap: 8px; }
  .row-side { flex-direction: column; align-items: flex-end; gap: 6px; }
}
