:root {
  --bg: #12261e;
  --bg2: #1a3429;
  --card: #fffaf0;
  --ink: #1d1a16;
  --muted: #6d655b;
  --red: #c8283a;
  --red-dark: #9e1b2b;
  --green: #2f7d4f;
  --gold: #d9a441;
  --line: #e6dccb;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: radial-gradient(circle at 20% 0%, var(--bg2), var(--bg) 60%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
.wrap.wide { max-width: 1100px; }

header.top {
  color: #fff;
  text-align: center;
  padding: 12px 0 8px;
}
header.top h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  margin: 0;
  letter-spacing: .5px;
}
header.top h1 span { color: var(--gold); }
header.top p { margin: 4px 0 0; color: #cfe0d6; font-size: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.card h2 { margin: 0 0 10px; font-size: 18px; }
.card h2 small { font-weight: 400; color: var(--muted); font-size: 13px; }

.identity { text-align: center; border-top: 6px solid var(--red); }
.identity .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.identity .character { font-family: Georgia, serif; font-size: 30px; font-weight: 700; margin: 2px 0; }
.identity .universe { color: var(--red); font-weight: 700; margin-top: 6px; }
.identity .meta { color: var(--muted); font-size: 15px; }

.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: #efe6d6; color: var(--ink); font-size: 13px; font-weight: 600;
}
.chip.ok { background: #d8efe1; color: var(--green); }
.chip.ko { background: #f7d9dd; color: var(--red-dark); }

label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }

select, input[type=text], input[type=password], textarea {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
textarea { min-height: 180px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: 0 0 auto; }

button {
  font: inherit; font-weight: 700;
  border: 0; border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--red); color: #fff;
}
button:hover { background: var(--red-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.block { width: 100%; margin-top: 14px; }
button.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
button.ghost:hover { background: #f3ecdf; }
button.green { background: var(--green); }
button.green:hover { background: #24643e; }
button.small { padding: 6px 10px; font-size: 13px; }
button.confirm { background: var(--gold); color: var(--ink); }

.link { background: none; color: var(--muted); padding: 0; font-weight: 400; text-decoration: underline; }
.link:hover { background: none; color: var(--ink); }

.msg { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 600; display: none; }
.msg.show { display: block; }
.msg.ok { background: #d8efe1; color: var(--green); }
.msg.ko { background: #f7d9dd; color: var(--red-dark); }

.banner {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--gold); color: var(--ink); font-weight: 700; text-align: center;
}

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 12px; margin-right: 8px; }
.empty { color: var(--muted); font-style: italic; }

.tabs { display: flex; gap: 6px; margin-top: 14px; }
.tabs button { flex: 1; background: rgba(255,255,255,.12); color: #fff; padding: 12px 6px; font-size: 15px; white-space: nowrap; }
#addPartner { margin-top: 10px; }
.tabs button.active { background: var(--card); color: var(--ink); }

.help { color: var(--muted); font-size: 14px; margin: 0 0 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.rank { font-weight: 800; color: var(--gold); width: 28px; }
.score { font-weight: 800; font-size: 18px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: 1px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.hidden { display: none !important; }

/* --- Équipe réunie --- */
.success { text-align: center; border-top: 6px solid var(--green); }
.big-emoji { font-size: 44px; line-height: 1; }
.rank-line { font-weight: 700; color: var(--green); margin: 4px 0 10px; }
.members { list-style: none; padding: 0; margin: 0 0 10px; }
.members li { padding: 8px; border-radius: 10px; background: #f3ecdf; margin-top: 6px; }

/* --- Point d'étape --- */
.checkpoint { text-align: center; border-top: 6px solid var(--gold); }
.cp-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.cp-score span { font-size: 40px; font-weight: 800; }
.cp-score small { font-size: 16px; font-weight: 600; }

/* --- Enquête --- */
.enquete-list { margin-top: 10px; }
.enq-row { display: grid; grid-template-columns: 1fr 1.3fr 20px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.enq-row:last-child { border-bottom: 0; }
.enq-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.enq-row select { padding: 8px 10px; font-size: 15px; }
.enq-row.filled select { border-color: var(--gold); background: #fff8e8; }
.enq-state { color: var(--green); font-weight: 800; text-align: center; }

/* --- Félicitations plein écran --- */
.overlay { position: fixed; inset: 0; background: rgba(10, 20, 15, .75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.overlay-box { background: var(--card); border-radius: var(--radius); padding: 24px 20px; max-width: 420px; width: 100%; text-align: center; animation: pop .35s ease-out; }
.overlay-box h2 { font-family: Georgia, serif; font-size: 28px; margin: 8px 0; }
.snow { font-size: 22px; letter-spacing: 6px; animation: float 2.5s ease-in-out infinite; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

tr.mine td { background: #fff3d6; }

/* --- Images des personnages --- */
.avatar { display: inline-block; object-fit: cover; background: #efe6d6; border-radius: 50%; flex: 0 0 auto; }
.avatar.big { width: 132px; height: 132px; border: 4px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.25); margin: -2px auto 8px; display: block; }
.avatar.thumb { width: 44px; height: 44px; }
.avatar.placeholder { display: inline-flex; align-items: center; justify-content: center; font-family: Georgia, serif; font-weight: 700; color: var(--red); }
.avatar.big.placeholder { display: flex; font-size: 56px; }
.avatar.thumb.placeholder { font-size: 20px; }
.members li { display: flex; align-items: center; gap: 10px; text-align: left; }
.congrats-team { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 4px; }
.congrats-team > div { display: flex; align-items: center; gap: 10px; text-align: left; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 12px; }
.img-cell { text-align: center; cursor: pointer; padding: 8px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; }
.img-cell:hover { border-color: var(--gold); }
.img-cell img, .img-empty { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 6px; }
.img-empty { background: #efe6d6; color: var(--muted); font-size: 34px; line-height: 84px; }
.img-name { font-weight: 700; font-size: 14px; }
.img-team { color: var(--muted); font-size: 12px; }
tr.absent td { opacity: .5; text-decoration: line-through; }
tr.absent td:last-child, tr.absent td:nth-last-child(2) { opacity: 1; text-decoration: none; }

/* --- Tests en duo --- */
.card h3 { font-size: 15px; margin: 16px 0 6px; }
.pending { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #fff3d6; font-size: 15px; }
.incoming { border-top: 6px solid var(--gold); animation: pop .3s ease-out; }
.incoming-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.banner.net { background: #f7d9dd; color: var(--red-dark); font-weight: 600; font-size: 14px; }

/* --- Enquête : personnage deviné --- */
.enq-row { grid-template-columns: 1fr 1.3fr 20px; grid-template-areas: "name team state" "char char char"; row-gap: 6px; padding: 8px 0; }
.enq-row .enq-name { grid-area: name; }
.enq-row select { grid-area: team; }
.enq-row .enq-state { grid-area: state; }
.enq-row .enq-char { grid-area: char; padding: 7px 10px; font-size: 15px; border-style: dashed; }
.enq-row .enq-char.filled { border-style: solid; border-color: var(--green); background: #f1faf4; }
.review-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.review-row.todo { background: #fff3d6; border-radius: 8px; padding: 8px; }

/* --- Liste déroulante avec recherche --- */
select.combo-native { display: none !important; }
.combo { position: relative; min-width: 0; }
.enq-row .combo { grid-area: team; }
.combo-input {
  width: 100%; font: inherit; padding: 10px 34px 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236d655b' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--ink); text-overflow: ellipsis;
}
.combo-input[readonly] { caret-color: transparent; }
.combo-input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.combo-input:disabled { background-color: #f3efe8; color: var(--muted); }
.enq-row .combo-input { padding: 8px 30px 8px 10px; font-size: 15px; }
.combo.filled .combo-input { border-color: var(--gold); background-color: #fff8e8; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; background: #fff; border: 1.5px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,.18); max-height: 240px; overflow-y: auto;
  overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch;
}
.combo-list li { padding: 10px 10px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.combo-list li.active, .combo-list li:hover { background: #f3ecdf; }
.combo-list li[aria-selected="true"] { font-weight: 700; }
.combo-list li.combo-none { color: var(--muted); font-style: italic; }
.combo-list li.combo-empty { color: var(--muted); font-style: italic; cursor: default; }
.enq-row .combo-list { left: auto; right: 0; min-width: 210px; }
