:root {
  --bg: #17161c;
  --panel: rgba(23, 22, 28, .9);
  --line: #3b3742;
  --ink: #fff4e0;
  --muted: #a39a8f;
  --red: #ff3b30;
  --red-d: #a3201a;
  --yellow: #ffbe0b;
  --cream: #efe2c6;
  --green: #5ee27a;
  --px: 'Press Start 2P', monospace;
  --ui: 'Silkscreen', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--ui); overflow: hidden; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#px { image-rendering: pixelated; image-rendering: crisp-edges; }
#hud { pointer-events: none; }
.hidden { display: none !important; }
a { color: var(--yellow); }
button { font-family: var(--ui); cursor: pointer; }

#hot { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0; transition: opacity .2s steps(3);
  box-shadow: inset 0 0 0 6px var(--red), inset 0 0 90px rgba(255,59,48,.55); }
#hot.on { opacity: 1; animation: hotPulse .5s steps(2) infinite; }
#hot.crit { animation-duration: .18s; }
@keyframes hotPulse { 50% { opacity: .45; } }

/* ---------- menu ---------- */
#menu { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 20;
  background: radial-gradient(ellipse at 50% 35%, rgba(255,190,11,.10), transparent 60%), rgba(12,11,15,.6); overflow-y: auto; }
.card { width: min(440px, 100%); background: var(--panel); border: 3px solid var(--line); box-shadow: 0 0 0 3px #000, 8px 8px 0 #000; padding: 26px 22px 18px; }
.title { font-family: var(--px); font-size: clamp(36px, 10vw, 56px); text-align: center; line-height: 1; text-shadow: 4px 4px 0 #000;
  margin-bottom: 12px; display: flex; justify-content: center; align-items: center; gap: 6px; }
.title .t1 { color: var(--red); }
.title .t2 { color: var(--yellow); }
.title .bomb { position: relative; width: .62em; height: .62em; background: #2b2830; border-radius: 50%; box-shadow: 4px 4px 0 #000, inset -.08em -.08em 0 #000, inset .1em .1em 0 #4a4552; margin: 0 2px; top: .06em; }
.title .bomb::before { content: ''; position: absolute; width: .1em; height: .2em; background: var(--muted); left: .32em; top: -.16em; transform: rotate(25deg); }
.title .bomb::after { content: ''; position: absolute; width: .14em; height: .14em; background: var(--yellow); left: .42em; top: -.3em; box-shadow: .08em -.06em 0 var(--red), -.06em -.1em 0 var(--ink); animation: spark .25s steps(2) infinite; }
@keyframes spark { 50% { transform: translate(1px, -2px) scale(.7); } }
.tag { text-align: center; color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.rules { border: 2px dashed var(--line); padding: 10px 12px; margin-bottom: 16px; font-size: 13px; line-height: 1.55; }
.rules b { color: var(--red); margin-right: 6px; }
.rules b.hl { color: var(--yellow); margin: 0; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
input { display: block; width: 100%; margin-top: 5px; background: #0f0e12; color: var(--ink); border: 2px solid var(--line); padding: 10px 11px; font-family: var(--ui); font-size: 15px; outline: none; }
input:focus { border-color: var(--yellow); }
.muted { color: var(--muted); opacity: .85; }
#err { color: var(--red); min-height: 18px; font-size: 13px; margin: 2px 0 8px; }
.cta { width: 100%; font-family: var(--px); font-size: 14px; padding: 15px 10px; background: var(--red); color: var(--ink); border: 0;
  box-shadow: inset 0 -5px 0 var(--red-d), 4px 4px 0 #000; text-shadow: 2px 2px 0 var(--red-d); }
.cta:hover { filter: brightness(1.08); }
.cta:active { transform: translate(2px, 2px); box-shadow: inset 0 -3px 0 var(--red-d), 2px 2px 0 #000; }
.ghost { width: 100%; margin-top: 8px; background: none; color: var(--muted); border: 2px solid var(--line); padding: 9px; font-size: 13px; }
.ghost:hover { color: var(--ink); border-color: var(--muted); }
.ca { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 8px 10px; background: #0f0e12; border: 2px solid var(--line); font-size: 12px; }
.ca .lbl { color: var(--yellow); white-space: nowrap; }
.ca code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--ui); }
.mini { background: var(--line); color: var(--ink); border: 0; padding: 4px 8px; font-size: 11px; }
.links { display: flex; justify-content: center; gap: 16px; margin-top: 12px; font-size: 12px; }

/* ---------- HUD ---------- */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#topbar { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: calc(100% - 270px); }
.brand { font-family: var(--px); font-size: 15px; text-shadow: 3px 3px 0 #000; margin-right: 6px; }
.brand .t1 { color: var(--red); } .brand .t2 { color: var(--yellow); }
.pill { background: var(--panel); border: 2px solid var(--line); padding: 5px 9px; font-size: 12px; color: var(--muted); display: flex; align-items: center; }
.pill b { color: var(--ink); }
.btn-pill { pointer-events: auto; color: var(--ink); }
.live { width: 8px; height: 8px; background: var(--green); margin-right: 7px; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

#roundBar { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; background: var(--panel); border: 2px solid var(--line);
  box-shadow: 4px 4px 0 #000; padding: 6px 12px; font-size: 12px; white-space: nowrap; }
#rbRound { color: var(--yellow); }
#rbRanked.on { color: var(--green); } #rbRanked.off { color: var(--muted); }

#board { position: absolute; top: 12px; right: 12px; width: 236px; background: var(--panel); border: 2px solid var(--line); box-shadow: 4px 4px 0 #000; font-size: 12px; }
.board-head { padding: 8px 10px; border-bottom: 2px solid var(--line); color: var(--red); }
#lbList { list-style: none; margin: 0; padding: 4px 0; }
#lbList li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; padding: 3px 10px; align-items: baseline; }
#lbList li .r { color: var(--muted); }
#lbList li:nth-child(1) .r { color: var(--yellow); }
#lbList li:nth-child(2) .r { color: #d9d4e8; }
#lbList li:nth-child(3) .r { color: #e39a5a; }
#lbList li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbList li .s { color: var(--yellow); }
#lbList li.mine { background: rgba(255,190,11,.12); }
#lbList li.empty { color: var(--muted); display: block; text-align: center; padding: 10px; }
#meRow { padding: 6px 10px; border-top: 2px solid var(--line); color: var(--muted); }
#meRow b { color: var(--ink); }
.board-foot { padding: 7px 10px 9px; border-top: 2px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.5; pointer-events: auto; }

#feed { position: absolute; top: 96px; left: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
#feed div { background: var(--panel); border-left: 3px solid var(--red); padding: 4px 8px; animation: feedIn .2s steps(3); }
#feed .k { color: var(--red); } #feed .v { color: var(--ink); } #feed .p { color: var(--yellow); margin-left: 6px; } #feed .w { color: var(--green); }
@keyframes feedIn { from { transform: translateX(-20px); opacity: 0; } }

#bigText { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-family: var(--px); font-size: clamp(22px, 6vw, 46px);
  color: var(--yellow); text-shadow: 4px 4px 0 #000; opacity: 0; transition: opacity .15s steps(3); padding: 0 12px; }
#bigText.show { opacity: 1; }
#bigText.red { color: var(--red); }
#bigText small { display: block; font-family: var(--ui); font-size: 16px; color: var(--ink); margin-top: 12px; text-shadow: 2px 2px 0 #000; }

#bottom { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: stretch; }
.stat, .bars { background: var(--panel); border: 2px solid var(--line); box-shadow: 4px 4px 0 #000; padding: 7px 12px; display: flex; flex-direction: column; justify-content: center; }
.stat .lbl, .bar .lbl { font-size: 10px; color: var(--muted); }
.stat span:last-child { font-family: var(--px); font-size: 18px; margin-top: 4px; color: var(--yellow); }
.bars { gap: 6px; min-width: 170px; }
.bar { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 6px; }
.bar i { display: block; height: 8px; background: #0f0e12; border: 1px solid var(--line); position: relative; overflow: hidden; }
.bar i::after { content: ''; position: absolute; inset: 0; width: var(--w, 0%); background: var(--c, var(--yellow)); }
.state { font-size: 12px; color: var(--ink); }
.state.bomb { color: var(--red); }
.state.dead { color: var(--muted); }

#controls { position: absolute; bottom: 14px; left: 12px; background: var(--panel); border: 2px solid var(--line); box-shadow: 4px 4px 0 #000;
  padding: 8px 10px 9px; font-size: 11px; color: var(--muted); pointer-events: auto; min-width: 190px; }
.ctl-head { color: var(--red); margin-bottom: 7px; letter-spacing: 1px; }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.ctl-row .what { color: var(--ink); }
.keys { display: flex; align-items: center; gap: 6px; }
.keys .or { font-size: 10px; }
.kgrid { display: grid; grid-template-columns: repeat(3, 18px); grid-template-rows: 18px 18px; gap: 2px; }
.kgrid .k-w { grid-column: 2; grid-row: 1; } .kgrid .k-a { grid-column: 1; grid-row: 2; }
.kgrid .k-s { grid-column: 2; grid-row: 2; } .kgrid .k-d { grid-column: 3; grid-row: 2; }
kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; background: #0f0e12; color: var(--ink);
  border: 1px solid var(--line); box-shadow: inset 0 -2px 0 #000; font-family: var(--ui); font-size: 10px; line-height: 1; }
kbd.wide { min-width: 64px; }
kbd.on { background: var(--yellow); color: #1d1a12; box-shadow: inset 0 -2px 0 #a87a00; border-color: var(--yellow); }
.ctl-tip { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; line-height: 1.4; }
.ctl-tip b { color: var(--red); font-weight: 700; }
#ctlToggle { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; padding: 0; border: 0; background: var(--line); color: var(--ink); font-size: 12px; line-height: 1; }
#controls.min { min-width: 0; }
#controls.min .ctl-row, #controls.min .ctl-tip { display: none; }
#controls.min .ctl-head { margin: 0 24px 0 0; }

#touch { display: none; }
@media (pointer: coarse) {
  #controls { display: none; }
  #touch { display: block; }
  #stick { position: absolute; left: 22px; bottom: 26px; width: 124px; height: 124px; border: 3px solid rgba(255,244,224,.25); border-radius: 50%; pointer-events: auto; }
  #knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; background: rgba(255,244,224,.3); border-radius: 50%; }
  #tDash { position: absolute; right: 26px; bottom: 36px; width: 92px; height: 92px; border-radius: 50%; border: 0; background: var(--yellow); color: #1d1a12;
    font-family: var(--px); font-size: 12px; box-shadow: 4px 4px 0 #000; pointer-events: auto; }
  #bottom { bottom: 172px; transform: translateX(-50%) scale(.78); transform-origin: bottom center; }
  #board { width: 180px; font-size: 10px; transform: scale(.85); transform-origin: top right; }
}
@media (max-width: 760px) {
  #board { display: none; }
  #topbar { max-width: calc(100% - 24px); }
  #roundBar { top: auto; bottom: 12px; font-size: 11px; }
  #feed { top: 92px; }
  .brand { font-size: 12px; }
}
@media (max-width: 760px) and (pointer: coarse) { #roundBar { bottom: auto; top: 92px; } #feed { top: 128px; } }
@media (max-width: 760px) and (pointer: fine) { #bottom { bottom: 50px; left: auto; right: 12px; transform: scale(.85); transform-origin: bottom right; } #controls { transform: scale(.9); transform-origin: bottom left; } #roundBar { left: auto; right: 12px; transform: none; bottom: auto; top: 92px; } }

/* ---------- v2 : salles, partage, bonus, emotes ---------- */
#roomPill { color: var(--ink); }
.btn-pill.share { color: #1d1a12; background: var(--yellow); border-color: var(--yellow); }
.ctl-items { display: flex; gap: 10px; margin: 2px 0 6px; flex-wrap: wrap; }
.ctl-items span { display: flex; align-items: center; gap: 4px; color: var(--ink); }
.ic { display: inline-block; width: 10px; height: 10px; border-radius: 50%; box-shadow: 1px 1px 0 #000; }
.ic-shield { background: #3ec7ff; } .ic-speed { background: #ffbe0b; } .ic-freeze { background: #bff4ff; }
.c-shield { color: #3ec7ff; } .c-speed { color: #ffbe0b; } .c-freeze { color: #bff4ff; }
.skins { font-size: 12px; text-align: center; color: var(--muted); margin: -6px 0 14px; }
.skins b { color: var(--ink); }
#controls.min .ctl-items { display: none; }

#shareBtn { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); pointer-events: auto; font-family: var(--px); font-size: 12px;
  padding: 12px 16px; border: 0; background: var(--yellow); color: #1d1a12; box-shadow: inset 0 -4px 0 #a87a00, 4px 4px 0 #000; animation: pop .4s steps(3); }
@keyframes pop { from { transform: translateX(-50%) scale(.6); } }
#shareModal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(8,7,10,.8); padding: 16px; }
.share-card { width: min(640px, 100%); background: var(--panel); border: 3px solid var(--line); box-shadow: 8px 8px 0 #000; padding: 16px; text-align: center; }
.share-card img { width: 100%; display: block; image-rendering: pixelated; border: 2px solid var(--line); }
.share-card p { color: var(--muted); font-size: 13px; margin: 12px 0; }
.share-actions { display: flex; gap: 10px; }
.cta.small { display: block; flex: 1; font-size: 11px; padding: 12px 8px; text-decoration: none; text-align: center; }
.cta.x { background: #1d1a12; color: var(--ink); box-shadow: inset 0 -4px 0 #000, 4px 4px 0 #000; text-shadow: none; border: 2px solid var(--line); }

#tEmotes { display: none; }
@media (pointer: coarse) {
  #tEmotes { display: flex; position: absolute; right: 18px; bottom: 140px; gap: 6px; pointer-events: auto; }
  #tEmotes button { font-family: var(--px); font-size: 8px; padding: 8px 6px; border: 0; background: var(--cream); color: #1d1a12; box-shadow: 2px 2px 0 #000; }
  #shareBtn { bottom: 230px; }
  #bottom { bottom: 190px; }
}

/* ---------- prizes ---------- */
.btn-pill.prizes { color: var(--yellow); }
.ghost.prizes-link { color: var(--yellow); border-color: rgba(255,190,11,.4); }
#prizesModal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(8,7,10,.82); padding: 16px; overflow-y: auto; }
.prizes-card { position: relative; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 3px solid var(--line);
  box-shadow: 0 0 0 3px #000, 8px 8px 0 #000; padding: 24px 22px; font-size: 14px; line-height: 1.55; }
.prizes-card h2 { font-family: var(--px); font-size: 30px; margin: 0 0 12px; text-shadow: 3px 3px 0 #000; }
.prizes-card h2 .t1 { color: var(--red); } .prizes-card h2 .t2 { color: var(--yellow); }
.prizes-card h3 { font-family: var(--px); font-size: 12px; color: var(--yellow); margin: 22px 0 8px; line-height: 1.4; }
.prizes-card ul { margin: 0; padding-left: 18px; }
.prizes-card li { margin-bottom: 5px; }
.prizes-card b { color: var(--ink); }
.prizes-card .lead { margin: 0 0 14px; color: var(--ink); }
.prizes-card .small { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.prizes-card .ok { color: var(--green); }
.x-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 2px solid var(--line); background: #0f0e12; color: var(--ink); font-size: 16px; }
.live-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.live-row div { background: #0f0e12; border: 2px solid var(--line); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.live-row .lbl { font-size: 10px; color: var(--muted); }
.live-row b { font-family: var(--px); font-size: 12px; color: var(--yellow); line-height: 1.3; }
.split { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.split div { background: #0f0e12; border: 2px solid var(--line); padding: 7px 6px; text-align: center; }
.split .rk { display: block; font-size: 11px; color: var(--muted); }
.split .pc { display: block; font-family: var(--px); font-size: 13px; color: var(--ink); margin-top: 4px; }
.split .of { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
.split div:first-child { border-color: var(--yellow); } .split div:first-child .pc { color: var(--yellow); }
@media (max-width: 520px) { .live-row { grid-template-columns: 1fr; } .split { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
