Files
argument.es/frontend.css
Malin 40c919fc64 feat: add viewer voting on user answers with leaderboard scoring
Viewers can now vote for their favourite audience answers during the
30-second voting window. Votes are persisted to the DB at round end
and aggregated as SUM(votes) in the JUGADORES leaderboard.

- db.ts: add persistUserAnswerVotes(); switch getPlayerScores() to SUM(votes)
- game.ts: add userAnswerVotes to RoundState; persist votes before saveRound
- server.ts: add userAnswerVoters map + /api/vote/respuesta endpoint
- frontend.tsx: add userAnswerVotes type; vote state/handler in App; ▲ buttons in Arena
- frontend.css: flex layout for user-answer rows; user-vote-btn styles

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 18:26:09 +01:00

1102 lines
22 KiB
CSS

/* ── Reset & Variables ────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg: #0a0a0a;
--surface: #111;
--border: #1c1c1c;
--text: #ededed;
--text-dim: #888;
--text-muted: #444;
--accent: #D97757;
--serif: 'DM Serif Display', Georgia, serif;
--sans: 'Inter', -apple-system, sans-serif;
--mono: 'JetBrains Mono', 'SF Mono', monospace;
}
body {
background: var(--bg);
color: var(--text);
font-family: var(--sans);
font-size: 14px;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
min-height: 100vh;
min-height: 100dvh;
}
/* ── Layout ──────────────────────────────────────────────────── */
.app {
min-height: 100vh;
min-height: 100dvh;
display: flex;
flex-direction: column;
}
.layout {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
}
.main {
flex: 1;
padding: 20px;
overflow-y: auto;
display: flex;
flex-direction: column;
}
/* ── Header ──────────────────────────────────────────────────── */
.header {
flex-shrink: 0;
margin-bottom: 28px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.logo {
display: inline-flex;
text-decoration: none;
}
.logo img {
height: 20px;
width: auto;
}
.viewer-pill {
display: inline-flex;
align-items: center;
gap: 8px;
font-family: var(--mono);
font-size: 11px;
letter-spacing: 0.4px;
text-transform: uppercase;
color: var(--text-dim);
border: 1px solid var(--border);
background: rgba(255, 255, 255, 0.02);
border-radius: 999px;
padding: 6px 10px;
white-space: nowrap;
}
.viewer-pill__dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #22c55e;
box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
animation: viewer-pulse 1.8s ease-out infinite;
}
@keyframes viewer-pulse {
0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
/* ── Arena ────────────────────────────────────────────────────── */
.arena {
flex: 1;
display: flex;
flex-direction: column;
}
.arena__meta {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 24px;
flex-shrink: 0;
}
.arena__round {
font-family: var(--mono);
font-size: 13px;
font-weight: 700;
letter-spacing: 0.5px;
text-transform: uppercase;
}
.arena__round .dim {
color: var(--text-muted);
}
.arena__phase {
font-family: var(--mono);
font-size: 11px;
letter-spacing: 1px;
text-transform: uppercase;
color: var(--text-dim);
}
.vote-panel {
margin: -10px 0 22px;
display: flex;
flex-direction: column;
gap: 10px;
}
.vote-panel__label {
font-family: var(--mono);
font-size: 11px;
letter-spacing: 0.5px;
text-transform: uppercase;
color: var(--text-muted);
}
.vote-panel__buttons {
display: flex;
gap: 10px;
}
.vote-btn {
flex: 1;
padding: 10px 16px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
cursor: pointer;
font-family: var(--sans);
font-size: 13px;
transition: border-color 0.15s, background 0.15s;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
}
.vote-btn:hover {
border-color: #444;
background: #1a1a1a;
}
.vote-btn--active {
border-color: var(--accent);
background: rgba(217, 119, 87, 0.12);
}
.vote-btn--active:hover {
background: rgba(217, 119, 87, 0.18);
}
/* ── Prompt ───────────────────────────────────────────────────── */
.prompt {
margin-bottom: 32px;
flex-shrink: 0;
}
.prompt__by {
font-family: var(--mono);
font-size: 11px;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.prompt__text {
font-family: var(--serif);
font-size: clamp(28px, 5vw, 52px);
line-height: 1.15;
color: var(--text);
letter-spacing: -0.5px;
border-left: 3px solid var(--accent);
padding-left: 20px;
}
.prompt__text--loading {
color: var(--text-muted);
border-left-color: var(--border);
}
.prompt__text--error {
color: #ef4444;
font-family: var(--mono);
font-size: 16px;
border-left-color: #ef4444;
}
/* ── Showdown ─────────────────────────────────────────────────── */
.showdown {
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
min-height: 0;
}
/* ── Contestant ───────────────────────────────────────────────── */
.contestant {
border-left: 3px solid var(--accent);
padding: 16px 20px;
display: flex;
flex-direction: column;
gap: 12px;
transition: background 0.3s;
}
.contestant--winner {
border-left-width: 4px;
background: rgba(255, 255, 255, 0.03);
animation: winner-reveal 1.5s ease-out;
}
@keyframes winner-reveal {
0% { background: rgba(255, 255, 255, 0); }
30% { background: rgba(255, 255, 255, 0.06); }
100% { background: rgba(255, 255, 255, 0.03); }
}
.contestant__head {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
.win-tag {
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 1px;
padding: 3px 8px;
background: var(--text);
color: var(--bg);
border-radius: 3px;
}
.contestant__body {
flex: 1;
min-height: 0;
}
.answer {
font-family: var(--serif);
font-size: clamp(20px, 3.5vw, 28px);
line-height: 1.3;
color: var(--text-dim);
letter-spacing: -0.3px;
}
.contestant--winner .answer {
color: var(--text);
}
.answer--loading {
color: var(--text-muted);
}
.answer--error {
color: #ef4444;
font-family: var(--mono);
font-size: 13px;
}
.contestant__foot {
display: flex;
flex-direction: column;
gap: 8px;
flex-shrink: 0;
}
/* ── Vote Bar ─────────────────────────────────────────────────── */
.vote-bar {
height: 3px;
background: var(--border);
border-radius: 2px;
overflow: hidden;
}
.vote-bar__fill {
height: 100%;
border-radius: 2px;
transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.vote-meta {
display: flex;
align-items: center;
gap: 6px;
font-family: var(--mono);
font-size: 12px;
}
.vote-meta__count {
font-weight: 700;
font-size: 16px;
}
.vote-meta__label {
color: var(--text-muted);
}
.vote-meta__dots {
display: flex;
gap: 4px;
margin-left: auto;
}
.voter-dot {
width: 16px;
height: 16px;
border-radius: 50%;
object-fit: contain;
opacity: 0.7;
}
.voter-dot--letter {
font-size: 10px;
font-weight: 700;
display: inline-flex;
align-items: center;
justify-content: center;
}
/* ── Votable Contestant ──────────────────────────────────────── */
.contestant--votable {
cursor: pointer;
transition: background 0.2s, border-color 0.2s;
}
.contestant--votable:hover {
background: rgba(255, 255, 255, 0.04);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.contestant--votable:active {
background: rgba(255, 255, 255, 0.06);
}
/* ── My Vote Highlight ──────────────────────────────────────── */
.contestant--my-vote {
background: rgba(255, 255, 255, 0.03);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.my-vote-tag {
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 1px;
padding: 3px 8px;
border: 1px solid var(--text-muted);
color: var(--text-dim);
border-radius: 3px;
}
/* ── Viewer Votes ────────────────────────────────────────────── */
.viewer-vote-bar {
margin-top: 4px;
}
.viewer-vote-bar__fill {
background: #666 !important;
}
.viewer-vote-meta {
color: var(--text-muted);
}
.viewer-vote-meta__count {
color: #999 !important;
}
.viewer-vote-meta__icon {
margin-left: auto;
font-size: 14px;
}
.vote-countdown {
color: var(--text);
font-weight: 700;
margin-left: 8px;
}
/* ── Tie ──────────────────────────────────────────────────────── */
.tie-label {
text-align: center;
font-family: var(--mono);
font-size: 13px;
font-weight: 700;
letter-spacing: 1px;
text-transform: uppercase;
color: var(--text-muted);
padding: 16px 0;
}
/* ── Standings ────────────────────────────────────────────────── */
.standings {
border-top: 1px solid var(--border);
background: var(--surface);
padding: 16px 20px;
display: flex;
flex-direction: column;
gap: 20px;
max-height: 50vh;
overflow-y: auto;
flex-shrink: 0;
}
.standings__head {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.standings__links {
display: flex;
gap: 10px;
}
.standings__title {
font-family: var(--mono);
font-size: 11px;
font-weight: 700;
letter-spacing: 1px;
text-transform: uppercase;
color: var(--text-dim);
}
.standings__link {
font-family: var(--mono);
font-size: 11px;
color: var(--text-muted);
text-decoration: none;
transition: color 0.2s;
}
.standings__link:hover {
color: var(--text);
}
/* ── Leaderboard Section ─────────────────────────────────────── */
.lb-section {
display: flex;
flex-direction: column;
gap: 2px;
}
.lb-section__head {
padding-bottom: 6px;
border-bottom: 1px solid var(--border);
margin-bottom: 2px;
}
.lb-section__label {
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 1.5px;
text-transform: uppercase;
color: var(--text-muted);
}
.lb-section__list {
display: flex;
flex-direction: column;
}
/* ── Leaderboard Entry ───────────────────────────────────────── */
.lb-entry {
padding: 6px 0 4px;
opacity: 0.55;
transition: opacity 0.3s;
}
.lb-entry--active,
.lb-entry:hover {
opacity: 1;
}
.lb-entry__top {
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 5px;
}
.lb-entry__rank {
width: 20px;
flex-shrink: 0;
text-align: center;
font-family: var(--mono);
font-size: 11px;
color: var(--text-muted);
}
.lb-entry__score {
margin-left: auto;
font-family: var(--mono);
font-size: 12px;
font-weight: 700;
color: var(--text-dim);
min-width: 14px;
text-align: right;
}
.lb-entry__bar {
margin-left: 26px;
height: 3px;
background: var(--border);
border-radius: 2px;
overflow: hidden;
}
.lb-entry__fill {
height: 100%;
border-radius: 2px;
transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
/* ── Connecting ───────────────────────────────────────────────── */
.connecting {
height: 100vh;
height: 100dvh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16px;
background: var(--bg);
}
.connecting__logo {
display: flex;
}
.connecting__logo img {
height: 64px;
width: auto;
}
.connecting__sub {
font-family: var(--mono);
font-size: 13px;
color: var(--text-muted);
letter-spacing: 1px;
text-transform: uppercase;
}
/* ── Waiting ──────────────────────────────────────────────────── */
.waiting {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-family: var(--serif);
font-size: 28px;
color: var(--text-muted);
}
/* ── Game Over ────────────────────────────────────────────────── */
.game-over {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
gap: 28px;
padding: 48px 0;
}
.game-over__label {
font-family: var(--mono);
font-size: 14px;
font-weight: 700;
letter-spacing: 3px;
text-transform: uppercase;
color: var(--text-muted);
}
.game-over__winner {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
}
.game-over__crown { font-size: 40px; }
.game-over__name {
font-family: var(--serif);
font-size: clamp(32px, 7vw, 56px);
line-height: 1.1;
display: flex;
align-items: center;
gap: 16px;
}
.game-over__name img { width: 40px; height: 40px; }
.game-over__sub {
font-size: 14px;
color: var(--text-dim);
}
/* ── Next Round Toast ─────────────────────────────────────────── */
.next-toast {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: var(--surface);
border: 1px solid var(--border);
padding: 10px 20px;
border-radius: 20px;
font-family: var(--mono);
font-size: 12px;
color: var(--text-dim);
display: flex;
align-items: center;
gap: 6px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
z-index: 100;
animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
white-space: nowrap;
max-width: calc(100vw - 40px);
}
@keyframes toast-in {
from { opacity: 0; transform: translate(-50%, 12px); }
to { opacity: 1; transform: translate(-50%, 0); }
}
/* ── Model Tag ────────────────────────────────────────────────── */
.model-tag {
display: inline-flex;
align-items: center;
gap: 6px;
font-weight: 600;
font-size: 14px;
white-space: nowrap;
}
.model-tag--sm {
font-size: 12px;
gap: 4px;
}
.model-tag__logo {
width: 18px;
height: 18px;
object-fit: contain;
}
.model-tag--sm .model-tag__logo {
width: 14px;
height: 14px;
}
/* ── Utility ──────────────────────────────────────────────────── */
.dots span {
animation: blink 1.4s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
0%, 80%, 100% { opacity: 0.15; }
40% { opacity: 1; }
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
/* ── Site footer (inside main) ───────────────────────────────── */
.site-footer {
flex-shrink: 0;
margin-top: 32px;
padding: 16px 0 4px;
border-top: 1px solid var(--border);
font-size: 11px;
color: var(--text-muted);
line-height: 1.9;
}
.site-footer a {
color: var(--text-dim);
text-decoration: none;
}
.site-footer a:hover {
color: var(--text);
text-decoration: underline;
}
/* ── Player leaderboard name ─────────────────────────────────── */
.lb-entry__name {
font-size: 12px;
font-weight: 500;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* ── User answers (audience) ─────────────────────────────────── */
.user-answers {
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid var(--border);
}
.user-answers__label {
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 1.5px;
text-transform: uppercase;
color: var(--text-muted);
margin-bottom: 8px;
}
.user-answers__list {
display: flex;
flex-direction: column;
gap: 6px;
}
.user-answer {
font-size: 13px;
line-height: 1.4;
display: flex;
align-items: center;
gap: 8px;
justify-content: space-between;
}
.user-answer__main {
flex: 1;
min-width: 0;
}
.user-answer__vote {
display: flex;
align-items: center;
gap: 5px;
flex-shrink: 0;
}
.user-vote-btn {
background: none;
border: 1px solid var(--border);
border-radius: 4px;
color: var(--text-muted);
font-size: 10px;
padding: 2px 7px;
cursor: pointer;
transition: border-color 0.15s, color 0.15s;
line-height: 1.4;
}
.user-vote-btn:hover {
border-color: #444;
color: var(--text-dim);
}
.user-vote-btn--active {
border-color: var(--accent);
color: var(--accent);
}
.user-vote-count {
font-family: var(--mono);
font-size: 11px;
font-weight: 700;
color: var(--text-muted);
min-width: 14px;
text-align: right;
}
.user-answer__name {
font-family: var(--mono);
font-size: 11px;
font-weight: 700;
color: var(--accent);
}
.user-answer__sep {
color: var(--text-muted);
}
.user-answer__text {
color: var(--text-dim);
font-family: var(--serif);
font-size: 15px;
}
/* ── Propose Answer widget ───────────────────────────────────── */
.propose {
flex-shrink: 0;
border-top: 1px solid var(--border);
padding: 14px 0 10px;
display: flex;
flex-direction: column;
gap: 8px;
}
.propose__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.propose__title {
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 1.2px;
text-transform: uppercase;
color: var(--text-muted);
}
.propose__badge {
font-size: 11px;
font-weight: 600;
color: #4caf7d;
background: rgba(76, 175, 125, 0.12);
border: 1px solid rgba(76, 175, 125, 0.25);
border-radius: 20px;
padding: 2px 10px;
white-space: nowrap;
}
.propose__badge--empty {
color: var(--text-muted);
background: rgba(255, 255, 255, 0.03);
border-color: var(--border);
}
.propose__tiers {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
}
.propose__tier {
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
padding: 8px 6px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 7px;
cursor: pointer;
font-family: var(--sans);
color: var(--text);
transition: border-color 0.15s, background 0.15s;
}
.propose__tier:hover { border-color: #444; }
.propose__tier--selected {
border-color: var(--accent);
background: rgba(217, 119, 87, 0.08);
}
.propose__tier__price {
font-size: 14px;
font-weight: 700;
color: var(--accent);
}
.propose__tier__label {
font-size: 10px;
color: var(--text-dim);
}
.propose__row {
display: flex;
gap: 6px;
align-items: flex-start;
}
.propose__row--mt { margin-top: 2px; }
.propose__input {
flex: 1;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 6px;
padding: 7px 10px;
color: var(--text);
font-family: var(--sans);
font-size: 13px;
min-width: 0;
}
.propose__input:focus { outline: none; border-color: #444; }
.propose__input::placeholder { color: var(--text-muted); }
.propose__textarea {
flex: 1;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 6px;
padding: 7px 10px;
color: var(--text);
font-family: var(--sans);
font-size: 13px;
line-height: 1.4;
resize: none;
min-width: 0;
}
.propose__textarea:focus { outline: none; border-color: #444; }
.propose__textarea::placeholder { color: var(--text-muted); }
.propose__btn {
padding: 7px 14px;
background: var(--accent);
border: none;
border-radius: 6px;
color: #fff;
font-size: 13px;
font-weight: 600;
cursor: pointer;
font-family: var(--sans);
white-space: nowrap;
flex-shrink: 0;
transition: opacity 0.15s;
}
.propose__btn:hover:not(:disabled) { opacity: 0.85; }
.propose__btn:disabled { opacity: 0.35; cursor: not-allowed; }
.propose__hint {
font-size: 11px;
color: var(--text-muted);
font-family: var(--mono);
}
.propose__msg {
font-size: 12px;
margin: 0;
}
.propose__msg--ok { color: #4caf7d; }
.propose__msg--error { color: #ff6b6b; }
.propose__spinner {
width: 14px;
height: 14px;
border: 2px solid var(--border);
border-top-color: var(--accent);
border-radius: 50%;
animation: propose-spin 0.8s linear infinite;
flex-shrink: 0;
}
@keyframes propose-spin { to { transform: rotate(360deg); } }
.propose__link-btn {
background: none;
border: none;
padding: 0;
color: var(--text-muted);
font-size: 11px;
font-family: var(--mono);
cursor: pointer;
text-decoration: underline;
}
.propose__link-btn:hover { color: var(--text-dim); }
/* ── Desktop (1024px+) ───────────────────────────────────────── */
@media (min-width: 1024px) {
body {
height: 100vh;
overflow: hidden;
}
.app { height: 100vh; }
.layout {
flex-direction: row;
overflow: hidden;
}
.main {
padding: 88px 48px 32px;
position: relative;
align-items: center;
}
.header {
position: absolute;
top: 32px;
left: 48px;
right: 48px;
margin-bottom: 0;
}
.arena {
max-width: 900px;
width: 100%;
margin: auto 0;
}
.prompt { margin-bottom: 40px; }
.prompt__text { padding-left: 24px; }
.showdown {
flex-direction: row;
align-items: flex-start;
gap: 32px;
}
.contestant { flex: 1; }
.standings {
width: 280px;
border-top: none;
border-left: 1px solid var(--border);
max-height: none;
overflow-y: auto;
padding: 24px;
gap: 24px;
}
}