:root {
  color-scheme: light dark;
  --bg: #efe9dd; --bg2: #e2d9c7; --ink: #1d1a24; --muted: #6a6474; --line: rgba(29,26,36,.16);
  --panel: rgba(250,246,238,.9); --panel-ink: #1d1a24; --accent: #d9342b; --accent-ink: #fff;
  --hp: #d9342b; --ki: #2c7fe0; --xp: #e0a81f; --track: rgba(29,26,36,.2);
  --univers: #d9342b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14111d; --bg2: #1e1a2b; --ink: #f3eee4; --muted: #a09aac; --line: rgba(243,238,228,.16);
    --panel: rgba(22,18,32,.86); --panel-ink: #f3eee4; --accent: #ff5a4a; --accent-ink: #14111d;
    --hp: #ff5a4a; --ki: #4ea3ff; --xp: #ffc73a; --track: rgba(255,255,255,.16);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 600 16px/1.25 'Barlow Condensed', system-ui, sans-serif; }
canvas#gl, canvas#ov { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#ov { pointer-events: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Menu */
.screen { position: fixed; inset: 0; overflow: auto; padding: 4vh 16px 32px; display: flex; flex-direction: column; align-items: center; gap: 20px;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg)); }
.logo { font: 400 clamp(46px, 8vw, 92px)/.86 'Bangers', Impact, sans-serif; letter-spacing: .02em; margin: 0; text-align: center; }
.logo span { color: var(--accent); }
h2 { font: 400 34px/1 'Bangers', Impact, sans-serif; letter-spacing: .03em; margin: 8px 0 14px; text-align: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.narrow { width: min(340px, 100%); display: grid; gap: 8px; }
.narrow input { background: transparent; border: 2px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 20px; }
.err { color: var(--accent); margin: 0; min-height: 20px; }
.primary { background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 10px 16px; font-size: 20px; font-weight: 700; }
.ghost { color: var(--muted); padding: 6px 8px; }
#accueil { position: absolute; top: 12px; left: 12px; text-decoration: none; }
#m-univers, #m-chars { width: min(1120px, 100%); }
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 820px; margin: auto; }
.pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 16px 10px 14px; border-radius: 12px; overflow: hidden;
  background: var(--panel); border: 2px solid var(--line); transition: transform .14s ease, border-color .14s ease; }
.pick:hover, .pick:focus-visible { transform: translateY(-3px); border-color: var(--c); }
.pick::before { content: ''; position: absolute; inset: 0 0 auto; height: 6px; background: var(--c); }
.pick canvas { width: 96px; height: 144px; image-rendering: pixelated; }
.pick .trio { display: flex; }
.pick .trio canvas { width: 56px; height: 84px; margin: 0 -7px; }
.pick b { font: 400 26px/1 'Bangers', Impact, sans-serif; letter-spacing: .03em; }
.pick small { color: var(--muted); font-size: 14px; }
.tag { position: absolute; top: 12px; right: 8px; font-size: 12px; font-weight: 700; color: var(--accent-ink); background: var(--accent); padding: 1px 6px; border-radius: 4px; }
.week { display: flex; justify-content: center; align-items: center; gap: 14px; font-size: 20px; flex-wrap: wrap; }
.week b { font: 400 28px/1 'Bangers', Impact, sans-serif; letter-spacing: .03em; }
.week i { font-style: normal; color: var(--muted); }
@media (max-width: 860px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (prefers-reduced-motion: reduce) { .pick { transition: none; } }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; color: var(--panel-ink); user-select: none; }
#hud button, #hud input, .sheet, #say { pointer-events: auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px); }
#unit { position: absolute; top: 12px; left: 12px; display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 8px; width: 296px; }
#portrait { width: 40px; height: 60px; image-rendering: pixelated; flex: none; }
.unit-main { flex: 1; display: grid; gap: 3px; min-width: 0; }
.unit-name { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-name span { color: var(--muted); }
.bar { position: relative; height: 13px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .12s linear; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 13px; color: #fff; text-shadow: 0 1px 1px #000; }
.bar.hp i { background: var(--hp); } .bar.ki i { background: var(--ki); }
.bar.xp { height: 5px; } .bar.xp i { background: var(--xp); }
.pts { position: absolute; right: -10px; top: -8px; width: 26px; height: 26px; border-radius: 50%; background: var(--xp); color: #1d1a24; font-weight: 700; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(1.14); } }
@media (prefers-reduced-motion: reduce) { .pts { animation: none; } }

#warchip { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); padding: 6px 14px; display: flex; gap: 10px; align-items: baseline; font-size: 17px; white-space: nowrap; color: var(--panel-ink); }
#warchip b { font: 400 22px/1 'Bangers', Impact, sans-serif; letter-spacing: .03em; }
#match { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); padding: 6px 12px; display: flex; gap: 12px; align-items: center; font-size: 20px; }
#match .sc { font: 400 30px/1 'Bangers', Impact, sans-serif; min-width: 48px; text-align: center; }
.zones { display: flex; gap: 5px; }
.zones em { font-style: normal; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; color: #fff; background: #5b5a68; text-shadow: 0 1px 1px #000; border: 2px solid transparent; }

#right { position: absolute; top: 12px; right: 12px; width: 190px; display: grid; gap: 8px; }
#mini { width: 190px; height: 142px; display: block; image-rendering: pixelated; padding: 0; }
#quest { padding: 8px 10px; font-size: 15px; }
#quest b { display: block; font-size: 17px; }
#quest.ready { border-color: var(--xp); }

#chat { position: absolute; left: 12px; bottom: 12px; width: 340px; display: grid; gap: 4px; }
#chat-log { max-height: 150px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 15px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
#chat-log b { color: var(--c, #ffd76a); }
#chat-in { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; width: 100%; color: var(--panel-ink); opacity: .75; }
#chat-in:focus { opacity: 1; outline: none; border-color: var(--accent); }

#bar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 6px; }
.slot { position: relative; width: 66px; height: 66px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 3px 4px; text-align: center; font-size: 12px; line-height: 1; backdrop-filter: blur(6px); }
.slot kbd { position: absolute; top: 3px; left: 5px; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); }
.slot .cd { position: absolute; inset: auto 0 0; background: rgba(0,0,0,.55); height: 0; }
.slot span { position: relative; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot.off { opacity: .45; }
.slot.on { border-color: var(--xp); box-shadow: 0 0 0 1px var(--xp) inset; }
.slot .cnt { position: absolute; top: 3px; right: 5px; font-size: 14px; font-weight: 700; }

#prompt { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--panel); padding: 4px 12px; border-radius: 6px; }
#say { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); width: min(520px, 90vw); padding: 12px 16px; cursor: pointer; font-size: 18px; }
#say b { display: block; color: var(--accent); }
#banner { position: absolute; top: 22%; left: 0; right: 0; text-align: center; font: 400 clamp(34px, 5vw, 62px)/1 'Bangers', Impact, sans-serif; letter-spacing: .03em; color: #fff; text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,.6); }
#toasts { position: absolute; top: 34%; left: 0; right: 0; display: grid; gap: 3px; justify-items: center; font-size: 19px; color: #fff; text-shadow: 0 1px 2px #000; }
#dead { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #fff; background: rgba(40,0,0,.45); font: 400 64px/1 'Bangers', Impact, sans-serif; }
#dead small { font-size: 34px; }
.sheet { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(430px, 92vw); padding: 16px 18px; display: grid; gap: 10px; }
.sheet h3 { font: 400 30px/1 'Bangers', Impact, sans-serif; letter-spacing: .03em; margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 18px; }
.row small { color: var(--muted); font-size: 15px; }
.plus { width: 30px; height: 30px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.plus:disabled { opacity: .3; cursor: default; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; text-align: center; }
.vs b { font: 400 25px/1 'Bangers', Impact, sans-serif; display: block; }
.vs strong { font-size: 30px; }
.gauge { height: 10px; border-radius: 5px; overflow: hidden; display: flex; background: var(--track); }
.gauge i { display: block; }
.next { color: var(--muted); font-size: 15px; }
#loading { position: absolute; inset: 0; display: grid; place-content: center; background: var(--bg); color: var(--ink); font: 400 40px 'Bangers', Impact, sans-serif; }
