:root {
  --bg: #0d0e14;
  --panel: #16181f;
  --panel2: #1d2029;
  --text: #e8e6e3;
  --muted: #8b8f9a;
  --accent: #c62828;
  --accent2: #6a1b9a;
  --green: #2e7d32;
  --blue: #1565c0;
  --gold: #c9a227;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #2b1d33 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
}
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 0.85em; }
.err { color: #ff8a80; min-height: 1.2em; font-size: 0.9em; }

/* ---------------- cards / screens */
.card {
  max-width: 520px;
  margin: 8vh auto 4vh;
  background: var(--panel);
  border: 1px solid #2c2f3a;
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: 0 18px 60px rgba(0,0,0,.5);
}
.card.wide { max-width: 680px; }
.title {
  font-size: 2.2em;
  margin: 0 0 .3em;
  letter-spacing: .5px;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(198,40,40,.45);
}
.title.small { font-size: 1.5em; }
.subtitle { color: var(--muted); margin-top: 0; }

.field { margin: 14px 0; display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .85em; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
input {
  background: var(--panel2);
  border: 1px solid #343845;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1em;
  outline: none;
}
input:focus { border-color: var(--accent2); }

.btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid #3a3e4c;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 1em;
  cursor: pointer;
  transition: .15s;
}
.btn:hover { filter: brightness(1.2); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); }
.btn.primary:hover { filter: brightness(1.25); }
.btn.danger { background: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn.ghost { opacity: .7; }
.btn.small { padding: 6px 12px; font-size: .9em; border-radius: 7px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.link { background: none; border: none; color: var(--muted); cursor: pointer; text-decoration: underline; }
.rowcenter { display: flex; gap: 12px; margin: 18px 0; }

/* ---------------- lobby */
.players { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.playerchip {
  border: 1px solid #3a3e4c;
  background: var(--panel2);
  border-radius: 10px;
  padding: 8px 14px;
}
.playerchip.bot { background: #14161d; border-style: dashed; }
.host { color: var(--gold); font-size: .85em; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 10px 0; }
.charcard { border: 1px solid #3a3e4c; border-left: 4px solid; border-radius: 8px; padding: 8px; font-size: .85em; }
.charcard.omb { border-left-color: #8a2b62; }
.charcard.cha { border-left-color: #2b6f8a; }
.charcard.neu { border-left-color: #4a7a3a; }
.charcard .cond { color: var(--muted); font-size: .92em; margin-top: 4px; }

.log {
  background: var(--panel2);
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
  padding: 10px;
  font-size: .88em;
  color: #cfcdc9;
}

/* ---------------- jeu */
#gameScreen { display: none; height: 100vh; }
#gameScreen.active { display: flex; flex-direction: column; }
#gameScreen header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 16px;
  background: rgba(0,0,0,.35);
  border-bottom: 1px solid #2c2f3a;
}
#gameScreen .code { color: var(--muted); }
#gameScreen .turn { font-size: 1.05em; }
#gameScreen main { flex: 1; display: flex; min-height: 0; }
.boardwrap { flex: 1; position: relative; padding: 16px; overflow: auto; }
#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 340px;
}
.zone {
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid #33363f;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.zone.here { border-color: var(--gold); box-shadow: 0 0 14px rgba(201,162,39,.25); }
.znums { position: absolute; top: 8px; right: 10px; color: var(--gold); font-weight: 700; font-size: .9em; }
.zicon { font-size: 1.6em; }
.zname { font-weight: 700; }
.zeffect { color: var(--muted); font-size: .78em; flex: 1; }
.zocc { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pawn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-size: .58em;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
  border: 2px solid rgba(255,255,255,.25);
}
.pawn[data-me] { outline: 2px solid var(--gold); outline-offset: 1px; }

.side { width: 330px; border-left: 1px solid #2c2f3a; padding: 14px; overflow-y: auto; background: rgba(0,0,0,.25); }
.mecard { background: var(--panel); border: 1px solid #2c2f3a; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.merow { margin: 3px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.merow.cond { color: var(--muted); font-size: .85em; }
.merow.eq { font-size: .85em; color: #cfcdc9; }
.charname { font-size: 1.15em; font-weight: 700; }
.bar { background: #0a0a0e; border-radius: 6px; height: 8px; overflow: hidden; margin: 6px 0; }
.barfill { background: linear-gradient(90deg, #2e7d32, #ef6c00, #c62828); height: 100%; transition: width .3s; }

.pending {
  background: var(--panel);
  border: 1px dashed #3a3e4c;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.pending.active { border-color: var(--gold); border-style: solid; }
.ptext { margin-bottom: 8px; }
.pchoices, .ptargets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.attackbar { margin-bottom: 12px; }
.abilitybox { background: var(--panel); border: 1px solid #2c2f3a; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }

.badge {
  font-size: .72em;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid;
}
.badge.omb { color: #ff9fb6; border-color: #8a2b62; }
.badge.cha { color: #9bd8ff; border-color: #2b6f8a; }
.badge.neu { color: #b8e2a8; border-color: #4a7a3a; }
.badge.unknown { color: var(--muted); border-color: var(--muted); }

#gameScreen footer { border-top: 1px solid #2c2f3a; background: rgba(0,0,0,.35); padding: 8px 16px; display: flex; gap: 16px; }
.strip { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.pstrip { border: 1px solid #343845; border-left-width: 4px; border-radius: 9px; padding: 6px 10px; min-width: 130px; background: var(--panel); font-size: .85em; }
.pstrip.dead { opacity: .45; filter: grayscale(.6); }
.pstrip.me { background: var(--panel2); }
.ps-row { white-space: nowrap; }
.ps-row.dmg { color: var(--muted); }
.ps-row.eq { color: #9fb7d0; font-size: .9em; max-width: 220px; white-space: normal; }

.logbox {
  flex: 1;
  background: var(--panel);
  border: 1px solid #2c2f3a;
  border-radius: 10px;
  padding: 8px 12px;
  overflow-y: auto;
  max-height: 130px;
  font-size: .85em;
  color: #cfcdc9;
}

.gameover {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 8, 16, .95);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 20px 28px;
  text-align: center;
  z-index: 30;
  box-shadow: 0 0 40px rgba(201,162,39,.4);
}

/* CSS pour le log : nouveaux événements surlignés + bouton live flottant */
.logbox .lognew { background: rgba(201,162,39,.10); border-radius: 4px; }
#logLive {
  position: absolute; bottom: 10px; right: 14px;
  background: var(--gold); color: #16181f; border: none; border-radius: 16px;
  padding: 4px 12px; font-size: .85em; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.5);
}

@media (max-width: 900px) {
  #gameScreen main { flex-direction: column; }
  .side { width: auto; border-left: none; border-top: 1px solid #2c2f3a; max-height: 45vh; }
  #board { grid-template-rows: repeat(2, 140px); }
  #board { height: auto; }
  #gameScreen footer { flex-direction: column; }
}