:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --text: #26221c;
  --muted: #6b6459;
  --border: #ddd6c9;
  --accent: #2a9d8f;
  --danger: #d1495b;

  --c-depart: #d9d4c7;
  --c-travail: #f2c14e;
  --c-repos: #8ecae6;
  --c-investir: #f4a261;
  --c-encherir: #52b788;
  --c-loterie: #b088f9;
  --c-evenement: #4d96c9;
  --c-payday: #ffd166;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.2rem; margin: 0; }

.code-badge {
  font-family: monospace;
  font-size: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
}

#app { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.hidden { display: none !important; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.card h2 { margin-top: 0; }

label { display: block; margin: 0.6rem 0; font-size: 0.9rem; color: var(--muted); }
input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}
input[type="color"] { padding: 0.15rem; height: 2.4rem; }

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.75rem;
}
button:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
button.secondary { background: var(--muted); }
button.danger { background: var(--danger); }

#screen-home { display: flex; gap: 1rem; flex-wrap: wrap; }
#screen-home .card { flex: 1 1 260px; }

.error { color: var(--danger); font-weight: 600; }
.hint { color: var(--muted); font-size: 0.9rem; }

.code-big { font-family: monospace; font-size: 1.6rem; letter-spacing: 0.1em; }

.player-chip-list, .players-list { list-style: none; padding: 0; margin: 0; }
.player-chip-list li, .players-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.player-chip-list li:last-child, .players-list li:last-child { border-bottom: none; }

.dot {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.2);
}

.players-list .active { font-weight: 700; }
.players-list .bankrupt { text-decoration: line-through; opacity: 0.6; }
.players-list .stat { color: var(--muted); font-size: 0.85rem; margin-left: auto; text-align: right; }

/* --- Plateau --- */
.board-layout { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.board-wrap { flex: 2 1 480px; overflow-x: auto; }
.side-panel { flex: 1 1 260px; min-width: 260px; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(64px, 1fr));
  gap: 4px;
  min-width: 480px;
}

.day-cell {
  position: relative;
  border-radius: 6px;
  padding: 0.35rem;
  min-height: 64px;
  font-size: 0.75rem;
  color: rgba(0,0,0,0.65);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.day-cell .day-number { font-weight: 700; }
.day-cell.type-DEPART { background: var(--c-depart); }
.day-cell.type-TRAVAIL { background: var(--c-travail); }
.day-cell.type-REPOS { background: var(--c-repos); }
.day-cell.type-INVESTIR { background: var(--c-investir); }
.day-cell.type-ENCHERIR { background: var(--c-encherir); }
.day-cell.type-LOTERIE { background: var(--c-loterie); }
.day-cell.type-EVENEMENT { background: var(--c-evenement); }
.day-cell.payday {
  background: var(--c-payday);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 50%;
  width: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tokens-on-cell { display: flex; flex-wrap: wrap; gap: 2px; }
.token {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 1.5px solid white;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.75rem; margin-top: 0.5rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.legend .swatch { width: 0.8rem; height: 0.8rem; border-radius: 3px; display: inline-block; }

.activity-log { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; font-size: 0.85rem; }
.activity-log li { padding: 0.3rem 0; border-bottom: 1px dashed var(--border); }
.activity-log .amount-pos { color: #2a9d8f; font-weight: 700; }
.activity-log .amount-neg { color: var(--danger); font-weight: 700; }

.final-scores { padding-left: 1.4rem; }
.final-scores li { margin-bottom: 0.4rem; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}
.modal {
  background: var(--panel);
  border-radius: 10px;
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
}
.modal h3 { margin-top: 0; }
.modal .row { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.modal .row button { flex: 1; margin-top: 0; }

@media (max-width: 720px) {
  .board-grid { grid-template-columns: repeat(7, minmax(40px, 1fr)); }
  .day-cell { min-height: 48px; font-size: 0.65rem; padding: 0.2rem; }
}
