:root {
  --paper: #efe6cf;
  --paper-2: #e4d8b8;
  --ink: #2a2116;
  --ink-2: #5b4a33;
  --red: #9b1c1c;
  --blue: #2f5fa8;
  --olive: #5f6b3a;
  --line: rgba(60, 44, 24, 0.35);
  font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #2b2a26; }
[hidden] { display: none !important; }
button {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--paper-2); border: 1px solid var(--ink-2);
  border-radius: 3px; padding: 5px 11px; cursor: pointer; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
button:hover:not(:disabled) { background: #f6edd6; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--olive); color: #f6f1e0; border-color: #39401f; }
button.primary:hover:not(:disabled) { background: #6f7c45; }
button.active { background: var(--ink); color: var(--paper); }
input {
  font: inherit; padding: 6px 8px; border: 1px solid var(--ink-2); background: #fbf6e8; border-radius: 2px; width: 100%;
}
label { display: block; margin: 8px 0; font-size: 14px; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ------------------------------------------------ salon */
#lobby, #join {
  min-height: 100%; padding: 32px 16px;
  background: #3a372f url('/assets/normandie/relief.jpg') center / cover fixed;
}
.lobby-paper {
  max-width: 980px; margin: 0 auto; background: rgba(239, 230, 207, 0.96); padding: 28px 34px;
  border: 1px solid #5b4a33; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 0 60px rgba(120, 90, 40, 0.18);
}
.lobby-paper.narrow { max-width: 520px; }
.lobby-head { position: relative; border-bottom: 3px double var(--ink); margin-bottom: 18px; }
.lobby-head h1 { font-size: 46px; letter-spacing: 3px; margin: 0; text-transform: uppercase; }
.lobby-head .sub { font-style: italic; margin: 6px 0 14px; }
.stamp {
  position: absolute; right: 0; top: 4px; transform: rotate(-8deg); color: var(--red); border: 3px solid var(--red);
  padding: 2px 10px; font: bold 18px 'Courier New', monospace; letter-spacing: 2px; opacity: 0.8;
}
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px) { .lobby-grid { grid-template-columns: 1fr; } }
.card { border: 1px solid var(--line); padding: 14px 18px; background: rgba(255, 252, 240, 0.5); }
.card h2 { font-size: 18px; text-transform: uppercase; letter-spacing: 1px; margin: 4px 0 10px; border-bottom: 1px solid var(--line); }
fieldset { border: 1px solid var(--line); margin: 10px 0; padding: 4px 10px; }
legend { font-size: 13px; font-style: italic; }
label.radio { display: flex; gap: 8px; align-items: center; margin: 5px 0; }
label.radio input { width: auto; }
.game-list { list-style: none; padding: 0; margin: 0 0 14px; }
.game-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dotted var(--line); font-size: 14px; }
.game-list li .g-name { flex: 1; }
footer { margin-top: 18px; }

/* ------------------------------------------------ partie */
#game { position: fixed; inset: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#board.dragging { cursor: grabbing; }
#board.target { cursor: crosshair; }
#topbar {
  position: absolute; left: 0; right: 0; top: 0; height: 44px; display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: linear-gradient(#efe6cf, #e1d4b1); border-bottom: 2px solid var(--ink); font-size: 14px; z-index: 5;
  white-space: nowrap; overflow: hidden;
}
#topbar > span { flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#topbar #tb-turn, #topbar #tb-vp { flex-shrink: 0; } /* le tour et le score ne doivent jamais être tronqués */
#topbar .brand { flex-shrink: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topbar button { flex-shrink: 0; }
#topbar .brand { font-weight: bold; text-transform: uppercase; letter-spacing: 2px; color: var(--ink); text-decoration: none; }
#tb-side.allies { color: var(--blue); font-weight: bold; }
#tb-side.axis { color: var(--red); font-weight: bold; }
#tb-side.wait::after { content: ' (en attente)'; font-weight: normal; color: var(--ink-2); }
.panel {
  background: rgba(239, 230, 207, 0.95); border: 1px solid var(--ink-2); box-shadow: 0 3px 14px rgba(0, 0, 0, 0.35);
  padding: 8px 10px; font-size: 13px;
}
#sidebar {
  position: absolute; right: 10px; top: 54px; width: 340px; max-height: calc(100% - 64px); overflow: auto;
  display: flex; flex-direction: column; gap: 8px; z-index: 4;
}
#sidebar summary { cursor: pointer; font-weight: bold; text-transform: uppercase; font-size: 14px; letter-spacing: 1px; }
#sidebar .panel { font-size: 15px; }
#sidebar .small { font-size: 14px; }
.panel h3 { margin: 0 0 4px; font-size: 15px; }
#sidebar .panel h3 { font-size: 18px; }
.uc-head { display: flex; gap: 10px; align-items: center; }
.uc-icon { width: 76px; height: 76px; flex: none; background: radial-gradient(circle, #f6eedb 0%, #e4d8b8 70%); border: 1px solid var(--line); border-radius: 50%; }
.uc-lore { margin: 6px 0 4px; border-left: 3px solid #c9a13b; padding: 2px 0 2px 10px; }
.uc-lore summary { cursor: pointer; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: #8a6a1a; }
.uc-lore p { margin: 6px 0 2px; font-size: 14px; line-height: 1.5; font-style: italic; color: #3c3020; }
.uc-lore.hero { border-left-color: #9b1c1c; }
.uc-lore.hero summary { color: #9b1c1c; }
.uc-group { display: inline-block; margin: 3px 6px 0 0; padding: 0 7px; border-radius: 9px; font-size: 12px; background: #e8d9a8; color: #5c4b15; border: 1px dashed #c9a13b; }
.uc-who { display: inline-block; margin-top: 3px; padding: 0 7px; border-radius: 9px; font-size: 11px; font-weight: bold; color: #fff; }
.uc-who.friend { background: #1f63c6; }
.uc-who.enemy { background: #c0161b; }
.uc-radar { display: block; width: 318px; height: 220px; margin: 2px auto 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 6px 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; }
.bar { height: 7px; background: #cbbd98; border: 1px solid var(--ink-2); position: relative; margin-top: 4px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--olive); }
.stars { color: #b8902a; letter-spacing: 1px; }
.tag { display: inline-block; padding: 0 5px; border-radius: 2px; font-size: 11px; margin: 2px 2px 0 0; background: #d9cca8; }
.tag.bad { background: #e3b4ac; color: #6b1010; }
.tag.good { background: #c7d6b0; }
.obj { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dotted var(--line); }
.obj .A { color: var(--blue); font-weight: bold; }
.obj .X { color: var(--red); }
.vp-total { margin-top: 6px; font-weight: bold; }
.reinf { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px dotted var(--line); }
.combat-row { display: flex; justify-content: space-between; font-size: 14px; margin: 3px 0; }
.combat-row b { font-size: 16px; }

#bottom {
  position: absolute; left: 10px; bottom: 10px; width: min(560px, calc(100% - 370px)); height: 190px; display: flex;
  flex-direction: column; z-index: 4; padding: 0;
}
.tabs { display: flex; gap: 4px; padding: 5px 6px; border-bottom: 1px solid var(--line); align-items: center; }
.tabs button { padding: 2px 9px; font-size: 13px; }
.tab { flex: 1; overflow: auto; padding: 4px 10px; display: flex; flex-direction: column; }
#log, #chat { list-style: none; margin: 0; padding: 0; font: 12.5px 'Courier New', monospace; flex: 1; }
#log li, #chat li { padding: 1px 0; }
#log li .t { color: var(--ink-2); }
#log li.turn { font-weight: bold; border-top: 1px dotted var(--line); margin-top: 3px; padding-top: 3px; }
#chat li .who { font-weight: bold; }
#chat-form { display: flex; gap: 6px; padding: 6px 0; }
#chat-badge:not(:empty) { background: var(--red); color: #fff; border-radius: 8px; padding: 0 5px; font-size: 11px; }
#toast {
  position: absolute; left: 50%; top: 56px; transform: translateX(-50%); background: #2a2116; color: var(--paper);
  padding: 7px 16px; border-radius: 3px; z-index: 10; font-size: 14px; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}
#cover, #modal { position: absolute; inset: 0; background: rgba(25, 22, 16, 0.94); z-index: 20; display: flex; align-items: center; justify-content: center; }
#modal { background: rgba(25, 22, 16, 0.6); }
.cover-box, .modal-box {
  background: var(--paper); border: 1px solid var(--ink); padding: 24px 30px; max-width: 640px; max-height: 85vh; overflow: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.cover-box { text-align: center; }
.modal-box h2 { margin-top: 0; }
.modal-box table { border-collapse: collapse; font-size: 13px; }
.modal-box td, .modal-box th { border-bottom: 1px dotted var(--line); padding: 2px 8px; text-align: left; }

/* ------------------------------------------------ choix de la campagne */
h2.section { font-size: 18px; text-transform: uppercase; letter-spacing: 1px; margin: 4px 0 10px; }
.campaigns { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 22px; }
.campaign {
  position: relative; border: 1px solid var(--line); background: rgba(255, 252, 240, 0.6); cursor: pointer; text-align: left;
  padding: 0; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.campaign:hover { background: #fbf4df; }
.campaign.selected { outline: 3px solid var(--olive); background: #fbf4df; }
.campaign .thumb { height: 110px; background-size: cover; background-position: center; border-bottom: 1px solid var(--line); }
.campaign .body { padding: 9px 12px 12px; }
.campaign .era { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--red); }
.campaign h3 { margin: 2px 0 2px; font-size: 17px; }
.campaign .period { font-style: italic; font-size: 13px; color: var(--ink-2); }
.campaign .vs { font-size: 13px; margin-top: 5px; }
.explain { margin: 4px 0 6px; line-height: 1.4; }
.explain b { font-weight: bold; }
.facts { margin: 4px 0; padding-left: 16px; }
.facts li { margin: 2px 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot.A { background: var(--blue); }
.dot.X { background: var(--red); }

/* ================================================ menu principal (Hexagame) */
#lobby { min-height: 100%; padding: 0; background: #16181a; color: #ece4cf; font-family: Georgia, 'Iowan Old Style', serif; }
.hq-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 28px; padding: 14px 36px;
  background: rgba(18, 20, 22, 0.92); backdrop-filter: blur(6px); border-bottom: 1px solid #3a3a34;
}
.hq-brand { font: bold 26px/1 Georgia, serif; letter-spacing: 6px; color: #f1e6c8; }
.hq-logo { color: #c9a13b; margin-right: 4px; }
.hq-tabs { display: flex; gap: 6px; align-items: center; }
.hq-tabs button, .hq-link {
  background: none; border: none; box-shadow: none; color: #b9b19c; font: 15px Georgia, serif; padding: 8px 14px; border-radius: 20px;
  text-decoration: none; cursor: pointer;
}
.hq-tabs button:hover, .hq-link:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.hq-tabs button.active { color: #16181a; background: #c9a13b; }
.hq-head .spacer { flex: 1; }
.hq-user { color: #b9b19c; font-size: 14px; display: flex; align-items: center; gap: 6px; }
#join-count:not(:empty) { background: #9b1c1c; color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.hq-main { max-width: 1280px; margin: 0 auto; padding: 26px 36px 60px; }
.hq-intro { color: #a9a18c; font-style: italic; margin: 0 0 18px; }
.hq-h2 { font-size: 20px; letter-spacing: 1px; margin: 6px 0 14px; color: #f1e6c8; }
.era-block { margin-bottom: 30px; }
.era-title { font: bold 13px Georgia, serif; text-transform: uppercase; letter-spacing: 3px; color: #c9a13b; margin: 0 0 12px; border-bottom: 1px solid #34342e; padding-bottom: 6px; }
.era-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }
.ccard {
  position: relative; height: 230px; border-radius: 10px; overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  border: 1px solid #3a3a34; background: #22242a; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45); transition: transform 0.15s, box-shadow 0.15s;
  color: #f4ecd8; font: inherit;
}
.ccard:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6); border-color: #c9a13b; }
.ccard .bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: saturate(0.9) brightness(0.85); }
.ccard .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 10, 12, 0) 25%, rgba(10, 10, 12, 0.88) 78%); }
.ccard .units { position: absolute; top: 10px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 16px; pointer-events: none; }
.ccard .units img { height: 118px; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.55)); }
.ccard .units img.flip { transform: scaleX(-1); }
.ccard .vs { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); font: bold 15px Georgia, serif; color: #f1e6c8; background: rgba(0, 0, 0, 0.55); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; }
.ccard .txt { position: absolute; left: 18px; right: 18px; bottom: 14px; }
.ccard h3 { margin: 0 0 3px; font-size: 21px; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
.ccard .meta { font-size: 13px; color: #d9cfb6; }
.ccard .sidesline { font-size: 13px; color: #c9a13b; margin-top: 3px; }
/* cartes avec illustration peinte */
.ccard.art { height: 260px; }
.ccard.art .bg { filter: none; transition: transform 0.6s ease; }
.ccard.art:hover .bg { transform: scale(1.05); }
.ccard.art .shade { background: linear-gradient(180deg, rgba(10, 10, 12, 0) 38%, rgba(10, 10, 12, 0.6) 62%, rgba(10, 10, 12, 0.94) 100%); }
.ccard.art::after { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(201, 161, 59, 0.35); border-radius: 6px; pointer-events: none; }
.ccard.art .meta { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: #c9a13b; }
.ccard.art h3 { font-size: 22px; margin: 2px 0 6px; }
.ccard.art .sidesline { display: flex; align-items: center; gap: 7px; color: #ece4cf; }
.ccard.art .sidesline img { width: 30px; height: 30px; object-fit: contain; border-radius: 50%; background: rgba(241, 230, 200, 0.92); border: 1px solid #c9a13b; }
.ccard.art .sidesline img.flip { transform: scaleX(-1); }
.ccard.art .sidesline i { color: #a9a18c; font-size: 12px; }
#view-join .game-list li, #view-mine .game-list li { border-bottom: 1px solid #2e2e2a; color: #e4dcc6; }
#view-join .muted, #view-mine .muted { color: #8f887a; }
#lobby button.primary { background: #c9a13b; border-color: #8a6d22; color: #1a1712; }
#lobby button.primary:hover { background: #dbb34a; }
#lobby .game-list button { background: #2a2c30; color: #ece4cf; border-color: #4a4a44; }

.setup { position: fixed; inset: 0; z-index: 30; background: rgba(8, 8, 10, 0.72); display: flex; align-items: center; justify-content: center; padding: 20px; }
.setup-box { position: relative; width: min(860px, 100%); max-height: 94vh; overflow: auto; background: #f1e9d4; color: #2a2116; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7); }
.setup-close { position: absolute; right: 12px; top: 10px; z-index: 2; border-radius: 50%; width: 34px; height: 34px; padding: 0; font-size: 20px; background: rgba(255, 255, 255, 0.85); }
.setup-cover { height: 150px; background-size: cover; background-position: center; position: relative; }
.setup-cover.art { height: 260px; background-position: center 35%; }
.setup-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(241, 233, 212, 1)); }
.setup-body { padding: 0 32px 28px; margin-top: -30px; position: relative; }
.setup-body h2 { margin: 2px 0 2px; font-size: 28px; }
.setup-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: #7a6a4a; margin: 18px 0 8px; }
.setup-body .era { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: #9b1c1c; }
.setup-body .period { font-style: italic; color: #5b4a33; }
.setup-desc { line-height: 1.5; margin: 10px 0 0; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.side-card { display: flex; align-items: center; gap: 12px; border: 2px solid #d4c7a6; border-radius: 10px; padding: 10px 12px; cursor: pointer; background: #faf5e8; margin: 0; }
.side-card input { display: none; }
.side-card img { width: 86px; height: 86px; object-fit: contain; }
.side-card b { display: block; font-size: 17px; }
.side-card small { color: #6b5a40; }
.side-card:has(input:checked) { border-color: #5f6b3a; background: #eef0dc; box-shadow: 0 0 0 3px rgba(95, 107, 58, 0.25); }
.segmented { display: flex; border: 1px solid #b9a982; border-radius: 22px; overflow: hidden; width: fit-content; }
.segmented label { margin: 0; }
.segmented input { display: none; }
.segmented span { display: block; padding: 8px 18px; cursor: pointer; font-size: 14px; }
.segmented input:checked + span { background: #5f6b3a; color: #f6f1e0; }
.setup-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin-top: 10px; }
.online-note { margin: 8px 0 0; font-size: 14px; color: #5f6b3a; }
.invite-box { margin-top: 18px; padding: 14px 16px; border: 2px solid #5f6b3a; border-radius: 10px; background: #eef0dc; }
.invite-box h3 { margin: 0 0 6px; color: #2a2116; }
.invite-row { display: flex; gap: 8px; margin: 10px 0 4px; }
.invite-row input { flex: 1; font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid #b9a982; border-radius: 6px; background: #fff; }
/* prestige : renforts levés */
#prestige-val { float: right; color: #9b6b10; font-weight: bold; }
.levy { display: flex; align-items: center; gap: 8px; width: 100%; margin: 3px 0; padding: 3px 8px 3px 4px; text-align: left; font-size: 14px; }
.levy canvas { width: 30px; height: 30px; flex: none; }
.levy span { flex: 1; }
.levy b { color: #9b6b10; }
.levy.on { outline: 2px solid #c9a13b; background: #f6e7b8; }

/* briefing d'ouverture */
#brief { position: fixed; inset: 0; z-index: 40; background: rgba(8, 8, 10, 0.78); display: grid; place-items: center; padding: 18px; }
.brief-box { width: min(980px, 100%); max-height: 94vh; overflow: auto; background: #f1e9d4; color: #2a2116; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7); }
.brief-img { height: min(46vh, 430px); background: #2a2c30 center / cover no-repeat; border-radius: 12px 12px 0 0; position: relative; }
.brief-img::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 60%, rgba(241, 233, 212, 1)); }
.brief-body { padding: 0 34px 24px; margin-top: -26px; position: relative; }
.brief-step { font-size: 12px; text-transform: uppercase; letter-spacing: 3px; color: #9b1c1c; }
.brief-body h2 { margin: 4px 0 8px; font-size: 28px; }
.brief-body p { font-size: 17px; line-height: 1.55; margin: 0 0 10px; }
.brief-objs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 18px; margin: 6px 0 4px; font-size: 15px; }
.brief-objs span b { color: #9b1c1c; }
.brief-win { font-size: 15px; color: #5b4a33; font-style: italic; margin: 6px 0 0; }
.brief-nav { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.brief-nav .primary { margin-left: auto; font-size: 16px; padding: 8px 22px; border-radius: 20px; }
.brief-dots { display: flex; gap: 6px; }
.brief-dots i { width: 9px; height: 9px; border-radius: 50%; background: #cbbd98; }
.brief-dots i.on { background: #9b1c1c; }
.brief-skip { background: none; border: none; box-shadow: none; color: #7a6a4a; font-size: 13px; text-decoration: underline; padding: 8px 0 0; }
#review { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 35; }
.review-box { display: flex; align-items: center; gap: 12px; background: rgba(241, 233, 212, 0.97); border: 2px solid #c9a13b; border-radius: 26px; padding: 8px 10px 8px 20px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); font-size: 17px; }
.review-box b { font-size: 19px; }
.review-box span { color: #5b4a33; }
button.big { margin-top: 18px; font-size: 17px; padding: 10px 28px; border-radius: 24px; }
@media (max-width: 700px) { .sides, .setup-fields { grid-template-columns: 1fr; } .era-grid { grid-template-columns: 1fr; } }
