/* Police Monocraft (Idrees Hassan, licence SIL OFL 1.1 : fonts/Monocraft-LICENSE.txt), comme dans Core Wars .io */
@font-face { font-family: 'Monocraft'; src: url('../fonts/Monocraft.ttf') format('truetype'); font-display: block; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b1133; color: #fff; font-family: 'Monocraft', monospace; user-select: none; -webkit-user-select: none; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }
.t { text-shadow: 2px 2px 0 #000; }
.panel { background: rgba(0, 0, 0, 0.5); border: 2px solid #000; box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.12), inset -2px -2px 0 rgba(0, 0, 0, 0.35); }
#hud { position: fixed; inset: 0; pointer-events: none; }

/* Score : manches gagnées, chrono, joueurs en vie (un carré à la couleur de chaque agent) */
#score { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 10px; font-size: 24px; }
#score .mid { min-width: 76px; text-align: center; font-size: 20px; display: flex; justify-content: center; align-items: center; }
#timer.buy { color: #9fd0ff; }
.sb-b { color: #8fb0ff; } .sb-r { color: #ff8a76; }
.alive { display: flex; gap: 3px; }
.alive i { width: 12px; height: 16px; display: block; border: 2px solid #000; }
.alive i.off { opacity: 0.25; }

/* Bandeau de manche */
.banner { position: absolute; left: 50%; top: 76px; transform: translateX(-50%); text-align: center; text-shadow: 3px 3px 0 #000; }
#bannerT { font-size: clamp(28px, 5vw, 52px); color: #f0e2c0; }
#bannerS { font-size: 20px; color: #d8d0b8; margin-top: 6px; letter-spacing: 3px; }
.banner.win #bannerT { color: #ffd84a; } .banner.lose #bannerT { color: #ff8a76; }

/* Mini-carte */
#minimap { position: absolute; left: 14px; top: 12px; width: 192px; height: 128px; border: 2px solid #000; image-rendering: pixelated; }

/* Fil des éliminations */
#feed { position: absolute; right: 14px; top: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; }
#feed div { background: rgba(0, 0, 0, 0.45); padding: 3px 8px; display: flex; align-items: center; gap: 7px; text-shadow: 1px 1px 0 #000; }
.ic { display: inline-block; height: 12px; background-size: 100% 100%; image-rendering: pixelated; }
.ic-pistol { width: 20px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h10v2H0zM0 2h4v1H0zM1 3h3v3H1zM5 2h1v2H5z' fill='%23e8e8e8'/%3E%3C/svg%3E"); }
.ic-smg { width: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 6' shape-rendering='crispEdges'%3E%3Cpath d='M3 1h8v2H3zM11 1h2v1h-2zM0 1h1v3H0zM1 2h2v1H1zM4 3h2v3H4zM7 3h2v2H7z' fill='%23e8e8e8'/%3E%3C/svg%3E"); }
.ic-rifle { width: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 6' shape-rendering='crispEdges'%3E%3Cpath d='M0 2h4v3H1V4H0zM4 2h6v2H4zM10 2h5v1h-5zM6 4h2v2H6z' fill='%23e8e8e8'/%3E%3C/svg%3E"); }
.ic-sniper { width: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 6' shape-rendering='crispEdges'%3E%3Cpath d='M0 2h5v3H2V4H0zM5 2h6v2H5zM11 2h7v1h-7zM6 0h5v1H6zM7 1h1v1H7zM9 1h1v1H9zM6 4h2v2H6z' fill='%23e8e8e8'/%3E%3C/svg%3E"); }
.ic-head { width: 12px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 6' shape-rendering='crispEdges'%3E%3Cpath d='M1 0h4v1H1zM0 1h6v3H0zM1 4h4v2H1z' fill='%23ff5a4a'/%3E%3C/svg%3E"); }
.ic-core { width: 12px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 6' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h6v6H0z' fill='%232a2d33'/%3E%3Cpath d='M1 1h4v4H1z' fill='%23f0c040'/%3E%3Cpath d='M2 2h2v2H2z' fill='%23fff4c0'/%3E%3C/svg%3E"); }
.ic.big { width: 22px; height: 22px; }
#coreIco.blink { animation: blink 0.25s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

/* Cœurs (bedwars : pixel, minimalistes, pointe en triangle, faits de rectangles) : 20 points de vie chacun ; bouclier dessous */
#vitals { position: absolute; left: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
#hearts { display: flex; gap: 5px; }
#hearts i { width: 28px; height: 24px; display: block; image-rendering: pixelated; background-size: 100% 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 6' shape-rendering='crispEdges'%3E%3Cpath d='M1 0h2v1H1zM4 0h2v1H4zM0 1h7v2H0zM1 3h5v1H1zM2 4h3v1H2zM3 5h1v1H3z' fill='%23000' fill-opacity='.55'/%3E%3C/svg%3E"); }
#hearts i.full, #hearts i.half, #hearts i.low { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 6' shape-rendering='crispEdges'%3E%3Cpath d='M1 0h2v1H1zM4 0h2v1H4zM0 1h7v2H0zM1 3h5v1H1zM2 4h3v1H2zM3 5h1v1H3z' fill='%23d4302a'/%3E%3Cpath d='M1 1h1v1H1z' fill='%23ff9a8a'/%3E%3C/svg%3E"); }
#hearts i.half { clip-path: inset(0 45% 0 0); }
#hearts i.low { clip-path: inset(0 70% 0 0); }
#shieldBox { width: 160px; height: 10px; background: rgba(0, 0, 0, 0.6); border: 2px solid #000; }
#shield { height: 100%; background: linear-gradient(#9fd0ff 0 30%, #4f8fd8 30% 100%); }

/* Capacité de l'agent : son icône, ses charges */
#abBox { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
#abBox.off .ab { opacity: 0.3; }
#abPips { display: flex; gap: 4px; height: 6px; }
#abPips i { width: 10px; height: 6px; display: block; background: #f0e2c0; border: 1px solid #000; }
.ab { display: block; width: 32px; height: 32px; background-size: 100% 100%; image-rendering: pixelated; }
.ab-dash { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M0 3h5v2H0zM4 1h1v6H4zM5 2h1v4H5zM6 3h1v2H6z' fill='%2393e2f3'/%3E%3C/svg%3E"); }
.ab-wall { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h3v2H0zM4 0h4v2H4zM0 3h1v2H0zM2 3h4v2H2zM7 3h1v2H7zM0 6h3v2H0zM4 6h4v2H4z' fill='%23c2a6f0'/%3E%3C/svg%3E"); }
.ab-radar { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h8v1H0zM0 7h8v1H0zM0 1h1v6H0zM7 1h1v6H7zM2 2h4v1H2zM2 5h4v1H2zM2 3h1v2H2zM5 3h1v2H5z' fill='%239ab4f0'/%3E%3Cpath d='M3 3h2v2H3z' fill='%23ff8a76'/%3E%3C/svg%3E"); }
.ab-heal { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M3 0h2v8H3zM0 3h8v2H0z' fill='%239be0a0'/%3E%3C/svg%3E"); }
.ab-smoke { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M0 3h4v4H0zM3 0h4v4H3z' fill='%23d8d4cc'/%3E%3Cpath d='M4 4h4v4H4z' fill='%23aaa69e'/%3E%3C/svg%3E"); }
.ab-flash { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath d='M3 0h2v8H3zM0 3h8v2H0z' fill='%23f5e59a'/%3E%3Cpath d='M1 1h1v1H1zM6 1h1v1H6zM1 6h1v1H1zM6 6h1v1H6zM3 3h2v2H3z' fill='%23fff'/%3E%3C/svg%3E"); }

/* Arme : nom, munitions, rechargement ; crédits pendant les achats ; noyau porté */
#ammoBox { position: absolute; right: 18px; bottom: 18px; padding: 7px 12px; min-width: 150px; text-align: right; text-shadow: 2px 2px 0 #000; }
#wName { font-size: 13px; color: #d8d0b8; }
.ammoRow { display: flex; justify-content: flex-end; align-items: baseline; gap: 6px; }
#ammoN { font-size: 34px; min-height: 40px; }
#ammoM { font-size: 15px; color: #b8b0a0; }
#reloadWrap { margin-top: 4px; height: 5px; background: rgba(0, 0, 0, 0.6); }
#reload { height: 100%; width: 0; background: #e8e8e8; }
#creditBox, .buyHead { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 16px; color: #ffe066; margin-bottom: 4px; }
.cr { display: inline-block; width: 12px; height: 12px; background: #e8c040; border: 2px solid #000; box-shadow: inset -2px -2px 0 #a8801a; }
#carry { display: flex; justify-content: flex-end; margin-bottom: 4px; }

/* Réticule : petit losange blanc, net (pas de pixels) ; touche : une croix, rouge à la tête */
#reticle, #hitm { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
#reticle { width: 14px; height: 14px; }
#hitm { width: 26px; height: 26px; opacity: 0; transition: opacity 0.05s; }
#hitm path { stroke: #fff; }
#hitm.head path { stroke: #ff3b2f; }
#hurt { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, rgba(160, 0, 0, 0) 55%, rgba(160, 0, 0, 0.7) 100%); }
#blind { position: absolute; inset: 0; opacity: 0; background: #fffef4; }

/* Pose / désamorçage */
#progBox { position: absolute; left: 50%; top: calc(50% + 40px); transform: translateX(-50%); width: 240px; height: 14px; padding: 2px; }
#prog { height: 100%; width: 0; background: #f0c040; }
#progBox.def #prog { background: #8fb0ff; }
#spect { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); padding: 6px 14px; font-size: 18px; }

/* Lunette : un carré de vue, des fils fins, tout le reste noir */
#scope { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#scope .win { position: relative; width: min(78vh, 78vw); height: min(78vh, 78vw); box-shadow: 0 0 0 200vmax #050505; border: 4px solid #050505; outline: 2px solid #2a2d33; }
#scope .h, #scope .v { position: absolute; background: rgba(0, 0, 0, 0.85); display: block; }
#scope .h { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; }
#scope .v { top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; }

/* Tableau des scores (Tab) */
#board { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 12px; pointer-events: none; }
#boardWrap { display: flex; gap: 18px; }
table.sb { border-collapse: collapse; font-size: 14px; min-width: 260px; }
table.sb th { text-align: left; padding: 3px 8px; font-weight: normal; border-bottom: 2px solid #000; }
table.sb td { padding: 2px 8px; text-shadow: 1px 1px 0 #000; }
table.sb td + td, table.sb th + th { text-align: right; }
table.sb td:last-child { color: #ffe066; }
table.sb tr.me td:first-child { color: #ffe066; }
table.sb tr.dead td { opacity: 0.5; }
#thB { color: #8fb0ff; } #thR { color: #ff8a76; }

/* Achats */
#buy { position: fixed; left: 50%; top: 58%; transform: translate(-50%, -50%); padding: 12px 14px; width: min(420px, 92vw); }
#buyItems { display: flex; flex-direction: column; gap: 4px; }
button.mc.buy { width: 100%; justify-content: flex-start; gap: 12px; padding: 0 12px; font-size: 16px; }
button.mc.buy span { flex: 1; text-align: left; }
button.mc.buy b { font-weight: normal; color: #ffe066; }
button.mc.buy.poor { opacity: 0.45; }
button.mc.buy.owned { --mc-hi: #5a7ab0; --mc-lo: #1a2a48; background: #2f4878; }
.bi { display: inline-block; width: 42px; height: 18px; background-size: contain; background-repeat: no-repeat; background-position: center; image-rendering: pixelated; }
.bi-smg { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 6' shape-rendering='crispEdges'%3E%3Cpath d='M3 1h8v2H3zM11 1h2v1h-2zM0 1h1v3H0zM1 2h2v1H1zM4 3h2v3H4zM7 3h2v2H7z' fill='%23e8e8e8'/%3E%3C/svg%3E"); }
.bi-rifle { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 6' shape-rendering='crispEdges'%3E%3Cpath d='M0 2h4v3H1V4H0zM4 2h6v2H4zM10 2h5v1h-5zM6 4h2v2H6z' fill='%23e8e8e8'/%3E%3C/svg%3E"); }
.bi-sniper { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 6' shape-rendering='crispEdges'%3E%3Cpath d='M0 2h5v3H2V4H0zM5 2h6v2H5zM11 2h7v1h-7zM6 0h5v1H6zM7 1h1v1H7zM9 1h1v1H9zM6 4h2v2H6z' fill='%23e8e8e8'/%3E%3C/svg%3E"); }
.bi-0, .bi-1 { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 6' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h6v4H5v1H4v1H2V5H1V4H0z' fill='%234f8fd8'/%3E%3Cpath d='M1 1h2v1H1z' fill='%239fd0ff'/%3E%3C/svg%3E"); }
.bi-0 { transform: scale(0.7); }

/* Écrans */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(5, 7, 26, 0.45); }
#screen-start { background: linear-gradient(90deg, rgba(5, 7, 26, 0) 0 42%, rgba(5, 7, 26, 0.55) 70%); align-items: flex-end; padding-right: max(4vw, 18px); }
#screen-start > * { margin-left: 0; margin-right: 0; }
.logo { font-size: clamp(40px, 8vw, 88px); letter-spacing: 3px; color: #e8dcc0; text-shadow: 4px 4px 0 #8a4a2a, 7px 7px 0 #000; margin-bottom: 18px; font-weight: normal; }
#agents { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: min(420px, 90vw); margin-bottom: 10px; }
button.mc.agent { width: 100%; height: 52px; justify-content: flex-start; gap: 10px; padding: 0 10px; font-size: 15px; margin: 0; }
button.mc.agent .ab { width: 26px; height: 26px; }
button.mc.agent.sel { --mc-hi: #c8a86a; --mc-lo: #5a4218; background: #8a6a34; color: #fff; }
#screen-start #bPlay { width: min(420px, 90vw); }
.end-title { font-size: clamp(40px, 8vw, 80px); text-shadow: 4px 4px 0 #000; }
.end-title.win { color: #ffd84a; } .end-title.lose { color: #e86a5a; }
#endScore { font-size: 34px; text-shadow: 3px 3px 0 #000; margin-bottom: 6px; }
#endBoard { display: flex; gap: 18px; padding: 10px; margin-bottom: 10px; }

/* Boutons de Core Wars .io (button.mc) */
button.mc {
  --mcb: 2px; --mc-hi: #454545; --mc-lo: #181818;
  display: flex; align-items: center; justify-content: center; width: min(360px, 86vw); height: 44px; margin: 2px auto;
  background: #2b2b2b; border: var(--mcb) solid #000; border-radius: 0;
  box-shadow: inset var(--mcb) var(--mcb) 0 var(--mc-hi), inset calc(-1 * var(--mcb)) calc(-1 * var(--mcb)) 0 var(--mc-lo);
  color: #e0e0e0; font: 18px 'Monocraft', monospace; text-shadow: 2px 2px 0 #000; cursor: pointer; outline: none;
}
button.mc:hover { --mc-hi: #5e5e5e; --mc-lo: #1e1e1e; background: #3c3c3c; color: #ffffa0; }
button.mc:focus-visible { border-color: #ffffa0; }
button.mc:active { --mc-hi: #141414; --mc-lo: #3a3a3a; background: #242424; transform: translateY(1px); }
button.mc.mc-green { --mc-hi: #5a9a4a; --mc-lo: #1f4418; background: #3f7a32; color: #fff; }
button.mc.mc-green:hover { --mc-hi: #6cb85a; --mc-lo: #2a5a20; background: #4f9a40; color: #ffffa0; }
button.mc.mc-green:active { --mc-hi: #1f4418; --mc-lo: #5a9a4a; background: #36692b; }
#buy, #buyItems { pointer-events: auto; }
