Files
tavolo/web/style.css
woggioni a606f14550 Add chess-style Elo ratings for players
Each player's rating starts at 1500 and updates transactionally with
every finished match: a team's rating is the mean of its two members
and the standard K=32 formula decides the zero-sum delta applied to
both members of a team. Ratings are per game type in a new
player_rating table; match_player records each match's elo_delta.

- GET /api/leaderboard exposes elo and sorts by it
- GET /api/me/matches includes per-player elo deltas
- new GET /api/me/ratings returns the caller's rating per game type
- frontend: Elo column on the leaderboard, per-match delta in the
  history page, current rating in the lobby
- python -m tavolo.backfill_elo recomputes all ratings from the
  recorded match history (one-off backfill for existing matches)
2026-09-18 13:36:17 +00:00

645 lines
10 KiB
CSS

/* Scopone scientifico frontend — dark table-felt theme. */
:root {
--felt: #1d5c38;
--felt-dark: #14341f;
--panel: #223026;
--panel-light: #2e4234;
--text: #f1f0e8;
--muted: #a9b7ab;
--accent: #e8c547;
--danger: #d9534f;
--team-a: #7db4e8;
--team-b: #e8967d;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: "Segoe UI", system-ui, sans-serif;
background: var(--felt-dark);
color: var(--text);
}
.app {
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* ---------- shared chrome ---------- */
.top-nav {
display: flex;
gap: 1rem;
align-items: center;
padding: 0.75rem 1rem;
background: rgba(0, 0, 0, 0.25);
}
.top-nav a {
color: var(--accent);
text-decoration: none;
}
.whoami {
margin-right: auto;
}
.whoami .rating {
color: var(--muted, #888);
}
.panel {
background: var(--panel);
border-radius: 12px;
padding: 1.25rem 1.5rem;
margin: 1rem;
}
.button {
display: inline-block;
background: var(--panel-light);
color: var(--text);
border: 1px solid #4c6a54;
border-radius: 8px;
padding: 0.55rem 1.1rem;
margin: 0.25rem 0.25rem 0.25rem 0;
cursor: pointer;
font-size: 1rem;
text-decoration: none;
}
.button.primary {
background: var(--accent);
border-color: var(--accent);
color: #1d1d1d;
font-weight: 600;
}
.button:hover {
filter: brightness(1.15);
}
.status {
color: var(--muted);
text-align: center;
margin: 2rem;
}
.toast {
position: fixed;
top: 1rem;
left: 50%;
transform: translateX(-50%);
background: var(--danger);
color: #fff;
padding: 0.6rem 1.2rem;
border-radius: 8px;
z-index: 30;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
/* ---------- lobby / pages ---------- */
.lobby h1,
.page h1 {
text-align: center;
margin-top: 2rem;
}
.lobby-grid,
.page {
max-width: 720px;
margin: 0 auto;
width: 100%;
}
.login-panel {
text-align: center;
}
.target-buttons {
display: flex;
gap: 0.5rem;
}
.check {
display: flex;
align-items: center;
gap: 0.4rem;
}
.join-form {
display: flex;
gap: 0.5rem;
}
.join-form input {
flex: 1;
font-size: 1.2rem;
text-transform: uppercase;
letter-spacing: 0.3em;
padding: 0.5rem;
border-radius: 8px;
border: 1px solid #4c6a54;
background: var(--panel-light);
color: var(--text);
}
.join-code {
font-size: 2.4rem;
font-weight: 700;
letter-spacing: 0.35em;
color: var(--accent);
text-align: center;
margin: 0.5rem 0;
}
.status-panel {
max-width: 520px;
margin: 3rem auto;
text-align: center;
}
.roster {
list-style: none;
padding: 0;
text-align: center;
}
table.matches {
width: 100%;
border-collapse: collapse;
margin: 1rem;
}
table.matches th,
table.matches td {
padding: 0.5rem 0.75rem;
text-align: left;
border-bottom: 1px solid #3c5543;
}
table.matches td.won {
color: #8bc34a;
font-weight: 600;
}
table.matches td.lost {
color: var(--muted);
}
/* ---------- game table ---------- */
.hud {
display: flex;
gap: 1.5rem;
align-items: center;
justify-content: center;
padding: 0.6rem 1rem;
background: rgba(0, 0, 0, 0.3);
}
.hud a {
color: var(--accent);
text-decoration: none;
}
.hud-scores {
font-weight: 600;
}
.turn-note {
color: var(--muted);
}
.turn-note.you {
color: var(--accent);
font-weight: 700;
}
.turn-timer {
color: var(--muted);
font-variant-numeric: tabular-nums;
}
.table-wrap {
display: flex;
flex-direction: column;
flex: 1;
}
.table-grid {
flex: 1;
display: grid;
grid-template-columns: 1fr 2.4fr 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
". top ."
"left center right"
"bottom bottom bottom";
gap: 0.5rem;
padding: 0.75rem;
}
.seat-top {
grid-area: top;
}
.seat-left {
grid-area: left;
}
.seat-right {
grid-area: right;
}
.seat-bottom {
grid-area: bottom;
text-align: center;
}
.seat {
background: var(--panel);
border: 2px solid transparent;
border-radius: 10px;
padding: 0.5rem 0.75rem;
text-align: center;
/* Fixed height keeps the table from jumping as cards are played. */
display: flex;
flex-direction: column;
justify-content: flex-start;
min-height: 116px;
align-self: center;
width: 100%;
}
.seat.active {
border-color: var(--accent);
box-shadow: 0 0 12px rgba(232, 197, 71, 0.45);
}
.seat-name {
font-weight: 600;
display: flex;
gap: 0.5rem;
align-items: center;
justify-content: center;
}
.team-badge {
font-size: 0.7rem;
background: var(--panel-light);
border-radius: 4px;
padding: 0.1rem 0.35rem;
color: var(--muted);
}
/* Opponents' hidden hands: a tidy grid so the count reads at a glance. */
.seat-cards {
display: grid;
grid-template-columns: repeat(5, auto);
gap: 2px;
justify-content: center;
margin: 0.35rem 0;
}
.seat-stats {
font-size: 0.8rem;
color: var(--muted);
margin-top: auto;
}
/* The viewer's own stats sit above the hand; no flex context here. */
.seat-bottom .seat-stats {
margin-bottom: 0.35rem;
}
.center {
grid-area: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.75rem;
min-height: 230px;
}
.table-cards {
display: flex;
flex-wrap: wrap;
gap: 0.4rem;
justify-content: center;
min-height: 90px;
align-items: center;
}
.table-empty {
color: var(--muted);
font-style: italic;
}
/* ---------- cards ---------- */
.card-img {
border-radius: 6px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
background: #fff;
user-select: none;
}
.card-img.mini {
height: 34px;
}
.card-img.move-card {
height: 54px;
vertical-align: middle;
}
.card-img.table-card {
height: 84px;
}
.card-img.hand-card {
height: 120px;
}
.hand {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
justify-content: center;
align-items: flex-end;
min-height: 132px;
}
.hand-slot {
background: none;
border: none;
padding: 0;
cursor: pointer;
transition: transform 0.1s ease;
}
.hand-slot:hover {
transform: translateY(-8px);
}
.hand-slot.selected {
outline: 3px solid var(--accent);
border-radius: 8px;
transform: translateY(-10px);
}
.hint {
color: var(--muted);
font-size: 0.85rem;
}
/* ---------- move banner ---------- */
.move-banner {
display: flex;
align-items: center;
gap: 0.4rem;
background: rgba(0, 0, 0, 0.35);
border-radius: 999px;
padding: 0.35rem 1rem;
font-size: 0.95rem;
}
.scopa-badge {
background: var(--accent);
color: #1d1d1d;
font-weight: 700;
border-radius: 999px;
padding: 0.15rem 0.6rem;
margin-left: 0.25rem;
}
/* ---------- connection banner ---------- */
.conn-banner {
display: flex;
align-items: center;
justify-content: center;
gap: 0.75rem;
background: rgba(232, 197, 71, 0.15);
border: 1px solid var(--accent);
border-radius: 8px;
color: var(--accent);
padding: 0.4rem 1rem;
margin: 0.5rem auto 0;
width: fit-content;
}
.conn-banner a {
color: var(--accent);
text-decoration: underline;
}
/* ---------- overlays ---------- */
.overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.65);
display: flex;
align-items: center;
justify-content: center;
z-index: 20;
}
.picker {
background: var(--panel);
border-radius: 14px;
padding: 1.5rem 2rem;
text-align: center;
min-width: 320px;
}
.capture-options {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin: 1rem 0;
}
.capture-option {
background: var(--panel-light);
border: 1px solid #4c6a54;
border-radius: 10px;
padding: 0.4rem;
cursor: pointer;
display: flex;
gap: 0.4rem;
justify-content: center;
}
.capture-option:hover {
border-color: var(--accent);
}
.gameover-actions {
display: flex;
gap: 0.75rem;
justify-content: center;
margin-top: 1rem;
}
/* ---------- hand-end scoring summary ---------- */
.summary-panel {
min-width: 420px;
max-width: 560px;
text-align: left;
}
.summary-panel h2 {
text-align: center;
margin-top: 0;
}
.score-rows {
display: flex;
flex-direction: column;
gap: 0.4rem;
margin: 0.75rem 0;
}
.score-row {
display: flex;
align-items: center;
gap: 0.75rem;
background: var(--panel-light);
border-left: 4px solid transparent;
border-radius: 8px;
padding: 0.45rem 0.75rem;
}
.score-row.team-a {
border-left-color: var(--team-a);
}
.score-row.team-b {
border-left-color: var(--team-b);
}
.score-row.tie {
opacity: 0.65;
}
.score-icon {
width: 32px;
flex-shrink: 0;
display: flex;
justify-content: center;
}
.card-img.score-mini {
height: 38px;
}
.score-body {
flex: 1;
}
.score-title {
font-weight: 700;
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--muted);
}
.score-text {
font-size: 0.95rem;
}
.score-points {
font-weight: 700;
white-space: nowrap;
}
.score-row.team-a .score-points {
color: var(--team-a);
}
.score-row.team-b .score-points {
color: var(--team-b);
}
.totals {
margin: 1rem 0;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.total-row {
display: grid;
grid-template-columns: 4.5rem 1fr 4rem;
gap: 0.6rem;
align-items: center;
}
.total-label {
font-weight: 600;
}
.total-value {
font-weight: 700;
text-align: right;
}
.gained {
margin-left: 0.35rem;
font-size: 0.85rem;
opacity: 0.85;
}
.total-row.team-a .gained {
color: var(--team-a);
}
.total-row.team-b .gained {
color: var(--team-b);
}
.progress {
height: 10px;
background: rgba(0, 0, 0, 0.35);
border-radius: 999px;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: 999px;
transition: width 0.4s ease;
}
.total-row.team-a .progress-fill {
background: var(--team-a);
}
.total-row.team-b .progress-fill {
background: var(--team-b);
}
.summary-actions {
text-align: center;
margin-top: 0.5rem;
}
.final-score {
text-align: center;
font-size: 1.25rem;
font-weight: 700;
}