/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #e0e0e0;
  --text-muted: #8899aa;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --success: #2ecc71;
  --warning: #f1c40f;
  --error: #e74c3c;
  --gold: #f1c40f;
  --radius: 8px;

  /* Couleurs des dés */
  --die-d4: #e74c3c;
  --die-d6: #3498db;
  --die-d8: #2ecc71;
  --die-d10: #e67e22;
  --die-d12: #9b59b6;
  --die-d20: #f1c40f;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

/* === Écrans === */
.screen { display: none; width: 100%; max-width: 700px; }
.screen.active { display: block; }

/* === Titres === */
h1 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* === Sections config === */
.config-section {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.config-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.5rem;
}

/* === Dés — formes CSS === */
.die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  position: relative;
  flex-shrink: 0;
}

.die-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.die-label {
  font-size: 0.6rem;
  font-weight: 400;
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.7;
}

.die-d4 .die-inner  { background: var(--die-d4);  clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.die-d6 .die-inner  { background: var(--die-d6);  border-radius: 6px; }
.die-d8 .die-inner  { background: var(--die-d8);  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.die-d10 .die-inner { background: var(--die-d10); clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%); }
.die-d12 .die-inner { background: var(--die-d12); clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.die-d20 .die-inner { background: var(--die-d20); border-radius: 50%; color: #1a1a2e; }

/* === Presets pool === */
.pool-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.btn-preset.active {
  color: var(--text-primary);
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.15);
}

/* === Pool de dés (config) === */
.dice-pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.dice-pool-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255,255,255,0.03);
  padding: 0.75rem;
  border-radius: var(--radius);
}

.dice-counter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.dice-counter button {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.dice-counter button:hover { background: var(--bg-card); }
.dice-counter button:active { background: var(--accent); }

.dice-counter .count {
  width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
}

.dice-total {
  margin-top: 1rem;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dice-total span { color: var(--text-primary); font-weight: 700; }

/* === Joueurs === */
.player-count-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.player-count-row label { font-weight: 600; }

.player-count-row select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
}

/* === Bots config === */
.bot-list { display: flex; flex-direction: column; gap: 0.75rem; }

.bot-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.03);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
}

.bot-row .bot-name {
  font-weight: 600;
  min-width: 60px;
}

.bot-row select, .bot-row input {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
}

.bot-row input[type="number"] { width: 80px; }

.bot-settings {
  display: flex;
  gap: 1rem;
  flex: 1;
  flex-wrap: wrap;
}

.bot-setting {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bot-setting label {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 32px;
}

.bot-row .custom-mc,
.bot-row .custom-kelly,
.bot-row .custom-bluff { display: none; }
.bot-row .custom-mc.visible,
.bot-row .custom-kelly.visible,
.bot-row .custom-bluff.visible { display: inline-block; }

.bot-row input.custom-kelly,
.bot-row input.custom-bluff { width: 70px; }

/* === Info-tip (tooltips) === */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  font-size: 0.6rem;
  color: var(--text-muted);
  cursor: default;
  position: relative;
  vertical-align: middle;
}

.info-tip:hover { color: var(--text-primary); border-color: var(--text-primary); }

.info-tip-content {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  width: 220px;
  white-space: normal;
  z-index: 10;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}

.info-tip-content strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.8rem;
}

.info-tip-content hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 0.3rem 0;
}

.info-tip:hover .info-tip-content { display: block; }

/* === Économie === */
.economy-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.economy-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.economy-field label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.economy-field input {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  width: 120px;
}

/* === Validation === */
.validation-errors {
  color: var(--error);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: 0.5rem;
}

/* === Bouton principal === */
.btn-primary {
  display: block;
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  margin-top: 0.5rem;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Bouton secondaire === */
.btn-secondary {
  padding: 0.6rem 1.2rem;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover { background: var(--bg-secondary); border-color: var(--accent); }

/* === Écran de jeu === */
#screen-game h1 { margin-bottom: 1rem; }

/* Info bandeau */
.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--bg-secondary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.game-info span { font-weight: 600; }

/* Aide contextuelle */
.game-help {
  font-style: italic;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.game-help:empty { display: none; }

/* Pool de dés (jeu) */
.game-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 1rem;
  min-height: 60px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.game-pool:empty { display: none; }

.game-pool .die {
  margin-bottom: 12px;
}

.die.clickable { cursor: pointer; background: rgba(255, 255, 255, 0.05); }
.die.clickable > * { pointer-events: none; }
.die.clickable:hover {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.die.disabled { opacity: 0.3; pointer-events: none; }

/* Joueurs */
.game-players {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.player-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.75rem;
  border: 2px solid transparent;
  transition: border-color 0.2s, opacity 0.2s;
}

.player-card.active { border-color: var(--accent); }
.player-card.folded { opacity: 0.4; }
.player-card.eliminated { opacity: 0.25; }
.player-card.winner { border-color: var(--gold); box-shadow: 0 0 12px rgba(241, 196, 15, 0.4); }

.player-card .player-win {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  margin-top: 0.4rem;
}

.player-card .player-name {
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.player-card .player-bankroll {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.player-card .player-bet {
  font-size: 0.85rem;
  color: var(--warning);
}

.player-card .player-action {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.3rem;
  padding: 0.2rem 0.5rem;
  background: rgba(233, 69, 96, 0.15);
  border-radius: 4px;
  display: inline-block;
}

.player-card .player-dice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.player-card .player-dice .die {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}

.player-card .player-dice .die .die-label { display: none; }

.player-card .player-total {
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 0.4rem;
  color: var(--success);
}

.player-card .player-eliminated {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--error);
  margin-top: 0.3rem;
}

.player-card .player-allin {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1a1a2e;
  background: var(--gold);
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  display: inline-block;
  margin-top: 0.3rem;
}

/* Actions */
.game-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1rem;
  min-height: 42px;
  align-items: center;
}

.game-actions:empty { display: none; }

.game-actions .btn-primary,
.game-actions .btn-secondary {
  display: inline-block;
  width: auto;
  margin: 0;
}

.btn-preset {
  padding: 0.3rem 0.6rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-preset:hover { color: var(--text-primary); border-color: var(--accent); }

.game-actions input[type="number"] {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  width: 100px;
}

/* Log */
.game-log {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.game-log:empty { display: none; }

.game-log div { border-bottom: 1px solid rgba(255,255,255,0.05); padding: 0.15rem 0; }

/* Badge premier joueur */
.badge-first {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 0.2rem;
}

/* Valeur de draft sur les dés du joueur */
/* Dé relancé — visible de tous */
.die-rerolled {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 0 8px rgba(241, 196, 15, 0.5);
}

/* Dé sélectionné pour relance (avant validation) */
.die.selected {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

/* === Aide — lien + modale === */
.help-link {
  position: fixed;
  top: 1rem;
  right: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  z-index: 100;
  transition: color 0.15s;
}

.help-link:hover { color: var(--text-primary); }

.help-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.help-modal.active { display: flex; }

.help-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.help-modal-content {
  position: relative;
  background: var(--bg-secondary);
  max-width: 650px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 2rem;
  border-radius: var(--radius);
  z-index: 1;
}

.help-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.help-modal-close:hover { color: var(--text-primary); }

.help-modal-content h1 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

.help-modal-content h2 {
  font-size: 1.15rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.help-modal-content h3 {
  font-size: 1rem;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.help-modal-content p {
  margin-bottom: 0.5rem;
  line-height: 1.6;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.help-modal-content ul {
  margin-bottom: 0.5rem;
  padding-left: 1.25rem;
}

.help-modal-content li {
  margin-bottom: 0.25rem;
  line-height: 1.5;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.help-modal-content strong { color: var(--text-primary); }

.die-draft-value {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.2);
}
