:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b675f;
  --line: #e2dfd8;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --voted-bg: #fff3ec;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #201f1d;
    --text: #f1efea;
    --muted: #a39f96;
    --line: #34322e;
    --accent: #fb7a3c;
    --accent-text: #1a0d05;
    --voted-bg: #2e1f16;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 680px; margin: 0 auto; padding: 24px 16px 64px; }
header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.3rem; margin: 40px 0 8px; }
#who { color: var(--muted); font-size: 0.9rem; display: flex; gap: 10px; align-items: baseline; }
.lead { margin-top: 0; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
input {
  flex: 1; min-width: 0;
  font: inherit; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
#code { letter-spacing: 0.2em; font-variant-numeric: tabular-nums; }

button {
  font: inherit; cursor: pointer;
  padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  font-weight: 600;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--accent); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; text-decoration: underline; margin-top: 10px; }
#who button.link { margin: 0; }
.msg { color: var(--muted); min-height: 1.4em; margin: 10px 0 0; }

.sticky {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line);
}
#counter { margin: 0; font-weight: 600; }
.sticky .msg { margin: 2px 0 0; min-height: 0; color: var(--accent); }

ol { list-style: none; padding: 0; margin: 0; }
#songs li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
#songs li.voted { background: var(--voted-bg); border-color: var(--accent); }
.song { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.title { font-weight: 600; }
.artist { color: var(--muted); font-size: 0.9rem; }
.yt { color: var(--accent); white-space: nowrap; text-decoration: none; }
.yt:hover { text-decoration: underline; }
button.vote { flex: none; min-width: 96px; background: transparent; color: var(--accent); }
button.vote.on { background: var(--accent); color: var(--accent-text); }

#results-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.result-head { display: flex; align-items: center; gap: 12px; }
.count { font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
details { margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
summary { cursor: pointer; }
.voters { margin: 4px 0 0; word-break: break-word; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

#board {
  position: fixed; inset: 0; z-index: 10;
  background: var(--bg); color: var(--text);
  padding: 3vmin; cursor: pointer;
}
#board-list {
  height: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--rows, 33), minmax(0, 1fr));
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  column-gap: 2.5em;
  line-height: 1.2;
  overflow: hidden;
}
#board-list li {
  display: flex; align-items: center; gap: 0.6em;
  border-bottom: 1px solid var(--line);
  min-height: 0;
}
#board-list .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; }
#board-list .pts { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
#board-hint {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); margin: 0;
  padding: 6px 12px; border-radius: 6px; font-size: 0.85rem;
  background: var(--text); color: var(--bg);
  transition: opacity 0.4s;
}
#board-hint.gone { opacity: 0; }

