:root {
  --accent: #D2691E;
  --easy: #FFB366;
  --medium: #FF8C33;
  --hard: #D2691E;
  --text: #000;
  --muted: #666;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 24px 16px 40px;
  background: #fff;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  text-align: center;
}
h1 {
  margin: 0;
  font-size: 48px;
  font-weight: 300;
  letter-spacing: 8px;
}
.tagline {
  margin: 4px 0 20px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.tabs {
  display: inline-flex;
  margin: -6px 0 18px;
  border: 1px solid #000;
  border-radius: 4px;
  overflow: hidden;
}
.tab {
  padding: 6px 22px;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #000;
  text-decoration: none;
  background: #fff;
}
.tab + .tab { border-left: 1px solid #000; }
.tab:hover { background: #f2f2f2; }
.tab.active { background: #000; color: #fff; }
.round-label {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--easy);
}
.round-label[data-difficulty="medium"] { color: var(--medium); }
.round-label[data-difficulty="hard"] { color: var(--hard); }
.board-wrap {
  display: block;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}
#board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid #000;
  background: #fff;
  cursor: crosshair;
  touch-action: manipulation;
}
#board.played { cursor: not-allowed; }
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin-top: 12px;
  font-size: 14px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
}
.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid #333;
  border-radius: 2px;
  margin-right: 6px;
}
.legend-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.confirm {
  margin-top: 12px;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.confirm:hover { background: #B8551A; }

/* Results */
.results { max-width: 600px; margin: 24px auto 0; }
.review {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 16px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 14px;
}
.review-label { color: var(--muted); margin-right: 4px; }
.review-btn {
  padding: 6px 14px;
  font: inherit;
  background: #fff;
  border: 1px solid #000;
  border-radius: 4px;
  cursor: pointer;
}
.review-tilt { margin-left: 12px; color: var(--muted); border-color: #999; }
.review-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.card {
  padding: 24px 20px;
  border: 2px solid #000;
  background: #fff;
}
.total {
  font-size: 48px;
  font-weight: 300;
  color: var(--accent);
  margin-bottom: 16px;
}
.rows {
  padding: 12px;
  background: #f9f9f9;
  text-align: left;
}
.row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
  border-left: 4px solid var(--accent);
  font-size: 14px;
}
.row:last-child { margin-bottom: 0; }
.row-name { font-weight: 600; letter-spacing: 1px; }
.row-score { font-weight: 600; }
.row-detail { text-align: right; color: #333; }
.row-total { border-left-color: #000; }
.stat { margin: 14px 0 0; font-size: 15px; }
.share-btn {
  margin-top: 20px;
  padding: 12px 32px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  background: #000;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.share-btn:hover { background: #333; }
.share-msg { margin: 10px 0 0; min-height: 1.2em; font-size: 13px; color: var(--muted); }
.start-over { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.start-over a { color: var(--muted); }
.share-text { text-align: left; font-size: 12px; white-space: pre-wrap; }
/* Nickname box (first visit, and "change name" on the results card) */
.nickname {
  max-width: 600px;
  margin: 0 auto 14px;
  padding: 10px 12px;
  background: #fdf3ea;
  border: 1px solid #f0d2b8;
  border-radius: 6px;
}
.nickname-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.nickname-label { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.nickname-input {
  width: 11em;
  padding: 6px 8px;
  font: inherit;
  border: 1px solid #999;
  border-radius: 4px;
}
.nickname-save {
  padding: 6px 16px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.nickname-save:hover { background: #B8551A; }
.link-btn {
  padding: 0;
  font: inherit;
  color: var(--muted);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--text); }
.name-line { margin-top: 14px; font-size: 13px; color: #333; }
.name-line .nickname-form { justify-content: center; }
.muted { color: var(--muted); }

/* Histogram of everyone's totals: 10 bars, the tallest is 80 px */
.histogram {
  margin-top: 16px;
  padding: 14px 8px 0;
  border-top: 1px dashed #ccc;
}
.histo-bars, .histo-labels { display: flex; gap: 6px; }
.histo-bars { height: 80px; align-items: flex-end; border-bottom: 1px solid #ccc; }
.histo-slot { flex: 1; }
.histo-bar {
  background: #D2691E;
  border: 1px solid #a95616;
  border-bottom: none;
}
.histo-bar.empty { border: none; }
.histo-label { flex: 1; margin-top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Today's leaderboard */
.leaderboard {
  margin-top: 16px;
  padding: 16px 12px;
  border: 2px solid #000;
  background: #fff;
}
.leaderboard > .muted { margin: 0; font-size: 14px; }
.leaderboard-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.leaderboard-count { margin: 2px 0 10px; font-size: 13px; }
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.leaderboard-table th {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid #000;
}
.leaderboard-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #eee; }
.leaderboard-table .col-rank { width: 2.5em; color: var(--muted); }
.leaderboard-table .col-num,
.leaderboard-table th.col-num { text-align: right; white-space: nowrap; }
.leaderboard-table .col-name { overflow-wrap: anywhere; }
.leaderboard-table .anonymous { color: var(--muted); font-style: italic; }
.leaderboard-table tr.you td { background: #fde3cf; font-weight: 600; }
.leaderboard-table tr.you .col-rank { color: var(--text); }
.leaderboard-table .gap-row td { color: var(--muted); text-align: center; padding: 2px; }
footer {
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}
@media (max-width: 650px) {
  h1 { font-size: 36px; letter-spacing: 6px; }
  .histo-bars, .histo-labels { gap: 3px; }
  .histo-label { font-size: 9px; }
  .leaderboard { padding: 14px 6px; }
  .leaderboard-table { font-size: 13px; }
  .leaderboard-table th, .leaderboard-table td { padding: 6px 4px; }
}
