* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #15120c;
  --panel: #211c12;
  --panel2: #2b2417;
  --border: #3d3420;
  --text: #efe6d0;
  --muted: #a89a78;
  --gold: #e0b34c;
  --red: #d9534f;
  --green: #4caf6d;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% -10%, #2b2312 0%, var(--bg) 60%);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100dvh;
}

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px calc(32px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }

/* ── Accueil ── */
.app-header { text-align: center; padding: 26px 0 20px; }
.app-header h1 {
  font-family: 'Cinzel', serif;
  font-size: 2.2rem;
  letter-spacing: .04em;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(224,179,76,.25);
}
.tagline { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.lobby-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.group-card {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  cursor: pointer;
  transition: transform .08s, border-color .15s;
  width: 100%; text-align: left; color: inherit; font: inherit;
}
.group-card:active { transform: scale(.98); border-color: var(--gold); }
.group-card .g-icon { font-size: 1.7rem; }
.group-card .g-name { font-family: 'Cinzel', serif; font-weight: 800; font-size: 1.15rem; flex: 1; }
.group-card .g-meta { color: var(--muted); font-size: .85rem; }

/* ── Vue groupe ── */
.group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0 16px;
}
.group-header h2 {
  flex: 1; text-align: center;
  font-family: 'Cinzel', serif;
  font-size: 1.35rem; color: var(--gold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  width: 42px; height: 42px; border-radius: 12px; font-size: 1.15rem;
  cursor: pointer; flex-shrink: 0;
}
.icon-btn:active { border-color: var(--gold); }

.player-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }

/* ── Carte joueur ── */
.player-card {
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: 76px 1fr;
  grid-template-areas: "avatar main" "hpbar hpbar" "ctrl ctrl";
  gap: 10px 14px;
  position: relative;
}
.player-card.ko { filter: saturate(.35); }
.player-card.ko::after {
  content: "💀 K.O.";
  position: absolute; top: 10px; right: 12px;
  background: var(--red); color: #fff;
  font-weight: 800; font-size: .78rem;
  padding: 4px 10px; border-radius: 999px;
  letter-spacing: .05em;
}

.avatar {
  grid-area: avatar;
  width: 76px; height: 76px; border-radius: 14px;
  border: 3px solid var(--gold);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.1rem; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.p-main { grid-area: main; display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 0; }
.p-name-frame {
  align-self: flex-start;
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 4px 12px;
  font-family: 'Cinzel', serif;
  font-weight: 800; font-size: 1.05rem;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(0,0,0,.25);
}
.p-hp-line { display: flex; align-items: baseline; gap: 6px; }
.p-hp { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.p-hpmax { color: var(--muted); font-size: 1rem; font-weight: 600; }
.p-edit {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; color: var(--muted);
  font-size: 1.05rem; cursor: pointer; padding: 6px;
}
.player-card.ko .p-edit { display: none; }

.hp-bar { grid-area: hpbar; height: 10px; border-radius: 999px; background: #000a; overflow: hidden; border: 1px solid var(--border); }
.hp-bar > div { height: 100%; border-radius: 999px; transition: width .35s, background-color .35s; }

/* Contrôles PV : [−] [saisie] [+] */
.hp-ctrl { grid-area: ctrl; display: grid; grid-template-columns: 1fr 90px 1fr; gap: 10px; }
.hp-btn {
  border: none; border-radius: 12px;
  font-size: 1.5rem; font-weight: 800;
  height: 52px; cursor: pointer; color: #fff;
  transition: transform .06s;
}
.hp-btn:active { transform: scale(.95); }
.hp-btn.minus { background: linear-gradient(160deg, #b5423e, #8e2f2c); }
.hp-btn.plus { background: linear-gradient(160deg, #3f9e63, #2d7a49); }
.hp-input {
  width: 100%; height: 52px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 1.3rem; font-weight: 700; text-align: center;
  font-family: inherit;
}
.hp-input:focus { outline: none; border-color: var(--gold); }
.hp-input::placeholder { color: #5c5340; font-size: 1rem; font-weight: 600; }

/* ── Boutons ── */
.btn {
  display: block; width: 100%;
  border: none; border-radius: 14px;
  padding: 15px; font-size: 1.05rem; font-weight: 700;
  font-family: inherit; cursor: pointer;
  transition: transform .06s;
}
.btn:active { transform: scale(.98); }
.btn-gold { background: linear-gradient(160deg, var(--gold), #b8902f); color: #221a05; }
.btn-ghost { background: none; border: 1px dashed var(--border); color: var(--muted); }
.btn-danger { background: none; border: 1px solid #6e3230; color: var(--red); }

/* ── Modale ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.65);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; border-bottom: 1px solid var(--border); }
}
.modal h3 { font-family: 'Cinzel', serif; color: var(--gold); margin-bottom: 16px; font-size: 1.15rem; }
.field { margin-bottom: 14px; }
.field label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 6px; font-weight: 600; }
.field input[type=text], .field input[type=number], .field input[type=password] {
  width: 100%; padding: 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--gold); }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 38px; height: 38px; border-radius: 10px;
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }
.color-custom { width: 38px; height: 38px; border: none; background: none; padding: 0; cursor: pointer; }

.avatar-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.emoji-opt {
  width: 46px; height: 46px; border-radius: 10px;
  background: var(--bg); border: 2px solid var(--border);
  font-size: 1.5rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.emoji-opt.sel { border-color: var(--gold); }
.upload-btn {
  height: 46px; padding: 0 14px; border-radius: 10px;
  background: var(--bg); border: 2px dashed var(--border);
  color: var(--muted); font-family: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer;
}
.avatar-preview { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; border: 2px solid var(--gold); }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
.modal .btn-danger { margin-top: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--gold);
  color: var(--text); padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; z-index: 100; white-space: nowrap;
}

.empty-hint { text-align: center; color: var(--muted); padding: 34px 20px; font-size: .95rem; line-height: 1.5; }
