:root {
  --bg-primary: #1a1a2e;
  --bg-card: #16213e;
  --accent-gold: #f4d03f;
  --accent-red: #e74c3c;
  --accent-green: #27ae60;
  --text-primary: #ffffff;
  --text-muted: #a0a0a0;
  --border: #2c3e50;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 1rem;
}

#app { max-width: 480px; margin: 0 auto; }

/* Pages */
.page { display: none; animation: fadeIn 0.2s ease-out; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Home */
.logo { font-size: 4rem; text-align: center; margin-top: 2rem; }
h1 { text-align: center; font-size: 1.8rem; margin: 0.5rem 0; }
.tagline { text-align: center; color: var(--text-muted); margin-bottom: 2rem; }
.home-actions { display: flex; flex-direction: column; gap: 0.75rem; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 0.875rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent-gold); color: #1a1a2e; }
.btn-secondary { background: var(--border); color: var(--text-primary); }
.btn-danger { background: var(--accent-red); color: white; }
.btn-small { padding: 0.5rem 0.75rem; font-size: 0.85rem; width: auto; }
.btn-back { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; margin-bottom: 1rem; padding: 0.25rem 0; }

/* Forms */
form { display: flex; flex-direction: column; gap: 1rem; }
label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; }
input, select {
  width: 100%;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent-gold); outline-offset: 0; }

/* Lobby */
.lobby-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; }
.lobby-header h2 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.code-display { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.9rem; }
.code { font-family: 'Courier New', monospace; font-weight: 700; color: var(--accent-gold); font-size: 1.1rem; letter-spacing: 2px; }
.btn-copy { background: none; border: none; cursor: pointer; font-size: 1rem; opacity: 0.6; transition: opacity 0.2s; }
.btn-copy:hover { opacity: 1; }
.lobby-actions-top { display: flex; gap: 0.5rem; }

/* Players */
.players-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }

.player-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s;
  user-select: none;
}
.player-card:active { transform: scale(0.98); }

.player-info { display: flex; flex-direction: column; gap: 0.25rem; }
.player-pseudo { font-weight: 600; font-size: 1rem; }
.player-badge { font-size: 0.7rem; background: var(--accent-gold); color: #1a1a2e; padding: 0.15rem 0.4rem; border-radius: 4px; display: inline-block; }
.player-solde { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.player-solde.positive { color: var(--accent-green); }
.player-solde.negative { color: var(--accent-red); }

@keyframes flashGreen {
  0%, 100% { background: var(--bg-card); }
  50% { background: rgba(39, 174, 96, 0.3); }
}
@keyframes flashRed {
  0%, 100% { background: var(--bg-card); }
  50% { background: rgba(231, 76, 60, 0.3); }
}
.flash-positive { animation: flashGreen 0.5s ease-out; }
.flash-negative { animation: flashRed 0.5s ease-out; }

/* Player action modal */
.player-action-buttons { display: flex; flex-direction: column; gap: 0.75rem; margin: 1.5rem 0; }
.player-action-buttons .btn { padding: 1.5rem; font-size: 1.2rem; }
#player-action-subtitle { text-align: center; color: var(--text-muted); margin-top: 0.5rem; }
.btn-cancel { background: none; border: none; color: var(--text-muted); cursor: pointer; width: 100%; padding: 0.75rem; }

/* Transactions List */
.transactions-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; max-height: 60vh; overflow-y: auto; }
.transaction-item {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.15s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
.transaction-info { font-size: 0.9rem; }
.transaction-arrow { color: var(--text-muted); margin: 0 0.5rem; }
.transaction-montant { font-weight: 700; font-variant-numeric: tabular-nums; }
.transaction-montant.positive { color: var(--accent-green); }
.transaction-montant.negative { color: var(--accent-red); }
.transaction-time { font-size: 0.75rem; color: var(--text-muted); }

/* Lobby Actions */
.lobby-actions { display: flex; flex-direction: column; gap: 0.75rem; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); justify-content: center; align-items: center; padding: 1rem; z-index: 100; }
.modal.active { display: flex; }
.modal-content { background: var(--bg-card); border-radius: 16px; padding: 1.5rem; width: 100%; max-width: 360px; }
.modal-content h3 { margin-bottom: 1rem; text-align: center; }
.modal-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.modal-actions .btn { flex: 1; }

/* Big Code for invite */
.big-code { font-family: 'Courier New', monospace; font-size: 3rem; font-weight: 700; text-align: center; color: var(--accent-gold); letter-spacing: 8px; padding: 1.5rem; background: var(--bg-primary); border-radius: 12px; margin: 1rem 0; }

/* Archived banner */
.archive-banner { background: var(--accent-red); color: white; text-align: center; padding: 0.5rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }

/* NumPad */
.numpad-container { margin: 1rem 0; }
.numpad-amount-display {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 60px;
}
.numpad-amount-display span:first-child { font-size: 1.5rem; color: var(--accent-gold); font-weight: 700; }
#numpad-value { font-size: 2rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: 2px; }

.numpad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad-btn {
  background: var(--bg-primary);
  border: none;
  border-radius: 12px;
  padding: 1rem;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.numpad-btn:active { background: var(--border); transform: scale(0.95); }
.numpad-btn.numpad-clear { color: var(--accent-red); }
.numpad-btn.numpad-back { font-size: 1.2rem; }

/* Transfer row selects */
.transfer-row { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.75rem; }
.transfer-row label { font-size: 0.8rem; color: var(--text-muted); }
.transfer-row select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

/* Section title */
.section-title { font-size: 1rem; color: var(--text-muted); margin: 2rem 0 0.75rem 0; }

/* Parties list */
.parties-list { display: flex; flex-direction: column; gap: 0.5rem; }
.party-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.party-card:active { transform: scale(0.98); }
.party-card .party-info { display: flex; flex-direction: column; gap: 0.2rem; }
.party-card .party-nom { font-weight: 600; }
.party-card .party-code { font-family: 'Courier New', monospace; color: var(--accent-gold); font-size: 0.9rem; }
.party-card .party-join { color: var(--text-muted); font-size: 0.9rem; }

/* Player join buttons */
.existing-players { display: flex; flex-direction: column; gap: 0.5rem; }
.player-join-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s;
}
.player-join-btn:active { transform: scale(0.98); }
.player-join-btn:hover { border-color: var(--accent-gold); }
.player-join-pseudo { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.player-join-solde { color: var(--text-muted); font-size: 0.9rem; }

/* Toast */
#toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 100px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#toast.visible { opacity: 1; }
/* Pending badge */
.pending-badge {
  display: inline-block;
  background: var(--accent-gold);
  color: #1a1a2e;
  font-size: 0.65rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  margin-left: 0.3rem;
  vertical-align: middle;
}
.transaction-item.pending {
  opacity: 0.7;
  border-left: 3px solid var(--accent-gold);
}
