:root {
  --bg: #161a15;
  --bg2: #1f251d;
  --panel: rgba(255, 244, 214, .055);
  --panel-strong: rgba(255, 244, 214, .09);
  --line: rgba(216, 178, 90, .28);
  --text: #efe6d2;
  --muted: #b2a88f;
  --gold: #d8b25a;
  --gold-hi: #f3d98a;
  --jade: #4f8dff;
  --red: #e0533f;
  --cw: 124px;
  --radius: 10px;
  --font-title: 'Cinzel', Georgia, serif;
  --font: 'Source Sans 3', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 20% -10%, rgba(47, 191, 113, .10), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(216, 178, 90, .10), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M0 47 H47 V6 H12 V36 H36 V18 H24 V26' fill='none' stroke='%23d8b25a' stroke-opacity='.045' stroke-width='2'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-title); letter-spacing: .02em; margin: 0 0 .5em; }
.muted { color: var(--muted); }
.code { font-family: var(--font-title); color: var(--gold-hi); letter-spacing: .15em; }

/* Boutons */
.btn {
  font: 600 15px/1 var(--font);
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 244, 214, .14); border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, .link:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(#e7c56d, #b98b2c); color: #20170a; border-color: #f3d98a; box-shadow: 0 2px 0 #6e5114; }
.btn-primary:hover { background: linear-gradient(#f3d98a, #c99a36); }
.btn-explore { background: linear-gradient(#2f8f57, #1d6a3e); border-color: #63d796; color: #f3fff7; box-shadow: 0 2px 0 #0f3d23; }
.btn-explore:hover { background: linear-gradient(#37a565, #217a47); }
.btn-camp { background: linear-gradient(#c96a35, #96441c); border-color: #f0a06e; color: #fff4ea; box-shadow: 0 2px 0 #5a260c; }
.btn-camp:hover { background: linear-gradient(#d97a43, #a54d21); }
.btn-ghost { background: transparent; }
.btn-small { padding: 7px 11px; font-size: 13px; }
.btn.selected { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--gold); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; margin-top: 14px; }

input {
  font: 16px var(--font);
  color: var(--text);
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  width: 100%;
}
input::placeholder { color: #7f7764; }

/* Accueil & salon */
.screen { min-height: 100vh; }
#screen-home, #screen-lobby { display: grid; place-items: center; padding: 24px 16px; }
.home-card, .lobby-card {
  width: min(440px, 100%);
  background: linear-gradient(rgba(31, 37, 29, .92), rgba(22, 26, 21, .92));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.home-hero { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.home-hero .card { width: 66px; }
.home-hero .card:nth-child(1) { transform: rotate(-8deg) translateY(6px); }
.home-hero .card:nth-child(3) { transform: rotate(8deg) translateY(6px); }
h1 { font-size: 30px; color: var(--gold-hi); }
.tagline { color: var(--muted); margin: 0 0 22px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.home-actions { display: grid; gap: 10px; }
.home-actions .btn-primary { width: 100%; padding: 14px; font-size: 16px; }
.or { color: var(--muted); font-size: 13px; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-family: var(--font-title); }
.invite { display: flex; gap: 8px; margin-bottom: 18px; }
.invite input { font-size: 14px; }
.lobby-players { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; text-align: left; }
.lobby-players li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--panel); border-radius: 8px; }
.lobby-players .name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.lobby-actions { display: grid; gap: 8px; margin-top: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, .4); }
.tag { font-size: 12px; color: var(--muted); }
.off { opacity: .5; }

/* Partie */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; background: rgba(0, 0, 0, .35); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--font-title); color: var(--gold-hi); font-size: 16px; }
.brand .code { font-size: 12px; margin-left: 8px; opacity: .8; }
.topbar-actions { display: flex; gap: 6px; }

.status {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 16px;
  min-height: 58px; padding: 10px 16px;
  background: linear-gradient(#f3ead2, #e5d7b1);
  color: #2a2113;
  border-bottom: 2px solid #b98b2c;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  text-align: center;
}
.status-text { font-weight: 700; font-size: 16px; }
.status-text .pname { padding: 0 2px; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.status.alert { background: linear-gradient(#f6d2c8, #e9a996); border-bottom-color: var(--red); }
.status.yourturn { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 6px 26px rgba(216, 178, 90, .7); } }

.layout { display: grid; grid-template-columns: 1fr 270px; gap: 16px; padding: 16px; align-items: start; }
.board { min-width: 0; display: grid; gap: 16px; }
.board-top { display: grid; grid-template-columns: auto 1fr; gap: 16px; }
.left-col { display: grid; gap: 14px; justify-items: center; align-content: start; }
.deck { display: grid; justify-items: center; gap: 6px; }
.deck .card { width: calc(var(--cw) * 1.05); box-shadow: 4px 4px 0 #0d0f0c, 7px 7px 0 #2a2f27; }
.deck-count { font-size: 13px; color: var(--muted); }

.rounds { display: grid; grid-template-columns: repeat(2, 84px); gap: 5px; }
.floor { border-radius: 7px; overflow: hidden; line-height: 0; transition: filter .6s, transform .3s, box-shadow .3s; }
.floor .floor-svg { width: 100%; height: auto; display: block; }
.floor.f5 { grid-column: 1 / span 2; justify-self: center; width: 84px; }
.floor.locked { filter: grayscale(1) brightness(.75) contrast(.9); }
.floor.current { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 14px rgba(243, 217, 138, .7); }
.floor.done { filter: saturate(.85); }
.path-wrap { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; align-content: start; }
.path { display: flex; flex-wrap: wrap; gap: 8px; min-height: calc(var(--cw) * 1.4); align-content: flex-start; }
.path-empty { color: var(--muted); align-self: center; margin: auto; }

.card { width: var(--cw); aspect-ratio: 100 / 140; position: relative; border-radius: 7px; flex: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45)); }
.card .card-svg { width: 100%; height: 100%; display: block; }
.card.flip-in { animation: flipIn .55s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes flipIn { 0% { transform: translateY(-30px) rotateY(90deg) scale(.9); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
.card.taken { opacity: .32; filter: grayscale(.7); }
.card.taken::after { content: 'emportée'; position: absolute; inset: auto 0 44% 0; text-align: center; font: 700 12px var(--font); background: rgba(0, 0, 0, .75); color: var(--gold-hi); padding: 3px 0; }
.card.hazard-warn { outline: 2px solid rgba(224, 83, 63, .55); outline-offset: 1px; border-radius: 7px; }
.card.disaster { outline: 3px dashed var(--red); outline-offset: 3px; animation: shake .5s 2; }
@keyframes shake { 25% { transform: translateX(-5px) rotate(-1deg); } 75% { transform: translateX(5px) rotate(1deg); } }
.card .stack {
  position: absolute; right: -6px; bottom: -6px; min-width: 32px; height: 32px; padding: 0 6px;
  display: flex; align-items: center; gap: 2px; justify-content: center;
  background: #0f1e3f; border: 2px solid var(--jade); border-radius: 16px;
  font-weight: 700; font-size: 15px; color: #d6e6ff; box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.jade-icon { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }
.relic-icon { width: 22px; height: 24px; display: inline-block; vertical-align: middle; }

.hazards { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.hazards .lbl { margin-right: 4px; }
.hz { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 4px; border-radius: 20px; background: rgba(0, 0, 0, .25); border: 1px solid transparent; }
.hz .hz-icon { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(0,0,0,.5); }
.hz.seen { border-color: var(--red); background: rgba(224, 83, 63, .18); color: #ffd6cc; font-weight: 700; }
.hz .left { font-size: 11px; opacity: .8; }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pl {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  position: relative; transition: background .2s, border-color .2s;
}
.pl.me { background: rgba(216, 178, 90, .12); border-color: var(--gold); }
.pl.camp { opacity: .78; }
.pl.fled { background: rgba(224, 83, 63, .12); border-color: rgba(224, 83, 63, .6); }
.pl .dcard { width: 64px; }
.pl .slot { width: 64px; aspect-ratio: 100/140; border: 2px dashed var(--line); border-radius: 7px; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; padding: 4px; }
.pl .slot .dots::after { content: '…'; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1em; text-align: left; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.pl .info { min-width: 0; display: grid; gap: 4px; }
.pl .pname { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .where { font-size: 13px; color: var(--muted); }
.pl .where.red { color: #ffb4a6; font-weight: 600; }
.pl .stats { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 14px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.chip.bag { border-color: rgba(79, 141, 255, .6); color: #d6e6ff; }
.chip.chest { border-color: var(--gold); color: var(--gold-hi); }
.chip.relics { border-color: #7fd6a6; }
.pl .force { margin-top: 4px; justify-self: start; }
.badge-off { font-size: 11px; color: #ffb4a6; }
.pl .gain { position: absolute; top: -10px; right: 10px; background: var(--jade); color: #06301e; font-weight: 700; padding: 2px 8px; border-radius: 10px; font-size: 13px; animation: pop .4s ease-out; }
.pl .gain.loss { background: var(--red); color: #fff; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.sidebar { display: grid; gap: 12px; position: sticky; top: 76px; max-height: calc(100vh - 92px); grid-template-rows: auto 1fr; min-height: 0; }
.side-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.side-players li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel); border-radius: 8px; font-size: 14px; }
.side-players .n { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: 4px; align-content: start; min-height: 120px; }
.log li { background: rgba(243, 234, 210, .92); color: #2a2113; padding: 7px 10px; border-radius: 6px; font-size: 13.5px; line-height: 1.35; }
.log li.bad { background: #f3c4b8; }
.log li.round { background: linear-gradient(#e7c56d, #c99a36); font-weight: 700; text-align: center; }
.log li.good { background: #cdeed9; }
.pname { font-weight: 700; }

/* Fenêtres */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5, 7, 5, .72); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: linear-gradient(#232a21, #181d17); border: 1px solid var(--gold); border-radius: 16px; padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop .25s ease-out;
}
.modal h2 { color: var(--gold-hi); font-size: 24px; text-align: center; }
.modal .sub { text-align: center; color: var(--muted); margin: -4px 0 16px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.rules { line-height: 1.5; }
.rules h3 { font-size: 16px; color: var(--gold); margin-top: 16px; }
.rules ul { padding-left: 20px; }
.rules li { margin-bottom: 6px; }
table.recap { width: 100%; border-collapse: collapse; font-size: 15px; }
.recap th, .recap td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.recap th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.recap td.num, .recap th.num { text-align: right; font-variant-numeric: tabular-nums; }
.recap tr.win td { color: var(--gold-hi); font-weight: 700; }
.recap .rank { font-family: var(--font-title); font-weight: 700; width: 34px; }
.disaster-banner { display: flex; align-items: center; gap: 14px; background: rgba(224, 83, 63, .15); border: 1px solid var(--red); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.disaster-banner .card { width: 54px; }
.note { font-size: 13px; color: var(--muted); margin-top: 10px; text-align: center; }
.trophy { text-align: center; }
.trophy .relic-icon { width: 70px; height: 78px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; background: #2a1d17; color: #ffd6cc; border: 1px solid var(--red); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.ok { background: #102a1c; color: #c9ffe0; border-color: var(--jade); }
.conn { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--red); color: #fff; text-align: center; padding: 6px; font-weight: 700; font-size: 14px; }

.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 2000px rgba(224, 83, 63, .35); } 100% { box-shadow: inset 0 0 0 2000px rgba(224, 83, 63, 0); } }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .log { max-height: 260px; }
}
@media (max-width: 640px) {
  :root { --cw: 64px; }
  .layout { padding: 10px; gap: 10px; }
  .board-top { grid-template-columns: 1fr; }
  .left-col { grid-template-columns: auto 1fr; justify-items: start; align-items: center; }
  .deck { grid-template-columns: auto auto; align-items: center; }
  .deck .card { width: 52px; }
  .rounds { justify-self: end; grid-template-columns: repeat(2, 50px); }
  .floor.f5 { width: 50px; }
  .status { padding: 8px 10px; }
  .status-text { font-size: 14px; }
  .status-actions .btn { padding: 12px 14px; }
  .path { gap: 6px; }
  .card .stack { min-width: 26px; height: 26px; font-size: 13px; right: -4px; bottom: -4px; }
  .players { grid-template-columns: 1fr; }
  .pl .dcard, .pl .slot { width: 48px; }
  .topbar { padding: 6px 10px; }
  .brand { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

.logo-wrap { margin: 0 0 6px; }
.logo-wrap .logo-svg { width: min(340px, 92%); height: auto; display: block; margin: 0 auto; filter: drop-shadow(0 6px 18px rgba(0,0,0,.5)); }
.brand-logo { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; }
.brand-logo span { font-family: var(--font-title); font-weight: 700; font-size: 19px; letter-spacing: .14em; background: linear-gradient(#fff3c4, #f0c45a 45%, #c98f22 55%, #8a5a12); -webkit-background-clip: text; background-clip: text; color: transparent; }
