/* Age of Power : un seul thème sombre (plateau de jeu de nuit, braises). */
:root {
  --night: #0d1216;
  --stone: #17202a;
  --stone-2: #202c37;
  --edge: #354553;
  --parch: #ece4d2;
  --muted: #93a2ad;
  --ember: #ff8a3d;
  --ember-deep: #b8501a;
  --ayy: #d8a640;
  --cro: #e6e9ee;
  --neutre: #b9875c;
  --ok: #9fe870;
  --bad: #ff5a4f;
  --f-display: "Alegreya SC", "Palatino Linotype", Georgia, serif;
  --f-ui: "Fira Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --b: clamp(44px, 12.4vmin, 60px);
  --gap: 6px;
  --mm: clamp(92px, 27vmin, 156px);
  --bar: 40px;
  --inl: max(8px, env(safe-area-inset-left, 0px));
  --inr: max(8px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--night);
  color: var(--parch);
  font-family: var(--f-ui);
  font-size: 14px;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
input { -webkit-user-select: text; user-select: text; }
button {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--edge);
  background: linear-gradient(180deg, var(--stone-2), var(--stone));
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 2px 6px rgba(0,0,0,.35);
  touch-action: manipulation;
}
button:active, button.pressed { transform: translateY(1px); filter: brightness(1.25); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
button:disabled { opacity: .38; cursor: default; }
.main { background: linear-gradient(180deg, var(--ember), var(--ember-deep)); border-color: #ffb27e; color: #1b0d04; font-weight: 600; }

/* ---------- écrans accueil et salon ---------- */
.screen { position: absolute; inset: 0; overflow-y: auto; padding: max(16px, env(safe-area-inset-top, 0px)) var(--inr) max(16px, env(safe-area-inset-bottom, 0px)) var(--inl); display: grid; place-items: center;
  background: radial-gradient(120% 80% at 20% 110%, rgba(255,138,61,.16), transparent 60%), radial-gradient(90% 70% at 100% 0%, rgba(91,152,255,.12), transparent 60%), var(--night); }
.panel { width: min(560px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 22px 20px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(27,37,48,.94), rgba(20,28,36,.94)); border: 1px solid var(--edge); box-shadow: 0 14px 50px rgba(0,0,0,.5); }
.title { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: clamp(30px, 8vw, 44px); line-height: 1; letter-spacing: .03em; color: var(--ember); text-wrap: balance; }
.tag { margin: -4px 0 4px; color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field input {
  height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--edge); background: #0f161c; color: var(--parch);
  font: 500 17px var(--f-ui); min-width: 0;
}
#codeIn { text-transform: uppercase; letter-spacing: .3em; font-weight: 600; }
.row { display: flex; gap: 8px; min-width: 0; }
.row > input { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button, .row button { height: 46px; padding: 0 18px; font-weight: 600; }
.msg { margin: 0; min-height: 1.2em; font-size: 13.5px; color: var(--bad); }
.note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.divider { height: 1px; background: var(--edge); opacity: .7; }

.code-block { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.code-block .lbl { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.code-block b { font-family: var(--f-display); font-size: 34px; letter-spacing: .14em; color: var(--parch); }
.code-block button { height: 40px; padding: 0 14px; font-size: 13px; }
.link { margin: 0; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.slot { border: 1px solid var(--edge); border-radius: 12px; padding: 12px 14px; background: rgba(0,0,0,.2); display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; min-width: 0; }
.slot::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.slot.side1 { background: rgba(80,20,10,.18); }
.slot .fac { font-family: var(--f-display); font-weight: 700; font-size: 17px; color: var(--c); }
.slot .who { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .who i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.slot .who i.on { background: var(--ok); }
.slot .free { color: var(--muted); font-style: italic; }
.slot .tagline { font-size: 12.5px; color: var(--muted); }
.slot button { height: 36px; font-size: 13px; padding: 0 12px; align-self: flex-start; }
.modes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modes button { height: 40px; padding: 0 16px; font-weight: 600; }
.modes button.on { border-color: var(--ember); box-shadow: 0 0 0 2px rgba(255,138,61,.45); }
.slot select { height: 36px; border-radius: 8px; border: 1px solid var(--edge); background: #0f161c; color: var(--parch); font: 500 14px var(--f-ui); padding: 0 8px; max-width: 100%; }
.slot .side { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.slot .pcol { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: 0; }
.shopList { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.shopItem { text-align: left; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; min-height: 76px; }
.shopItem b { font-size: 14px; }
.shopItem span { font-size: 12px; color: var(--muted); }
.shopItem i { font-style: normal; color: #ffd36b; font-weight: 600; font-size: 13px; }
#shopSell button { height: 40px; padding: 0 12px; font-size: 13px; }
.cmd.item { border-color: #8a6ab0; }
.cmd.ult { border-color: #e07a3a; }
.badge { font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--edge); color: var(--muted); }

/* ---------- vocal ---------- */
.mic { height: 34px; padding: 0 14px; font-weight: 600; letter-spacing: .03em;
  background: linear-gradient(180deg, var(--ember), var(--ember-deep)); border-color: #ffb27e; color: #1b0d04; }
.mic.pressed { box-shadow: 0 0 0 4px rgba(255,138,61,.35); }
.mic.locked { background: linear-gradient(180deg, #ffd08a, var(--ember)); box-shadow: 0 0 0 3px rgba(255,208,138,.45); }
.vchips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.vchip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--edge); background: rgba(13,18,22,.85); font-size: 12.5px; max-width: 140px; }
.vchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vchip i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.vchip.on i { background: var(--ok); }
.vchip.speak { border-color: var(--ember); box-shadow: 0 0 0 2px rgba(255,138,61,.45); }
.vchip.muted span { text-decoration: line-through; color: var(--muted); }
.voice-dock { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- jeu ---------- */
#game { position: absolute; inset: 0; overflow: hidden; }
#c, #ov { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#c { touch-action: none; outline: none; }
#ov { pointer-events: none; }
#top {
  position: absolute; top: 0; left: 0; right: 0; height: var(--bar);
  padding-inline: var(--inl) var(--inr);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(13,18,22,.92), rgba(13,18,22,.72));
  border-bottom: 1px solid rgba(53,69,83,.7);
  font-variant-numeric: tabular-nums;
}
.brand { font-family: var(--f-display); font-weight: 700; font-size: 16px; letter-spacing: .03em; color: var(--ember); white-space: nowrap; }
.stat { font-size: 13px; color: var(--muted); white-space: nowrap; }
.stat b { color: var(--parch); font-weight: 600; }
.mid { margin-inline: auto; display: flex; align-items: baseline; gap: 8px; font-size: 13px; white-space: nowrap; min-width: 0; overflow: hidden; }
.mid b { font-size: 15px; }
.mid span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.net { font-size: 11px; color: var(--muted); text-align: right; line-height: 1.15; min-width: 46px; }
#menuBtn { height: 30px; padding: 0 10px; font-size: 12px; }
.res { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; color: var(--muted); white-space: nowrap; min-width: 0; }
.res b { color: var(--parch); font-weight: 600; font-size: 14px; }
.res .gold b { color: #ffd36b; }
.res .wood b { color: #d9a46e; }
.res b.full { color: var(--bad); }
#voiceBar { position: absolute; top: calc(var(--bar) + 6px); right: var(--inr); justify-content: flex-end; max-width: 50%; pointer-events: auto; }
#hint {
  position: absolute; top: calc(var(--bar) + 42px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 2 * var(--b) - 120px);
  padding: 6px 6px 6px 14px; border-radius: 999px; background: rgba(23,32,42,.94); border: 1px solid var(--ember); font-size: 13px;
}
#hint span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hint button { min-width: 0; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 12px; flex: none; }
#toast {
  position: absolute; top: calc(var(--bar) + 84px); left: 50%; transform: translateX(-50%); z-index: 30;
  padding: 8px 14px; border-radius: 8px; background: rgba(13,18,22,.92); border: 1px solid var(--edge);
  font-size: 13px; max-width: 72%; text-align: center; pointer-events: none;
}
#netBanner { position: absolute; top: var(--bar); left: 0; right: 0; padding: 6px 12px; text-align: center; font-size: 13px; background: rgba(255,90,79,.9); color: #1b0605; font-weight: 600; z-index: 25; }
#left { position: absolute; top: calc(var(--bar) + 8px); left: var(--inl); display: flex; flex-direction: column; gap: var(--gap); }
#left .row { gap: var(--gap); }
#heroBtn { width: calc(var(--b) * 1.3); height: calc(var(--b) * 1.3); padding: 0; position: relative; overflow: hidden; display: grid; place-items: center; border-color: #b99a4e; }
#heroBtn .glyph { font-family: var(--f-display); font-size: calc(var(--b) * .6); font-weight: 700; color: #e7c66f; line-height: 1; }
#heroBtn .lvl { position: absolute; top: 3px; right: 4px; font-size: 11px; font-weight: 600; color: var(--parch); }
#heroBtn .hb { position: absolute; left: 5px; right: 5px; bottom: 5px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.5); overflow: hidden; }
#heroBtn .hb i { display: block; height: 100%; background: var(--ok); width: 100%; }
#heroBtn .mb { position: absolute; left: 5px; right: 5px; bottom: 12px; height: 3px; border-radius: 2px; background: rgba(0,0,0,.5); overflow: hidden; }
#heroBtn .mb i { display: block; height: 100%; background: #6fb4ff; width: 100%; }
#heroBtn .rsp { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(13,18,22,.82); font-size: 13px; font-weight: 600; }
#heroBtn.sel { box-shadow: 0 0 0 2px var(--ok); }
#armyBtn, #idleBtn { width: var(--b); height: calc(var(--b) * 1.3); padding: 0 2px; font-size: 11.5px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.05; }
#armyBtn b, #idleBtn b { font-size: 16px; }
#idleBtn small { font-size: 9.5px; color: var(--ember); font-weight: 600; min-height: 1em; }
#idleBtn.alert { border-color: var(--ember); }
.groups { display: flex; gap: var(--gap); }
.grp { width: var(--b); height: var(--b); position: relative; font-size: 16px; font-weight: 600; }
.grp small { position: absolute; right: 5px; bottom: 3px; font-size: 10px; color: var(--muted); font-weight: 500; }
.grp.armed { border-color: var(--ok); }
#mini {
  position: absolute; left: var(--inl); bottom: 8px; width: var(--mm); height: var(--mm);
  border-radius: 10px; border: 1px solid var(--edge); background: #0b1014; overflow: hidden; touch-action: none; box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
#mm { width: 100%; height: 100%; display: block; }
#sel {
  position: absolute; bottom: 8px; left: calc(var(--inl) + var(--mm) + 8px); right: calc(var(--inr) + var(--b) * 3 + var(--gap) * 2 + 8px);
  min-height: 64px; max-height: calc(var(--b) * 1.8); padding: 8px 10px; border-radius: 10px;
  background: rgba(23,32,42,.9); border: 1px solid var(--edge); display: flex; flex-direction: column; gap: 6px; overflow: hidden; min-width: 0;
}
#sel .empty { color: var(--muted); font-size: 13px; line-height: 1.35; }
#sel .one { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 13px; }
#sel .one > b { font-family: var(--f-display); font-size: 16px; font-weight: 700; }
#sel .one .k { color: var(--muted); }
#sel .one .k b { font-size: 13px; color: var(--parch); font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 3px; }
.bar { height: 6px; border-radius: 3px; background: rgba(0,0,0,.45); overflow: hidden; }
.bar.thin { height: 4px; }
.bar i { display: block; height: 100%; }
.ports { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; overflow: hidden; }
.port { width: 34px; height: 34px; padding: 0; border-radius: 7px; position: relative; font-family: var(--f-display); font-weight: 700; font-size: 15px; display: grid; place-items: center; }
.port i { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 3px; border-radius: 2px; }
.port.q { cursor: default; color: var(--parch); }
.port.q.wait { outline: 1px dashed var(--bad); }
.port.more { font-family: var(--f-ui); font-size: 12px; color: var(--muted); }
#right { position: absolute; right: var(--inr); bottom: 8px; display: flex; flex-direction: column; gap: var(--gap); align-items: stretch; }
#pingBtn { height: calc(var(--b) * .78); font-size: 13px; font-weight: 500; }
#pingMenu {
  position: absolute; right: 0; bottom: calc(100% + 6px); display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
  width: calc(var(--b) * 3 + var(--gap) * 2); padding: 6px; border-radius: 10px; background: rgba(13,18,22,.94); border: 1px solid var(--edge);
}
#pingMenu button { height: 40px; font-size: 12px; }
.grid { display: grid; grid-template-columns: repeat(3, var(--b)); gap: var(--gap); }
.cmd { width: var(--b); height: var(--b); padding: 0 2px; position: relative; overflow: hidden; font-size: 11.5px; font-weight: 600; line-height: 1.05; display: grid; place-content: center; text-align: center; }
.cmd small { display: block; font-size: 9.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.cmd.eco { border-color: #7d6a45; }
.cmd.locked { opacity: .5; }
.cmd.long { font-size: min(10.5px, calc(var(--b) * .19)); letter-spacing: -.02em; }
.cmd.void { visibility: hidden; }
.cmd small.cost { color: var(--parch); font-weight: 600; }
.cmd small.cost .g { font-style: normal; color: #ffd36b; }
.cmd small.cost .w { font-style: normal; color: #d9a46e; }
.cmd.armed { border-color: var(--ember); box-shadow: 0 0 0 2px rgba(255,138,61,.55); }
.cmd.spell { border-color: #b99a4e; font-size: min(10.5px, calc(var(--b) * .2)); letter-spacing: -.01em; }
.cmd.spell::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: conic-gradient(rgba(5,8,10,.72) calc(var(--cd, 0) * 1turn), transparent 0); }
#lasso { position: absolute; border: 1.5px solid var(--ok); background: rgba(159,232,112,.12); pointer-events: none; border-radius: 3px; }

/* ---------- feuilles ---------- */
.sheet { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(8,11,14,.78); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; z-index: 40; }
.card { width: min(640px, 100%); max-height: 100%; overflow-y: auto; background: linear-gradient(180deg, #1b2530, #141c24); border: 1px solid var(--edge); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.card h1 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: 28px; letter-spacing: .03em; color: var(--ember); text-wrap: balance; }
.card h1 small { display: block; font-family: var(--f-ui); font-size: 12px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.card h2 { margin: 4px 0 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.card p { margin: 0; font-size: 14px; line-height: 1.45; max-width: 62ch; }
.gest { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px 18px; margin: 0; padding: 0; list-style: none; font-size: 13.5px; }
.gest li { min-width: 0; }
.gest b { color: var(--ember); font-weight: 600; }
.endstats { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.endstats th, .endstats td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--edge); }
.endstats th:first-child, .endstats td:first-child { text-align: left; }
.endstats th { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.tablewrap { overflow-x: auto; }
#err { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; font-size: 15px; }

@media (max-width: 900px) {
  #top .brand, #top .stat.foe { display: none; }
}
@media (max-width: 700px) {
  .res { gap: 7px; font-size: 11px; }
  .res b { font-size: 13px; }
  .net { display: none; }
}
@media (max-width: 560px) {
  #sel { display: none; }
}
@media (max-height: 340px) {
  :root { --bar: 34px; }
  #pingBtn { display: none; }
}
@media (prefers-reduced-motion: reduce) { button:active { transform: none; } }
